[chronojump] Changes new lines characters.



commit 95ef43449ba7bab947b0370801a65bba69163c28
Author: Carles Pina i Estany <carles pina cat>
Date:   Fri Sep 30 14:06:36 2016 +0200

    Changes new lines characters.
    
    Previously some files used Windows end of lines or mixed. Now all the
    *.cs files have Unix endings.
    
    This is the result of:
    find . -iname "*.cs" -exec dos2unix {} \;

 CesarPlayer/Capturer/GstCameraCapturer.cs          |  978 +-
 CesarPlayer/Capturer/ICapturer.cs                  |  186 +-
 CesarPlayer/Capturer/ObjectManager.cs              |   78 +-
 CesarPlayer/Editor/GstVideoSplitter.cs             |  866 +-
 CesarPlayer/Editor/IVideoEditor.cs                 |  166 +-
 CesarPlayer/Gui/CapturerBin.cs                     |  776 +-
 CesarPlayer/Gui/PlayerBin.cs                       | 1248 +-
 CesarPlayer/Gui/VolumeWindow.cs                    |   34 +-
 CesarPlayer/MultimediaFactory.cs                   |  218 +-
 CesarPlayer/Player/IPlayer.cs                      |   32 +-
 CesarPlayer/Utils/TimeString.cs                    |   34 +-
 chronojump_server/ChronojumpServer.cs              | 3506 +++---
 .../pina_to_pina-good/ChronojumpServerAlive.cs     |  166 +-
 src/chronojump.cs                                  | 1164 +-
 src/commandLineEncoder.cs                          |    2 +-
 src/gui/chronojump.cs                              |14048 ++++++++++----------
 src/gui/chronopic.cs                               | 2220 ++--
 src/gui/movingStartWindow.cs                       |  346 +-
 src/gui/networks.cs                                |  516 +-
 src/gui/old/chronojumpServerOld.cs                 |  628 +-
 src/gui/preferences.cs                             | 2430 ++--
 src/json.cs                                        |  492 +-
 src/log.cs                                         |   10 +-
 src/server.cs                                      | 1368 +-
 src/util.cs                                        |   12 +-
 src/utilAll.cs                                     |    8 +-
 testing-stuff/json_get.cs                          |   98 +-
 testing-stuff/json_ping.cs                         |   98 +-
 testing-stuff/json_post.cs                         |  182 +-
 29 files changed, 15955 insertions(+), 15955 deletions(-)
---
diff --git a/CesarPlayer/Capturer/GstCameraCapturer.cs b/CesarPlayer/Capturer/GstCameraCapturer.cs
index 7f6b0d5..4d1709c 100644
--- a/CesarPlayer/Capturer/GstCameraCapturer.cs
+++ b/CesarPlayer/Capturer/GstCameraCapturer.cs
@@ -1,489 +1,489 @@
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//
-
-namespace LongoMatch.Video.Capturer {
-
-       using System;
-       using System.Collections;
-       using System.Runtime.InteropServices;
-       using LongoMatch.Video.Common;
-
-#region Autogenerated code
-       public  class GstCameraCapturer : Gtk.HBox, LongoMatch.Video.Capturer.ICapturer {
-               
-               public event EllpasedTimeHandler EllapsedTime;
-               
-               private LiveSourceTimer timer;
-
-               [Obsolete]
-               protected GstCameraCapturer(GLib.GType gtype) : base(gtype) {}
-               public GstCameraCapturer(IntPtr raw) : base(raw) {}
-
-               [DllImport("libcesarplayer.dll")]
-               static extern unsafe IntPtr gst_camera_capturer_new(IntPtr filename, out IntPtr err);
-
-               public unsafe GstCameraCapturer (string filename) : base (IntPtr.Zero)
-               {
-                       if (GetType () != typeof (GstCameraCapturer)) {
-                               throw new InvalidOperationException ("Can't override this constructor.");
-                       }
-                       IntPtr error = IntPtr.Zero;
-                       Raw = gst_camera_capturer_new(GLib.Marshaller.StringToPtrGStrdup(filename), out 
error);
-                       if (error != IntPtr.Zero) throw new GLib.GException (error);
-                       
-                       timer = new LiveSourceTimer();  
-                       timer.EllapsedTime += delegate(int ellapsedTime) {
-                               if (EllapsedTime!= null)
-                                       EllapsedTime(ellapsedTime);
-                       };                      
-               }
-
-               [GLib.Property ("output_height")]
-               public uint OutputHeight {
-                       get {
-                               GLib.Value val = GetProperty ("output_height");
-                               uint ret = (uint) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("output_height", val);
-                               val.Dispose ();
-                       }
-               }
-
-               [GLib.Property ("output_width")]
-               public uint OutputWidth {
-                       get {
-                               GLib.Value val = GetProperty ("output_width");
-                               uint ret = (uint) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("output_width", val);
-                               val.Dispose ();
-                       }
-               }
-
-               [GLib.Property ("video_bitrate")]
-               public uint VideoBitrate {
-                       get {
-                               GLib.Value val = GetProperty ("video_bitrate");
-                               uint ret = (uint) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("video_bitrate", val);
-                               val.Dispose ();
-                       }
-               }
-
-               [GLib.Property ("output_file")]
-               public string OutputFile {
-                       get {
-                               GLib.Value val = GetProperty ("output_file");
-                               string ret = (string) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("output_file", val);
-                               val.Dispose ();
-                       }
-               }
-
-               [GLib.Property ("audio_bitrate")]
-               public uint AudioBitrate {
-                       get {
-                               GLib.Value val = GetProperty ("audio_bitrate");
-                               uint ret = (uint) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("audio_bitrate", val);
-                               val.Dispose ();
-                       }
-               }
-               
-               [GLib.Property ("device_id")]
-               public string DeviceID {
-                       get {
-                               GLib.Value val = GetProperty ("device_id");
-                               string ret = (string) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("device_id", val);
-                               val.Dispose ();
-                       }
-               }
-               
-#pragma warning disable 0169
-               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-               delegate void ErrorSignalDelegate (IntPtr arg0, IntPtr arg1, IntPtr gch);
-
-               static void ErrorSignalCallback (IntPtr arg0, IntPtr arg1, IntPtr gch)
-               {
-                       ErrorArgs args = new ErrorArgs ();
-                       try {
-                               GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
-                               if (sig == null)
-                                       throw new Exception("Unknown signal GC handle received " + gch);
-
-                               args.Args = new object[1];
-                               args.Args[0] = GLib.Marshaller.Utf8PtrToString (arg1);
-                               ErrorHandler handler = (ErrorHandler) sig.Handler;
-                               handler (GLib.Object.GetObject (arg0), args);
-                       } catch (Exception e) {
-                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
-                       }
-               }
-
-               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-               delegate void ErrorVMDelegate (IntPtr gcc, IntPtr message);
-
-               static ErrorVMDelegate ErrorVMCallback;
-
-               static void error_cb (IntPtr gcc, IntPtr message)
-               {
-                       try {
-                               GstCameraCapturer gcc_managed = GLib.Object.GetObject (gcc, false) as 
GstCameraCapturer;
-                               gcc_managed.OnError (GLib.Marshaller.Utf8PtrToString (message));
-                       } catch (Exception e) {
-                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
-                       }
-               }
-
-               private static void OverrideError (GLib.GType gtype)
-               {
-                       if (ErrorVMCallback == null)
-                               ErrorVMCallback = new ErrorVMDelegate (error_cb);
-                       OverrideVirtualMethod (gtype, "error", ErrorVMCallback);
-               }
-
-               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Capturer.GstCameraCapturer), 
ConnectionMethod="OverrideError")]
-               protected virtual void OnError (string message)
-               {
-                       GLib.Value ret = GLib.Value.Empty;
-                       GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
-                       GLib.Value[] vals = new GLib.Value [2];
-                       vals [0] = new GLib.Value (this);
-                       inst_and_params.Append (vals [0]);
-                       vals [1] = new GLib.Value (message);
-                       inst_and_params.Append (vals [1]);
-                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
-                       foreach (GLib.Value v in vals)
-                               v.Dispose ();
-               }
-
-               [GLib.Signal("error")]
-               public event ErrorHandler Error {
-                       add {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "error", new 
ErrorSignalDelegate(ErrorSignalCallback));
-                               sig.AddDelegate (value);
-                       }
-                       remove {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "error", new 
ErrorSignalDelegate(ErrorSignalCallback));
-                               sig.RemoveDelegate (value);
-                       }
-               }
-               
-               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-               delegate void DeviceChangeSignalDelegate (IntPtr arg0, int arg1, IntPtr gch);
-
-               static void DeviceChangeSignalCallback (IntPtr arg0, int arg1, IntPtr gch)
-               {
-                       DeviceChangeArgs args = new DeviceChangeArgs ();
-                       try {
-                               GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
-                               if (sig == null)
-                                       throw new Exception("Unknown signal GC handle received " + gch);
-
-                               args.Args = new object[1];
-                               args.Args[0] = arg1;
-                               DeviceChangeHandler handler = (DeviceChangeHandler) sig.Handler;
-                               handler (GLib.Object.GetObject (arg0), args);
-                       } catch (Exception e) {
-                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
-                       }
-               }
-
-               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-               delegate void DeviceChangeVMDelegate (IntPtr gcc, int deviceChange);
-
-               static DeviceChangeVMDelegate DeviceChangeVMCallback;
-
-               static void device_change_cb (IntPtr gcc, int deviceChange)
-               {
-                       try {
-                               GstCameraCapturer gcc_managed = GLib.Object.GetObject (gcc, false) as 
GstCameraCapturer;
-                               gcc_managed.OnDeviceChange (deviceChange);
-                       } catch (Exception e) {
-                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
-                       }
-               }
-
-               private static void OverrideDeviceChange (GLib.GType gtype)
-               {
-                       if (DeviceChangeVMCallback == null)
-                               DeviceChangeVMCallback = new DeviceChangeVMDelegate (device_change_cb);
-                       OverrideVirtualMethod (gtype, "device_change", DeviceChangeVMCallback);
-               }
-
-               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Capturer.GstCameraCapturer), 
ConnectionMethod="OverrideDeviceChange")]
-               protected virtual void OnDeviceChange (int deviceChange)
-               {
-                       GLib.Value ret = GLib.Value.Empty;
-                       GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
-                       GLib.Value[] vals = new GLib.Value [2];
-                       vals [0] = new GLib.Value (this);
-                       inst_and_params.Append (vals [0]);
-                       vals [1] = new GLib.Value (deviceChange);
-                       inst_and_params.Append (vals [1]);
-                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
-                       foreach (GLib.Value v in vals)
-                               v.Dispose ();
-               }
-
-               [GLib.Signal("device_change")]
-               public event DeviceChangeHandler DeviceChange {
-                       add {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "device_change", new 
DeviceChangeSignalDelegate(DeviceChangeSignalCallback));
-                               sig.AddDelegate (value);
-                       }
-                       remove {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "device_change", new 
DeviceChangeSignalDelegate(DeviceChangeSignalCallback));
-                               sig.RemoveDelegate (value);
-                       }
-               }
-
-               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-               delegate void EosVMDelegate (IntPtr gcc);
-
-               static EosVMDelegate EosVMCallback;
-
-               static void eos_cb (IntPtr gcc)
-               {
-                       try {
-                               GstCameraCapturer gcc_managed = GLib.Object.GetObject (gcc, false) as 
GstCameraCapturer;
-                               gcc_managed.OnEos ();
-                       } catch (Exception e) {
-                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
-                       }
-               }
-
-               private static void OverrideEos (GLib.GType gtype)
-               {
-                       if (EosVMCallback == null)
-                               EosVMCallback = new EosVMDelegate (eos_cb);
-                       OverrideVirtualMethod (gtype, "eos", EosVMCallback);
-               }
-
-               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Capturer.GstCameraCapturer), 
ConnectionMethod="OverrideEos")]
-               protected virtual void OnEos ()
-               {
-                       GLib.Value ret = GLib.Value.Empty;
-                       GLib.ValueArray inst_and_params = new GLib.ValueArray (1);
-                       GLib.Value[] vals = new GLib.Value [1];
-                       vals [0] = new GLib.Value (this);
-                       inst_and_params.Append (vals [0]);
-                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
-                       foreach (GLib.Value v in vals)
-                               v.Dispose ();
-               }
-
-               [GLib.Signal("eos")]
-               public event System.EventHandler Eos {
-                       add {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "eos");
-                               sig.AddDelegate (value);
-                       }
-                       remove {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "eos");
-                               sig.RemoveDelegate (value);
-                       }
-               }
-#pragma warning restore 0169
-
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_camera_capturer_init_backend(out int argc, IntPtr argv);
-
-               public static int InitBackend(string argv) {
-                       int argc;
-                       gst_camera_capturer_init_backend(out argc, GLib.Marshaller.StringToPtrGStrdup(argv));
-                       return argc;
-               }
-
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_camera_capturer_stop(IntPtr raw);
-
-               public void Stop() {
-                       timer.Stop();
-                       gst_camera_capturer_stop(Handle);
-               }
-
-       
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_camera_capturer_toggle_pause(IntPtr raw);
-
-               public void TogglePause() {
-                       timer.TogglePause();
-                       gst_camera_capturer_toggle_pause(Handle);
-               }
-       
-               public int CurrentTime{
-                       get{
-                               return timer.CurrentTime;
-                       }
-               }
-
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_camera_capturer_start(IntPtr raw);
-
-               public void Start() {
-                       timer.Start();
-                       gst_camera_capturer_start(Handle);
-               }
-
-
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_camera_capturer_run(IntPtr raw);
-
-               public void Run() {
-                       gst_camera_capturer_run(Handle);
-               }
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_camera_capturer_close(IntPtr raw);
-
-               public void Close() {
-                       gst_camera_capturer_close(Handle);
-               }               
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern bool gst_camera_capturer_set_video_muxer(IntPtr raw, int type, out IntPtr 
error);
-
-               public bool SetVideoMuxer(VideoMuxerType type) {
-                       IntPtr error = IntPtr.Zero;
-                       bool raw_ret = gst_camera_capturer_set_video_muxer(Handle, (int) type, out error);
-                       if (error != IntPtr.Zero) throw new GLib.GException (error);
-                       bool ret = raw_ret;
-                       return ret;
-               }
-
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern bool gst_camera_capturer_set_video_encoder(IntPtr raw, int type, out IntPtr 
error);
-
-               public bool SetVideoEncoder(VideoEncoderType type) {
-                       IntPtr error = IntPtr.Zero;
-                       bool raw_ret = gst_camera_capturer_set_video_encoder(Handle, (int) type, out error);
-                       if (error != IntPtr.Zero) throw new GLib.GException (error);
-                       bool ret = raw_ret;
-                       return ret;
-               }
-
-               [DllImport("libcesarplayer.dll")]
-               static extern bool gst_camera_capturer_set_audio_encoder(IntPtr raw, int type, out IntPtr 
error);
-
-               public bool SetAudioEncoder(AudioEncoderType type) {
-                       IntPtr error = IntPtr.Zero;                     
-                       bool raw_ret = gst_camera_capturer_set_audio_encoder(Handle, (int) type, out error);
-                       if (error != IntPtr.Zero) throw new GLib.GException (error);
-                       bool ret = raw_ret;
-                       return ret;
-               }
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern bool gst_camera_capturer_set_source(IntPtr raw, int type, out IntPtr error);
-
-               public bool SetSource(CaptureSourceType type) {
-                       IntPtr error = IntPtr.Zero;                     
-                       bool raw_ret = gst_camera_capturer_set_source(Handle, (int) type, out error);
-                       if (error != IntPtr.Zero) throw new GLib.GException (error);
-                       bool ret = raw_ret;
-                       return ret;
-               }               
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern IntPtr gst_camera_capturer_get_type();
-
-               public static new GLib.GType GType { 
-                       get {
-                               IntPtr raw_ret = gst_camera_capturer_get_type();
-                               GLib.GType ret = new GLib.GType(raw_ret);
-                               return ret;
-                       }
-               } 
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern IntPtr gst_camera_capturer_enum_audio_devices();
-
-               public static string[] AudioDevices { 
-                       get {
-                               IntPtr raw_ret = gst_camera_capturer_enum_audio_devices();
-                               return (string[])GLib.Marshaller.ListPtrToArray(raw_ret, typeof(GLib.List),  
true, false, typeof(String));
-                       }
-               }
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern IntPtr gst_camera_capturer_enum_video_devices();
-
-               public static string[] VideoDevices { 
-                       get {
-                               IntPtr raw_ret = gst_camera_capturer_enum_video_devices();
-                               return (string[])GLib.Marshaller.ListPtrToArray(raw_ret, typeof(GLib.List),  
true, false, typeof(String));                                      
-                       }
-               }
-               
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern IntPtr gst_camera_capturer_get_current_frame(IntPtr raw);
-               [DllImport("libcesarplayer.dll")]
-               static extern IntPtr gst_camera_capturer_unref_pixbuf(IntPtr raw);
-               
-               public Gdk.Pixbuf CurrentFrame {
-                       get {
-                               IntPtr raw_ret = gst_camera_capturer_get_current_frame (Handle);
-                               Gdk.Pixbuf p = GLib.Object.GetObject (raw_ret) as Gdk.Pixbuf;
-                               /* The refcount for p is now 2. We need to decrease the counter to 1
-                                * so that p.Dipose() sets it to 0 and triggers the pixbuf destroy function
-                                * that frees the associated data*/ 
-                               gst_camera_capturer_unref_pixbuf (raw_ret);
-                               return p;
-                       }
-               }               
-               
-               static GstCameraCapturer ()
-               {
-                       LongoMatch.GtkSharp.Capturer.ObjectManager.Initialize ();
-               }
-#endregion
-               
-       }
-}
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+namespace LongoMatch.Video.Capturer {
+
+       using System;
+       using System.Collections;
+       using System.Runtime.InteropServices;
+       using LongoMatch.Video.Common;
+
+#region Autogenerated code
+       public  class GstCameraCapturer : Gtk.HBox, LongoMatch.Video.Capturer.ICapturer {
+               
+               public event EllpasedTimeHandler EllapsedTime;
+               
+               private LiveSourceTimer timer;
+
+               [Obsolete]
+               protected GstCameraCapturer(GLib.GType gtype) : base(gtype) {}
+               public GstCameraCapturer(IntPtr raw) : base(raw) {}
+
+               [DllImport("libcesarplayer.dll")]
+               static extern unsafe IntPtr gst_camera_capturer_new(IntPtr filename, out IntPtr err);
+
+               public unsafe GstCameraCapturer (string filename) : base (IntPtr.Zero)
+               {
+                       if (GetType () != typeof (GstCameraCapturer)) {
+                               throw new InvalidOperationException ("Can't override this constructor.");
+                       }
+                       IntPtr error = IntPtr.Zero;
+                       Raw = gst_camera_capturer_new(GLib.Marshaller.StringToPtrGStrdup(filename), out 
error);
+                       if (error != IntPtr.Zero) throw new GLib.GException (error);
+                       
+                       timer = new LiveSourceTimer();  
+                       timer.EllapsedTime += delegate(int ellapsedTime) {
+                               if (EllapsedTime!= null)
+                                       EllapsedTime(ellapsedTime);
+                       };                      
+               }
+
+               [GLib.Property ("output_height")]
+               public uint OutputHeight {
+                       get {
+                               GLib.Value val = GetProperty ("output_height");
+                               uint ret = (uint) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("output_height", val);
+                               val.Dispose ();
+                       }
+               }
+
+               [GLib.Property ("output_width")]
+               public uint OutputWidth {
+                       get {
+                               GLib.Value val = GetProperty ("output_width");
+                               uint ret = (uint) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("output_width", val);
+                               val.Dispose ();
+                       }
+               }
+
+               [GLib.Property ("video_bitrate")]
+               public uint VideoBitrate {
+                       get {
+                               GLib.Value val = GetProperty ("video_bitrate");
+                               uint ret = (uint) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("video_bitrate", val);
+                               val.Dispose ();
+                       }
+               }
+
+               [GLib.Property ("output_file")]
+               public string OutputFile {
+                       get {
+                               GLib.Value val = GetProperty ("output_file");
+                               string ret = (string) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("output_file", val);
+                               val.Dispose ();
+                       }
+               }
+
+               [GLib.Property ("audio_bitrate")]
+               public uint AudioBitrate {
+                       get {
+                               GLib.Value val = GetProperty ("audio_bitrate");
+                               uint ret = (uint) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("audio_bitrate", val);
+                               val.Dispose ();
+                       }
+               }
+               
+               [GLib.Property ("device_id")]
+               public string DeviceID {
+                       get {
+                               GLib.Value val = GetProperty ("device_id");
+                               string ret = (string) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("device_id", val);
+                               val.Dispose ();
+                       }
+               }
+               
+#pragma warning disable 0169
+               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+               delegate void ErrorSignalDelegate (IntPtr arg0, IntPtr arg1, IntPtr gch);
+
+               static void ErrorSignalCallback (IntPtr arg0, IntPtr arg1, IntPtr gch)
+               {
+                       ErrorArgs args = new ErrorArgs ();
+                       try {
+                               GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
+                               if (sig == null)
+                                       throw new Exception("Unknown signal GC handle received " + gch);
+
+                               args.Args = new object[1];
+                               args.Args[0] = GLib.Marshaller.Utf8PtrToString (arg1);
+                               ErrorHandler handler = (ErrorHandler) sig.Handler;
+                               handler (GLib.Object.GetObject (arg0), args);
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                       }
+               }
+
+               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+               delegate void ErrorVMDelegate (IntPtr gcc, IntPtr message);
+
+               static ErrorVMDelegate ErrorVMCallback;
+
+               static void error_cb (IntPtr gcc, IntPtr message)
+               {
+                       try {
+                               GstCameraCapturer gcc_managed = GLib.Object.GetObject (gcc, false) as 
GstCameraCapturer;
+                               gcc_managed.OnError (GLib.Marshaller.Utf8PtrToString (message));
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                       }
+               }
+
+               private static void OverrideError (GLib.GType gtype)
+               {
+                       if (ErrorVMCallback == null)
+                               ErrorVMCallback = new ErrorVMDelegate (error_cb);
+                       OverrideVirtualMethod (gtype, "error", ErrorVMCallback);
+               }
+
+               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Capturer.GstCameraCapturer), 
ConnectionMethod="OverrideError")]
+               protected virtual void OnError (string message)
+               {
+                       GLib.Value ret = GLib.Value.Empty;
+                       GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
+                       GLib.Value[] vals = new GLib.Value [2];
+                       vals [0] = new GLib.Value (this);
+                       inst_and_params.Append (vals [0]);
+                       vals [1] = new GLib.Value (message);
+                       inst_and_params.Append (vals [1]);
+                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
+                       foreach (GLib.Value v in vals)
+                               v.Dispose ();
+               }
+
+               [GLib.Signal("error")]
+               public event ErrorHandler Error {
+                       add {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "error", new 
ErrorSignalDelegate(ErrorSignalCallback));
+                               sig.AddDelegate (value);
+                       }
+                       remove {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "error", new 
ErrorSignalDelegate(ErrorSignalCallback));
+                               sig.RemoveDelegate (value);
+                       }
+               }
+               
+               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+               delegate void DeviceChangeSignalDelegate (IntPtr arg0, int arg1, IntPtr gch);
+
+               static void DeviceChangeSignalCallback (IntPtr arg0, int arg1, IntPtr gch)
+               {
+                       DeviceChangeArgs args = new DeviceChangeArgs ();
+                       try {
+                               GLib.Signal sig = ((GCHandle) gch).Target as GLib.Signal;
+                               if (sig == null)
+                                       throw new Exception("Unknown signal GC handle received " + gch);
+
+                               args.Args = new object[1];
+                               args.Args[0] = arg1;
+                               DeviceChangeHandler handler = (DeviceChangeHandler) sig.Handler;
+                               handler (GLib.Object.GetObject (arg0), args);
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                       }
+               }
+
+               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+               delegate void DeviceChangeVMDelegate (IntPtr gcc, int deviceChange);
+
+               static DeviceChangeVMDelegate DeviceChangeVMCallback;
+
+               static void device_change_cb (IntPtr gcc, int deviceChange)
+               {
+                       try {
+                               GstCameraCapturer gcc_managed = GLib.Object.GetObject (gcc, false) as 
GstCameraCapturer;
+                               gcc_managed.OnDeviceChange (deviceChange);
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                       }
+               }
+
+               private static void OverrideDeviceChange (GLib.GType gtype)
+               {
+                       if (DeviceChangeVMCallback == null)
+                               DeviceChangeVMCallback = new DeviceChangeVMDelegate (device_change_cb);
+                       OverrideVirtualMethod (gtype, "device_change", DeviceChangeVMCallback);
+               }
+
+               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Capturer.GstCameraCapturer), 
ConnectionMethod="OverrideDeviceChange")]
+               protected virtual void OnDeviceChange (int deviceChange)
+               {
+                       GLib.Value ret = GLib.Value.Empty;
+                       GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
+                       GLib.Value[] vals = new GLib.Value [2];
+                       vals [0] = new GLib.Value (this);
+                       inst_and_params.Append (vals [0]);
+                       vals [1] = new GLib.Value (deviceChange);
+                       inst_and_params.Append (vals [1]);
+                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
+                       foreach (GLib.Value v in vals)
+                               v.Dispose ();
+               }
+
+               [GLib.Signal("device_change")]
+               public event DeviceChangeHandler DeviceChange {
+                       add {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "device_change", new 
DeviceChangeSignalDelegate(DeviceChangeSignalCallback));
+                               sig.AddDelegate (value);
+                       }
+                       remove {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "device_change", new 
DeviceChangeSignalDelegate(DeviceChangeSignalCallback));
+                               sig.RemoveDelegate (value);
+                       }
+               }
+
+               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+               delegate void EosVMDelegate (IntPtr gcc);
+
+               static EosVMDelegate EosVMCallback;
+
+               static void eos_cb (IntPtr gcc)
+               {
+                       try {
+                               GstCameraCapturer gcc_managed = GLib.Object.GetObject (gcc, false) as 
GstCameraCapturer;
+                               gcc_managed.OnEos ();
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                       }
+               }
+
+               private static void OverrideEos (GLib.GType gtype)
+               {
+                       if (EosVMCallback == null)
+                               EosVMCallback = new EosVMDelegate (eos_cb);
+                       OverrideVirtualMethod (gtype, "eos", EosVMCallback);
+               }
+
+               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Capturer.GstCameraCapturer), 
ConnectionMethod="OverrideEos")]
+               protected virtual void OnEos ()
+               {
+                       GLib.Value ret = GLib.Value.Empty;
+                       GLib.ValueArray inst_and_params = new GLib.ValueArray (1);
+                       GLib.Value[] vals = new GLib.Value [1];
+                       vals [0] = new GLib.Value (this);
+                       inst_and_params.Append (vals [0]);
+                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
+                       foreach (GLib.Value v in vals)
+                               v.Dispose ();
+               }
+
+               [GLib.Signal("eos")]
+               public event System.EventHandler Eos {
+                       add {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "eos");
+                               sig.AddDelegate (value);
+                       }
+                       remove {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "eos");
+                               sig.RemoveDelegate (value);
+                       }
+               }
+#pragma warning restore 0169
+
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_camera_capturer_init_backend(out int argc, IntPtr argv);
+
+               public static int InitBackend(string argv) {
+                       int argc;
+                       gst_camera_capturer_init_backend(out argc, GLib.Marshaller.StringToPtrGStrdup(argv));
+                       return argc;
+               }
+
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_camera_capturer_stop(IntPtr raw);
+
+               public void Stop() {
+                       timer.Stop();
+                       gst_camera_capturer_stop(Handle);
+               }
+
+       
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_camera_capturer_toggle_pause(IntPtr raw);
+
+               public void TogglePause() {
+                       timer.TogglePause();
+                       gst_camera_capturer_toggle_pause(Handle);
+               }
+       
+               public int CurrentTime{
+                       get{
+                               return timer.CurrentTime;
+                       }
+               }
+
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_camera_capturer_start(IntPtr raw);
+
+               public void Start() {
+                       timer.Start();
+                       gst_camera_capturer_start(Handle);
+               }
+
+
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_camera_capturer_run(IntPtr raw);
+
+               public void Run() {
+                       gst_camera_capturer_run(Handle);
+               }
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_camera_capturer_close(IntPtr raw);
+
+               public void Close() {
+                       gst_camera_capturer_close(Handle);
+               }               
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern bool gst_camera_capturer_set_video_muxer(IntPtr raw, int type, out IntPtr 
error);
+
+               public bool SetVideoMuxer(VideoMuxerType type) {
+                       IntPtr error = IntPtr.Zero;
+                       bool raw_ret = gst_camera_capturer_set_video_muxer(Handle, (int) type, out error);
+                       if (error != IntPtr.Zero) throw new GLib.GException (error);
+                       bool ret = raw_ret;
+                       return ret;
+               }
+
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern bool gst_camera_capturer_set_video_encoder(IntPtr raw, int type, out IntPtr 
error);
+
+               public bool SetVideoEncoder(VideoEncoderType type) {
+                       IntPtr error = IntPtr.Zero;
+                       bool raw_ret = gst_camera_capturer_set_video_encoder(Handle, (int) type, out error);
+                       if (error != IntPtr.Zero) throw new GLib.GException (error);
+                       bool ret = raw_ret;
+                       return ret;
+               }
+
+               [DllImport("libcesarplayer.dll")]
+               static extern bool gst_camera_capturer_set_audio_encoder(IntPtr raw, int type, out IntPtr 
error);
+
+               public bool SetAudioEncoder(AudioEncoderType type) {
+                       IntPtr error = IntPtr.Zero;                     
+                       bool raw_ret = gst_camera_capturer_set_audio_encoder(Handle, (int) type, out error);
+                       if (error != IntPtr.Zero) throw new GLib.GException (error);
+                       bool ret = raw_ret;
+                       return ret;
+               }
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern bool gst_camera_capturer_set_source(IntPtr raw, int type, out IntPtr error);
+
+               public bool SetSource(CaptureSourceType type) {
+                       IntPtr error = IntPtr.Zero;                     
+                       bool raw_ret = gst_camera_capturer_set_source(Handle, (int) type, out error);
+                       if (error != IntPtr.Zero) throw new GLib.GException (error);
+                       bool ret = raw_ret;
+                       return ret;
+               }               
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern IntPtr gst_camera_capturer_get_type();
+
+               public static new GLib.GType GType { 
+                       get {
+                               IntPtr raw_ret = gst_camera_capturer_get_type();
+                               GLib.GType ret = new GLib.GType(raw_ret);
+                               return ret;
+                       }
+               } 
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern IntPtr gst_camera_capturer_enum_audio_devices();
+
+               public static string[] AudioDevices { 
+                       get {
+                               IntPtr raw_ret = gst_camera_capturer_enum_audio_devices();
+                               return (string[])GLib.Marshaller.ListPtrToArray(raw_ret, typeof(GLib.List),  
true, false, typeof(String));
+                       }
+               }
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern IntPtr gst_camera_capturer_enum_video_devices();
+
+               public static string[] VideoDevices { 
+                       get {
+                               IntPtr raw_ret = gst_camera_capturer_enum_video_devices();
+                               return (string[])GLib.Marshaller.ListPtrToArray(raw_ret, typeof(GLib.List),  
true, false, typeof(String));                                      
+                       }
+               }
+               
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern IntPtr gst_camera_capturer_get_current_frame(IntPtr raw);
+               [DllImport("libcesarplayer.dll")]
+               static extern IntPtr gst_camera_capturer_unref_pixbuf(IntPtr raw);
+               
+               public Gdk.Pixbuf CurrentFrame {
+                       get {
+                               IntPtr raw_ret = gst_camera_capturer_get_current_frame (Handle);
+                               Gdk.Pixbuf p = GLib.Object.GetObject (raw_ret) as Gdk.Pixbuf;
+                               /* The refcount for p is now 2. We need to decrease the counter to 1
+                                * so that p.Dipose() sets it to 0 and triggers the pixbuf destroy function
+                                * that frees the associated data*/ 
+                               gst_camera_capturer_unref_pixbuf (raw_ret);
+                               return p;
+                       }
+               }               
+               
+               static GstCameraCapturer ()
+               {
+                       LongoMatch.GtkSharp.Capturer.ObjectManager.Initialize ();
+               }
+#endregion
+               
+       }
+}
diff --git a/CesarPlayer/Capturer/ICapturer.cs b/CesarPlayer/Capturer/ICapturer.cs
index 4960bdb..5c7a06e 100644
--- a/CesarPlayer/Capturer/ICapturer.cs
+++ b/CesarPlayer/Capturer/ICapturer.cs
@@ -1,93 +1,93 @@
-// ICapturer.cs
-//
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//
-
-using System;
-using LongoMatch.Video.Common;
-using Gdk;
-
-namespace LongoMatch.Video.Capturer
-{
-       
-       
-       public interface ICapturer
-       {       
-               event EllpasedTimeHandler EllapsedTime;
-               event ErrorHandler Error;
-               event DeviceChangeHandler DeviceChange;
-                       
-               uint OutputWidth {
-                       get ;
-                       set ;
-               }
-
-               uint OutputHeight {
-                       get;
-                       set ;
-               }
-               
-                string OutputFile {
-                       get ;
-                       set ;
-               }
-                               
-               uint VideoBitrate {
-                       get;
-                       set ;
-               }
-               
-               uint AudioBitrate {
-                       get ;
-                       set ;
-               }
-               
-               int CurrentTime {
-                       get ;
-               }
-               
-               Pixbuf CurrentFrame {
-                       get;
-               }
-               
-               string DeviceID {
-                       set;
-                       get;
-               }
-               
-               bool SetVideoEncoder(VideoEncoderType type);
-               
-               bool SetAudioEncoder(AudioEncoderType type);
-               
-               bool SetVideoMuxer(VideoMuxerType type);
-               
-               bool SetSource(CaptureSourceType type);
-               
-               void TogglePause();
-               
-               void Start();
-               
-               void Stop();
-               
-               void Run();
-               
-               void Close();
-               
-               void Dispose();
-       }
-}
+// ICapturer.cs
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+using System;
+using LongoMatch.Video.Common;
+using Gdk;
+
+namespace LongoMatch.Video.Capturer
+{
+       
+       
+       public interface ICapturer
+       {       
+               event EllpasedTimeHandler EllapsedTime;
+               event ErrorHandler Error;
+               event DeviceChangeHandler DeviceChange;
+                       
+               uint OutputWidth {
+                       get ;
+                       set ;
+               }
+
+               uint OutputHeight {
+                       get;
+                       set ;
+               }
+               
+                string OutputFile {
+                       get ;
+                       set ;
+               }
+                               
+               uint VideoBitrate {
+                       get;
+                       set ;
+               }
+               
+               uint AudioBitrate {
+                       get ;
+                       set ;
+               }
+               
+               int CurrentTime {
+                       get ;
+               }
+               
+               Pixbuf CurrentFrame {
+                       get;
+               }
+               
+               string DeviceID {
+                       set;
+                       get;
+               }
+               
+               bool SetVideoEncoder(VideoEncoderType type);
+               
+               bool SetAudioEncoder(AudioEncoderType type);
+               
+               bool SetVideoMuxer(VideoMuxerType type);
+               
+               bool SetSource(CaptureSourceType type);
+               
+               void TogglePause();
+               
+               void Start();
+               
+               void Stop();
+               
+               void Run();
+               
+               void Close();
+               
+               void Dispose();
+       }
+}
diff --git a/CesarPlayer/Capturer/ObjectManager.cs b/CesarPlayer/Capturer/ObjectManager.cs
index ed2be4c..1e4ff83 100644
--- a/CesarPlayer/Capturer/ObjectManager.cs
+++ b/CesarPlayer/Capturer/ObjectManager.cs
@@ -1,39 +1,39 @@
-// ObjectManager.cs
-//
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//
-// This file was generated by the Gtk# code generator.
-// Any changes made will be lost if regenerated.
-
-namespace LongoMatch.GtkSharp.Capturer {
-
-       public class ObjectManager {
-
-               static bool initialized = false;
-               // Call this method from the appropriate module init function.
-               public static void Initialize ()
-               {
-                       if (initialized)
-                               return;
-
-                       initialized = true;
-
-                       GLib.GType.Register (LongoMatch.Video.Capturer.GstCameraCapturer.GType, typeof 
(LongoMatch.Video.Capturer.GstCameraCapturer));
-               }
-       }
-}
+// ObjectManager.cs
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+// This file was generated by the Gtk# code generator.
+// Any changes made will be lost if regenerated.
+
+namespace LongoMatch.GtkSharp.Capturer {
+
+       public class ObjectManager {
+
+               static bool initialized = false;
+               // Call this method from the appropriate module init function.
+               public static void Initialize ()
+               {
+                       if (initialized)
+                               return;
+
+                       initialized = true;
+
+                       GLib.GType.Register (LongoMatch.Video.Capturer.GstCameraCapturer.GType, typeof 
(LongoMatch.Video.Capturer.GstCameraCapturer));
+               }
+       }
+}
diff --git a/CesarPlayer/Editor/GstVideoSplitter.cs b/CesarPlayer/Editor/GstVideoSplitter.cs
index c97c1cb..7c298a9 100644
--- a/CesarPlayer/Editor/GstVideoSplitter.cs
+++ b/CesarPlayer/Editor/GstVideoSplitter.cs
@@ -1,433 +1,433 @@
-// GstVideoSplitter.cs
-//
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//
-
-namespace LongoMatch.Video.Editor {
-
-       using System;
-       using System.Collections;
-       using System.Runtime.InteropServices;
-       using LongoMatch.Video.Common;
-
-
-       public class GstVideoSplitter : GLib.Object, IVideoEditor, IVideoSplitter {
-
-               [DllImport("libcesarplayer.dll")]
-               static extern unsafe IntPtr gst_video_editor_new(out IntPtr err);
-
-               public event ProgressHandler Progress;
-               
-               public unsafe GstVideoSplitter () : base (IntPtr.Zero)
-               {
-                       if (GetType () != typeof (GstVideoSplitter)) {
-                               throw new InvalidOperationException ("Can't override this constructor.");
-                       }
-                       IntPtr error = IntPtr.Zero;
-                       Raw = gst_video_editor_new(out error);
-                       if (error != IntPtr.Zero) throw new GLib.GException (error);
-                       PercentCompleted += delegate(object o, PercentCompletedArgs args) {
-                               if (Progress!= null)
-                                       Progress (args.Percent);
-                       };
-               }
-
-               #region Properties
-               
-               [GLib.Property ("enable-audio")]
-               public bool EnableAudio {
-                       get {
-                               GLib.Value val = GetProperty ("enable-audio");
-                               bool ret = (bool) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("enable-audio", val);
-                               val.Dispose ();
-                       }
-               }
-               
-               [GLib.Property ("enable-title")]
-               public bool EnableTitle {
-                       get {
-                               GLib.Value val = GetProperty ("enable-title");
-                               bool ret = (bool) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("enable-title", val);
-                               val.Dispose ();
-                       }
-               }
-               
-               [GLib.Property ("video_bitrate")]
-               public int VideoBitrate {
-                       get {
-                               GLib.Value val = GetProperty ("video_bitrate");
-                               int ret = (int) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("video_bitrate", val);
-                               val.Dispose ();
-                       }
-               }
-
-               [GLib.Property ("audio_bitrate")]
-               public int AudioBitrate {
-                       get {
-                               GLib.Value val = GetProperty ("audio_bitrate");
-                               int ret = (int) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("audio_bitrate", val);
-                               val.Dispose ();
-                       }
-               }
-               
-               [GLib.Property ("width")]
-               public int Width {
-                       get {
-                               GLib.Value val = GetProperty ("width");
-                               int ret = (int) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("width", val);
-                               val.Dispose ();
-                       }
-               }
-               
-               [GLib.Property ("height")]
-               public int Height {
-                       get {
-                               GLib.Value val = GetProperty ("height");
-                               int ret = (int) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);
-                               SetProperty("height", val);
-                               val.Dispose ();
-                       }
-               }
-               
-               [GLib.Property ("output_file")]
-               public string OutputFile {
-                       get {
-                               GLib.Value val = GetProperty ("output_file");
-                               string ret = (string) val;
-                               val.Dispose ();
-                               return ret;
-                       }
-                       set {
-                               GLib.Value val = new GLib.Value(value);                         
-                               SetProperty("output_file", val);
-                               val.Dispose ();
-                       }
-               }
-               
-               #endregion
-
-               
-               
-               #region GSignals
-#pragma warning disable 0169
-               [GLib.CDeclCallback]
-               delegate void ErrorVMDelegate (IntPtr gvc, IntPtr message);
-
-               static ErrorVMDelegate ErrorVMCallback;
-
-               static void error_cb (IntPtr gvc, IntPtr message)
-               {
-                       try {
-                               GstVideoSplitter gvc_managed = GLib.Object.GetObject (gvc, false) as 
GstVideoSplitter;
-                               gvc_managed.OnError (GLib.Marshaller.Utf8PtrToString (message));
-                       } catch (Exception e) {
-                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
-                       }
-               }
-
-               private static void OverrideError (GLib.GType gtype)
-               {
-                       if (ErrorVMCallback == null)
-                               ErrorVMCallback = new ErrorVMDelegate (error_cb);
-                       OverrideVirtualMethod (gtype, "error", ErrorVMCallback);
-               }
-
-               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Editor.GstVideoSplitter), 
ConnectionMethod="OverrideError")]
-               protected virtual void OnError (string message)
-               {
-                       GLib.Value ret = GLib.Value.Empty;
-                       GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
-                       GLib.Value[] vals = new GLib.Value [2];
-                       vals [0] = new GLib.Value (this);
-                       inst_and_params.Append (vals [0]);
-                       vals [1] = new GLib.Value (message);
-                       inst_and_params.Append (vals [1]);
-                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
-                       foreach (GLib.Value v in vals)
-                               v.Dispose ();
-               }
-
-               [GLib.Signal("error")]
-               public event ErrorHandler Error {
-                       add {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "error", typeof (ErrorArgs));
-                               sig.AddDelegate (value);
-                       }
-                       remove {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "error", typeof (ErrorArgs));
-                               sig.RemoveDelegate (value);
-                       }
-               }
-               
-
-               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-               delegate void PercentCompletedVMDelegate (IntPtr gvc, float percent);
-
-               static PercentCompletedVMDelegate PercentCompletedVMCallback;
-
-               static void percentcompleted_cb (IntPtr gvc, float percent)
-               {
-                       try {
-                               GstVideoSplitter gvc_managed = GLib.Object.GetObject (gvc, false) as 
GstVideoSplitter;
-                               gvc_managed.OnPercentCompleted (percent);
-                       } catch (Exception e) {
-                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
-                       }
-               }
-
-               private static void OverridePercentCompleted (GLib.GType gtype)
-               {
-                       if (PercentCompletedVMCallback == null)
-                               PercentCompletedVMCallback = new PercentCompletedVMDelegate 
(percentcompleted_cb);
-                       OverrideVirtualMethod (gtype, "percent_completed", PercentCompletedVMCallback);
-               }
-
-               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Editor.GstVideoSplitter), 
ConnectionMethod="OverridePercentCompleted")]
-               protected virtual void OnPercentCompleted (float percent)
-               {
-                       GLib.Value ret = GLib.Value.Empty;
-                       GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
-                       GLib.Value[] vals = new GLib.Value [2];
-                       vals [0] = new GLib.Value (this);
-                       inst_and_params.Append (vals [0]);
-                       vals [1] = new GLib.Value (percent);
-                       inst_and_params.Append (vals [1]);
-                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
-                       foreach (GLib.Value v in vals)
-                               v.Dispose ();
-               }
-
-               [GLib.Signal("percent_completed")]
-               public event PercentCompletedHandler PercentCompleted {
-                       add {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "percent_completed", typeof 
(PercentCompletedArgs));
-                               sig.AddDelegate (value);
-                       }
-                       remove {
-                               GLib.Signal sig = GLib.Signal.Lookup (this, "percent_completed", typeof 
(PercentCompletedArgs));
-                               sig.RemoveDelegate (value);
-                       }
-               }
-#pragma warning restore 0169
-               #endregion
-               
-               #region Public Methods
-
-               [DllImport("libcesarplayer.dll")]
-               static extern IntPtr gst_video_editor_get_type();
-
-               public static new GLib.GType GType { 
-                       get {
-                               IntPtr raw_ret = gst_video_editor_get_type();
-                               GLib.GType ret = new GLib.GType(raw_ret);
-                               return ret;
-                       }
-               }
-               
-               
-
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_video_editor_clear_segments_list(IntPtr raw);
-
-               public void ClearList() {
-                       gst_video_editor_clear_segments_list(Handle);
-               }
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_video_editor_add_segment(IntPtr raw, string file_path, long start, 
long duration, double rate, IntPtr title, bool hasAudio);
-
-               public void AddSegment(string filePath, long start, long duration, double rate, string title, 
bool hasAudio) {
-                       if (Environment.OSVersion.Platform == PlatformID.Win32NT)
-                               filePath="file:///"+filePath;
-                       gst_video_editor_add_segment(Handle, filePath, start, duration, rate, 
GLib.Marshaller.StringToPtrGStrdup(title), hasAudio);
-               }
-               
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_video_editor_start(IntPtr raw);
-
-               public void Start() {
-                       gst_video_editor_start(Handle);
-               }
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_video_editor_cancel(IntPtr raw);
-
-               public void Cancel() {
-                       // The handle might have already been dealocated
-                       try{
-                               gst_video_editor_cancel(Handle);
-                       }catch{
-                       }
-               }
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_video_editor_set_video_encoder(IntPtr raw, out IntPtr error_ptr, int 
type);
-
-               public void SetVideoEncoder(out string error, VideoEncoderType codec) {
-                       IntPtr error_ptr = IntPtr.Zero;
-                       gst_video_editor_set_video_encoder(Handle,out error_ptr,(int)codec);
-                       if (error_ptr != IntPtr.Zero)
-                               error = GLib.Marshaller.Utf8PtrToString(error_ptr);
-                       else
-                               error = null;
-               }
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_video_editor_set_audio_encoder(IntPtr raw, out IntPtr error_ptr, int 
type);
-
-               public void SetAudioEncoder(out string error, AudioEncoderType codec) {
-                       IntPtr error_ptr = IntPtr.Zero;
-                       gst_video_editor_set_audio_encoder(Handle,out error_ptr,(int)codec);
-                       if (error_ptr != IntPtr.Zero)
-                               error = GLib.Marshaller.Utf8PtrToString(error_ptr);
-                       else
-                               error = null;
-               }
-               
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_video_editor_set_video_muxer(IntPtr raw, out IntPtr error_ptr, int 
type);
-
-               public void SetVideoMuxer(out string error, VideoMuxerType muxer) {
-                       IntPtr error_ptr = IntPtr.Zero;
-                       gst_video_editor_set_video_muxer(Handle,out error_ptr,(int)muxer);
-                       if (error_ptr != IntPtr.Zero)
-                               error = GLib.Marshaller.Utf8PtrToString(error_ptr);
-                       else
-                               error = null;
-               }
-
-               [DllImport("libcesarplayer.dll")]
-               static extern void gst_video_editor_init_backend(out int argc, IntPtr argv);
-
-               public static int InitBackend(string argv) {
-                       int argc;
-                       gst_video_editor_init_backend(out argc, GLib.Marshaller.StringToPtrGStrdup(argv));
-                       return argc;
-               }
-               
-               
-               public void SetSegment (string filePath, long start, long duration, double rate, string 
title, bool hasAudio){
-                       ClearList();
-                       AddSegment(filePath, start, duration, rate, title,hasAudio);
-               }
-               
-               public VideoQuality VideoQuality{
-                       set{VideoBitrate=(int)value;}
-               }
-               
-               public AudioQuality AudioQuality{
-                       set{AudioBitrate = (int)value;}
-               }
-               
-               public VideoFormat VideoFormat{
-                       set{
-                               if (value == VideoFormat.PORTABLE){
-                                       Height = 240;
-                                       Width = 320;
-                               }
-                               else if (value == VideoFormat.VGA){
-                                       Height = 480 ;
-                                       Width = 640;
-                               }
-                               else if (value == VideoFormat.TV){
-                                       Height = 576;
-                                       Width = 720;
-                               }
-                               else if (value == VideoFormat.HD720p){
-                                       Height = 720;
-                                       Width = 1280;
-                               }
-                               else if (value == VideoFormat.HD1080p){
-                                       Height = 1080;
-                                       Width = 1920;
-                               }
-                       }
-               }
-               
-               public AudioEncoderType AudioEncoder{
-                       set{
-                               string error;
-                               SetAudioEncoder(out error,value);
-                               if (error != null)
-                                       throw new Exception(error);
-                       }
-               }
-               
-               public VideoEncoderType VideoEncoder{
-                       set{
-                               string error;
-                               SetVideoEncoder(out error, value);
-                               if (error != null)
-                                       throw new Exception(error);
-                       }
-               }
-               
-               public VideoMuxerType VideoMuxer{
-                       set{
-                               string error;
-                               SetVideoMuxer(out error,value);
-                               if (error != null)
-                                       throw new Exception(error);
-                       }
-               }
-               
-               public string TempDir{
-                       set{;}
-               }
-               
-               #endregion
-
-               
-       }
-}
+// GstVideoSplitter.cs
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+namespace LongoMatch.Video.Editor {
+
+       using System;
+       using System.Collections;
+       using System.Runtime.InteropServices;
+       using LongoMatch.Video.Common;
+
+
+       public class GstVideoSplitter : GLib.Object, IVideoEditor, IVideoSplitter {
+
+               [DllImport("libcesarplayer.dll")]
+               static extern unsafe IntPtr gst_video_editor_new(out IntPtr err);
+
+               public event ProgressHandler Progress;
+               
+               public unsafe GstVideoSplitter () : base (IntPtr.Zero)
+               {
+                       if (GetType () != typeof (GstVideoSplitter)) {
+                               throw new InvalidOperationException ("Can't override this constructor.");
+                       }
+                       IntPtr error = IntPtr.Zero;
+                       Raw = gst_video_editor_new(out error);
+                       if (error != IntPtr.Zero) throw new GLib.GException (error);
+                       PercentCompleted += delegate(object o, PercentCompletedArgs args) {
+                               if (Progress!= null)
+                                       Progress (args.Percent);
+                       };
+               }
+
+               #region Properties
+               
+               [GLib.Property ("enable-audio")]
+               public bool EnableAudio {
+                       get {
+                               GLib.Value val = GetProperty ("enable-audio");
+                               bool ret = (bool) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("enable-audio", val);
+                               val.Dispose ();
+                       }
+               }
+               
+               [GLib.Property ("enable-title")]
+               public bool EnableTitle {
+                       get {
+                               GLib.Value val = GetProperty ("enable-title");
+                               bool ret = (bool) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("enable-title", val);
+                               val.Dispose ();
+                       }
+               }
+               
+               [GLib.Property ("video_bitrate")]
+               public int VideoBitrate {
+                       get {
+                               GLib.Value val = GetProperty ("video_bitrate");
+                               int ret = (int) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("video_bitrate", val);
+                               val.Dispose ();
+                       }
+               }
+
+               [GLib.Property ("audio_bitrate")]
+               public int AudioBitrate {
+                       get {
+                               GLib.Value val = GetProperty ("audio_bitrate");
+                               int ret = (int) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("audio_bitrate", val);
+                               val.Dispose ();
+                       }
+               }
+               
+               [GLib.Property ("width")]
+               public int Width {
+                       get {
+                               GLib.Value val = GetProperty ("width");
+                               int ret = (int) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("width", val);
+                               val.Dispose ();
+                       }
+               }
+               
+               [GLib.Property ("height")]
+               public int Height {
+                       get {
+                               GLib.Value val = GetProperty ("height");
+                               int ret = (int) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);
+                               SetProperty("height", val);
+                               val.Dispose ();
+                       }
+               }
+               
+               [GLib.Property ("output_file")]
+               public string OutputFile {
+                       get {
+                               GLib.Value val = GetProperty ("output_file");
+                               string ret = (string) val;
+                               val.Dispose ();
+                               return ret;
+                       }
+                       set {
+                               GLib.Value val = new GLib.Value(value);                         
+                               SetProperty("output_file", val);
+                               val.Dispose ();
+                       }
+               }
+               
+               #endregion
+
+               
+               
+               #region GSignals
+#pragma warning disable 0169
+               [GLib.CDeclCallback]
+               delegate void ErrorVMDelegate (IntPtr gvc, IntPtr message);
+
+               static ErrorVMDelegate ErrorVMCallback;
+
+               static void error_cb (IntPtr gvc, IntPtr message)
+               {
+                       try {
+                               GstVideoSplitter gvc_managed = GLib.Object.GetObject (gvc, false) as 
GstVideoSplitter;
+                               gvc_managed.OnError (GLib.Marshaller.Utf8PtrToString (message));
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                       }
+               }
+
+               private static void OverrideError (GLib.GType gtype)
+               {
+                       if (ErrorVMCallback == null)
+                               ErrorVMCallback = new ErrorVMDelegate (error_cb);
+                       OverrideVirtualMethod (gtype, "error", ErrorVMCallback);
+               }
+
+               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Editor.GstVideoSplitter), 
ConnectionMethod="OverrideError")]
+               protected virtual void OnError (string message)
+               {
+                       GLib.Value ret = GLib.Value.Empty;
+                       GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
+                       GLib.Value[] vals = new GLib.Value [2];
+                       vals [0] = new GLib.Value (this);
+                       inst_and_params.Append (vals [0]);
+                       vals [1] = new GLib.Value (message);
+                       inst_and_params.Append (vals [1]);
+                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
+                       foreach (GLib.Value v in vals)
+                               v.Dispose ();
+               }
+
+               [GLib.Signal("error")]
+               public event ErrorHandler Error {
+                       add {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "error", typeof (ErrorArgs));
+                               sig.AddDelegate (value);
+                       }
+                       remove {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "error", typeof (ErrorArgs));
+                               sig.RemoveDelegate (value);
+                       }
+               }
+               
+
+               [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
+               delegate void PercentCompletedVMDelegate (IntPtr gvc, float percent);
+
+               static PercentCompletedVMDelegate PercentCompletedVMCallback;
+
+               static void percentcompleted_cb (IntPtr gvc, float percent)
+               {
+                       try {
+                               GstVideoSplitter gvc_managed = GLib.Object.GetObject (gvc, false) as 
GstVideoSplitter;
+                               gvc_managed.OnPercentCompleted (percent);
+                       } catch (Exception e) {
+                               GLib.ExceptionManager.RaiseUnhandledException (e, false);
+                       }
+               }
+
+               private static void OverridePercentCompleted (GLib.GType gtype)
+               {
+                       if (PercentCompletedVMCallback == null)
+                               PercentCompletedVMCallback = new PercentCompletedVMDelegate 
(percentcompleted_cb);
+                       OverrideVirtualMethod (gtype, "percent_completed", PercentCompletedVMCallback);
+               }
+
+               [GLib.DefaultSignalHandler(Type=typeof(LongoMatch.Video.Editor.GstVideoSplitter), 
ConnectionMethod="OverridePercentCompleted")]
+               protected virtual void OnPercentCompleted (float percent)
+               {
+                       GLib.Value ret = GLib.Value.Empty;
+                       GLib.ValueArray inst_and_params = new GLib.ValueArray (2);
+                       GLib.Value[] vals = new GLib.Value [2];
+                       vals [0] = new GLib.Value (this);
+                       inst_and_params.Append (vals [0]);
+                       vals [1] = new GLib.Value (percent);
+                       inst_and_params.Append (vals [1]);
+                       g_signal_chain_from_overridden (inst_and_params.ArrayPtr, ref ret);
+                       foreach (GLib.Value v in vals)
+                               v.Dispose ();
+               }
+
+               [GLib.Signal("percent_completed")]
+               public event PercentCompletedHandler PercentCompleted {
+                       add {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "percent_completed", typeof 
(PercentCompletedArgs));
+                               sig.AddDelegate (value);
+                       }
+                       remove {
+                               GLib.Signal sig = GLib.Signal.Lookup (this, "percent_completed", typeof 
(PercentCompletedArgs));
+                               sig.RemoveDelegate (value);
+                       }
+               }
+#pragma warning restore 0169
+               #endregion
+               
+               #region Public Methods
+
+               [DllImport("libcesarplayer.dll")]
+               static extern IntPtr gst_video_editor_get_type();
+
+               public static new GLib.GType GType { 
+                       get {
+                               IntPtr raw_ret = gst_video_editor_get_type();
+                               GLib.GType ret = new GLib.GType(raw_ret);
+                               return ret;
+                       }
+               }
+               
+               
+
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_video_editor_clear_segments_list(IntPtr raw);
+
+               public void ClearList() {
+                       gst_video_editor_clear_segments_list(Handle);
+               }
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_video_editor_add_segment(IntPtr raw, string file_path, long start, 
long duration, double rate, IntPtr title, bool hasAudio);
+
+               public void AddSegment(string filePath, long start, long duration, double rate, string title, 
bool hasAudio) {
+                       if (Environment.OSVersion.Platform == PlatformID.Win32NT)
+                               filePath="file:///"+filePath;
+                       gst_video_editor_add_segment(Handle, filePath, start, duration, rate, 
GLib.Marshaller.StringToPtrGStrdup(title), hasAudio);
+               }
+               
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_video_editor_start(IntPtr raw);
+
+               public void Start() {
+                       gst_video_editor_start(Handle);
+               }
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_video_editor_cancel(IntPtr raw);
+
+               public void Cancel() {
+                       // The handle might have already been dealocated
+                       try{
+                               gst_video_editor_cancel(Handle);
+                       }catch{
+                       }
+               }
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_video_editor_set_video_encoder(IntPtr raw, out IntPtr error_ptr, int 
type);
+
+               public void SetVideoEncoder(out string error, VideoEncoderType codec) {
+                       IntPtr error_ptr = IntPtr.Zero;
+                       gst_video_editor_set_video_encoder(Handle,out error_ptr,(int)codec);
+                       if (error_ptr != IntPtr.Zero)
+                               error = GLib.Marshaller.Utf8PtrToString(error_ptr);
+                       else
+                               error = null;
+               }
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_video_editor_set_audio_encoder(IntPtr raw, out IntPtr error_ptr, int 
type);
+
+               public void SetAudioEncoder(out string error, AudioEncoderType codec) {
+                       IntPtr error_ptr = IntPtr.Zero;
+                       gst_video_editor_set_audio_encoder(Handle,out error_ptr,(int)codec);
+                       if (error_ptr != IntPtr.Zero)
+                               error = GLib.Marshaller.Utf8PtrToString(error_ptr);
+                       else
+                               error = null;
+               }
+               
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_video_editor_set_video_muxer(IntPtr raw, out IntPtr error_ptr, int 
type);
+
+               public void SetVideoMuxer(out string error, VideoMuxerType muxer) {
+                       IntPtr error_ptr = IntPtr.Zero;
+                       gst_video_editor_set_video_muxer(Handle,out error_ptr,(int)muxer);
+                       if (error_ptr != IntPtr.Zero)
+                               error = GLib.Marshaller.Utf8PtrToString(error_ptr);
+                       else
+                               error = null;
+               }
+
+               [DllImport("libcesarplayer.dll")]
+               static extern void gst_video_editor_init_backend(out int argc, IntPtr argv);
+
+               public static int InitBackend(string argv) {
+                       int argc;
+                       gst_video_editor_init_backend(out argc, GLib.Marshaller.StringToPtrGStrdup(argv));
+                       return argc;
+               }
+               
+               
+               public void SetSegment (string filePath, long start, long duration, double rate, string 
title, bool hasAudio){
+                       ClearList();
+                       AddSegment(filePath, start, duration, rate, title,hasAudio);
+               }
+               
+               public VideoQuality VideoQuality{
+                       set{VideoBitrate=(int)value;}
+               }
+               
+               public AudioQuality AudioQuality{
+                       set{AudioBitrate = (int)value;}
+               }
+               
+               public VideoFormat VideoFormat{
+                       set{
+                               if (value == VideoFormat.PORTABLE){
+                                       Height = 240;
+                                       Width = 320;
+                               }
+                               else if (value == VideoFormat.VGA){
+                                       Height = 480 ;
+                                       Width = 640;
+                               }
+                               else if (value == VideoFormat.TV){
+                                       Height = 576;
+                                       Width = 720;
+                               }
+                               else if (value == VideoFormat.HD720p){
+                                       Height = 720;
+                                       Width = 1280;
+                               }
+                               else if (value == VideoFormat.HD1080p){
+                                       Height = 1080;
+                                       Width = 1920;
+                               }
+                       }
+               }
+               
+               public AudioEncoderType AudioEncoder{
+                       set{
+                               string error;
+                               SetAudioEncoder(out error,value);
+                               if (error != null)
+                                       throw new Exception(error);
+                       }
+               }
+               
+               public VideoEncoderType VideoEncoder{
+                       set{
+                               string error;
+                               SetVideoEncoder(out error, value);
+                               if (error != null)
+                                       throw new Exception(error);
+                       }
+               }
+               
+               public VideoMuxerType VideoMuxer{
+                       set{
+                               string error;
+                               SetVideoMuxer(out error,value);
+                               if (error != null)
+                                       throw new Exception(error);
+                       }
+               }
+               
+               public string TempDir{
+                       set{;}
+               }
+               
+               #endregion
+
+               
+       }
+}
diff --git a/CesarPlayer/Editor/IVideoEditor.cs b/CesarPlayer/Editor/IVideoEditor.cs
index 68cc46c..0bc4c1b 100644
--- a/CesarPlayer/Editor/IVideoEditor.cs
+++ b/CesarPlayer/Editor/IVideoEditor.cs
@@ -1,83 +1,83 @@
-// IVideoEditor.cs
-//
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//
-
-using System;
-using System.Collections.Generic;
-using LongoMatch.Video.Common;
-
-namespace LongoMatch.Video.Editor
-{
-       
-       
-       public interface IVideoEditor
-       {
-               event ProgressHandler Progress;         
-               
-               VideoQuality VideoQuality{
-                       set;
-               }
-               
-               AudioQuality AudioQuality{
-                       set;
-               }
-               
-               VideoFormat VideoFormat{
-                       set;
-               }
-               
-               AudioEncoderType AudioEncoder{
-                       set;
-               }
-               
-               VideoEncoderType VideoEncoder{
-                       set;
-               }
-               
-               VideoMuxerType VideoMuxer{
-                       set;
-               }               
-               
-               string OutputFile{
-                       set;
-               }
-               
-               string TempDir{
-                       set;
-               }
-               
-               bool EnableTitle{
-                       set;
-               }
-               
-               bool EnableAudio{
-                       set;
-               }
-               
-                       
-               void AddSegment (string filePath, long start, long duration, double rate, string title, bool 
hasAudio) ;
-               
-               void ClearList();
-               
-               void Start();           
-               
-               void Cancel();
-               
-       }
-}
+// IVideoEditor.cs
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+using System;
+using System.Collections.Generic;
+using LongoMatch.Video.Common;
+
+namespace LongoMatch.Video.Editor
+{
+       
+       
+       public interface IVideoEditor
+       {
+               event ProgressHandler Progress;         
+               
+               VideoQuality VideoQuality{
+                       set;
+               }
+               
+               AudioQuality AudioQuality{
+                       set;
+               }
+               
+               VideoFormat VideoFormat{
+                       set;
+               }
+               
+               AudioEncoderType AudioEncoder{
+                       set;
+               }
+               
+               VideoEncoderType VideoEncoder{
+                       set;
+               }
+               
+               VideoMuxerType VideoMuxer{
+                       set;
+               }               
+               
+               string OutputFile{
+                       set;
+               }
+               
+               string TempDir{
+                       set;
+               }
+               
+               bool EnableTitle{
+                       set;
+               }
+               
+               bool EnableAudio{
+                       set;
+               }
+               
+                       
+               void AddSegment (string filePath, long start, long duration, double rate, string title, bool 
hasAudio) ;
+               
+               void ClearList();
+               
+               void Start();           
+               
+               void Cancel();
+               
+       }
+}
diff --git a/CesarPlayer/Gui/CapturerBin.cs b/CesarPlayer/Gui/CapturerBin.cs
index 76a9960..e01e7bb 100644
--- a/CesarPlayer/Gui/CapturerBin.cs
+++ b/CesarPlayer/Gui/CapturerBin.cs
@@ -1,271 +1,271 @@
-// CapturerBin.cs
-//
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//
-
-using System;
-using Gtk;
-using Gdk;
-using GLib;
-using LongoMatch.Video;
-using LongoMatch.Video.Common;
-using LongoMatch.Video.Capturer;
-using LongoMatch.Video.Utils;
-using Mono.Unix;
-
-namespace LongoMatch.Gui
-{
-       
-       
+// CapturerBin.cs
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+using System;
+using Gtk;
+using Gdk;
+using GLib;
+using LongoMatch.Video;
+using LongoMatch.Video.Common;
+using LongoMatch.Video.Capturer;
+using LongoMatch.Video.Utils;
+using Mono.Unix;
+
+namespace LongoMatch.Gui
+{
+       
+       
        [System.ComponentModel.Category("CesarPlayer")]
        [System.ComponentModel.ToolboxItem(true)]
-       public partial class CapturerBin : Gtk.Bin
-       {
-               public event EventHandler CaptureFinished;
-               public event ErrorHandler Error;
-               public event NewSnapshotHandler NewSnapshot;
-               public event NewSnapshotHandler NewSnapshotMini;
-               
-               private Pixbuf logopix;
-               private CapturePropertiesStruct captureProps;
-               private CapturerType capturerType;
-               private bool captureStarted;
-               private bool capturing;
-               private const int THUMBNAIL_MAX_WIDTH = 150;            
-               
-               ICapturer capturer;
-               
-               public CapturerBin()
-               {
-                       this.Build();
-                       captureProps = new CapturePropertiesStruct();
-                       captureProps.Width = 320;
-                       captureProps.Height = 240;
-                       captureProps.VideoBitrate = 1000;
-                       captureProps.AudioBitrate = 128;
-                       captureProps.VideoEncoder = VideoEncoderType.H264;
-                       captureProps.AudioEncoder = AudioEncoderType.Aac;
-                       captureProps.Muxer = VideoMuxerType.Mp4;
-                       captureProps.OutputFile = "";
-                       captureProps.CaptureSourceType = CaptureSourceType.System;
-                       Type = CapturerType.Fake;
+       public partial class CapturerBin : Gtk.Bin
+       {
+               public event EventHandler CaptureFinished;
+               public event ErrorHandler Error;
+               public event NewSnapshotHandler NewSnapshot;
+               public event NewSnapshotHandler NewSnapshotMini;
+               
+               private Pixbuf logopix;
+               private CapturePropertiesStruct captureProps;
+               private CapturerType capturerType;
+               private bool captureStarted;
+               private bool capturing;
+               private const int THUMBNAIL_MAX_WIDTH = 150;            
+               
+               ICapturer capturer;
+               
+               public CapturerBin()
+               {
+                       this.Build();
+                       captureProps = new CapturePropertiesStruct();
+                       captureProps.Width = 320;
+                       captureProps.Height = 240;
+                       captureProps.VideoBitrate = 1000;
+                       captureProps.AudioBitrate = 128;
+                       captureProps.VideoEncoder = VideoEncoderType.H264;
+                       captureProps.AudioEncoder = AudioEncoderType.Aac;
+                       captureProps.Muxer = VideoMuxerType.Mp4;
+                       captureProps.OutputFile = "";
+                       captureProps.CaptureSourceType = CaptureSourceType.System;
+                       Type = CapturerType.Fake;
                                
                        snapshotbutton.Visible = false;
                        timelabel.Visible = false;
-               }               
-               
-               public CapturerType Type {
-                       set {
-                               /* Close any previous instance of the capturer */
-                               Close();
-
-                               MultimediaFactory factory = new MultimediaFactory();
-                               capturer = factory.getCapturer(value);  
-                               capturer.EllapsedTime += OnTick;
-                               if (value != CapturerType.Fake){
-                                       capturer.Error += OnError;
-                                       capturer.DeviceChange += OnDeviceChange;
-                                       capturerhbox.Add((Widget)capturer);
-                                       (capturer as Widget).Visible = true;
-                                       capturerhbox.Visible = true;
-                                       logodrawingarea.Visible = false;
-                                } else{
-                                       logodrawingarea.Visible = true;
-                                       capturerhbox.Visible = false;
-                               }
-                               
-                               
-                               SetProperties();
-                               capturerType = value;
-                       }
-
-               }
-               
-               public string Logo{
-                       set{
-                               try{
-                                       this.logopix = new Pixbuf(value);
-                               }catch{
-                                       /* FIXME: Add log */
-                               }
-                       }
-               }
-               
-               public int CurrentTime {
-                       get {
-                               if (capturer == null)
-                                       return -1;
-                               return capturer.CurrentTime;
-                       }
-               }
-               
-               public bool Capturing{
-                       get{
-                               return capturing;
-                       }
-               }
-               
-               public CapturePropertiesStruct CaptureProperties{
-                       set{
-                               captureProps = value;
-                       }
-               }
-               
-               public void Start(){
-                       if (capturer == null)
-                               return;
-                       
-                       capturing = true;
-                       captureStarted = true;
+               }               
+               
+               public CapturerType Type {
+                       set {
+                               /* Close any previous instance of the capturer */
+                               Close();
+
+                               MultimediaFactory factory = new MultimediaFactory();
+                               capturer = factory.getCapturer(value);  
+                               capturer.EllapsedTime += OnTick;
+                               if (value != CapturerType.Fake){
+                                       capturer.Error += OnError;
+                                       capturer.DeviceChange += OnDeviceChange;
+                                       capturerhbox.Add((Widget)capturer);
+                                       (capturer as Widget).Visible = true;
+                                       capturerhbox.Visible = true;
+                                       logodrawingarea.Visible = false;
+                                } else{
+                                       logodrawingarea.Visible = true;
+                                       capturerhbox.Visible = false;
+                               }
+                               
                                
-                       recbutton.Visible = false;
-                       pausebutton.Visible = false;
-                       //stopbutton.Visible = true;
-                       stopbutton.Visible = false;
+                               SetProperties();
+                               capturerType = value;
+                       }
+
+               }
+               
+               public string Logo{
+                       set{
+                               try{
+                                       this.logopix = new Pixbuf(value);
+                               }catch{
+                                       /* FIXME: Add log */
+                               }
+                       }
+               }
+               
+               public int CurrentTime {
+                       get {
+                               if (capturer == null)
+                                       return -1;
+                               return capturer.CurrentTime;
+                       }
+               }
+               
+               public bool Capturing{
+                       get{
+                               return capturing;
+                       }
+               }
+               
+               public CapturePropertiesStruct CaptureProperties{
+                       set{
+                               captureProps = value;
+                       }
+               }
+               
+               public void Start(){
+                       if (capturer == null)
+                               return;
+                       
+                       capturing = true;
+                       captureStarted = true;
+                               
+                       recbutton.Visible = false;
+                       pausebutton.Visible = false;
+                       //stopbutton.Visible = true;
+                       stopbutton.Visible = false;
                        
-                       capturer.Start();
-               }
+                       capturer.Start();
+               }
 /*
-               public void SnapshotDone(){
-                       if (capturer == null)
-                               return;
+               public void SnapshotDone(){
+                       if (capturer == null)
+                               return;
 
-               }
+               }
 */
-               
-               public void TogglePause(){
-                       if (capturer == null)
-                               return;
-                       
-                       capturing = !capturing;
-                       recbutton.Visible = !capturing;
-                       pausebutton.Visible = capturing;
-                       capturer.TogglePause();
-               }
-               
-               public void Stop() {
-                       if (capturer != null){
-                               capturing = false;
-                               captureStarted = false;
-                               capturer.Stop();
-                       }
-               }
-               
-               public void Run(){
+               
+               public void TogglePause(){
+                       if (capturer == null)
+                               return;
+                       
+                       capturing = !capturing;
+                       recbutton.Visible = !capturing;
+                       pausebutton.Visible = capturing;
+                       capturer.TogglePause();
+               }
+               
+               public void Stop() {
+                       if (capturer != null){
+                               capturing = false;
+                               captureStarted = false;
+                               capturer.Stop();
+                       }
+               }
+               
+               public void Run(){
                        if (capturer != null) {
-                               capturer.Run();
+                               capturer.Run();
                                SetButtonsVisibility();
                        }
                }
 
-               public void Close(){
-                       /* resetting common properties */
-                       pausebutton.Visible = false;
-                       stopbutton.Visible = false;
+               public void Close(){
+                       /* resetting common properties */
+                       pausebutton.Visible = false;
+                       stopbutton.Visible = false;
                        //recbutton.Visible = true;
                        recbutton.Visible = false;
-                       captureStarted = false;
-                       capturing = false;
+                       captureStarted = false;
+                       capturing = false;
                        OnTick(0);
-                       
-                       if (capturer == null)
-                       return;
-                       
-                       /* stopping and closing capturer */
+                       
+                       if (capturer == null)
+                       return;
+                       
+                       /* stopping and closing capturer */
                        try {
-                               capturer.Stop();
-                               capturer.Close();
-                               if (capturerType == CapturerType.Live){
-                                       /* release and dispose live capturer */
-                                       capturer.Error -= OnError;
-                                       capturer.DeviceChange += OnDeviceChange;
-                                       capturerhbox.Remove(capturer as Gtk.Widget);
-                                       capturer.Dispose();
-                               }
+                               capturer.Stop();
+                               capturer.Close();
+                               if (capturerType == CapturerType.Live){
+                                       /* release and dispose live capturer */
+                                       capturer.Error -= OnError;
+                                       capturer.DeviceChange += OnDeviceChange;
+                                       capturerhbox.Remove(capturer as Gtk.Widget);
+                                       capturer.Dispose();
+                               }
                        } catch (Exception e) {}
-                       capturer = null;
-               }
-               
-               public Pixbuf CurrentMiniatureFrame {
-                       get {
-                               int h, w;
-                               double rate;
-                               Pixbuf scaled_pix;
-                               Pixbuf pix;
-                               
-                               if (capturer == null)
-                                       return null;
-                               
-                               pix = capturer.CurrentFrame;
-                               
-                               if (pix == null)
-                                       return null;
-                               
-                               w = pix.Width;
-                               h = pix.Height;
-                               rate = (double)w / (double)h;
-                               
-                               if (h > w) {
-                                       w = (int)(THUMBNAIL_MAX_WIDTH * rate);
-                                       h = THUMBNAIL_MAX_WIDTH;
-                               } else {
-                                       h = (int)(THUMBNAIL_MAX_WIDTH / rate);
-                                       w = THUMBNAIL_MAX_WIDTH;
-                               }
-                               scaled_pix = pix.ScaleSimple (w, h, Gdk.InterpType.Bilinear);
-                               pix.Dispose();
-                                       
-                               return scaled_pix;                                                     
-                       }
-               }
-               
-               private void SetProperties(){
-                       if (capturer == null)
-                               return;
-                       
-                       capturer.DeviceID = captureProps.DeviceID;
-                       capturer.OutputFile = captureProps.OutputFile;
-                       capturer.OutputHeight = captureProps.Height;
-                       capturer.OutputWidth = captureProps.Width;
-                       capturer.SetVideoEncoder(captureProps.VideoEncoder);
-                       capturer.SetAudioEncoder(captureProps.AudioEncoder);
-                       capturer.SetVideoMuxer(captureProps.Muxer);     
-                       capturer.SetSource(captureProps.CaptureSourceType);
-                       capturer.VideoBitrate = captureProps.VideoBitrate;
-                       capturer.AudioBitrate = captureProps.AudioBitrate;
-               }
+                       capturer = null;
+               }
+               
+               public Pixbuf CurrentMiniatureFrame {
+                       get {
+                               int h, w;
+                               double rate;
+                               Pixbuf scaled_pix;
+                               Pixbuf pix;
+                               
+                               if (capturer == null)
+                                       return null;
+                               
+                               pix = capturer.CurrentFrame;
+                               
+                               if (pix == null)
+                                       return null;
+                               
+                               w = pix.Width;
+                               h = pix.Height;
+                               rate = (double)w / (double)h;
+                               
+                               if (h > w) {
+                                       w = (int)(THUMBNAIL_MAX_WIDTH * rate);
+                                       h = THUMBNAIL_MAX_WIDTH;
+                               } else {
+                                       h = (int)(THUMBNAIL_MAX_WIDTH / rate);
+                                       w = THUMBNAIL_MAX_WIDTH;
+                               }
+                               scaled_pix = pix.ScaleSimple (w, h, Gdk.InterpType.Bilinear);
+                               pix.Dispose();
+                                       
+                               return scaled_pix;                                                     
+                       }
+               }
+               
+               private void SetProperties(){
+                       if (capturer == null)
+                               return;
+                       
+                       capturer.DeviceID = captureProps.DeviceID;
+                       capturer.OutputFile = captureProps.OutputFile;
+                       capturer.OutputHeight = captureProps.Height;
+                       capturer.OutputWidth = captureProps.Width;
+                       capturer.SetVideoEncoder(captureProps.VideoEncoder);
+                       capturer.SetAudioEncoder(captureProps.AudioEncoder);
+                       capturer.SetVideoMuxer(captureProps.Muxer);     
+                       capturer.SetSource(captureProps.CaptureSourceType);
+                       capturer.VideoBitrate = captureProps.VideoBitrate;
+                       capturer.AudioBitrate = captureProps.AudioBitrate;
+               }
 
                private void SetButtonsVisibility() {
-                       bool snapshot = capturerType == CapturerType.Snapshot;
-                       //recbutton.Visible = !snapshot;
+                       bool snapshot = capturerType == CapturerType.Snapshot;
+                       //recbutton.Visible = !snapshot;
                        recbutton.Visible = false;
-                       pausebutton.Visible = false;
-                       stopbutton.Visible = false;
-                       snapshotbutton.Visible = snapshot;
-                       //timelabel.Visible = !snapshot;
-                       timelabel.Visible = false;
+                       pausebutton.Visible = false;
+                       stopbutton.Visible = false;
+                       snapshotbutton.Visible = snapshot;
+                       //timelabel.Visible = !snapshot;
+                       timelabel.Visible = false;
                }
 
-
+
                //called from Chronojump
                public void ClickRec () {
-                       if (capturer == null)
-                               return;
+                       if (capturer == null)
+                               return;
                
                        recbutton.Visible = false;
                        stopbutton.Visible = true;
@@ -275,175 +275,175 @@ namespace LongoMatch.Gui
                public void ClickStop () {
                        //CaptureFinished(this, new EventArgs());
                        
-                       //recbutton.Visible = true;
-                       recbutton.Visible = false;
-                       pausebutton.Visible = false;
-                       stopbutton.Visible = false;
+                       //recbutton.Visible = true;
+                       recbutton.Visible = false;
+                       pausebutton.Visible = false;
+                       stopbutton.Visible = false;
                        
                        Stop();
                        //Run();
                }
 
                
-               protected virtual void OnRecbuttonClicked (object sender, System.EventArgs e)
-               {
-                       if (capturer == null)
-                               return;
+               protected virtual void OnRecbuttonClicked (object sender, System.EventArgs e)
+               {
+                       if (capturer == null)
+                               return;
                        
                        recbutton.Visible = false;
                        stopbutton.Visible = true;
 
-                       if (captureStarted == true){
-                               if (capturing)
-                                       return;
-                               TogglePause();
-                       }
+                       if (captureStarted == true){
+                               if (capturing)
+                                       return;
+                               TogglePause();
+                       }
                        else 
-                               Start();        
-               }
-
-               protected virtual void OnPausebuttonClicked (object sender, System.EventArgs e)
-               {
-                       if (capturer != null && capturing)
-                               TogglePause();                                          
-               }
-
-               protected virtual void OnStopbuttonClicked (object sender, System.EventArgs e)
-               {
-                       int res;
-                       
-                       if (capturer == null)
-                               return;
+                               Start();        
+               }
+
+               protected virtual void OnPausebuttonClicked (object sender, System.EventArgs e)
+               {
+                       if (capturer != null && capturing)
+                               TogglePause();                                          
+               }
+
+               protected virtual void OnStopbuttonClicked (object sender, System.EventArgs e)
+               {
+                       int res;
+                       
+                       if (capturer == null)
+                               return;
 
                        /*
-                       
-                       MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, DialogFlags.Modal, 
MessageType.Question, ButtonsType.YesNo,
-                                                            Catalog.GetString("You are going to stop and 
finish the current capture."+"\n"+
-                                                                              "Do you want to proceed?"));
-                       res = md.Run();
-                       md.Destroy();
-                       if (res == (int)ResponseType.Yes){
-                               md = new MessageDialog((Gtk.Window)this.Toplevel, DialogFlags.Modal, 
MessageType.Info, ButtonsType.None,
-                                                                    Catalog.GetString("Finalizing file. This 
can take a while"));
-                               md.Show();
-                               Stop();
-                               md.Destroy();
-                               recbutton.Visible = true;
-                               pausebutton.Visible = false;
-                               stopbutton.Visible = false;
-                               if (CaptureFinished != null)
-                                       CaptureFinished(this, new EventArgs());
-                       }
+                       
+                       MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, DialogFlags.Modal, 
MessageType.Question, ButtonsType.YesNo,
+                                                            Catalog.GetString("You are going to stop and 
finish the current capture."+"\n"+
+                                                                              "Do you want to proceed?"));
+                       res = md.Run();
+                       md.Destroy();
+                       if (res == (int)ResponseType.Yes){
+                               md = new MessageDialog((Gtk.Window)this.Toplevel, DialogFlags.Modal, 
MessageType.Info, ButtonsType.None,
+                                                                    Catalog.GetString("Finalizing file. This 
can take a while"));
+                               md.Show();
+                               Stop();
+                               md.Destroy();
+                               recbutton.Visible = true;
+                               pausebutton.Visible = false;
+                               stopbutton.Visible = false;
+                               if (CaptureFinished != null)
+                                       CaptureFinished(this, new EventArgs());
+                       }
                        */
                        
-                       recbutton.Visible = true;
-                       pausebutton.Visible = false;
-                       stopbutton.Visible = false;
+                       recbutton.Visible = true;
+                       pausebutton.Visible = false;
+                       stopbutton.Visible = false;
                        /*
                        if (CaptureFinished != null) {
                                Console.WriteLine("OnStopbuttonclicked 1");
-                               CaptureFinished(this, new EventArgs());
+                               CaptureFinished(this, new EventArgs());
                        }
                        */
                        Stop();
-               }                               
-               
-               protected virtual void OnTick (int ellapsedTime){
-                       timelabel.Text = "Time: " + TimeString.MSecondsToSecondsString(CurrentTime);
-               }
-               
-               protected virtual void OnError (object o, ErrorArgs args)
-               {
-                       if (Error != null)
-                               Error (o, args);
-                       
-                       Close();
-               }
-               
-               protected virtual void OnDeviceChange (object o, DeviceChangeArgs args)
-               {
-                       /* device disconnected, pause capture */
-                       if (args.DeviceChange == -1){                           
-                               if (capturing) 
-                                       TogglePause();
-                                       
-                               recbutton.Sensitive = false;
-                               
-                               MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, 
DialogFlags.Modal,
-                                                                    MessageType.Question, ButtonsType.Ok,
-                                                                    Catalog.GetString("Device disconnected. 
" +
-                                                                       "The capture will be paused"));
-                               md.Icon=Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog);
-                               md.Run();
-                               md.Destroy();                   
-                       } else {
-                               recbutton.Sensitive = true;
-                               MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, 
DialogFlags.Modal,
-                                                                    MessageType.Question, ButtonsType.YesNo,
-                                                                    Catalog.GetString("Device reconnected." +
-                                                                       "Do you want to restart the 
capture?"));
-                               md.Icon=Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog);
-                               if (md.Run() == (int)ResponseType.Yes){
-                                       Console.WriteLine ("Accepted to toggle pause");
-                                       TogglePause();
-                               }
-                               md.Destroy();
-                       }                               
-               }
-               
-               protected virtual void OnLogodrawingareaExposeEvent (object o, Gtk.ExposeEventArgs args)
+               }                               
+               
+               protected virtual void OnTick (int ellapsedTime){
+                       timelabel.Text = "Time: " + TimeString.MSecondsToSecondsString(CurrentTime);
+               }
+               
+               protected virtual void OnError (object o, ErrorArgs args)
+               {
+                       if (Error != null)
+                               Error (o, args);
+                       
+                       Close();
+               }
+               
+               protected virtual void OnDeviceChange (object o, DeviceChangeArgs args)
+               {
+                       /* device disconnected, pause capture */
+                       if (args.DeviceChange == -1){                           
+                               if (capturing) 
+                                       TogglePause();
+                                       
+                               recbutton.Sensitive = false;
+                               
+                               MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, 
DialogFlags.Modal,
+                                                                    MessageType.Question, ButtonsType.Ok,
+                                                                    Catalog.GetString("Device disconnected. 
" +
+                                                                       "The capture will be paused"));
+                               md.Icon=Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog);
+                               md.Run();
+                               md.Destroy();                   
+                       } else {
+                               recbutton.Sensitive = true;
+                               MessageDialog md = new MessageDialog((Gtk.Window)this.Toplevel, 
DialogFlags.Modal,
+                                                                    MessageType.Question, ButtonsType.YesNo,
+                                                                    Catalog.GetString("Device reconnected." +
+                                                                       "Do you want to restart the 
capture?"));
+                               md.Icon=Stetic.IconLoader.LoadIcon(md, "longomatch", Gtk.IconSize.Dialog);
+                               if (md.Run() == (int)ResponseType.Yes){
+                                       Console.WriteLine ("Accepted to toggle pause");
+                                       TogglePause();
+                               }
+                               md.Destroy();
+                       }                               
+               }
+               
+               protected virtual void OnLogodrawingareaExposeEvent (object o, Gtk.ExposeEventArgs args)
                {       
-                       Gdk.Window win;
-                       Pixbuf frame;
-                       int width, height, allocWidth, allocHeight, logoX, logoY;
-                       float ratio;
-                       
-                       if (logopix == null)
-                               return;
-
-                       win = logodrawingarea.GdkWindow;
-                       width = logopix.Width;
-                       height = logopix.Height;
-                       allocWidth = logodrawingarea.Allocation.Width;
-                       allocHeight = logodrawingarea.Allocation.Height;
-                       
+                       Gdk.Window win;
+                       Pixbuf frame;
+                       int width, height, allocWidth, allocHeight, logoX, logoY;
+                       float ratio;
+                       
+                       if (logopix == null)
+                               return;
+
+                       win = logodrawingarea.GdkWindow;
+                       width = logopix.Width;
+                       height = logopix.Height;
+                       allocWidth = logodrawingarea.Allocation.Width;
+                       allocHeight = logodrawingarea.Allocation.Height;
+                       
                        // Checking if allocated space is smaller than our logo 
-                       if ((float) allocWidth / width > (float) allocHeight / height) {
-                               ratio = (float) allocHeight / height;
-                       } else {
-                               ratio = (float) allocWidth / width;
-                       }
-                       width = (int) (width * ratio);
-                       height = (int) (height * ratio);
-                       
-                       logoX = (allocWidth / 2) - (width / 2);
-                       logoY = (allocHeight / 2) - (height / 2);
-
+                       if ((float) allocWidth / width > (float) allocHeight / height) {
+                               ratio = (float) allocHeight / height;
+                       } else {
+                               ratio = (float) allocWidth / width;
+                       }
+                       width = (int) (width * ratio);
+                       height = (int) (height * ratio);
+                       
+                       logoX = (allocWidth / 2) - (width / 2);
+                       logoY = (allocHeight / 2) - (height / 2);
+
                        // Drawing our frame
-                       frame = new Pixbuf(Colorspace.Rgb, false, 8, allocWidth, allocHeight);
-                       logopix.Composite(frame, 0, 0, allocWidth, allocHeight, logoX, logoY, 
-                                         ratio, ratio, InterpType.Bilinear, 255);
-                       
-                       win.DrawPixbuf (this.Style.BlackGC, frame, 0, 0,
-                                       0, 0, allocWidth, allocHeight,
-                                       RgbDither.Normal, 0, 0);
-                       frame.Dispose();
-                       return;
-               }
-               
-               protected virtual void OnSnapshotbuttonClicked (object sender, System.EventArgs e)
-               {
-                       Pixbuf frame = capturer.CurrentFrame;
-                       if (frame != null && NewSnapshot != null) {
-                               NewSnapshot(frame);
-                       }
+                       frame = new Pixbuf(Colorspace.Rgb, false, 8, allocWidth, allocHeight);
+                       logopix.Composite(frame, 0, 0, allocWidth, allocHeight, logoX, logoY, 
+                                         ratio, ratio, InterpType.Bilinear, 255);
+                       
+                       win.DrawPixbuf (this.Style.BlackGC, frame, 0, 0,
+                                       0, 0, allocWidth, allocHeight,
+                                       RgbDither.Normal, 0, 0);
+                       frame.Dispose();
+                       return;
+               }
+               
+               protected virtual void OnSnapshotbuttonClicked (object sender, System.EventArgs e)
+               {
+                       Pixbuf frame = capturer.CurrentFrame;
+                       if (frame != null && NewSnapshot != null) {
+                               NewSnapshot(frame);
+                       }
                        
-                       Pixbuf frameMini = CurrentMiniatureFrame;
-                       if (frameMini != null && NewSnapshotMini != null) {
-                               NewSnapshotMini(frameMini);
-                       }
-               }
-               
-               
-       }
-}
+                       Pixbuf frameMini = CurrentMiniatureFrame;
+                       if (frameMini != null && NewSnapshotMini != null) {
+                               NewSnapshotMini(frameMini);
+                       }
+               }
+               
+               
+       }
+}
diff --git a/CesarPlayer/Gui/PlayerBin.cs b/CesarPlayer/Gui/PlayerBin.cs
index 089429a..57998bd 100644
--- a/CesarPlayer/Gui/PlayerBin.cs
+++ b/CesarPlayer/Gui/PlayerBin.cs
@@ -1,624 +1,624 @@
-// PlayerBin.cs 
-//
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//
-using System;
-using Gtk;
-using Gdk;
-using Mono.Unix;
-using System.Runtime.InteropServices;
-using LongoMatch.Video;
-using LongoMatch.Video.Common;
-using LongoMatch.Video.Player;
-using LongoMatch.Video.Utils;
-
-namespace LongoMatch.Gui
-{
-       [System.ComponentModel.Category("LongoMatch")]
-       [System.ComponentModel.ToolboxItem(true)]
-               
-       public partial class PlayerBin : Gtk.Bin
-       {
-               
-               public event SegmentClosedHandler SegmentClosedEvent;
-               public event TickHandler Tick;
-               public event ErrorHandler Error;
-               public event StateChangeHandler PlayStateChanged;
-               public event NextButtonClickedHandler Next;
-               public event PrevButtonClickedHandler Prev;
-               public event DrawFrameHandler DrawFrame;
-               public event SeekEventHandler SeekEvent;
-                       
-               private const int THUMBNAIL_MAX_WIDTH = 100;
-               private TickHandler tickHandler;
-               private IPlayer player;
-               private long length=0;
-               private string slength;
-               private long segmentStartTime;
-               private long segmentStopTime;
-               private bool seeking=false;
-               private double[] seeksQueue; 
-               private bool IsPlayingPrevState = false;
-               private float rate=1;
-               private double previousVLevel = 1;
-               private bool muted=false;
-               private object[] pendingSeek=null; //{start,stop,rate}
-               //the player.mrl is diferent from the filename as it's an uri eg:file:///foo.avi
-               private string filename = null;
-               protected VolumeWindow vwin;
-               
-                               
-#region Constructors           
-               public PlayerBin()
-               {               
-                       this.Build();
-                       PlayerInit();
-                       vwin = new VolumeWindow();
-                       vwin.VolumeChanged += new VolumeChangedHandler(OnVolumeChanged);
-                       controlsbox.Visible = false;    
-                       UnSensitive();
-                       timescale.Adjustment.PageIncrement = 0.01;
-                       timescale.Adjustment.StepIncrement = 0.0001;
-                       playbutton.CanFocus = false;
-                       prevbutton.CanFocus = false;
-                       nextbutton.CanFocus = false;
-                       volumebutton.CanFocus = false;
-                       timescale.CanFocus = false;
-                       vscale1.CanFocus = false;       
-                       drawbutton.CanFocus = false;
-                       seeksQueue = new double[2];
-                       seeksQueue [0] = -1;
-                       seeksQueue [1] = -1;
-               }
-               
-#endregion
-       
-#region Properties
-               
-               public IPlayer Player{
-                       get{return player;}
-               }
-               
-               public long AccurateCurrentTime{
-                       get{return player.AccurateCurrentTime;}
-               }
-               
-               public long CurrentTime{
-                       get{return player.CurrentTime;}
-               }
-               
-               public long StreamLength{
-                       get{return player.StreamLength;}
-               }
-               
-               public float Rate{
-                       get{return rate;}
-                       set{vscale1.Value = (int)(value*25);}
-               }
-               
-               public bool FullScreen{
-                       set{
-                               if (value)
-                                       GdkWindow.Fullscreen();
-                               else 
-                                       GdkWindow.Unfullscreen();                               
-                       }
-               }
-               
-               public Pixbuf CurrentMiniatureFrame{
-                       get{
-                               Pixbuf pixbuf = 
player.GetCurrentFrame(THUMBNAIL_MAX_WIDTH,THUMBNAIL_MAX_WIDTH);                                
-                               return pixbuf;
-                       }
-               }
-               
-               public Pixbuf CurrentFrame{
-                       get{return player.GetCurrentFrame();}
-               }
-               
-               public Pixbuf LogoPixbuf{
-                       set{player.LogoPixbuf = value;}
-               }
-               
-               public bool DrawingMode {
-                       set{player.DrawingMode= value;}
-               }
-               
-               public Pixbuf DrawingPixbuf {
-                       set{player.DrawingPixbuf=value;}
-               }
-               
-               public bool LogoMode{
-                       set{player.LogoMode = value;}
-               }
-               
-               public bool ExpandLogo {
-                       get{return player.ExpandLogo;}
-                       set{player.ExpandLogo = value;}
-               }
-               
-               public bool Opened {
-                   get{return filename != null;}
-               }
-                       
-               public Widget VideoWidget{
-                       get{return ((Gtk.EventBox)player);}
-               }
-#endregion     
-               
-#region Public methods         
-               
-               public void Open (string mrl){
-                       filename = mrl;
-                       ResetGui();
-                       CloseActualSegment();                   
-                               try{
-                                       player.Open(mrl);
-                               }
-                               catch {
-                               //We handle this error async                            
-                               }
-               }
-               
-               public void Play(){                     
-                       player.Play();                  
-                       float val = GetRateFromScale();                                                 
-                       if (segmentStartTime == 0 && segmentStopTime==0)
-                               player.SetRate(val);
-                       else
-                               player.SetRateInSegment(val,segmentStopTime);           
-               }
-               
-               public void Pause(){
-                       player.Pause();
-               }               
-               
-               public void TogglePlay(){
-                       if (player.Playing)
-                               Pause();
-                       else 
-                               Play();
-               }
-               
-               public void SetLogo (string filename){
-                       player.Logo=filename;
-               }
-               
-               public void ResetGui(){
-                       closebutton.Hide();
-                       SetSensitive();
-                       timescale.Value=0;
-                       timelabel.Text="";
-                       player.CancelProgramedStop();                   
-               }
-       
-               public void SetPlayListElement(string fileName,long start, long stop, float rate, bool 
hasNext){
-                       if (hasNext)
-                               nextbutton.Sensitive = true;
-                       else
-                               nextbutton.Sensitive = false;
-                       
-                       if (fileName != filename){
-                               Open(fileName); 
-                               //Wait until the pipeline is prerolled and ready to seek
-                               pendingSeek = new object[3] {start,stop,rate};
-                       }
-                       else player.SegmentSeek(start,stop,rate);       
-                       
-                       segmentStartTime = start;
-                       segmentStopTime = stop;
-                       player.LogoMode = false;
-                       Rate = rate;
-               }
-               
-               public void Close(){
-                       player.Close();
-                       filename = null;
-                       timescale.Value = 0;
-                       UnSensitive();
-               }
-               
-               public void SeekTo(long time, bool accurate){
-                       player.SeekTime(time,1,accurate);
-                       if (SeekEvent != null)
-                               SeekEvent(time);
-               }
-               
-               public void SeekInSegment(long pos){
-                       player.SeekInSegment(pos, GetRateFromScale());
-                       if (SeekEvent != null)
-                               SeekEvent(pos);
-               }
-               
-               public void SeekToNextFrame(bool in_segment){
-                       int currentTime = (int)player.CurrentTime;
-                       if (segmentStopTime==0 | currentTime < segmentStopTime){
-                               if (player.Playing)
-                                       player.Pause();
-                               player.SeekToNextFrame( GetRateFromScale(), in_segment);
-                               if (SeekEvent != null)
-                                       SeekEvent(currentTime );
-                       }
-                       
-               }
-               
-               public void SeekToPreviousFrame(bool in_segment){
-                       long currentTime = player.CurrentTime;
-                       if (currentTime> segmentStartTime){
-                               if (player.Playing)
-                                       player.Pause();
-                               player.SeekToPreviousFrame( GetRateFromScale(),in_segment);
-                               if (SeekEvent != null)
-                                       SeekEvent(currentTime);
-                       }
-               }
-               
-               public void StepForward(){
-                       SeekFromTimescale(timescale.Value + timescale.Adjustment.PageIncrement);
-               }
-               
-               public void StepBackward(){                     
-                       SeekFromTimescale(timescale.Value - timescale.Adjustment.PageIncrement);
-               }
-               
-               public void FramerateUp(){
-                       vscale1.Adjustment.Value += vscale1.Adjustment.StepIncrement;
-               }
-               
-               public void FramerateDown(){
-                       vscale1.Adjustment.Value -= vscale1.Adjustment.StepIncrement;
-               }
-               
-               public void UpdateSegmentStartTime (long start){
-                       segmentStartTime = start;
-                       player.SegmentStartUpdate(start, GetRateFromScale());
-                       if (SeekEvent != null)
-                               SeekEvent(start);
-               }
-               
-               public void UpdateSegmentStopTime (long stop){
-                       segmentStopTime = stop;
-                       player.SegmentStopUpdate(stop, GetRateFromScale());     
-                       if (SeekEvent != null)
-                               SeekEvent(stop);
-               }
-               
-               public void SetStartStop(long start, long stop){
-                       segmentStartTime = start;
-                       segmentStopTime = stop;
-                       closebutton.Show();
-                       vscale1.Value = 25;
-                       player.SegmentSeek(start,stop, GetRateFromScale());     
-                       player.Play();
-               }
-               
-               public void CloseActualSegment(){
-                       closebutton.Hide();
-                       segmentStartTime = 0;
-                       segmentStopTime = 0;
-                       vscale1.Value=25;
-                       //timescale.Sensitive = true;
-                       slength = TimeString.MSecondsToSecondsString(length);
-                       if (SegmentClosedEvent != null)
-                               SegmentClosedEvent();
-                       player.CancelProgramedStop();                   
-               }
-               
-               public void SetSensitive(){
-                       controlsbox.Sensitive = true;
-                       vscale1.Sensitive = true;                                       
-               }
-               
-               public void UnSensitive(){                      
-                       controlsbox.Sensitive = false;
-                       vscale1.Sensitive = false;                              
-               }               
-                       
-               public void SeeControlsBox(bool see){
-                       controlsbox.Visible = see;
-               }
-               
-#endregion
-               
-#region Private methods
-               
-               private float GetRateFromScale(){
-                       VScale scale= vscale1;
-                       double val = scale.Value;
-                       
-                       if (val >25 ){
-                               val = val-25 ;                                  
-                       }
-                       else if (val <=25){                     
-                               val = val/25;
-                       }
-                       return (float)val;
-               }
-               
-               private bool InSegment(){
-                       return  !(segmentStopTime == 0 && segmentStartTime ==0) ;
-               }
-               
-               private void PlayerInit(){
-                       MultimediaFactory factory;
-                       Widget playerWidget;
-                       
-                       factory= new MultimediaFactory();
-                       player = factory.getPlayer(320,280);
-                       
-                       tickHandler = new TickHandler(OnTick);
-                       player.Tick += tickHandler;
-                       player.StateChange += new StateChangeHandler(OnStateChanged);
-                       player.Eos += new EventHandler (OnEndOfStream);
-                       player.Error += new ErrorHandler (OnError);
-                       player.ReadyToSeek += new EventHandler(OnReadyToSeek);
-                       
-                       playerWidget = (Widget)player;
-                       playerWidget.ButtonPressEvent += OnVideoboxButtonPressEvent;
-                       playerWidget.ScrollEvent += OnVideoboxScrollEvent;
-                       playerWidget.Show();
-                       videobox.Add(playerWidget);     
-                               
-               }
-               
-               private void SeekFromTimescale(double pos){                                             
-                       if (InSegment()){
-                               long seekPos = segmentStartTime + 
(long)(pos*(segmentStopTime-segmentStartTime));
-                               player.SeekInSegment(seekPos, GetRateFromScale());      
-                               timelabel.Text= TimeString.MSecondsToSecondsString(seekPos) + "/" + 
-                                       TimeString.MSecondsToSecondsString(segmentStopTime-segmentStartTime);
-                       }
-                       else {
-                               player.Position = pos;
-                               timelabel.Text= TimeString.MSecondsToSecondsString(player.CurrentTime) + "/" 
+ slength;
-                               Rate = 1;                               
-                       }       
-               }
-               
-#endregion
-               
-#region Callbacks
-               protected virtual void OnStateChanged(object o, StateChangeArgs args){
-                       if (args.Playing){
-                               playbutton.Hide();
-                               pausebutton.Show();
-                       }
-                       else{
-                               playbutton.Show();
-                               pausebutton.Hide();
-                       }
-                       if (PlayStateChanged != null)
-                               PlayStateChanged(this,args);
-               }
-               
-               protected void OnReadyToSeek(object o, EventArgs args){
-                       if (pendingSeek != null){
-                               player.SegmentSeek((long)pendingSeek[0],
-                                                  (long)pendingSeek[1],
-                                                  (float)pendingSeek[2]);
-                               player.Play();
-                               pendingSeek = null;
-                                                  
-                       }
-               }
-               
-               protected virtual void OnTick(object o,TickArgs args){
-                       long currentTime = args.CurrentTime;
-                       float currentposition = args.CurrentPosition;           
-                       long streamLength = args.StreamLength;          
-                       
-                       //Console.WriteLine ("Current Time:{0}\n Length:{1}\n",currentTime, streamLength);
-                       if (length != streamLength){                                                    
-                               length = streamLength;
-                               slength = TimeString.MSecondsToSecondsString(length);                         
  
-                       }
-                       
-                       if  (InSegment()){
-                               currentTime -= segmentStartTime;
-                               currentposition = 
(float)currentTime/(float)(segmentStopTime-segmentStartTime);
-                               slength = 
TimeString.MSecondsToSecondsString(segmentStopTime-segmentStartTime);
-                       }                                               
-                       
-                       timelabel.Text = TimeString.MSecondsToSecondsString(currentTime) + "/" + slength;     
                      
-                       timescale.Value = currentposition;
-                       if (Tick != null)
-                               Tick(o,args);
-                       
-               }
-               
-               protected virtual void OnTimescaleAdjustBounds(object o, Gtk.AdjustBoundsArgs args)
-               {
-                       double pos;             
-                       
-                       if (!seeking){
-                               seeking = true;
-                               IsPlayingPrevState = player.Playing;
-                               player.Tick -= tickHandler;
-                               player.Pause();
-                               seeksQueue [0] = -1;
-                               seeksQueue [1] = -1;
-                       }
-                       
-                       pos = timescale.Value;  
-                       seeksQueue[0] = seeksQueue[1];
-                       seeksQueue[1] = pos;
-                       
-                       SeekFromTimescale(pos);         
-               }               
-
-               protected virtual void OnTimescaleValueChanged(object sender, System.EventArgs e)
-               {
-                       if (seeking){
-                               /* Releasing the timescale always report value different from the real one. 
-                                * We need to cache previous position and seek again to the this position */  
                          
-                               SeekFromTimescale(seeksQueue[0] != -1 ? seeksQueue[0] : seeksQueue[1]);
-                               seeking=false;                          
-                               player.Tick += tickHandler;
-                               if (IsPlayingPrevState)
-                                       player.Play();
-                       }
-               }
-
-               protected virtual void OnPlaybuttonClicked(object sender, System.EventArgs e)
-               {
-                         Play();               
-               }
-
-               protected virtual void OnStopbuttonClicked(object sender, System.EventArgs e)
-               {
-                       player.SeekTime(segmentStartTime,1,true);
-               }
-
-               protected virtual void OnVolumebuttonClicked(object sender, System.EventArgs e)
-               {
-                       vwin.SetLevel(player.Volume);
-                       vwin.Show();
-               }
-
-               protected virtual void OnDestroyEvent(object o, Gtk.DestroyEventArgs args)
-               {
-                       player.Dispose();
-               }
-               
-               protected virtual void OnVolumeChanged(double level){
-                       player.Volume = level;
-                       if (level == 0)
-                               muted = true;
-                       else
-                               muted = false;
-               }
-
-               protected virtual void OnPausebuttonClicked (object sender, System.EventArgs e)
-               {                       
-                       player.Pause();
-               }
-               
-               protected virtual void OnEndOfStream (object o, EventArgs args){
-                       player.SeekInSegment(0, GetRateFromScale());
-                       player.Pause();                 
-               }
-               
-                               
-               protected virtual void OnError (object o, ErrorArgs args){
-                       if(Error != null)
-                               Error(o,args);
-               }
-
-               protected virtual void OnClosebuttonClicked (object sender, System.EventArgs e)
-               {
-                       CloseActualSegment();   
-               }
-
-               protected virtual void OnPrevbuttonClicked (object sender, System.EventArgs e)
-               {                       
-                       if (Prev != null)
-                               Prev();
-               }
-
-               protected virtual void OnNextbuttonClicked (object sender, System.EventArgs e)
-               {
-                       if (Next != null)
-                               Next();         
-               }
-
-               protected virtual void OnVscale1FormatValue (object o, Gtk.FormatValueArgs args)
-               {
-                       double val = args.Value;
-                       if (val >25 ){
-                               val = val-25 ;
-                               args.RetVal = val +"X";
-                       }
-                       else if (val ==25){
-                               args.RetVal = "1X";
-                       }
-                       else if (val <25){
-                               args.RetVal = "-"+val+"/25"+"X";
-                       }
-               }
-
-               protected virtual void OnVscale1ValueChanged (object sender, System.EventArgs e)
-               {
-                       float val = GetRateFromScale();
-                       
-                       // Mute for rate != 1
-                       if (val != 1 && player.Volume != 0){ 
-                               previousVLevel = player.Volume;
-                               player.Volume=0;
-                       }
-                       else if  (val != 1 && muted)
-                                 previousVLevel = 0;                   
-                       else if (val ==1)
-                               player.Volume = previousVLevel;                 
-                       
-                       if (InSegment()){
-                               player.SetRateInSegment(val,segmentStopTime);
-                       }
-                       else
-                               player.SetRate(val);                    
-                       rate = val;
-               }
-
-               protected virtual void OnVideoboxButtonPressEvent (object o, Gtk.ButtonPressEventArgs args)
-               {
-                       if(filename == null)
-                               return;
-                       /* FIXME: The pointer is grabbed when the event box is clicked.
-                        * Make sure to ungrab it in order to avoid clicks outisde the window
-                        * triggering this callback. This should be fixed properly.*/ 
-                       Pointer.Ungrab(Gtk.Global.CurrentEventTime);
-                       if (!player.Playing)
-                               Play();
-                       else 
-                               Pause();                
-               }
-               
-               protected virtual void OnVideoboxScrollEvent (object o, Gtk.ScrollEventArgs args)
-               {
-                       switch (args.Event.Direction){
-                               case ScrollDirection.Down:
-                                       SeekToPreviousFrame(InSegment());
-                                       break;
-                               case ScrollDirection.Up:
-                                       SeekToNextFrame(InSegment());
-                                       break;
-                               case ScrollDirection.Left:
-                                       StepBackward();
-                                       break;
-                               case ScrollDirection.Right:
-                                       StepForward();
-                                       break;
-                       }
-               }
-               
-               protected virtual void OnDrawButtonClicked (object sender, System.EventArgs e)
-               {
-                       int currentTime;
-                       
-                       currentTime = (int)AccurateCurrentTime;
-                       // If the player has reached the end of the segment the current time
-                       // will be unseekable and it's not possible to get a frame at this
-                       // instant. If we exceed the segment stop time, decrease in a 
-                       // milisecond the position. 
-                       if (InSegment() && currentTime >= segmentStopTime)
-                               currentTime -= 1;
-                       if (DrawFrame != null)
-                               DrawFrame(currentTime);
-               }
-#endregion     
-       }
-}
+// PlayerBin.cs 
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+using System;
+using Gtk;
+using Gdk;
+using Mono.Unix;
+using System.Runtime.InteropServices;
+using LongoMatch.Video;
+using LongoMatch.Video.Common;
+using LongoMatch.Video.Player;
+using LongoMatch.Video.Utils;
+
+namespace LongoMatch.Gui
+{
+       [System.ComponentModel.Category("LongoMatch")]
+       [System.ComponentModel.ToolboxItem(true)]
+               
+       public partial class PlayerBin : Gtk.Bin
+       {
+               
+               public event SegmentClosedHandler SegmentClosedEvent;
+               public event TickHandler Tick;
+               public event ErrorHandler Error;
+               public event StateChangeHandler PlayStateChanged;
+               public event NextButtonClickedHandler Next;
+               public event PrevButtonClickedHandler Prev;
+               public event DrawFrameHandler DrawFrame;
+               public event SeekEventHandler SeekEvent;
+                       
+               private const int THUMBNAIL_MAX_WIDTH = 100;
+               private TickHandler tickHandler;
+               private IPlayer player;
+               private long length=0;
+               private string slength;
+               private long segmentStartTime;
+               private long segmentStopTime;
+               private bool seeking=false;
+               private double[] seeksQueue; 
+               private bool IsPlayingPrevState = false;
+               private float rate=1;
+               private double previousVLevel = 1;
+               private bool muted=false;
+               private object[] pendingSeek=null; //{start,stop,rate}
+               //the player.mrl is diferent from the filename as it's an uri eg:file:///foo.avi
+               private string filename = null;
+               protected VolumeWindow vwin;
+               
+                               
+#region Constructors           
+               public PlayerBin()
+               {               
+                       this.Build();
+                       PlayerInit();
+                       vwin = new VolumeWindow();
+                       vwin.VolumeChanged += new VolumeChangedHandler(OnVolumeChanged);
+                       controlsbox.Visible = false;    
+                       UnSensitive();
+                       timescale.Adjustment.PageIncrement = 0.01;
+                       timescale.Adjustment.StepIncrement = 0.0001;
+                       playbutton.CanFocus = false;
+                       prevbutton.CanFocus = false;
+                       nextbutton.CanFocus = false;
+                       volumebutton.CanFocus = false;
+                       timescale.CanFocus = false;
+                       vscale1.CanFocus = false;       
+                       drawbutton.CanFocus = false;
+                       seeksQueue = new double[2];
+                       seeksQueue [0] = -1;
+                       seeksQueue [1] = -1;
+               }
+               
+#endregion
+       
+#region Properties
+               
+               public IPlayer Player{
+                       get{return player;}
+               }
+               
+               public long AccurateCurrentTime{
+                       get{return player.AccurateCurrentTime;}
+               }
+               
+               public long CurrentTime{
+                       get{return player.CurrentTime;}
+               }
+               
+               public long StreamLength{
+                       get{return player.StreamLength;}
+               }
+               
+               public float Rate{
+                       get{return rate;}
+                       set{vscale1.Value = (int)(value*25);}
+               }
+               
+               public bool FullScreen{
+                       set{
+                               if (value)
+                                       GdkWindow.Fullscreen();
+                               else 
+                                       GdkWindow.Unfullscreen();                               
+                       }
+               }
+               
+               public Pixbuf CurrentMiniatureFrame{
+                       get{
+                               Pixbuf pixbuf = 
player.GetCurrentFrame(THUMBNAIL_MAX_WIDTH,THUMBNAIL_MAX_WIDTH);                                
+                               return pixbuf;
+                       }
+               }
+               
+               public Pixbuf CurrentFrame{
+                       get{return player.GetCurrentFrame();}
+               }
+               
+               public Pixbuf LogoPixbuf{
+                       set{player.LogoPixbuf = value;}
+               }
+               
+               public bool DrawingMode {
+                       set{player.DrawingMode= value;}
+               }
+               
+               public Pixbuf DrawingPixbuf {
+                       set{player.DrawingPixbuf=value;}
+               }
+               
+               public bool LogoMode{
+                       set{player.LogoMode = value;}
+               }
+               
+               public bool ExpandLogo {
+                       get{return player.ExpandLogo;}
+                       set{player.ExpandLogo = value;}
+               }
+               
+               public bool Opened {
+                   get{return filename != null;}
+               }
+                       
+               public Widget VideoWidget{
+                       get{return ((Gtk.EventBox)player);}
+               }
+#endregion     
+               
+#region Public methods         
+               
+               public void Open (string mrl){
+                       filename = mrl;
+                       ResetGui();
+                       CloseActualSegment();                   
+                               try{
+                                       player.Open(mrl);
+                               }
+                               catch {
+                               //We handle this error async                            
+                               }
+               }
+               
+               public void Play(){                     
+                       player.Play();                  
+                       float val = GetRateFromScale();                                                 
+                       if (segmentStartTime == 0 && segmentStopTime==0)
+                               player.SetRate(val);
+                       else
+                               player.SetRateInSegment(val,segmentStopTime);           
+               }
+               
+               public void Pause(){
+                       player.Pause();
+               }               
+               
+               public void TogglePlay(){
+                       if (player.Playing)
+                               Pause();
+                       else 
+                               Play();
+               }
+               
+               public void SetLogo (string filename){
+                       player.Logo=filename;
+               }
+               
+               public void ResetGui(){
+                       closebutton.Hide();
+                       SetSensitive();
+                       timescale.Value=0;
+                       timelabel.Text="";
+                       player.CancelProgramedStop();                   
+               }
+       
+               public void SetPlayListElement(string fileName,long start, long stop, float rate, bool 
hasNext){
+                       if (hasNext)
+                               nextbutton.Sensitive = true;
+                       else
+                               nextbutton.Sensitive = false;
+                       
+                       if (fileName != filename){
+                               Open(fileName); 
+                               //Wait until the pipeline is prerolled and ready to seek
+                               pendingSeek = new object[3] {start,stop,rate};
+                       }
+                       else player.SegmentSeek(start,stop,rate);       
+                       
+                       segmentStartTime = start;
+                       segmentStopTime = stop;
+                       player.LogoMode = false;
+                       Rate = rate;
+               }
+               
+               public void Close(){
+                       player.Close();
+                       filename = null;
+                       timescale.Value = 0;
+                       UnSensitive();
+               }
+               
+               public void SeekTo(long time, bool accurate){
+                       player.SeekTime(time,1,accurate);
+                       if (SeekEvent != null)
+                               SeekEvent(time);
+               }
+               
+               public void SeekInSegment(long pos){
+                       player.SeekInSegment(pos, GetRateFromScale());
+                       if (SeekEvent != null)
+                               SeekEvent(pos);
+               }
+               
+               public void SeekToNextFrame(bool in_segment){
+                       int currentTime = (int)player.CurrentTime;
+                       if (segmentStopTime==0 | currentTime < segmentStopTime){
+                               if (player.Playing)
+                                       player.Pause();
+                               player.SeekToNextFrame( GetRateFromScale(), in_segment);
+                               if (SeekEvent != null)
+                                       SeekEvent(currentTime );
+                       }
+                       
+               }
+               
+               public void SeekToPreviousFrame(bool in_segment){
+                       long currentTime = player.CurrentTime;
+                       if (currentTime> segmentStartTime){
+                               if (player.Playing)
+                                       player.Pause();
+                               player.SeekToPreviousFrame( GetRateFromScale(),in_segment);
+                               if (SeekEvent != null)
+                                       SeekEvent(currentTime);
+                       }
+               }
+               
+               public void StepForward(){
+                       SeekFromTimescale(timescale.Value + timescale.Adjustment.PageIncrement);
+               }
+               
+               public void StepBackward(){                     
+                       SeekFromTimescale(timescale.Value - timescale.Adjustment.PageIncrement);
+               }
+               
+               public void FramerateUp(){
+                       vscale1.Adjustment.Value += vscale1.Adjustment.StepIncrement;
+               }
+               
+               public void FramerateDown(){
+                       vscale1.Adjustment.Value -= vscale1.Adjustment.StepIncrement;
+               }
+               
+               public void UpdateSegmentStartTime (long start){
+                       segmentStartTime = start;
+                       player.SegmentStartUpdate(start, GetRateFromScale());
+                       if (SeekEvent != null)
+                               SeekEvent(start);
+               }
+               
+               public void UpdateSegmentStopTime (long stop){
+                       segmentStopTime = stop;
+                       player.SegmentStopUpdate(stop, GetRateFromScale());     
+                       if (SeekEvent != null)
+                               SeekEvent(stop);
+               }
+               
+               public void SetStartStop(long start, long stop){
+                       segmentStartTime = start;
+                       segmentStopTime = stop;
+                       closebutton.Show();
+                       vscale1.Value = 25;
+                       player.SegmentSeek(start,stop, GetRateFromScale());     
+                       player.Play();
+               }
+               
+               public void CloseActualSegment(){
+                       closebutton.Hide();
+                       segmentStartTime = 0;
+                       segmentStopTime = 0;
+                       vscale1.Value=25;
+                       //timescale.Sensitive = true;
+                       slength = TimeString.MSecondsToSecondsString(length);
+                       if (SegmentClosedEvent != null)
+                               SegmentClosedEvent();
+                       player.CancelProgramedStop();                   
+               }
+               
+               public void SetSensitive(){
+                       controlsbox.Sensitive = true;
+                       vscale1.Sensitive = true;                                       
+               }
+               
+               public void UnSensitive(){                      
+                       controlsbox.Sensitive = false;
+                       vscale1.Sensitive = false;                              
+               }               
+                       
+               public void SeeControlsBox(bool see){
+                       controlsbox.Visible = see;
+               }
+               
+#endregion
+               
+#region Private methods
+               
+               private float GetRateFromScale(){
+                       VScale scale= vscale1;
+                       double val = scale.Value;
+                       
+                       if (val >25 ){
+                               val = val-25 ;                                  
+                       }
+                       else if (val <=25){                     
+                               val = val/25;
+                       }
+                       return (float)val;
+               }
+               
+               private bool InSegment(){
+                       return  !(segmentStopTime == 0 && segmentStartTime ==0) ;
+               }
+               
+               private void PlayerInit(){
+                       MultimediaFactory factory;
+                       Widget playerWidget;
+                       
+                       factory= new MultimediaFactory();
+                       player = factory.getPlayer(320,280);
+                       
+                       tickHandler = new TickHandler(OnTick);
+                       player.Tick += tickHandler;
+                       player.StateChange += new StateChangeHandler(OnStateChanged);
+                       player.Eos += new EventHandler (OnEndOfStream);
+                       player.Error += new ErrorHandler (OnError);
+                       player.ReadyToSeek += new EventHandler(OnReadyToSeek);
+                       
+                       playerWidget = (Widget)player;
+                       playerWidget.ButtonPressEvent += OnVideoboxButtonPressEvent;
+                       playerWidget.ScrollEvent += OnVideoboxScrollEvent;
+                       playerWidget.Show();
+                       videobox.Add(playerWidget);     
+                               
+               }
+               
+               private void SeekFromTimescale(double pos){                                             
+                       if (InSegment()){
+                               long seekPos = segmentStartTime + 
(long)(pos*(segmentStopTime-segmentStartTime));
+                               player.SeekInSegment(seekPos, GetRateFromScale());      
+                               timelabel.Text= TimeString.MSecondsToSecondsString(seekPos) + "/" + 
+                                       TimeString.MSecondsToSecondsString(segmentStopTime-segmentStartTime);
+                       }
+                       else {
+                               player.Position = pos;
+                               timelabel.Text= TimeString.MSecondsToSecondsString(player.CurrentTime) + "/" 
+ slength;
+                               Rate = 1;                               
+                       }       
+               }
+               
+#endregion
+               
+#region Callbacks
+               protected virtual void OnStateChanged(object o, StateChangeArgs args){
+                       if (args.Playing){
+                               playbutton.Hide();
+                               pausebutton.Show();
+                       }
+                       else{
+                               playbutton.Show();
+                               pausebutton.Hide();
+                       }
+                       if (PlayStateChanged != null)
+                               PlayStateChanged(this,args);
+               }
+               
+               protected void OnReadyToSeek(object o, EventArgs args){
+                       if (pendingSeek != null){
+                               player.SegmentSeek((long)pendingSeek[0],
+                                                  (long)pendingSeek[1],
+                                                  (float)pendingSeek[2]);
+                               player.Play();
+                               pendingSeek = null;
+                                                  
+                       }
+               }
+               
+               protected virtual void OnTick(object o,TickArgs args){
+                       long currentTime = args.CurrentTime;
+                       float currentposition = args.CurrentPosition;           
+                       long streamLength = args.StreamLength;          
+                       
+                       //Console.WriteLine ("Current Time:{0}\n Length:{1}\n",currentTime, streamLength);
+                       if (length != streamLength){                                                    
+                               length = streamLength;
+                               slength = TimeString.MSecondsToSecondsString(length);                         
  
+                       }
+                       
+                       if  (InSegment()){
+                               currentTime -= segmentStartTime;
+                               currentposition = 
(float)currentTime/(float)(segmentStopTime-segmentStartTime);
+                               slength = 
TimeString.MSecondsToSecondsString(segmentStopTime-segmentStartTime);
+                       }                                               
+                       
+                       timelabel.Text = TimeString.MSecondsToSecondsString(currentTime) + "/" + slength;     
                      
+                       timescale.Value = currentposition;
+                       if (Tick != null)
+                               Tick(o,args);
+                       
+               }
+               
+               protected virtual void OnTimescaleAdjustBounds(object o, Gtk.AdjustBoundsArgs args)
+               {
+                       double pos;             
+                       
+                       if (!seeking){
+                               seeking = true;
+                               IsPlayingPrevState = player.Playing;
+                               player.Tick -= tickHandler;
+                               player.Pause();
+                               seeksQueue [0] = -1;
+                               seeksQueue [1] = -1;
+                       }
+                       
+                       pos = timescale.Value;  
+                       seeksQueue[0] = seeksQueue[1];
+                       seeksQueue[1] = pos;
+                       
+                       SeekFromTimescale(pos);         
+               }               
+
+               protected virtual void OnTimescaleValueChanged(object sender, System.EventArgs e)
+               {
+                       if (seeking){
+                               /* Releasing the timescale always report value different from the real one. 
+                                * We need to cache previous position and seek again to the this position */  
                          
+                               SeekFromTimescale(seeksQueue[0] != -1 ? seeksQueue[0] : seeksQueue[1]);
+                               seeking=false;                          
+                               player.Tick += tickHandler;
+                               if (IsPlayingPrevState)
+                                       player.Play();
+                       }
+               }
+
+               protected virtual void OnPlaybuttonClicked(object sender, System.EventArgs e)
+               {
+                         Play();               
+               }
+
+               protected virtual void OnStopbuttonClicked(object sender, System.EventArgs e)
+               {
+                       player.SeekTime(segmentStartTime,1,true);
+               }
+
+               protected virtual void OnVolumebuttonClicked(object sender, System.EventArgs e)
+               {
+                       vwin.SetLevel(player.Volume);
+                       vwin.Show();
+               }
+
+               protected virtual void OnDestroyEvent(object o, Gtk.DestroyEventArgs args)
+               {
+                       player.Dispose();
+               }
+               
+               protected virtual void OnVolumeChanged(double level){
+                       player.Volume = level;
+                       if (level == 0)
+                               muted = true;
+                       else
+                               muted = false;
+               }
+
+               protected virtual void OnPausebuttonClicked (object sender, System.EventArgs e)
+               {                       
+                       player.Pause();
+               }
+               
+               protected virtual void OnEndOfStream (object o, EventArgs args){
+                       player.SeekInSegment(0, GetRateFromScale());
+                       player.Pause();                 
+               }
+               
+                               
+               protected virtual void OnError (object o, ErrorArgs args){
+                       if(Error != null)
+                               Error(o,args);
+               }
+
+               protected virtual void OnClosebuttonClicked (object sender, System.EventArgs e)
+               {
+                       CloseActualSegment();   
+               }
+
+               protected virtual void OnPrevbuttonClicked (object sender, System.EventArgs e)
+               {                       
+                       if (Prev != null)
+                               Prev();
+               }
+
+               protected virtual void OnNextbuttonClicked (object sender, System.EventArgs e)
+               {
+                       if (Next != null)
+                               Next();         
+               }
+
+               protected virtual void OnVscale1FormatValue (object o, Gtk.FormatValueArgs args)
+               {
+                       double val = args.Value;
+                       if (val >25 ){
+                               val = val-25 ;
+                               args.RetVal = val +"X";
+                       }
+                       else if (val ==25){
+                               args.RetVal = "1X";
+                       }
+                       else if (val <25){
+                               args.RetVal = "-"+val+"/25"+"X";
+                       }
+               }
+
+               protected virtual void OnVscale1ValueChanged (object sender, System.EventArgs e)
+               {
+                       float val = GetRateFromScale();
+                       
+                       // Mute for rate != 1
+                       if (val != 1 && player.Volume != 0){ 
+                               previousVLevel = player.Volume;
+                               player.Volume=0;
+                       }
+                       else if  (val != 1 && muted)
+                                 previousVLevel = 0;                   
+                       else if (val ==1)
+                               player.Volume = previousVLevel;                 
+                       
+                       if (InSegment()){
+                               player.SetRateInSegment(val,segmentStopTime);
+                       }
+                       else
+                               player.SetRate(val);                    
+                       rate = val;
+               }
+
+               protected virtual void OnVideoboxButtonPressEvent (object o, Gtk.ButtonPressEventArgs args)
+               {
+                       if(filename == null)
+                               return;
+                       /* FIXME: The pointer is grabbed when the event box is clicked.
+                        * Make sure to ungrab it in order to avoid clicks outisde the window
+                        * triggering this callback. This should be fixed properly.*/ 
+                       Pointer.Ungrab(Gtk.Global.CurrentEventTime);
+                       if (!player.Playing)
+                               Play();
+                       else 
+                               Pause();                
+               }
+               
+               protected virtual void OnVideoboxScrollEvent (object o, Gtk.ScrollEventArgs args)
+               {
+                       switch (args.Event.Direction){
+                               case ScrollDirection.Down:
+                                       SeekToPreviousFrame(InSegment());
+                                       break;
+                               case ScrollDirection.Up:
+                                       SeekToNextFrame(InSegment());
+                                       break;
+                               case ScrollDirection.Left:
+                                       StepBackward();
+                                       break;
+                               case ScrollDirection.Right:
+                                       StepForward();
+                                       break;
+                       }
+               }
+               
+               protected virtual void OnDrawButtonClicked (object sender, System.EventArgs e)
+               {
+                       int currentTime;
+                       
+                       currentTime = (int)AccurateCurrentTime;
+                       // If the player has reached the end of the segment the current time
+                       // will be unseekable and it's not possible to get a frame at this
+                       // instant. If we exceed the segment stop time, decrease in a 
+                       // milisecond the position. 
+                       if (InSegment() && currentTime >= segmentStopTime)
+                               currentTime -= 1;
+                       if (DrawFrame != null)
+                               DrawFrame(currentTime);
+               }
+#endregion     
+       }
+}
diff --git a/CesarPlayer/Gui/VolumeWindow.cs b/CesarPlayer/Gui/VolumeWindow.cs
index 6b4945e..ccd9706 100644
--- a/CesarPlayer/Gui/VolumeWindow.cs
+++ b/CesarPlayer/Gui/VolumeWindow.cs
@@ -1,21 +1,21 @@
 // VolumeWindow.cs 
-//
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
 //
 using System;
 using LongoMatch.Video.Common;
diff --git a/CesarPlayer/MultimediaFactory.cs b/CesarPlayer/MultimediaFactory.cs
index 9c15be5..d6f637e 100644
--- a/CesarPlayer/MultimediaFactory.cs
+++ b/CesarPlayer/MultimediaFactory.cs
@@ -1,109 +1,109 @@
-// PlayerMaker.cs 
-//
-//  Copyright(C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
-//
-
-using System;
-using LongoMatch.Video.Capturer;
-using LongoMatch.Video.Player;
-using LongoMatch.Video.Editor;
-using LongoMatch.Video.Utils;
-using LongoMatch.Video.Common;
-
-namespace LongoMatch.Video
-{
-       
-       
-       public class MultimediaFactory
-       {
-               
-               OperatingSystem oS;
-               
-               public MultimediaFactory()
-               {
-                       oS = Environment.OSVersion;     
-               }
-               
-               public IPlayer getPlayer(int width, int height){
-                       switch (oS.Platform) { 
-                               case PlatformID.Unix:
-                                       return new GstPlayer(width,height,PlayerUseType.Video);
-                                       
-                               case PlatformID.Win32NT:
-                                       return new GstPlayer(width,height,PlayerUseType.Video);
-                               
-                               default:
-                                       return new GstPlayer(width,height,PlayerUseType.Video);
-                       }               
-               }
-               
-               public IMetadataReader getMetadataReader(){
-                       
-                       switch (oS.Platform) { 
-                               case PlatformID.Unix:
-                                       return new GstPlayer(1,1,PlayerUseType.Metadata);
-                                       
-                               case PlatformID.Win32NT:
-                                       return new GstPlayer(1,1,PlayerUseType.Metadata);
-                                       
-                               default:
-                                       return new GstPlayer(1,1,PlayerUseType.Metadata);
-                       }
-               }
-               
-               public IFramesCapturer getFramesCapturer(){
-                       switch (oS.Platform) { 
-                               case PlatformID.Unix:
-                                       return new GstPlayer(1,1,PlayerUseType.Capture);
-                                       
-                               case PlatformID.Win32NT:
-                                       return new GstPlayer(1,1,PlayerUseType.Capture);
-                                       
-                               default:
-                                       return new GstPlayer(1,1,PlayerUseType.Capture);
-                       }
-               }
-               
-               public IVideoEditor getVideoEditor(){
-                       switch (oS.Platform) { 
-                               case PlatformID.Unix:
-                                       return new GstVideoSplitter();
-                                       
-                               case PlatformID.Win32NT:
-                                       return new GstVideoSplitter();  
-                                       
-                               default:
-                                       return new GstVideoSplitter();
-                       }
-               }       
-               
-               public ICapturer getCapturer(CapturerType type){
-                       switch (type) { 
-                               case CapturerType.Fake:
-                                       return new FakeCapturer();
-                                       
-                               case CapturerType.Live:
-                               case CapturerType.Snapshot:
-                                       return new GstCameraCapturer("test.avi");
-                                                                       
-                               default:
-                                       return new FakeCapturer();
-                       }                       
-               }
-       }
-}
+// PlayerMaker.cs 
+//
+//  Copyright(C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+//Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//
+
+using System;
+using LongoMatch.Video.Capturer;
+using LongoMatch.Video.Player;
+using LongoMatch.Video.Editor;
+using LongoMatch.Video.Utils;
+using LongoMatch.Video.Common;
+
+namespace LongoMatch.Video
+{
+       
+       
+       public class MultimediaFactory
+       {
+               
+               OperatingSystem oS;
+               
+               public MultimediaFactory()
+               {
+                       oS = Environment.OSVersion;     
+               }
+               
+               public IPlayer getPlayer(int width, int height){
+                       switch (oS.Platform) { 
+                               case PlatformID.Unix:
+                                       return new GstPlayer(width,height,PlayerUseType.Video);
+                                       
+                               case PlatformID.Win32NT:
+                                       return new GstPlayer(width,height,PlayerUseType.Video);
+                               
+                               default:
+                                       return new GstPlayer(width,height,PlayerUseType.Video);
+                       }               
+               }
+               
+               public IMetadataReader getMetadataReader(){
+                       
+                       switch (oS.Platform) { 
+                               case PlatformID.Unix:
+                                       return new GstPlayer(1,1,PlayerUseType.Metadata);
+                                       
+                               case PlatformID.Win32NT:
+                                       return new GstPlayer(1,1,PlayerUseType.Metadata);
+                                       
+                               default:
+                                       return new GstPlayer(1,1,PlayerUseType.Metadata);
+                       }
+               }
+               
+               public IFramesCapturer getFramesCapturer(){
+                       switch (oS.Platform) { 
+                               case PlatformID.Unix:
+                                       return new GstPlayer(1,1,PlayerUseType.Capture);
+                                       
+                               case PlatformID.Win32NT:
+                                       return new GstPlayer(1,1,PlayerUseType.Capture);
+                                       
+                               default:
+                                       return new GstPlayer(1,1,PlayerUseType.Capture);
+                       }
+               }
+               
+               public IVideoEditor getVideoEditor(){
+                       switch (oS.Platform) { 
+                               case PlatformID.Unix:
+                                       return new GstVideoSplitter();
+                                       
+                               case PlatformID.Win32NT:
+                                       return new GstVideoSplitter();  
+                                       
+                               default:
+                                       return new GstVideoSplitter();
+                       }
+               }       
+               
+               public ICapturer getCapturer(CapturerType type){
+                       switch (type) { 
+                               case CapturerType.Fake:
+                                       return new FakeCapturer();
+                                       
+                               case CapturerType.Live:
+                               case CapturerType.Snapshot:
+                                       return new GstCameraCapturer("test.avi");
+                                                                       
+                               default:
+                                       return new FakeCapturer();
+                       }                       
+               }
+       }
+}
diff --git a/CesarPlayer/Player/IPlayer.cs b/CesarPlayer/Player/IPlayer.cs
index 0f18b51..b24dbbf 100644
--- a/CesarPlayer/Player/IPlayer.cs
+++ b/CesarPlayer/Player/IPlayer.cs
@@ -1,21 +1,21 @@
 // IPlayer.cs
 //
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
 //
 
 using System;
diff --git a/CesarPlayer/Utils/TimeString.cs b/CesarPlayer/Utils/TimeString.cs
index e264a0f..d4f755f 100644
--- a/CesarPlayer/Utils/TimeString.cs
+++ b/CesarPlayer/Utils/TimeString.cs
@@ -1,21 +1,21 @@
 // TimeString.cs
-//
-//  Copyright (C) 2007-2009 Andoni Morales Alastruey
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-// 
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
-//
+//
+//  Copyright (C) 2007-2009 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// 
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
 //
 
 using System;
diff --git a/chronojump_server/ChronojumpServer.cs b/chronojump_server/ChronojumpServer.cs
index 60d0981..057935f 100644
--- a/chronojump_server/ChronojumpServer.cs
+++ b/chronojump_server/ChronojumpServer.cs
@@ -1,1753 +1,1753 @@
-// ------------------------------------------------------------------------------
-//  <autogenerated>
-//      This code was generated by a tool.
-//      Mono Runtime Version: 2.0.50727.1433
-// 
-//      Changes to this file may cause incorrect behavior and will be lost if 
-//      the code is regenerated.
-//  </autogenerated>
-// ------------------------------------------------------------------------------
-
-
-
-/// <remarks/>
-/// <remarks>
-///ChronojumpServer
-///</remarks>
-[System.Web.Services.WebServiceBinding(Name="ChronojumpServerSoap", 
Namespace="http://server.chronojump.org:80/";)]
-[System.Diagnostics.DebuggerStepThroughAttribute()]
-[System.ComponentModel.DesignerCategoryAttribute("code")]
-[System.Xml.Serialization.XmlIncludeAttribute(typeof(Session))]
-[System.Xml.Serialization.XmlIncludeAttribute(typeof(EventType))]
-[System.Xml.Serialization.XmlIncludeAttribute(typeof(Event))]
-public partial class ChronojumpServer : System.Web.Services.Protocols.SoapHttpClientProtocol {
-    
-    private System.Threading.SendOrPostCallback ConnectDatabaseOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback DisConnectDatabaseOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback CanINewOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback CanIOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback QueryOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback StatsOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadSessionOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UpdateSessionOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadSportOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadJumpTypeOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadJumpRjTypeOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadRunTypeOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadRunIntervalTypeOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadPersonOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadPersonSessionIfNeededOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadPingOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadEvaluatorOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback EditEvaluatorOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback SelectEvaluatorsOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadJumpOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadJumpRjOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadRunOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadRunIOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadRTOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadPulseOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback UploadMultiChronopicOperationCompleted;
-    
-    private System.Threading.SendOrPostCallback ListDirectoryOperationCompleted;
-    
-    public ChronojumpServer() {
-        //this.Url = "http://localhost:8080/chronojumpServer.asmx";;
-        this.Url = "http://server.chronojump.org:80/chronojumpServer.asmx";;
-        //this.Url = "http://localhost:80/chronojumpServer.asmx";;
-    }
-    
-    public event ConnectDatabaseCompletedEventHandler ConnectDatabaseCompleted;
-    
-    public event DisConnectDatabaseCompletedEventHandler DisConnectDatabaseCompleted;
-    
-    public event CanINewCompletedEventHandler CanINewCompleted;
-    
-    public event CanICompletedEventHandler CanICompleted;
-    
-    public event QueryCompletedEventHandler QueryCompleted;
-    
-    public event StatsCompletedEventHandler StatsCompleted;
-    
-    public event UploadSessionCompletedEventHandler UploadSessionCompleted;
-    
-    public event UpdateSessionCompletedEventHandler UpdateSessionCompleted;
-    
-    public event UploadSportCompletedEventHandler UploadSportCompleted;
-    
-    public event UploadJumpTypeCompletedEventHandler UploadJumpTypeCompleted;
-    
-    public event UploadJumpRjTypeCompletedEventHandler UploadJumpRjTypeCompleted;
-    
-    public event UploadRunTypeCompletedEventHandler UploadRunTypeCompleted;
-    
-    public event UploadRunIntervalTypeCompletedEventHandler UploadRunIntervalTypeCompleted;
-    
-    public event UploadPersonCompletedEventHandler UploadPersonCompleted;
-    
-    public event UploadPersonSessionIfNeededCompletedEventHandler UploadPersonSessionIfNeededCompleted;
-    
-    public event UploadPingCompletedEventHandler UploadPingCompleted;
-    
-    public event UploadEvaluatorCompletedEventHandler UploadEvaluatorCompleted;
-    
-    public event EditEvaluatorCompletedEventHandler EditEvaluatorCompleted;
-    
-    public event SelectEvaluatorsCompletedEventHandler SelectEvaluatorsCompleted;
-    
-    public event UploadJumpCompletedEventHandler UploadJumpCompleted;
-    
-    public event UploadJumpRjCompletedEventHandler UploadJumpRjCompleted;
-    
-    public event UploadRunCompletedEventHandler UploadRunCompleted;
-    
-    public event UploadRunICompletedEventHandler UploadRunICompleted;
-    
-    public event UploadRTCompletedEventHandler UploadRTCompleted;
-    
-    public event UploadPulseCompletedEventHandler UploadPulseCompleted;
-    
-    public event UploadMultiChronopicCompletedEventHandler UploadMultiChronopicCompleted;
-    
-    public event ListDirectoryCompletedEventHandler ListDirectoryCompleted;
-    
-    /// <remarks>
-///Conecta BBDD
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/ConnectDatabase";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string ConnectDatabase() {
-        object[] results = this.Invoke("ConnectDatabase", new object[0]);
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginConnectDatabase(System.AsyncCallback callback, object asyncState) {
-        return this.BeginInvoke("ConnectDatabase", new object[0], callback, asyncState);
-    }
-    
-    public string EndConnectDatabase(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void ConnectDatabaseAsync() {
-        this.ConnectDatabaseAsync(null);
-    }
-    
-    public void ConnectDatabaseAsync(object userState) {
-        if ((this.ConnectDatabaseOperationCompleted == null)) {
-            this.ConnectDatabaseOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnConnectDatabaseCompleted);
-        }
-        this.InvokeAsync("ConnectDatabase", new object[0], this.ConnectDatabaseOperationCompleted, 
userState);
-    }
-    
-    private void OnConnectDatabaseCompleted(object arg) {
-        if ((this.ConnectDatabaseCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.ConnectDatabaseCompleted(this, new ConnectDatabaseCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Desconecta BBDD
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/DisConnectDatabase";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string DisConnectDatabase() {
-        object[] results = this.Invoke("DisConnectDatabase", new object[0]);
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginDisConnectDatabase(System.AsyncCallback callback, object asyncState) {
-        return this.BeginInvoke("DisConnectDatabase", new object[0], callback, asyncState);
-    }
-    
-    public string EndDisConnectDatabase(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void DisConnectDatabaseAsync() {
-        this.DisConnectDatabaseAsync(null);
-    }
-    
-    public void DisConnectDatabaseAsync(object userState) {
-        if ((this.DisConnectDatabaseOperationCompleted == null)) {
-            this.DisConnectDatabaseOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnDisConnectDatabaseCompleted);
-        }
-        this.InvokeAsync("DisConnectDatabase", new object[0], this.DisConnectDatabaseOperationCompleted, 
userState);
-    }
-    
-    private void OnDisConnectDatabaseCompleted(object arg) {
-        if ((this.DisConnectDatabaseCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.DisConnectDatabaseCompleted(this, new 
DisConnectDatabaseCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, 
invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Check actions that client can do depending on it's version)
-///</remarks>
-    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/CanINew";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public bool CanINew(string action, string clientVersion) {
-        object[] results = this.Invoke("CanINew", new object[] {
-                    action,
-                    clientVersion});
-        return ((bool)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginCanINew(string action, string clientVersion, System.AsyncCallback 
callback, object asyncState) {
-        return this.BeginInvoke("CanINew", new object[] {
-                    action,
-                    clientVersion}, callback, asyncState);
-    }
-    
-    public bool EndCanINew(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((bool)(results[0]));
-    }
-    
-    public void CanINewAsync(string action, string clientVersion) {
-        this.CanINewAsync(action, clientVersion, null);
-    }
-    
-    public void CanINewAsync(string action, string clientVersion, object userState) {
-        if ((this.CanINewOperationCompleted == null)) {
-            this.CanINewOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnCanINewCompleted);
-        }
-        this.InvokeAsync("CanINew", new object[] {
-                    action,
-                    clientVersion}, this.CanINewOperationCompleted, userState);
-    }
-    
-    private void OnCanINewCompleted(object arg) {
-        if ((this.CanINewCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.CanINewCompleted(this, new CanINewCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, 
invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Check actions that client can do depending on it's version)
-///</remarks>
-    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/CanI";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public bool CanI(string action, double clientVersion) {
-        object[] results = this.Invoke("CanI", new object[] {
-                    action,
-                    clientVersion});
-        return ((bool)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginCanI(string action, double clientVersion, System.AsyncCallback callback, 
object asyncState) {
-        return this.BeginInvoke("CanI", new object[] {
-                    action,
-                    clientVersion}, callback, asyncState);
-    }
-    
-    public bool EndCanI(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((bool)(results[0]));
-    }
-    
-    public void CanIAsync(string action, double clientVersion) {
-        this.CanIAsync(action, clientVersion, null);
-    }
-    
-    public void CanIAsync(string action, double clientVersion, object userState) {
-        if ((this.CanIOperationCompleted == null)) {
-            this.CanIOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCanICompleted);
-        }
-        this.InvokeAsync("CanI", new object[] {
-                    action,
-                    clientVersion}, this.CanIOperationCompleted, userState);
-    }
-    
-    private void OnCanICompleted(object arg) {
-        if ((this.CanICompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.CanICompleted(this, new CanICompletedEventArgs(invokeArgs.Results, invokeArgs.Error, 
invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Query
-///</remarks>
-    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/Query";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string Query(string tableName, string test, string variable, int sex, string ageInterval, int 
countryID, int sportID, int speciallityID, int levelID, int evaluatorID) {
-        object[] results = this.Invoke("Query", new object[] {
-                    tableName,
-                    test,
-                    variable,
-                    sex,
-                    ageInterval,
-                    countryID,
-                    sportID,
-                    speciallityID,
-                    levelID,
-                    evaluatorID});
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginQuery(string tableName, string test, string variable, int sex, string 
ageInterval, int countryID, int sportID, int speciallityID, int levelID, int evaluatorID, 
System.AsyncCallback callback, object asyncState) {
-        return this.BeginInvoke("Query", new object[] {
-                    tableName,
-                    test,
-                    variable,
-                    sex,
-                    ageInterval,
-                    countryID,
-                    sportID,
-                    speciallityID,
-                    levelID,
-                    evaluatorID}, callback, asyncState);
-    }
-    
-    public string EndQuery(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void QueryAsync(string tableName, string test, string variable, int sex, string ageInterval, int 
countryID, int sportID, int speciallityID, int levelID, int evaluatorID) {
-        this.QueryAsync(tableName, test, variable, sex, ageInterval, countryID, sportID, speciallityID, 
levelID, evaluatorID, null);
-    }
-    
-    public void QueryAsync(string tableName, string test, string variable, int sex, string ageInterval, int 
countryID, int sportID, int speciallityID, int levelID, int evaluatorID, object userState) {
-        if ((this.QueryOperationCompleted == null)) {
-            this.QueryOperationCompleted = new System.Threading.SendOrPostCallback(this.OnQueryCompleted);
-        }
-        this.InvokeAsync("Query", new object[] {
-                    tableName,
-                    test,
-                    variable,
-                    sex,
-                    ageInterval,
-                    countryID,
-                    sportID,
-                    speciallityID,
-                    levelID,
-                    evaluatorID}, this.QueryOperationCompleted, userState);
-    }
-    
-    private void OnQueryCompleted(object arg) {
-        if ((this.QueryCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.QueryCompleted(this, new QueryCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, 
invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Stats
-///</remarks>
-    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/Stats";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string[] Stats() {
-        object[] results = this.Invoke("Stats", new object[0]);
-        return ((string[])(results[0]));
-    }
-    
-    public System.IAsyncResult BeginStats(System.AsyncCallback callback, object asyncState) {
-        return this.BeginInvoke("Stats", new object[0], callback, asyncState);
-    }
-    
-    public string[] EndStats(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string[])(results[0]));
-    }
-    
-    public void StatsAsync() {
-        this.StatsAsync(null);
-    }
-    
-    public void StatsAsync(object userState) {
-        if ((this.StatsOperationCompleted == null)) {
-            this.StatsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnStatsCompleted);
-        }
-        this.InvokeAsync("Stats", new object[0], this.StatsOperationCompleted, userState);
-    }
-    
-    private void OnStatsCompleted(object arg) {
-        if ((this.StatsCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.StatsCompleted(this, new StatsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, 
invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a session
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadSession";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadSession(ServerSession mySession) {
-        object[] results = this.Invoke("UploadSession", new object[] {
-                    mySession});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadSession(ServerSession mySession, System.AsyncCallback callback, 
object asyncState) {
-        return this.BeginInvoke("UploadSession", new object[] {
-                    mySession}, callback, asyncState);
-    }
-    
-    public int EndUploadSession(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadSessionAsync(ServerSession mySession) {
-        this.UploadSessionAsync(mySession, null);
-    }
-    
-    public void UploadSessionAsync(ServerSession mySession, object userState) {
-        if ((this.UploadSessionOperationCompleted == null)) {
-            this.UploadSessionOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadSessionCompleted);
-        }
-        this.InvokeAsync("UploadSession", new object[] {
-                    mySession}, this.UploadSessionOperationCompleted, userState);
-    }
-    
-    private void OnUploadSessionCompleted(object arg) {
-        if ((this.UploadSessionCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadSessionCompleted(this, new UploadSessionCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Update session uploadingState
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UpdateSession";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UpdateSession(int sessionID, int state) {
-        object[] results = this.Invoke("UpdateSession", new object[] {
-                    sessionID,
-                    state});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUpdateSession(int sessionID, int state, System.AsyncCallback callback, 
object asyncState) {
-        return this.BeginInvoke("UpdateSession", new object[] {
-                    sessionID,
-                    state}, callback, asyncState);
-    }
-    
-    public int EndUpdateSession(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UpdateSessionAsync(int sessionID, int state) {
-        this.UpdateSessionAsync(sessionID, state, null);
-    }
-    
-    public void UpdateSessionAsync(int sessionID, int state, object userState) {
-        if ((this.UpdateSessionOperationCompleted == null)) {
-            this.UpdateSessionOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUpdateSessionCompleted);
-        }
-        this.InvokeAsync("UpdateSession", new object[] {
-                    sessionID,
-                    state}, this.UpdateSessionOperationCompleted, userState);
-    }
-    
-    private void OnUpdateSessionCompleted(object arg) {
-        if ((this.UpdateSessionCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UpdateSessionCompleted(this, new UpdateSessionCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload an sport (user defined)
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadSport";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadSport(Sport mySport) {
-        object[] results = this.Invoke("UploadSport", new object[] {
-                    mySport});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadSport(Sport mySport, System.AsyncCallback callback, object 
asyncState) {
-        return this.BeginInvoke("UploadSport", new object[] {
-                    mySport}, callback, asyncState);
-    }
-    
-    public int EndUploadSport(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadSportAsync(Sport mySport) {
-        this.UploadSportAsync(mySport, null);
-    }
-    
-    public void UploadSportAsync(Sport mySport, object userState) {
-        if ((this.UploadSportOperationCompleted == null)) {
-            this.UploadSportOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadSportCompleted);
-        }
-        this.InvokeAsync("UploadSport", new object[] {
-                    mySport}, this.UploadSportOperationCompleted, userState);
-    }
-    
-    private void OnUploadSportCompleted(object arg) {
-        if ((this.UploadSportCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadSportCompleted(this, new UploadSportCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a jump type (user defined)
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadJumpType";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string UploadJumpType(JumpType type, int evalSID) {
-        object[] results = this.Invoke("UploadJumpType", new object[] {
-                    type,
-                    evalSID});
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadJumpType(JumpType type, int evalSID, System.AsyncCallback 
callback, object asyncState) {
-        return this.BeginInvoke("UploadJumpType", new object[] {
-                    type,
-                    evalSID}, callback, asyncState);
-    }
-    
-    public string EndUploadJumpType(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void UploadJumpTypeAsync(JumpType type, int evalSID) {
-        this.UploadJumpTypeAsync(type, evalSID, null);
-    }
-    
-    public void UploadJumpTypeAsync(JumpType type, int evalSID, object userState) {
-        if ((this.UploadJumpTypeOperationCompleted == null)) {
-            this.UploadJumpTypeOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadJumpTypeCompleted);
-        }
-        this.InvokeAsync("UploadJumpType", new object[] {
-                    type,
-                    evalSID}, this.UploadJumpTypeOperationCompleted, userState);
-    }
-    
-    private void OnUploadJumpTypeCompleted(object arg) {
-        if ((this.UploadJumpTypeCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadJumpTypeCompleted(this, new UploadJumpTypeCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a jumpRj type (user defined)
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadJumpRjType";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string UploadJumpRjType(JumpType type, int evalSID) {
-        object[] results = this.Invoke("UploadJumpRjType", new object[] {
-                    type,
-                    evalSID});
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadJumpRjType(JumpType type, int evalSID, System.AsyncCallback 
callback, object asyncState) {
-        return this.BeginInvoke("UploadJumpRjType", new object[] {
-                    type,
-                    evalSID}, callback, asyncState);
-    }
-    
-    public string EndUploadJumpRjType(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void UploadJumpRjTypeAsync(JumpType type, int evalSID) {
-        this.UploadJumpRjTypeAsync(type, evalSID, null);
-    }
-    
-    public void UploadJumpRjTypeAsync(JumpType type, int evalSID, object userState) {
-        if ((this.UploadJumpRjTypeOperationCompleted == null)) {
-            this.UploadJumpRjTypeOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadJumpRjTypeCompleted);
-        }
-        this.InvokeAsync("UploadJumpRjType", new object[] {
-                    type,
-                    evalSID}, this.UploadJumpRjTypeOperationCompleted, userState);
-    }
-    
-    private void OnUploadJumpRjTypeCompleted(object arg) {
-        if ((this.UploadJumpRjTypeCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadJumpRjTypeCompleted(this, new UploadJumpRjTypeCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a run type (user defined)
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRunType";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string UploadRunType(RunType type, int evalSID) {
-        object[] results = this.Invoke("UploadRunType", new object[] {
-                    type,
-                    evalSID});
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadRunType(RunType type, int evalSID, System.AsyncCallback callback, 
object asyncState) {
-        return this.BeginInvoke("UploadRunType", new object[] {
-                    type,
-                    evalSID}, callback, asyncState);
-    }
-    
-    public string EndUploadRunType(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void UploadRunTypeAsync(RunType type, int evalSID) {
-        this.UploadRunTypeAsync(type, evalSID, null);
-    }
-    
-    public void UploadRunTypeAsync(RunType type, int evalSID, object userState) {
-        if ((this.UploadRunTypeOperationCompleted == null)) {
-            this.UploadRunTypeOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRunTypeCompleted);
-        }
-        this.InvokeAsync("UploadRunType", new object[] {
-                    type,
-                    evalSID}, this.UploadRunTypeOperationCompleted, userState);
-    }
-    
-    private void OnUploadRunTypeCompleted(object arg) {
-        if ((this.UploadRunTypeCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadRunTypeCompleted(this, new UploadRunTypeCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a run interval type (user defined)
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRunIntervalType";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string UploadRunIntervalType(RunType type, int evalSID) {
-        object[] results = this.Invoke("UploadRunIntervalType", new object[] {
-                    type,
-                    evalSID});
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadRunIntervalType(RunType type, int evalSID, System.AsyncCallback 
callback, object asyncState) {
-        return this.BeginInvoke("UploadRunIntervalType", new object[] {
-                    type,
-                    evalSID}, callback, asyncState);
-    }
-    
-    public string EndUploadRunIntervalType(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void UploadRunIntervalTypeAsync(RunType type, int evalSID) {
-        this.UploadRunIntervalTypeAsync(type, evalSID, null);
-    }
-    
-    public void UploadRunIntervalTypeAsync(RunType type, int evalSID, object userState) {
-        if ((this.UploadRunIntervalTypeOperationCompleted == null)) {
-            this.UploadRunIntervalTypeOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRunIntervalTypeCompleted);
-        }
-        this.InvokeAsync("UploadRunIntervalType", new object[] {
-                    type,
-                    evalSID}, this.UploadRunIntervalTypeOperationCompleted, userState);
-    }
-    
-    private void OnUploadRunIntervalTypeCompleted(object arg) {
-        if ((this.UploadRunIntervalTypeCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadRunIntervalTypeCompleted(this, new 
UploadRunIntervalTypeCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, 
invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a person
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadPerson";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadPerson(Person myPerson, int sessionID) {
-        object[] results = this.Invoke("UploadPerson", new object[] {
-                    myPerson,
-                    sessionID});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadPerson(Person myPerson, int sessionID, System.AsyncCallback 
callback, object asyncState) {
-        return this.BeginInvoke("UploadPerson", new object[] {
-                    myPerson,
-                    sessionID}, callback, asyncState);
-    }
-    
-    public int EndUploadPerson(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadPersonAsync(Person myPerson, int sessionID) {
-        this.UploadPersonAsync(myPerson, sessionID, null);
-    }
-    
-    public void UploadPersonAsync(Person myPerson, int sessionID, object userState) {
-        if ((this.UploadPersonOperationCompleted == null)) {
-            this.UploadPersonOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadPersonCompleted);
-        }
-        this.InvokeAsync("UploadPerson", new object[] {
-                    myPerson,
-                    sessionID}, this.UploadPersonOperationCompleted, userState);
-    }
-    
-    private void OnUploadPersonCompleted(object arg) {
-        if ((this.UploadPersonCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadPersonCompleted(this, new UploadPersonCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload person session if needed
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadPersonSessionIfNeeded";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadPersonSessionIfNeeded(PersonSession ps) {
-        object[] results = this.Invoke("UploadPersonSessionIfNeeded", new object[] {
-                    ps});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadPersonSessionIfNeeded(PersonSession ps, System.AsyncCallback 
callback, object asyncState) {
-        return this.BeginInvoke("UploadPersonSessionIfNeeded", new object[] {
-                    ps}, callback, asyncState);
-    }
-    
-    public int EndUploadPersonSessionIfNeeded(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadPersonSessionIfNeededAsync(PersonSession ps) {
-        this.UploadPersonSessionIfNeededAsync(ps, null);
-    }
-    
-    public void UploadPersonSessionIfNeededAsync(PersonSession ps, object userState) {
-        if ((this.UploadPersonSessionIfNeededOperationCompleted == null)) {
-            this.UploadPersonSessionIfNeededOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadPersonSessionIfNeededCompleted);
-        }
-        this.InvokeAsync("UploadPersonSessionIfNeeded", new object[] {
-                    ps}, this.UploadPersonSessionIfNeededOperationCompleted, userState);
-    }
-    
-    private void OnUploadPersonSessionIfNeededCompleted(object arg) {
-        if ((this.UploadPersonSessionIfNeededCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadPersonSessionIfNeededCompleted(this, new 
UploadPersonSessionIfNeededCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, 
invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a ping
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadPing";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string UploadPing(ServerPing myPing, bool doInsertion) {
-        object[] results = this.Invoke("UploadPing", new object[] {
-                    myPing,
-                    doInsertion});
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadPing(ServerPing myPing, bool doInsertion, System.AsyncCallback 
callback, object asyncState) {
-        return this.BeginInvoke("UploadPing", new object[] {
-                    myPing,
-                    doInsertion}, callback, asyncState);
-    }
-    
-    public string EndUploadPing(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void UploadPingAsync(ServerPing myPing, bool doInsertion) {
-        this.UploadPingAsync(myPing, doInsertion, null);
-    }
-    
-    public void UploadPingAsync(ServerPing myPing, bool doInsertion, object userState) {
-        if ((this.UploadPingOperationCompleted == null)) {
-            this.UploadPingOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadPingCompleted);
-        }
-        this.InvokeAsync("UploadPing", new object[] {
-                    myPing,
-                    doInsertion}, this.UploadPingOperationCompleted, userState);
-    }
-    
-    private void OnUploadPingCompleted(object arg) {
-        if ((this.UploadPingCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadPingCompleted(this, new UploadPingCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload an evaluator
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadEvaluator";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string UploadEvaluator(ServerEvaluator myEval) {
-        object[] results = this.Invoke("UploadEvaluator", new object[] {
-                    myEval});
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadEvaluator(ServerEvaluator myEval, System.AsyncCallback callback, 
object asyncState) {
-        return this.BeginInvoke("UploadEvaluator", new object[] {
-                    myEval}, callback, asyncState);
-    }
-    
-    public string EndUploadEvaluator(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void UploadEvaluatorAsync(ServerEvaluator myEval) {
-        this.UploadEvaluatorAsync(myEval, null);
-    }
-    
-    public void UploadEvaluatorAsync(ServerEvaluator myEval, object userState) {
-        if ((this.UploadEvaluatorOperationCompleted == null)) {
-            this.UploadEvaluatorOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadEvaluatorCompleted);
-        }
-        this.InvokeAsync("UploadEvaluator", new object[] {
-                    myEval}, this.UploadEvaluatorOperationCompleted, userState);
-    }
-    
-    private void OnUploadEvaluatorCompleted(object arg) {
-        if ((this.UploadEvaluatorCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadEvaluatorCompleted(this, new UploadEvaluatorCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Edit an evaluator
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/EditEvaluator";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public bool EditEvaluator(ServerEvaluator clientEval, int evalSID) {
-        object[] results = this.Invoke("EditEvaluator", new object[] {
-                    clientEval,
-                    evalSID});
-        return ((bool)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginEditEvaluator(ServerEvaluator clientEval, int evalSID, 
System.AsyncCallback callback, object asyncState) {
-        return this.BeginInvoke("EditEvaluator", new object[] {
-                    clientEval,
-                    evalSID}, callback, asyncState);
-    }
-    
-    public bool EndEditEvaluator(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((bool)(results[0]));
-    }
-    
-    public void EditEvaluatorAsync(ServerEvaluator clientEval, int evalSID) {
-        this.EditEvaluatorAsync(clientEval, evalSID, null);
-    }
-    
-    public void EditEvaluatorAsync(ServerEvaluator clientEval, int evalSID, object userState) {
-        if ((this.EditEvaluatorOperationCompleted == null)) {
-            this.EditEvaluatorOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnEditEvaluatorCompleted);
-        }
-        this.InvokeAsync("EditEvaluator", new object[] {
-                    clientEval,
-                    evalSID}, this.EditEvaluatorOperationCompleted, userState);
-    }
-    
-    private void OnEditEvaluatorCompleted(object arg) {
-        if ((this.EditEvaluatorCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.EditEvaluatorCompleted(this, new EditEvaluatorCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Select evaluators
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/SelectEvaluators";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string[] SelectEvaluators(bool addAnyString) {
-        object[] results = this.Invoke("SelectEvaluators", new object[] {
-                    addAnyString});
-        return ((string[])(results[0]));
-    }
-    
-    public System.IAsyncResult BeginSelectEvaluators(bool addAnyString, System.AsyncCallback callback, 
object asyncState) {
-        return this.BeginInvoke("SelectEvaluators", new object[] {
-                    addAnyString}, callback, asyncState);
-    }
-    
-    public string[] EndSelectEvaluators(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string[])(results[0]));
-    }
-    
-    public void SelectEvaluatorsAsync(bool addAnyString) {
-        this.SelectEvaluatorsAsync(addAnyString, null);
-    }
-    
-    public void SelectEvaluatorsAsync(bool addAnyString, object userState) {
-        if ((this.SelectEvaluatorsOperationCompleted == null)) {
-            this.SelectEvaluatorsOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnSelectEvaluatorsCompleted);
-        }
-        this.InvokeAsync("SelectEvaluators", new object[] {
-                    addAnyString}, this.SelectEvaluatorsOperationCompleted, userState);
-    }
-    
-    private void OnSelectEvaluatorsCompleted(object arg) {
-        if ((this.SelectEvaluatorsCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.SelectEvaluatorsCompleted(this, new SelectEvaluatorsCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a jump
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadJump";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadJump(Jump myTest) {
-        object[] results = this.Invoke("UploadJump", new object[] {
-                    myTest});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadJump(Jump myTest, System.AsyncCallback callback, object 
asyncState) {
-        return this.BeginInvoke("UploadJump", new object[] {
-                    myTest}, callback, asyncState);
-    }
-    
-    public int EndUploadJump(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadJumpAsync(Jump myTest) {
-        this.UploadJumpAsync(myTest, null);
-    }
-    
-    public void UploadJumpAsync(Jump myTest, object userState) {
-        if ((this.UploadJumpOperationCompleted == null)) {
-            this.UploadJumpOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadJumpCompleted);
-        }
-        this.InvokeAsync("UploadJump", new object[] {
-                    myTest}, this.UploadJumpOperationCompleted, userState);
-    }
-    
-    private void OnUploadJumpCompleted(object arg) {
-        if ((this.UploadJumpCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadJumpCompleted(this, new UploadJumpCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a jumpRj
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadJumpRj";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadJumpRj(JumpRj myTest) {
-        object[] results = this.Invoke("UploadJumpRj", new object[] {
-                    myTest});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadJumpRj(JumpRj myTest, System.AsyncCallback callback, object 
asyncState) {
-        return this.BeginInvoke("UploadJumpRj", new object[] {
-                    myTest}, callback, asyncState);
-    }
-    
-    public int EndUploadJumpRj(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadJumpRjAsync(JumpRj myTest) {
-        this.UploadJumpRjAsync(myTest, null);
-    }
-    
-    public void UploadJumpRjAsync(JumpRj myTest, object userState) {
-        if ((this.UploadJumpRjOperationCompleted == null)) {
-            this.UploadJumpRjOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadJumpRjCompleted);
-        }
-        this.InvokeAsync("UploadJumpRj", new object[] {
-                    myTest}, this.UploadJumpRjOperationCompleted, userState);
-    }
-    
-    private void OnUploadJumpRjCompleted(object arg) {
-        if ((this.UploadJumpRjCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadJumpRjCompleted(this, new UploadJumpRjCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a run
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRun";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadRun(Run myTest) {
-        object[] results = this.Invoke("UploadRun", new object[] {
-                    myTest});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadRun(Run myTest, System.AsyncCallback callback, object asyncState) {
-        return this.BeginInvoke("UploadRun", new object[] {
-                    myTest}, callback, asyncState);
-    }
-    
-    public int EndUploadRun(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadRunAsync(Run myTest) {
-        this.UploadRunAsync(myTest, null);
-    }
-    
-    public void UploadRunAsync(Run myTest, object userState) {
-        if ((this.UploadRunOperationCompleted == null)) {
-            this.UploadRunOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRunCompleted);
-        }
-        this.InvokeAsync("UploadRun", new object[] {
-                    myTest}, this.UploadRunOperationCompleted, userState);
-    }
-    
-    private void OnUploadRunCompleted(object arg) {
-        if ((this.UploadRunCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadRunCompleted(this, new UploadRunCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a run interval
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRunI";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadRunI(RunInterval myTest) {
-        object[] results = this.Invoke("UploadRunI", new object[] {
-                    myTest});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadRunI(RunInterval myTest, System.AsyncCallback callback, object 
asyncState) {
-        return this.BeginInvoke("UploadRunI", new object[] {
-                    myTest}, callback, asyncState);
-    }
-    
-    public int EndUploadRunI(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadRunIAsync(RunInterval myTest) {
-        this.UploadRunIAsync(myTest, null);
-    }
-    
-    public void UploadRunIAsync(RunInterval myTest, object userState) {
-        if ((this.UploadRunIOperationCompleted == null)) {
-            this.UploadRunIOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRunICompleted);
-        }
-        this.InvokeAsync("UploadRunI", new object[] {
-                    myTest}, this.UploadRunIOperationCompleted, userState);
-    }
-    
-    private void OnUploadRunICompleted(object arg) {
-        if ((this.UploadRunICompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadRunICompleted(this, new UploadRunICompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a reaction time
-///</remarks>
-    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRT";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadRT(ReactionTime myTest) {
-        object[] results = this.Invoke("UploadRT", new object[] {
-                    myTest});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadRT(ReactionTime myTest, System.AsyncCallback callback, object 
asyncState) {
-        return this.BeginInvoke("UploadRT", new object[] {
-                    myTest}, callback, asyncState);
-    }
-    
-    public int EndUploadRT(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadRTAsync(ReactionTime myTest) {
-        this.UploadRTAsync(myTest, null);
-    }
-    
-    public void UploadRTAsync(ReactionTime myTest, object userState) {
-        if ((this.UploadRTOperationCompleted == null)) {
-            this.UploadRTOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRTCompleted);
-        }
-        this.InvokeAsync("UploadRT", new object[] {
-                    myTest}, this.UploadRTOperationCompleted, userState);
-    }
-    
-    private void OnUploadRTCompleted(object arg) {
-        if ((this.UploadRTCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadRTCompleted(this, new UploadRTCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a pulse
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadPulse";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadPulse(Pulse myTest) {
-        object[] results = this.Invoke("UploadPulse", new object[] {
-                    myTest});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadPulse(Pulse myTest, System.AsyncCallback callback, object 
asyncState) {
-        return this.BeginInvoke("UploadPulse", new object[] {
-                    myTest}, callback, asyncState);
-    }
-    
-    public int EndUploadPulse(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadPulseAsync(Pulse myTest) {
-        this.UploadPulseAsync(myTest, null);
-    }
-    
-    public void UploadPulseAsync(Pulse myTest, object userState) {
-        if ((this.UploadPulseOperationCompleted == null)) {
-            this.UploadPulseOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadPulseCompleted);
-        }
-        this.InvokeAsync("UploadPulse", new object[] {
-                    myTest}, this.UploadPulseOperationCompleted, userState);
-    }
-    
-    private void OnUploadPulseCompleted(object arg) {
-        if ((this.UploadPulseCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadPulseCompleted(this, new UploadPulseCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///Upload a multiChronopic
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadMultiChronopic";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public int UploadMultiChronopic(MultiChronopic myTest) {
-        object[] results = this.Invoke("UploadMultiChronopic", new object[] {
-                    myTest});
-        return ((int)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginUploadMultiChronopic(MultiChronopic myTest, System.AsyncCallback 
callback, object asyncState) {
-        return this.BeginInvoke("UploadMultiChronopic", new object[] {
-                    myTest}, callback, asyncState);
-    }
-    
-    public int EndUploadMultiChronopic(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((int)(results[0]));
-    }
-    
-    public void UploadMultiChronopicAsync(MultiChronopic myTest) {
-        this.UploadMultiChronopicAsync(myTest, null);
-    }
-    
-    public void UploadMultiChronopicAsync(MultiChronopic myTest, object userState) {
-        if ((this.UploadMultiChronopicOperationCompleted == null)) {
-            this.UploadMultiChronopicOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadMultiChronopicCompleted);
-        }
-        this.InvokeAsync("UploadMultiChronopic", new object[] {
-                    myTest}, this.UploadMultiChronopicOperationCompleted, userState);
-    }
-    
-    private void OnUploadMultiChronopicCompleted(object arg) {
-        if ((this.UploadMultiChronopicCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.UploadMultiChronopicCompleted(this, new 
UploadMultiChronopicCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, 
invokeArgs.UserState));
-        }
-    }
-    
-    /// <remarks>
-///List directory files (only as a sample)
-///</remarks>
-    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/ListDirectory";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string[] ListDirectory(string path) {
-        object[] results = this.Invoke("ListDirectory", new object[] {
-                    path});
-        return ((string[])(results[0]));
-    }
-    
-    public System.IAsyncResult BeginListDirectory(string path, System.AsyncCallback callback, object 
asyncState) {
-        return this.BeginInvoke("ListDirectory", new object[] {
-                    path}, callback, asyncState);
-    }
-    
-    public string[] EndListDirectory(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string[])(results[0]));
-    }
-    
-    public void ListDirectoryAsync(string path) {
-        this.ListDirectoryAsync(path, null);
-    }
-    
-    public void ListDirectoryAsync(string path, object userState) {
-        if ((this.ListDirectoryOperationCompleted == null)) {
-            this.ListDirectoryOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnListDirectoryCompleted);
-        }
-        this.InvokeAsync("ListDirectory", new object[] {
-                    path}, this.ListDirectoryOperationCompleted, userState);
-    }
-    
-    private void OnListDirectoryCompleted(object arg) {
-        if ((this.ListDirectoryCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.ListDirectoryCompleted(this, new ListDirectoryCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-}
-
-
-public partial class ConnectDatabaseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal ConnectDatabaseCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void ConnectDatabaseCompletedEventHandler(object sender, ConnectDatabaseCompletedEventArgs 
args);
-
-public partial class DisConnectDatabaseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal DisConnectDatabaseCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void DisConnectDatabaseCompletedEventHandler(object sender, 
DisConnectDatabaseCompletedEventArgs args);
-
-public partial class CanINewCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal CanINewCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public bool Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((bool)(this.results[0]));
-        }
-    }
-}
-
-public delegate void CanINewCompletedEventHandler(object sender, CanINewCompletedEventArgs args);
-
-public partial class CanICompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal CanICompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public bool Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((bool)(this.results[0]));
-        }
-    }
-}
-
-public delegate void CanICompletedEventHandler(object sender, CanICompletedEventArgs args);
-
-public partial class QueryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal QueryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void QueryCompletedEventHandler(object sender, QueryCompletedEventArgs args);
-
-public partial class StatsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal StatsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string[] Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string[])(this.results[0]));
-        }
-    }
-}
-
-public delegate void StatsCompletedEventHandler(object sender, StatsCompletedEventArgs args);
-
-public partial class UploadSessionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadSessionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadSessionCompletedEventHandler(object sender, UploadSessionCompletedEventArgs args);
-
-public partial class UpdateSessionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UpdateSessionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UpdateSessionCompletedEventHandler(object sender, UpdateSessionCompletedEventArgs args);
-
-public partial class UploadSportCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadSportCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadSportCompletedEventHandler(object sender, UploadSportCompletedEventArgs args);
-
-public partial class UploadJumpTypeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadJumpTypeCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadJumpTypeCompletedEventHandler(object sender, UploadJumpTypeCompletedEventArgs 
args);
-
-public partial class UploadJumpRjTypeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadJumpRjTypeCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadJumpRjTypeCompletedEventHandler(object sender, UploadJumpRjTypeCompletedEventArgs 
args);
-
-public partial class UploadRunTypeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadRunTypeCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadRunTypeCompletedEventHandler(object sender, UploadRunTypeCompletedEventArgs args);
-
-public partial class UploadRunIntervalTypeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs 
{
-    
-    private object[] results;
-    
-    internal UploadRunIntervalTypeCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadRunIntervalTypeCompletedEventHandler(object sender, 
UploadRunIntervalTypeCompletedEventArgs args);
-
-public partial class UploadPersonCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadPersonCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadPersonCompletedEventHandler(object sender, UploadPersonCompletedEventArgs args);
-
-public partial class UploadPersonSessionIfNeededCompletedEventArgs : 
System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadPersonSessionIfNeededCompletedEventArgs(object[] results, System.Exception exception, 
bool cancelled, object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadPersonSessionIfNeededCompletedEventHandler(object sender, 
UploadPersonSessionIfNeededCompletedEventArgs args);
-
-public partial class UploadPingCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadPingCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadPingCompletedEventHandler(object sender, UploadPingCompletedEventArgs args);
-
-public partial class UploadEvaluatorCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadEvaluatorCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadEvaluatorCompletedEventHandler(object sender, UploadEvaluatorCompletedEventArgs 
args);
-
-public partial class EditEvaluatorCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal EditEvaluatorCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public bool Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((bool)(this.results[0]));
-        }
-    }
-}
-
-public delegate void EditEvaluatorCompletedEventHandler(object sender, EditEvaluatorCompletedEventArgs args);
-
-public partial class SelectEvaluatorsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal SelectEvaluatorsCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string[] Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string[])(this.results[0]));
-        }
-    }
-}
-
-public delegate void SelectEvaluatorsCompletedEventHandler(object sender, SelectEvaluatorsCompletedEventArgs 
args);
-
-public partial class UploadJumpCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadJumpCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadJumpCompletedEventHandler(object sender, UploadJumpCompletedEventArgs args);
-
-public partial class UploadJumpRjCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadJumpRjCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadJumpRjCompletedEventHandler(object sender, UploadJumpRjCompletedEventArgs args);
-
-public partial class UploadRunCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadRunCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadRunCompletedEventHandler(object sender, UploadRunCompletedEventArgs args);
-
-public partial class UploadRunICompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadRunICompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadRunICompletedEventHandler(object sender, UploadRunICompletedEventArgs args);
-
-public partial class UploadRTCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadRTCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadRTCompletedEventHandler(object sender, UploadRTCompletedEventArgs args);
-
-public partial class UploadPulseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadPulseCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadPulseCompletedEventHandler(object sender, UploadPulseCompletedEventArgs args);
-
-public partial class UploadMultiChronopicCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal UploadMultiChronopicCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public int Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((int)(this.results[0]));
-        }
-    }
-}
-
-public delegate void UploadMultiChronopicCompletedEventHandler(object sender, 
UploadMultiChronopicCompletedEventArgs args);
-
-public partial class ListDirectoryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal ListDirectoryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string[] Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string[])(this.results[0]));
-        }
-    }
-}
-
-public delegate void ListDirectoryCompletedEventHandler(object sender, ListDirectoryCompletedEventArgs args);
+// ------------------------------------------------------------------------------
+//  <autogenerated>
+//      This code was generated by a tool.
+//      Mono Runtime Version: 2.0.50727.1433
+// 
+//      Changes to this file may cause incorrect behavior and will be lost if 
+//      the code is regenerated.
+//  </autogenerated>
+// ------------------------------------------------------------------------------
+
+
+
+/// <remarks/>
+/// <remarks>
+///ChronojumpServer
+///</remarks>
+[System.Web.Services.WebServiceBinding(Name="ChronojumpServerSoap", 
Namespace="http://server.chronojump.org:80/";)]
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.ComponentModel.DesignerCategoryAttribute("code")]
+[System.Xml.Serialization.XmlIncludeAttribute(typeof(Session))]
+[System.Xml.Serialization.XmlIncludeAttribute(typeof(EventType))]
+[System.Xml.Serialization.XmlIncludeAttribute(typeof(Event))]
+public partial class ChronojumpServer : System.Web.Services.Protocols.SoapHttpClientProtocol {
+    
+    private System.Threading.SendOrPostCallback ConnectDatabaseOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback DisConnectDatabaseOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback CanINewOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback CanIOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback QueryOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback StatsOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadSessionOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UpdateSessionOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadSportOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadJumpTypeOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadJumpRjTypeOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadRunTypeOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadRunIntervalTypeOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadPersonOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadPersonSessionIfNeededOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadPingOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadEvaluatorOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback EditEvaluatorOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback SelectEvaluatorsOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadJumpOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadJumpRjOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadRunOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadRunIOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadRTOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadPulseOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback UploadMultiChronopicOperationCompleted;
+    
+    private System.Threading.SendOrPostCallback ListDirectoryOperationCompleted;
+    
+    public ChronojumpServer() {
+        //this.Url = "http://localhost:8080/chronojumpServer.asmx";;
+        this.Url = "http://server.chronojump.org:80/chronojumpServer.asmx";;
+        //this.Url = "http://localhost:80/chronojumpServer.asmx";;
+    }
+    
+    public event ConnectDatabaseCompletedEventHandler ConnectDatabaseCompleted;
+    
+    public event DisConnectDatabaseCompletedEventHandler DisConnectDatabaseCompleted;
+    
+    public event CanINewCompletedEventHandler CanINewCompleted;
+    
+    public event CanICompletedEventHandler CanICompleted;
+    
+    public event QueryCompletedEventHandler QueryCompleted;
+    
+    public event StatsCompletedEventHandler StatsCompleted;
+    
+    public event UploadSessionCompletedEventHandler UploadSessionCompleted;
+    
+    public event UpdateSessionCompletedEventHandler UpdateSessionCompleted;
+    
+    public event UploadSportCompletedEventHandler UploadSportCompleted;
+    
+    public event UploadJumpTypeCompletedEventHandler UploadJumpTypeCompleted;
+    
+    public event UploadJumpRjTypeCompletedEventHandler UploadJumpRjTypeCompleted;
+    
+    public event UploadRunTypeCompletedEventHandler UploadRunTypeCompleted;
+    
+    public event UploadRunIntervalTypeCompletedEventHandler UploadRunIntervalTypeCompleted;
+    
+    public event UploadPersonCompletedEventHandler UploadPersonCompleted;
+    
+    public event UploadPersonSessionIfNeededCompletedEventHandler UploadPersonSessionIfNeededCompleted;
+    
+    public event UploadPingCompletedEventHandler UploadPingCompleted;
+    
+    public event UploadEvaluatorCompletedEventHandler UploadEvaluatorCompleted;
+    
+    public event EditEvaluatorCompletedEventHandler EditEvaluatorCompleted;
+    
+    public event SelectEvaluatorsCompletedEventHandler SelectEvaluatorsCompleted;
+    
+    public event UploadJumpCompletedEventHandler UploadJumpCompleted;
+    
+    public event UploadJumpRjCompletedEventHandler UploadJumpRjCompleted;
+    
+    public event UploadRunCompletedEventHandler UploadRunCompleted;
+    
+    public event UploadRunICompletedEventHandler UploadRunICompleted;
+    
+    public event UploadRTCompletedEventHandler UploadRTCompleted;
+    
+    public event UploadPulseCompletedEventHandler UploadPulseCompleted;
+    
+    public event UploadMultiChronopicCompletedEventHandler UploadMultiChronopicCompleted;
+    
+    public event ListDirectoryCompletedEventHandler ListDirectoryCompleted;
+    
+    /// <remarks>
+///Conecta BBDD
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/ConnectDatabase";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string ConnectDatabase() {
+        object[] results = this.Invoke("ConnectDatabase", new object[0]);
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginConnectDatabase(System.AsyncCallback callback, object asyncState) {
+        return this.BeginInvoke("ConnectDatabase", new object[0], callback, asyncState);
+    }
+    
+    public string EndConnectDatabase(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void ConnectDatabaseAsync() {
+        this.ConnectDatabaseAsync(null);
+    }
+    
+    public void ConnectDatabaseAsync(object userState) {
+        if ((this.ConnectDatabaseOperationCompleted == null)) {
+            this.ConnectDatabaseOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnConnectDatabaseCompleted);
+        }
+        this.InvokeAsync("ConnectDatabase", new object[0], this.ConnectDatabaseOperationCompleted, 
userState);
+    }
+    
+    private void OnConnectDatabaseCompleted(object arg) {
+        if ((this.ConnectDatabaseCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.ConnectDatabaseCompleted(this, new ConnectDatabaseCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Desconecta BBDD
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/DisConnectDatabase";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string DisConnectDatabase() {
+        object[] results = this.Invoke("DisConnectDatabase", new object[0]);
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginDisConnectDatabase(System.AsyncCallback callback, object asyncState) {
+        return this.BeginInvoke("DisConnectDatabase", new object[0], callback, asyncState);
+    }
+    
+    public string EndDisConnectDatabase(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void DisConnectDatabaseAsync() {
+        this.DisConnectDatabaseAsync(null);
+    }
+    
+    public void DisConnectDatabaseAsync(object userState) {
+        if ((this.DisConnectDatabaseOperationCompleted == null)) {
+            this.DisConnectDatabaseOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnDisConnectDatabaseCompleted);
+        }
+        this.InvokeAsync("DisConnectDatabase", new object[0], this.DisConnectDatabaseOperationCompleted, 
userState);
+    }
+    
+    private void OnDisConnectDatabaseCompleted(object arg) {
+        if ((this.DisConnectDatabaseCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.DisConnectDatabaseCompleted(this, new 
DisConnectDatabaseCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, 
invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Check actions that client can do depending on it's version)
+///</remarks>
+    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/CanINew";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public bool CanINew(string action, string clientVersion) {
+        object[] results = this.Invoke("CanINew", new object[] {
+                    action,
+                    clientVersion});
+        return ((bool)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginCanINew(string action, string clientVersion, System.AsyncCallback 
callback, object asyncState) {
+        return this.BeginInvoke("CanINew", new object[] {
+                    action,
+                    clientVersion}, callback, asyncState);
+    }
+    
+    public bool EndCanINew(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((bool)(results[0]));
+    }
+    
+    public void CanINewAsync(string action, string clientVersion) {
+        this.CanINewAsync(action, clientVersion, null);
+    }
+    
+    public void CanINewAsync(string action, string clientVersion, object userState) {
+        if ((this.CanINewOperationCompleted == null)) {
+            this.CanINewOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnCanINewCompleted);
+        }
+        this.InvokeAsync("CanINew", new object[] {
+                    action,
+                    clientVersion}, this.CanINewOperationCompleted, userState);
+    }
+    
+    private void OnCanINewCompleted(object arg) {
+        if ((this.CanINewCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.CanINewCompleted(this, new CanINewCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, 
invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Check actions that client can do depending on it's version)
+///</remarks>
+    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/CanI";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public bool CanI(string action, double clientVersion) {
+        object[] results = this.Invoke("CanI", new object[] {
+                    action,
+                    clientVersion});
+        return ((bool)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginCanI(string action, double clientVersion, System.AsyncCallback callback, 
object asyncState) {
+        return this.BeginInvoke("CanI", new object[] {
+                    action,
+                    clientVersion}, callback, asyncState);
+    }
+    
+    public bool EndCanI(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((bool)(results[0]));
+    }
+    
+    public void CanIAsync(string action, double clientVersion) {
+        this.CanIAsync(action, clientVersion, null);
+    }
+    
+    public void CanIAsync(string action, double clientVersion, object userState) {
+        if ((this.CanIOperationCompleted == null)) {
+            this.CanIOperationCompleted = new System.Threading.SendOrPostCallback(this.OnCanICompleted);
+        }
+        this.InvokeAsync("CanI", new object[] {
+                    action,
+                    clientVersion}, this.CanIOperationCompleted, userState);
+    }
+    
+    private void OnCanICompleted(object arg) {
+        if ((this.CanICompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.CanICompleted(this, new CanICompletedEventArgs(invokeArgs.Results, invokeArgs.Error, 
invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Query
+///</remarks>
+    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/Query";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string Query(string tableName, string test, string variable, int sex, string ageInterval, int 
countryID, int sportID, int speciallityID, int levelID, int evaluatorID) {
+        object[] results = this.Invoke("Query", new object[] {
+                    tableName,
+                    test,
+                    variable,
+                    sex,
+                    ageInterval,
+                    countryID,
+                    sportID,
+                    speciallityID,
+                    levelID,
+                    evaluatorID});
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginQuery(string tableName, string test, string variable, int sex, string 
ageInterval, int countryID, int sportID, int speciallityID, int levelID, int evaluatorID, 
System.AsyncCallback callback, object asyncState) {
+        return this.BeginInvoke("Query", new object[] {
+                    tableName,
+                    test,
+                    variable,
+                    sex,
+                    ageInterval,
+                    countryID,
+                    sportID,
+                    speciallityID,
+                    levelID,
+                    evaluatorID}, callback, asyncState);
+    }
+    
+    public string EndQuery(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void QueryAsync(string tableName, string test, string variable, int sex, string ageInterval, int 
countryID, int sportID, int speciallityID, int levelID, int evaluatorID) {
+        this.QueryAsync(tableName, test, variable, sex, ageInterval, countryID, sportID, speciallityID, 
levelID, evaluatorID, null);
+    }
+    
+    public void QueryAsync(string tableName, string test, string variable, int sex, string ageInterval, int 
countryID, int sportID, int speciallityID, int levelID, int evaluatorID, object userState) {
+        if ((this.QueryOperationCompleted == null)) {
+            this.QueryOperationCompleted = new System.Threading.SendOrPostCallback(this.OnQueryCompleted);
+        }
+        this.InvokeAsync("Query", new object[] {
+                    tableName,
+                    test,
+                    variable,
+                    sex,
+                    ageInterval,
+                    countryID,
+                    sportID,
+                    speciallityID,
+                    levelID,
+                    evaluatorID}, this.QueryOperationCompleted, userState);
+    }
+    
+    private void OnQueryCompleted(object arg) {
+        if ((this.QueryCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.QueryCompleted(this, new QueryCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, 
invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Stats
+///</remarks>
+    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/Stats";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string[] Stats() {
+        object[] results = this.Invoke("Stats", new object[0]);
+        return ((string[])(results[0]));
+    }
+    
+    public System.IAsyncResult BeginStats(System.AsyncCallback callback, object asyncState) {
+        return this.BeginInvoke("Stats", new object[0], callback, asyncState);
+    }
+    
+    public string[] EndStats(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string[])(results[0]));
+    }
+    
+    public void StatsAsync() {
+        this.StatsAsync(null);
+    }
+    
+    public void StatsAsync(object userState) {
+        if ((this.StatsOperationCompleted == null)) {
+            this.StatsOperationCompleted = new System.Threading.SendOrPostCallback(this.OnStatsCompleted);
+        }
+        this.InvokeAsync("Stats", new object[0], this.StatsOperationCompleted, userState);
+    }
+    
+    private void OnStatsCompleted(object arg) {
+        if ((this.StatsCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.StatsCompleted(this, new StatsCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, 
invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a session
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadSession";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadSession(ServerSession mySession) {
+        object[] results = this.Invoke("UploadSession", new object[] {
+                    mySession});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadSession(ServerSession mySession, System.AsyncCallback callback, 
object asyncState) {
+        return this.BeginInvoke("UploadSession", new object[] {
+                    mySession}, callback, asyncState);
+    }
+    
+    public int EndUploadSession(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadSessionAsync(ServerSession mySession) {
+        this.UploadSessionAsync(mySession, null);
+    }
+    
+    public void UploadSessionAsync(ServerSession mySession, object userState) {
+        if ((this.UploadSessionOperationCompleted == null)) {
+            this.UploadSessionOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadSessionCompleted);
+        }
+        this.InvokeAsync("UploadSession", new object[] {
+                    mySession}, this.UploadSessionOperationCompleted, userState);
+    }
+    
+    private void OnUploadSessionCompleted(object arg) {
+        if ((this.UploadSessionCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadSessionCompleted(this, new UploadSessionCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Update session uploadingState
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UpdateSession";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UpdateSession(int sessionID, int state) {
+        object[] results = this.Invoke("UpdateSession", new object[] {
+                    sessionID,
+                    state});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUpdateSession(int sessionID, int state, System.AsyncCallback callback, 
object asyncState) {
+        return this.BeginInvoke("UpdateSession", new object[] {
+                    sessionID,
+                    state}, callback, asyncState);
+    }
+    
+    public int EndUpdateSession(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UpdateSessionAsync(int sessionID, int state) {
+        this.UpdateSessionAsync(sessionID, state, null);
+    }
+    
+    public void UpdateSessionAsync(int sessionID, int state, object userState) {
+        if ((this.UpdateSessionOperationCompleted == null)) {
+            this.UpdateSessionOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUpdateSessionCompleted);
+        }
+        this.InvokeAsync("UpdateSession", new object[] {
+                    sessionID,
+                    state}, this.UpdateSessionOperationCompleted, userState);
+    }
+    
+    private void OnUpdateSessionCompleted(object arg) {
+        if ((this.UpdateSessionCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UpdateSessionCompleted(this, new UpdateSessionCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload an sport (user defined)
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadSport";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadSport(Sport mySport) {
+        object[] results = this.Invoke("UploadSport", new object[] {
+                    mySport});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadSport(Sport mySport, System.AsyncCallback callback, object 
asyncState) {
+        return this.BeginInvoke("UploadSport", new object[] {
+                    mySport}, callback, asyncState);
+    }
+    
+    public int EndUploadSport(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadSportAsync(Sport mySport) {
+        this.UploadSportAsync(mySport, null);
+    }
+    
+    public void UploadSportAsync(Sport mySport, object userState) {
+        if ((this.UploadSportOperationCompleted == null)) {
+            this.UploadSportOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadSportCompleted);
+        }
+        this.InvokeAsync("UploadSport", new object[] {
+                    mySport}, this.UploadSportOperationCompleted, userState);
+    }
+    
+    private void OnUploadSportCompleted(object arg) {
+        if ((this.UploadSportCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadSportCompleted(this, new UploadSportCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a jump type (user defined)
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadJumpType";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string UploadJumpType(JumpType type, int evalSID) {
+        object[] results = this.Invoke("UploadJumpType", new object[] {
+                    type,
+                    evalSID});
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadJumpType(JumpType type, int evalSID, System.AsyncCallback 
callback, object asyncState) {
+        return this.BeginInvoke("UploadJumpType", new object[] {
+                    type,
+                    evalSID}, callback, asyncState);
+    }
+    
+    public string EndUploadJumpType(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void UploadJumpTypeAsync(JumpType type, int evalSID) {
+        this.UploadJumpTypeAsync(type, evalSID, null);
+    }
+    
+    public void UploadJumpTypeAsync(JumpType type, int evalSID, object userState) {
+        if ((this.UploadJumpTypeOperationCompleted == null)) {
+            this.UploadJumpTypeOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadJumpTypeCompleted);
+        }
+        this.InvokeAsync("UploadJumpType", new object[] {
+                    type,
+                    evalSID}, this.UploadJumpTypeOperationCompleted, userState);
+    }
+    
+    private void OnUploadJumpTypeCompleted(object arg) {
+        if ((this.UploadJumpTypeCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadJumpTypeCompleted(this, new UploadJumpTypeCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a jumpRj type (user defined)
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadJumpRjType";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string UploadJumpRjType(JumpType type, int evalSID) {
+        object[] results = this.Invoke("UploadJumpRjType", new object[] {
+                    type,
+                    evalSID});
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadJumpRjType(JumpType type, int evalSID, System.AsyncCallback 
callback, object asyncState) {
+        return this.BeginInvoke("UploadJumpRjType", new object[] {
+                    type,
+                    evalSID}, callback, asyncState);
+    }
+    
+    public string EndUploadJumpRjType(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void UploadJumpRjTypeAsync(JumpType type, int evalSID) {
+        this.UploadJumpRjTypeAsync(type, evalSID, null);
+    }
+    
+    public void UploadJumpRjTypeAsync(JumpType type, int evalSID, object userState) {
+        if ((this.UploadJumpRjTypeOperationCompleted == null)) {
+            this.UploadJumpRjTypeOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadJumpRjTypeCompleted);
+        }
+        this.InvokeAsync("UploadJumpRjType", new object[] {
+                    type,
+                    evalSID}, this.UploadJumpRjTypeOperationCompleted, userState);
+    }
+    
+    private void OnUploadJumpRjTypeCompleted(object arg) {
+        if ((this.UploadJumpRjTypeCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadJumpRjTypeCompleted(this, new UploadJumpRjTypeCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a run type (user defined)
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRunType";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string UploadRunType(RunType type, int evalSID) {
+        object[] results = this.Invoke("UploadRunType", new object[] {
+                    type,
+                    evalSID});
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadRunType(RunType type, int evalSID, System.AsyncCallback callback, 
object asyncState) {
+        return this.BeginInvoke("UploadRunType", new object[] {
+                    type,
+                    evalSID}, callback, asyncState);
+    }
+    
+    public string EndUploadRunType(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void UploadRunTypeAsync(RunType type, int evalSID) {
+        this.UploadRunTypeAsync(type, evalSID, null);
+    }
+    
+    public void UploadRunTypeAsync(RunType type, int evalSID, object userState) {
+        if ((this.UploadRunTypeOperationCompleted == null)) {
+            this.UploadRunTypeOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRunTypeCompleted);
+        }
+        this.InvokeAsync("UploadRunType", new object[] {
+                    type,
+                    evalSID}, this.UploadRunTypeOperationCompleted, userState);
+    }
+    
+    private void OnUploadRunTypeCompleted(object arg) {
+        if ((this.UploadRunTypeCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadRunTypeCompleted(this, new UploadRunTypeCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a run interval type (user defined)
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRunIntervalType";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string UploadRunIntervalType(RunType type, int evalSID) {
+        object[] results = this.Invoke("UploadRunIntervalType", new object[] {
+                    type,
+                    evalSID});
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadRunIntervalType(RunType type, int evalSID, System.AsyncCallback 
callback, object asyncState) {
+        return this.BeginInvoke("UploadRunIntervalType", new object[] {
+                    type,
+                    evalSID}, callback, asyncState);
+    }
+    
+    public string EndUploadRunIntervalType(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void UploadRunIntervalTypeAsync(RunType type, int evalSID) {
+        this.UploadRunIntervalTypeAsync(type, evalSID, null);
+    }
+    
+    public void UploadRunIntervalTypeAsync(RunType type, int evalSID, object userState) {
+        if ((this.UploadRunIntervalTypeOperationCompleted == null)) {
+            this.UploadRunIntervalTypeOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRunIntervalTypeCompleted);
+        }
+        this.InvokeAsync("UploadRunIntervalType", new object[] {
+                    type,
+                    evalSID}, this.UploadRunIntervalTypeOperationCompleted, userState);
+    }
+    
+    private void OnUploadRunIntervalTypeCompleted(object arg) {
+        if ((this.UploadRunIntervalTypeCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadRunIntervalTypeCompleted(this, new 
UploadRunIntervalTypeCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, 
invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a person
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadPerson";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadPerson(Person myPerson, int sessionID) {
+        object[] results = this.Invoke("UploadPerson", new object[] {
+                    myPerson,
+                    sessionID});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadPerson(Person myPerson, int sessionID, System.AsyncCallback 
callback, object asyncState) {
+        return this.BeginInvoke("UploadPerson", new object[] {
+                    myPerson,
+                    sessionID}, callback, asyncState);
+    }
+    
+    public int EndUploadPerson(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadPersonAsync(Person myPerson, int sessionID) {
+        this.UploadPersonAsync(myPerson, sessionID, null);
+    }
+    
+    public void UploadPersonAsync(Person myPerson, int sessionID, object userState) {
+        if ((this.UploadPersonOperationCompleted == null)) {
+            this.UploadPersonOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadPersonCompleted);
+        }
+        this.InvokeAsync("UploadPerson", new object[] {
+                    myPerson,
+                    sessionID}, this.UploadPersonOperationCompleted, userState);
+    }
+    
+    private void OnUploadPersonCompleted(object arg) {
+        if ((this.UploadPersonCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadPersonCompleted(this, new UploadPersonCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload person session if needed
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadPersonSessionIfNeeded";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadPersonSessionIfNeeded(PersonSession ps) {
+        object[] results = this.Invoke("UploadPersonSessionIfNeeded", new object[] {
+                    ps});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadPersonSessionIfNeeded(PersonSession ps, System.AsyncCallback 
callback, object asyncState) {
+        return this.BeginInvoke("UploadPersonSessionIfNeeded", new object[] {
+                    ps}, callback, asyncState);
+    }
+    
+    public int EndUploadPersonSessionIfNeeded(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadPersonSessionIfNeededAsync(PersonSession ps) {
+        this.UploadPersonSessionIfNeededAsync(ps, null);
+    }
+    
+    public void UploadPersonSessionIfNeededAsync(PersonSession ps, object userState) {
+        if ((this.UploadPersonSessionIfNeededOperationCompleted == null)) {
+            this.UploadPersonSessionIfNeededOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadPersonSessionIfNeededCompleted);
+        }
+        this.InvokeAsync("UploadPersonSessionIfNeeded", new object[] {
+                    ps}, this.UploadPersonSessionIfNeededOperationCompleted, userState);
+    }
+    
+    private void OnUploadPersonSessionIfNeededCompleted(object arg) {
+        if ((this.UploadPersonSessionIfNeededCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadPersonSessionIfNeededCompleted(this, new 
UploadPersonSessionIfNeededCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, 
invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a ping
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadPing";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string UploadPing(ServerPing myPing, bool doInsertion) {
+        object[] results = this.Invoke("UploadPing", new object[] {
+                    myPing,
+                    doInsertion});
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadPing(ServerPing myPing, bool doInsertion, System.AsyncCallback 
callback, object asyncState) {
+        return this.BeginInvoke("UploadPing", new object[] {
+                    myPing,
+                    doInsertion}, callback, asyncState);
+    }
+    
+    public string EndUploadPing(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void UploadPingAsync(ServerPing myPing, bool doInsertion) {
+        this.UploadPingAsync(myPing, doInsertion, null);
+    }
+    
+    public void UploadPingAsync(ServerPing myPing, bool doInsertion, object userState) {
+        if ((this.UploadPingOperationCompleted == null)) {
+            this.UploadPingOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadPingCompleted);
+        }
+        this.InvokeAsync("UploadPing", new object[] {
+                    myPing,
+                    doInsertion}, this.UploadPingOperationCompleted, userState);
+    }
+    
+    private void OnUploadPingCompleted(object arg) {
+        if ((this.UploadPingCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadPingCompleted(this, new UploadPingCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload an evaluator
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadEvaluator";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string UploadEvaluator(ServerEvaluator myEval) {
+        object[] results = this.Invoke("UploadEvaluator", new object[] {
+                    myEval});
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadEvaluator(ServerEvaluator myEval, System.AsyncCallback callback, 
object asyncState) {
+        return this.BeginInvoke("UploadEvaluator", new object[] {
+                    myEval}, callback, asyncState);
+    }
+    
+    public string EndUploadEvaluator(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void UploadEvaluatorAsync(ServerEvaluator myEval) {
+        this.UploadEvaluatorAsync(myEval, null);
+    }
+    
+    public void UploadEvaluatorAsync(ServerEvaluator myEval, object userState) {
+        if ((this.UploadEvaluatorOperationCompleted == null)) {
+            this.UploadEvaluatorOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadEvaluatorCompleted);
+        }
+        this.InvokeAsync("UploadEvaluator", new object[] {
+                    myEval}, this.UploadEvaluatorOperationCompleted, userState);
+    }
+    
+    private void OnUploadEvaluatorCompleted(object arg) {
+        if ((this.UploadEvaluatorCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadEvaluatorCompleted(this, new UploadEvaluatorCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Edit an evaluator
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/EditEvaluator";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public bool EditEvaluator(ServerEvaluator clientEval, int evalSID) {
+        object[] results = this.Invoke("EditEvaluator", new object[] {
+                    clientEval,
+                    evalSID});
+        return ((bool)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginEditEvaluator(ServerEvaluator clientEval, int evalSID, 
System.AsyncCallback callback, object asyncState) {
+        return this.BeginInvoke("EditEvaluator", new object[] {
+                    clientEval,
+                    evalSID}, callback, asyncState);
+    }
+    
+    public bool EndEditEvaluator(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((bool)(results[0]));
+    }
+    
+    public void EditEvaluatorAsync(ServerEvaluator clientEval, int evalSID) {
+        this.EditEvaluatorAsync(clientEval, evalSID, null);
+    }
+    
+    public void EditEvaluatorAsync(ServerEvaluator clientEval, int evalSID, object userState) {
+        if ((this.EditEvaluatorOperationCompleted == null)) {
+            this.EditEvaluatorOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnEditEvaluatorCompleted);
+        }
+        this.InvokeAsync("EditEvaluator", new object[] {
+                    clientEval,
+                    evalSID}, this.EditEvaluatorOperationCompleted, userState);
+    }
+    
+    private void OnEditEvaluatorCompleted(object arg) {
+        if ((this.EditEvaluatorCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.EditEvaluatorCompleted(this, new EditEvaluatorCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Select evaluators
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/SelectEvaluators";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string[] SelectEvaluators(bool addAnyString) {
+        object[] results = this.Invoke("SelectEvaluators", new object[] {
+                    addAnyString});
+        return ((string[])(results[0]));
+    }
+    
+    public System.IAsyncResult BeginSelectEvaluators(bool addAnyString, System.AsyncCallback callback, 
object asyncState) {
+        return this.BeginInvoke("SelectEvaluators", new object[] {
+                    addAnyString}, callback, asyncState);
+    }
+    
+    public string[] EndSelectEvaluators(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string[])(results[0]));
+    }
+    
+    public void SelectEvaluatorsAsync(bool addAnyString) {
+        this.SelectEvaluatorsAsync(addAnyString, null);
+    }
+    
+    public void SelectEvaluatorsAsync(bool addAnyString, object userState) {
+        if ((this.SelectEvaluatorsOperationCompleted == null)) {
+            this.SelectEvaluatorsOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnSelectEvaluatorsCompleted);
+        }
+        this.InvokeAsync("SelectEvaluators", new object[] {
+                    addAnyString}, this.SelectEvaluatorsOperationCompleted, userState);
+    }
+    
+    private void OnSelectEvaluatorsCompleted(object arg) {
+        if ((this.SelectEvaluatorsCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.SelectEvaluatorsCompleted(this, new SelectEvaluatorsCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a jump
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadJump";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadJump(Jump myTest) {
+        object[] results = this.Invoke("UploadJump", new object[] {
+                    myTest});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadJump(Jump myTest, System.AsyncCallback callback, object 
asyncState) {
+        return this.BeginInvoke("UploadJump", new object[] {
+                    myTest}, callback, asyncState);
+    }
+    
+    public int EndUploadJump(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadJumpAsync(Jump myTest) {
+        this.UploadJumpAsync(myTest, null);
+    }
+    
+    public void UploadJumpAsync(Jump myTest, object userState) {
+        if ((this.UploadJumpOperationCompleted == null)) {
+            this.UploadJumpOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadJumpCompleted);
+        }
+        this.InvokeAsync("UploadJump", new object[] {
+                    myTest}, this.UploadJumpOperationCompleted, userState);
+    }
+    
+    private void OnUploadJumpCompleted(object arg) {
+        if ((this.UploadJumpCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadJumpCompleted(this, new UploadJumpCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a jumpRj
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadJumpRj";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadJumpRj(JumpRj myTest) {
+        object[] results = this.Invoke("UploadJumpRj", new object[] {
+                    myTest});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadJumpRj(JumpRj myTest, System.AsyncCallback callback, object 
asyncState) {
+        return this.BeginInvoke("UploadJumpRj", new object[] {
+                    myTest}, callback, asyncState);
+    }
+    
+    public int EndUploadJumpRj(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadJumpRjAsync(JumpRj myTest) {
+        this.UploadJumpRjAsync(myTest, null);
+    }
+    
+    public void UploadJumpRjAsync(JumpRj myTest, object userState) {
+        if ((this.UploadJumpRjOperationCompleted == null)) {
+            this.UploadJumpRjOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadJumpRjCompleted);
+        }
+        this.InvokeAsync("UploadJumpRj", new object[] {
+                    myTest}, this.UploadJumpRjOperationCompleted, userState);
+    }
+    
+    private void OnUploadJumpRjCompleted(object arg) {
+        if ((this.UploadJumpRjCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadJumpRjCompleted(this, new UploadJumpRjCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a run
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRun";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadRun(Run myTest) {
+        object[] results = this.Invoke("UploadRun", new object[] {
+                    myTest});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadRun(Run myTest, System.AsyncCallback callback, object asyncState) {
+        return this.BeginInvoke("UploadRun", new object[] {
+                    myTest}, callback, asyncState);
+    }
+    
+    public int EndUploadRun(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadRunAsync(Run myTest) {
+        this.UploadRunAsync(myTest, null);
+    }
+    
+    public void UploadRunAsync(Run myTest, object userState) {
+        if ((this.UploadRunOperationCompleted == null)) {
+            this.UploadRunOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRunCompleted);
+        }
+        this.InvokeAsync("UploadRun", new object[] {
+                    myTest}, this.UploadRunOperationCompleted, userState);
+    }
+    
+    private void OnUploadRunCompleted(object arg) {
+        if ((this.UploadRunCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadRunCompleted(this, new UploadRunCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a run interval
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRunI";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadRunI(RunInterval myTest) {
+        object[] results = this.Invoke("UploadRunI", new object[] {
+                    myTest});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadRunI(RunInterval myTest, System.AsyncCallback callback, object 
asyncState) {
+        return this.BeginInvoke("UploadRunI", new object[] {
+                    myTest}, callback, asyncState);
+    }
+    
+    public int EndUploadRunI(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadRunIAsync(RunInterval myTest) {
+        this.UploadRunIAsync(myTest, null);
+    }
+    
+    public void UploadRunIAsync(RunInterval myTest, object userState) {
+        if ((this.UploadRunIOperationCompleted == null)) {
+            this.UploadRunIOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRunICompleted);
+        }
+        this.InvokeAsync("UploadRunI", new object[] {
+                    myTest}, this.UploadRunIOperationCompleted, userState);
+    }
+    
+    private void OnUploadRunICompleted(object arg) {
+        if ((this.UploadRunICompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadRunICompleted(this, new UploadRunICompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a reaction time
+///</remarks>
+    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadRT";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadRT(ReactionTime myTest) {
+        object[] results = this.Invoke("UploadRT", new object[] {
+                    myTest});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadRT(ReactionTime myTest, System.AsyncCallback callback, object 
asyncState) {
+        return this.BeginInvoke("UploadRT", new object[] {
+                    myTest}, callback, asyncState);
+    }
+    
+    public int EndUploadRT(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadRTAsync(ReactionTime myTest) {
+        this.UploadRTAsync(myTest, null);
+    }
+    
+    public void UploadRTAsync(ReactionTime myTest, object userState) {
+        if ((this.UploadRTOperationCompleted == null)) {
+            this.UploadRTOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadRTCompleted);
+        }
+        this.InvokeAsync("UploadRT", new object[] {
+                    myTest}, this.UploadRTOperationCompleted, userState);
+    }
+    
+    private void OnUploadRTCompleted(object arg) {
+        if ((this.UploadRTCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadRTCompleted(this, new UploadRTCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a pulse
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadPulse";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadPulse(Pulse myTest) {
+        object[] results = this.Invoke("UploadPulse", new object[] {
+                    myTest});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadPulse(Pulse myTest, System.AsyncCallback callback, object 
asyncState) {
+        return this.BeginInvoke("UploadPulse", new object[] {
+                    myTest}, callback, asyncState);
+    }
+    
+    public int EndUploadPulse(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadPulseAsync(Pulse myTest) {
+        this.UploadPulseAsync(myTest, null);
+    }
+    
+    public void UploadPulseAsync(Pulse myTest, object userState) {
+        if ((this.UploadPulseOperationCompleted == null)) {
+            this.UploadPulseOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadPulseCompleted);
+        }
+        this.InvokeAsync("UploadPulse", new object[] {
+                    myTest}, this.UploadPulseOperationCompleted, userState);
+    }
+    
+    private void OnUploadPulseCompleted(object arg) {
+        if ((this.UploadPulseCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadPulseCompleted(this, new UploadPulseCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///Upload a multiChronopic
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/UploadMultiChronopic";,
 RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public int UploadMultiChronopic(MultiChronopic myTest) {
+        object[] results = this.Invoke("UploadMultiChronopic", new object[] {
+                    myTest});
+        return ((int)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginUploadMultiChronopic(MultiChronopic myTest, System.AsyncCallback 
callback, object asyncState) {
+        return this.BeginInvoke("UploadMultiChronopic", new object[] {
+                    myTest}, callback, asyncState);
+    }
+    
+    public int EndUploadMultiChronopic(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((int)(results[0]));
+    }
+    
+    public void UploadMultiChronopicAsync(MultiChronopic myTest) {
+        this.UploadMultiChronopicAsync(myTest, null);
+    }
+    
+    public void UploadMultiChronopicAsync(MultiChronopic myTest, object userState) {
+        if ((this.UploadMultiChronopicOperationCompleted == null)) {
+            this.UploadMultiChronopicOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnUploadMultiChronopicCompleted);
+        }
+        this.InvokeAsync("UploadMultiChronopic", new object[] {
+                    myTest}, this.UploadMultiChronopicOperationCompleted, userState);
+    }
+    
+    private void OnUploadMultiChronopicCompleted(object arg) {
+        if ((this.UploadMultiChronopicCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.UploadMultiChronopicCompleted(this, new 
UploadMultiChronopicCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, 
invokeArgs.UserState));
+        }
+    }
+    
+    /// <remarks>
+///List directory files (only as a sample)
+///</remarks>
+    
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://server.chronojump.org:8080/ListDirectory";, 
RequestNamespace="http://server.chronojump.org:8080/";, 
ResponseNamespace="http://server.chronojump.org:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string[] ListDirectory(string path) {
+        object[] results = this.Invoke("ListDirectory", new object[] {
+                    path});
+        return ((string[])(results[0]));
+    }
+    
+    public System.IAsyncResult BeginListDirectory(string path, System.AsyncCallback callback, object 
asyncState) {
+        return this.BeginInvoke("ListDirectory", new object[] {
+                    path}, callback, asyncState);
+    }
+    
+    public string[] EndListDirectory(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string[])(results[0]));
+    }
+    
+    public void ListDirectoryAsync(string path) {
+        this.ListDirectoryAsync(path, null);
+    }
+    
+    public void ListDirectoryAsync(string path, object userState) {
+        if ((this.ListDirectoryOperationCompleted == null)) {
+            this.ListDirectoryOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnListDirectoryCompleted);
+        }
+        this.InvokeAsync("ListDirectory", new object[] {
+                    path}, this.ListDirectoryOperationCompleted, userState);
+    }
+    
+    private void OnListDirectoryCompleted(object arg) {
+        if ((this.ListDirectoryCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.ListDirectoryCompleted(this, new ListDirectoryCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+}
+
+
+public partial class ConnectDatabaseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal ConnectDatabaseCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void ConnectDatabaseCompletedEventHandler(object sender, ConnectDatabaseCompletedEventArgs 
args);
+
+public partial class DisConnectDatabaseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal DisConnectDatabaseCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void DisConnectDatabaseCompletedEventHandler(object sender, 
DisConnectDatabaseCompletedEventArgs args);
+
+public partial class CanINewCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal CanINewCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public bool Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((bool)(this.results[0]));
+        }
+    }
+}
+
+public delegate void CanINewCompletedEventHandler(object sender, CanINewCompletedEventArgs args);
+
+public partial class CanICompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal CanICompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public bool Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((bool)(this.results[0]));
+        }
+    }
+}
+
+public delegate void CanICompletedEventHandler(object sender, CanICompletedEventArgs args);
+
+public partial class QueryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal QueryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void QueryCompletedEventHandler(object sender, QueryCompletedEventArgs args);
+
+public partial class StatsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal StatsCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string[] Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string[])(this.results[0]));
+        }
+    }
+}
+
+public delegate void StatsCompletedEventHandler(object sender, StatsCompletedEventArgs args);
+
+public partial class UploadSessionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadSessionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadSessionCompletedEventHandler(object sender, UploadSessionCompletedEventArgs args);
+
+public partial class UpdateSessionCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UpdateSessionCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UpdateSessionCompletedEventHandler(object sender, UpdateSessionCompletedEventArgs args);
+
+public partial class UploadSportCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadSportCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadSportCompletedEventHandler(object sender, UploadSportCompletedEventArgs args);
+
+public partial class UploadJumpTypeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadJumpTypeCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadJumpTypeCompletedEventHandler(object sender, UploadJumpTypeCompletedEventArgs 
args);
+
+public partial class UploadJumpRjTypeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadJumpRjTypeCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadJumpRjTypeCompletedEventHandler(object sender, UploadJumpRjTypeCompletedEventArgs 
args);
+
+public partial class UploadRunTypeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadRunTypeCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadRunTypeCompletedEventHandler(object sender, UploadRunTypeCompletedEventArgs args);
+
+public partial class UploadRunIntervalTypeCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs 
{
+    
+    private object[] results;
+    
+    internal UploadRunIntervalTypeCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadRunIntervalTypeCompletedEventHandler(object sender, 
UploadRunIntervalTypeCompletedEventArgs args);
+
+public partial class UploadPersonCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadPersonCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadPersonCompletedEventHandler(object sender, UploadPersonCompletedEventArgs args);
+
+public partial class UploadPersonSessionIfNeededCompletedEventArgs : 
System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadPersonSessionIfNeededCompletedEventArgs(object[] results, System.Exception exception, 
bool cancelled, object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadPersonSessionIfNeededCompletedEventHandler(object sender, 
UploadPersonSessionIfNeededCompletedEventArgs args);
+
+public partial class UploadPingCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadPingCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadPingCompletedEventHandler(object sender, UploadPingCompletedEventArgs args);
+
+public partial class UploadEvaluatorCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadEvaluatorCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadEvaluatorCompletedEventHandler(object sender, UploadEvaluatorCompletedEventArgs 
args);
+
+public partial class EditEvaluatorCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal EditEvaluatorCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public bool Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((bool)(this.results[0]));
+        }
+    }
+}
+
+public delegate void EditEvaluatorCompletedEventHandler(object sender, EditEvaluatorCompletedEventArgs args);
+
+public partial class SelectEvaluatorsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal SelectEvaluatorsCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string[] Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string[])(this.results[0]));
+        }
+    }
+}
+
+public delegate void SelectEvaluatorsCompletedEventHandler(object sender, SelectEvaluatorsCompletedEventArgs 
args);
+
+public partial class UploadJumpCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadJumpCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadJumpCompletedEventHandler(object sender, UploadJumpCompletedEventArgs args);
+
+public partial class UploadJumpRjCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadJumpRjCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadJumpRjCompletedEventHandler(object sender, UploadJumpRjCompletedEventArgs args);
+
+public partial class UploadRunCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadRunCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadRunCompletedEventHandler(object sender, UploadRunCompletedEventArgs args);
+
+public partial class UploadRunICompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadRunICompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadRunICompletedEventHandler(object sender, UploadRunICompletedEventArgs args);
+
+public partial class UploadRTCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadRTCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object 
userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadRTCompletedEventHandler(object sender, UploadRTCompletedEventArgs args);
+
+public partial class UploadPulseCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadPulseCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadPulseCompletedEventHandler(object sender, UploadPulseCompletedEventArgs args);
+
+public partial class UploadMultiChronopicCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal UploadMultiChronopicCompletedEventArgs(object[] results, System.Exception exception, bool 
cancelled, object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public int Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((int)(this.results[0]));
+        }
+    }
+}
+
+public delegate void UploadMultiChronopicCompletedEventHandler(object sender, 
UploadMultiChronopicCompletedEventArgs args);
+
+public partial class ListDirectoryCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal ListDirectoryCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string[] Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string[])(this.results[0]));
+        }
+    }
+}
+
+public delegate void ListDirectoryCompletedEventHandler(object sender, ListDirectoryCompletedEventArgs args);
diff --git a/chronojump_server/server_alive/pina_to_pina-good/ChronojumpServerAlive.cs 
b/chronojump_server/server_alive/pina_to_pina-good/ChronojumpServerAlive.cs
index c447e8c..63f43f1 100644
--- a/chronojump_server/server_alive/pina_to_pina-good/ChronojumpServerAlive.cs
+++ b/chronojump_server/server_alive/pina_to_pina-good/ChronojumpServerAlive.cs
@@ -1,87 +1,87 @@
-// ------------------------------------------------------------------------------
-//  <autogenerated>
-//      This code was generated by a tool.
-//      Mono Runtime Version: 2.0.50727.42
-// 
-//      Changes to this file may cause incorrect behavior and will be lost if 
-//      the code is regenerated.
-//  </autogenerated>
-// ------------------------------------------------------------------------------
-
-
-
-/// <remarks/>
+// ------------------------------------------------------------------------------
+//  <autogenerated>
+//      This code was generated by a tool.
+//      Mono Runtime Version: 2.0.50727.42
+// 
+//      Changes to this file may cause incorrect behavior and will be lost if 
+//      the code is regenerated.
+//  </autogenerated>
+// ------------------------------------------------------------------------------
+
+
+
+/// <remarks/>
 /// <remarks>
 ///ChronojumpServerAlive
-///</remarks>
-[System.Web.Services.WebServiceBinding(Name="ChronojumpServerAliveSoap", Namespace="http://localhost:8080/";)]
-[System.Diagnostics.DebuggerStepThroughAttribute()]
-[System.ComponentModel.DesignerCategoryAttribute("code")]
-public class ChronojumpServerAlive : System.Web.Services.Protocols.SoapHttpClientProtocol {
-    
-    private System.Threading.SendOrPostCallback PingAliveOperationCompleted;
-    
-    public ChronojumpServerAlive() {
-        this.Url = "http://localhost:8080/chronojumpServerAlive.asmx";;
-    }
-    
-    private event PingAliveCompletedEventHandler PingAliveCompleted;
-    
+///</remarks>
+[System.Web.Services.WebServiceBinding(Name="ChronojumpServerAliveSoap", Namespace="http://localhost:8080/";)]
+[System.Diagnostics.DebuggerStepThroughAttribute()]
+[System.ComponentModel.DesignerCategoryAttribute("code")]
+public class ChronojumpServerAlive : System.Web.Services.Protocols.SoapHttpClientProtocol {
+    
+    private System.Threading.SendOrPostCallback PingAliveOperationCompleted;
+    
+    public ChronojumpServerAlive() {
+        this.Url = "http://localhost:8080/chronojumpServerAlive.asmx";;
+    }
+    
+    private event PingAliveCompletedEventHandler PingAliveCompleted;
+    
     /// <remarks>
 ///PingAlive
-///</remarks>
-    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost:8080/PingAlive";, 
RequestNamespace="http://localhost:8080/";, ResponseNamespace="http://localhost:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
-    public string PingAlive(string str) {
-        object[] results = this.Invoke("PingAlive", new object[] {
-                    str});
-        return ((string)(results[0]));
-    }
-    
-    public System.IAsyncResult BeginPingAlive(string str, System.AsyncCallback callback, object asyncState) {
-        return this.BeginInvoke("PingAlive", new object[] {
-                    str}, callback, asyncState);
-    }
-    
-    public string EndPingAlive(System.IAsyncResult asyncResult) {
-        object[] results = this.EndInvoke(asyncResult);
-        return ((string)(results[0]));
-    }
-    
-    public void PingAliveAsync(string str) {
-        this.PingAliveAsync(str, null);
-    }
-    
-    public void PingAliveAsync(string str, object userState) {
-        if ((this.PingAliveOperationCompleted == null)) {
-            this.PingAliveOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnPingAliveCompleted);
-        }
-        this.InvokeAsync("PingAlive", new object[] {
-                    str}, this.PingAliveOperationCompleted, userState);
-    }
-    
-    private void OnPingAliveCompleted(object arg) {
-        if ((this.PingAliveCompleted != null)) {
-            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
-            this.PingAliveCompleted(this, new PingAliveCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
-        }
-    }
-}
-
-public class PingAliveCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
-    
-    private object[] results;
-    
-    internal PingAliveCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
-            base(exception, cancelled, userState) {
-        this.results = results;
-    }
-    
-    public string Result {
-        get {
-            this.RaiseExceptionIfNecessary();
-            return ((string)(this.results[0]));
-        }
-    }
-}
-
-public delegate void PingAliveCompletedEventHandler(object sender, PingAliveCompletedEventArgs args);
+///</remarks>
+    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost:8080/PingAlive";, 
RequestNamespace="http://localhost:8080/";, ResponseNamespace="http://localhost:8080/";, 
ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, 
Use=System.Web.Services.Description.SoapBindingUse.Literal)]
+    public string PingAlive(string str) {
+        object[] results = this.Invoke("PingAlive", new object[] {
+                    str});
+        return ((string)(results[0]));
+    }
+    
+    public System.IAsyncResult BeginPingAlive(string str, System.AsyncCallback callback, object asyncState) {
+        return this.BeginInvoke("PingAlive", new object[] {
+                    str}, callback, asyncState);
+    }
+    
+    public string EndPingAlive(System.IAsyncResult asyncResult) {
+        object[] results = this.EndInvoke(asyncResult);
+        return ((string)(results[0]));
+    }
+    
+    public void PingAliveAsync(string str) {
+        this.PingAliveAsync(str, null);
+    }
+    
+    public void PingAliveAsync(string str, object userState) {
+        if ((this.PingAliveOperationCompleted == null)) {
+            this.PingAliveOperationCompleted = new 
System.Threading.SendOrPostCallback(this.OnPingAliveCompleted);
+        }
+        this.InvokeAsync("PingAlive", new object[] {
+                    str}, this.PingAliveOperationCompleted, userState);
+    }
+    
+    private void OnPingAliveCompleted(object arg) {
+        if ((this.PingAliveCompleted != null)) {
+            System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = 
((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg));
+            this.PingAliveCompleted(this, new PingAliveCompletedEventArgs(invokeArgs.Results, 
invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState));
+        }
+    }
+}
+
+public class PingAliveCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
+    
+    private object[] results;
+    
+    internal PingAliveCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, 
object userState) : 
+            base(exception, cancelled, userState) {
+        this.results = results;
+    }
+    
+    public string Result {
+        get {
+            this.RaiseExceptionIfNecessary();
+            return ((string)(this.results[0]));
+        }
+    }
+}
+
+public delegate void PingAliveCompletedEventHandler(object sender, PingAliveCompletedEventArgs args);
diff --git a/src/chronojump.cs b/src/chronojump.cs
index 0337efc..266fe70 100644
--- a/src/chronojump.cs
+++ b/src/chronojump.cs
@@ -1,72 +1,72 @@
-/*
- * This file is part of ChronoJump
- *
- * Chronojump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * Chronojump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *  Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
- */
-
-
-using System;
-using Gtk;
-using Glade;
-using Mono.Unix;
-using System.IO; //"File" things
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+
+using System;
+using Gtk;
+using Glade;
+using Mono.Unix;
+using System.IO; //"File" things
 using System.Threading;
-using System.Diagnostics; //Process
-
-using System.Collections; //ArrayList
+using System.Diagnostics; //Process
+
+using System.Collections; //ArrayList
 
 using System.Runtime.InteropServices;
-
 
-public class ChronoJump 
-{
-       SplashWindow splashWin;
-       
-       private static string progVersion = ""; //now in "version" file
+
+public class ChronoJump 
+{
+       SplashWindow splashWin;
+       
+       private static string progVersion = ""; //now in "version" file
        private static string progName = "Chronojump";
-       
+       
        private static string runningFolder;    
-
-       private string runningFileName; //useful for knowing if there are two chronojump instances
-       private string messageToShowOnBoot = "";
-       private string messageCrashedBefore = "";
-       private bool chronojumpHasToExit = false;
-               
-       [Widget] Gtk.Button fakeSplashButton; //raised when splash win ended
-       Thread thread;
-       bool needEndSplashWin = false;
-       bool needUpdateSplashMessage = false;
-       string splashMessage = "";
-       bool creatingDB = false; //on creation and on update always refresh labels
-       bool updatingDB = false;
+
+       private string runningFileName; //useful for knowing if there are two chronojump instances
+       private string messageToShowOnBoot = "";
+       private string messageCrashedBefore = "";
+       private bool chronojumpHasToExit = false;
+               
+       [Widget] Gtk.Button fakeSplashButton; //raised when splash win ended
+       Thread thread;
+       bool needEndSplashWin = false;
+       bool needUpdateSplashMessage = false;
+       string splashMessage = "";
+       bool creatingDB = false; //on creation and on update always refresh labels
+       bool updatingDB = false;
        private static string baseDirectory;
-
+
 
 #if OSTYPE_WINDOWS
        [DllImport("libglib-2.0-0.dll") /* willfully unmapped */ ]
        static extern bool g_setenv (String env, String val, bool overwrite);
 #endif
 
-       public static void Main(string [] args) 
-       {/*
-               bool timeLogPassedOk = Log.Start(args);
-               Log.WriteLine(string.Format("Time log passed: {0}", timeLogPassedOk.ToString()));
-               Log.WriteLine(string.Format("Client database option 1 in ... " + Util.GetDatabaseDir()));
-               Log.WriteLine(string.Format("Client database option 2 in ... " + Util.GetDatabaseTempDir()));
+       public static void Main(string [] args) 
+       {/*
+               bool timeLogPassedOk = Log.Start(args);
+               Log.WriteLine(string.Format("Time log passed: {0}", timeLogPassedOk.ToString()));
+               Log.WriteLine(string.Format("Client database option 1 in ... " + Util.GetDatabaseDir()));
+               Log.WriteLine(string.Format("Client database option 2 in ... " + Util.GetDatabaseTempDir()));
                */
                
                LogSync.Initialize();
@@ -74,40 +74,40 @@ public class ChronoJump
                Log.Start();
                LogB.Debugging = true; //now LogB.Debug will be shown. Also there will be thread info on 
Warning, Error, Information
 
-               var envPath = Environment.GetEnvironmentVariable ("PATH");
-               var rBinPath = "";
+               var envPath = Environment.GetEnvironmentVariable ("PATH");
+               var rBinPath = "";
                baseDirectory = Util.GetPrefixDir();
-               if(UtilAll.IsWindows()) {
-                       //Environment.SetEnvironmentVariable ("R_HOME", RelativeToPrefix ("library"));
-                       //rBinPath = RelativeToPrefix ("lib");
-                       //rBinPath = RelativeToPrefix ("library");
-                       //var rPath = System.Environment.Is64BitProcess ? @"C:\Program 
Files\R\R-3.0.2\bin\x64" : @"C:\Program Files\R\R-3.0.2\bin\i386";
-                       string x64 = "bin" + System.IO.Path.DirectorySeparatorChar + "x64";
-                       string i386 = "bin" + System.IO.Path.DirectorySeparatorChar + "i386";
-                       var rPath = System.Environment.Is64BitProcess ? 
-                               System.IO.Path.Combine(baseDirectory, x64) : 
System.IO.Path.Combine(baseDirectory, i386);
-
-                       if (Directory.Exists(rPath) == false) {
-                               LogB.Error("Could not found the specified path to the directory containing 
R.dll: ", rPath);
-                               throw new DirectoryNotFoundException(string.Format("Could not found the 
specified path to the directory containing R.dll: {0}", rPath));
-                       }
-
-                       var newPath = string.Format("{0}{1}{2}", rPath, System.IO.Path.PathSeparator, 
envPath);
-                       LogB.Information("newPath:", newPath);
-               
-                       System.Environment.SetEnvironmentVariable("PATH", newPath);
-                       LogB.Information("path:", System.Environment.GetEnvironmentVariable("PATH"));
-                       
-                       //use this because we don't want to look at the registry
-                       //we don't want to force user to install R
-                       Environment.SetEnvironmentVariable ("R_HOME", baseDirectory);
-                       LogB.Information("R_HOME:", baseDirectory);
-               } else {
+               if(UtilAll.IsWindows()) {
+                       //Environment.SetEnvironmentVariable ("R_HOME", RelativeToPrefix ("library"));
+                       //rBinPath = RelativeToPrefix ("lib");
+                       //rBinPath = RelativeToPrefix ("library");
+                       //var rPath = System.Environment.Is64BitProcess ? @"C:\Program 
Files\R\R-3.0.2\bin\x64" : @"C:\Program Files\R\R-3.0.2\bin\i386";
+                       string x64 = "bin" + System.IO.Path.DirectorySeparatorChar + "x64";
+                       string i386 = "bin" + System.IO.Path.DirectorySeparatorChar + "i386";
+                       var rPath = System.Environment.Is64BitProcess ? 
+                               System.IO.Path.Combine(baseDirectory, x64) : 
System.IO.Path.Combine(baseDirectory, i386);
+
+                       if (Directory.Exists(rPath) == false) {
+                               LogB.Error("Could not found the specified path to the directory containing 
R.dll: ", rPath);
+                               throw new DirectoryNotFoundException(string.Format("Could not found the 
specified path to the directory containing R.dll: {0}", rPath));
+                       }
+
+                       var newPath = string.Format("{0}{1}{2}", rPath, System.IO.Path.PathSeparator, 
envPath);
+                       LogB.Information("newPath:", newPath);
+               
+                       System.Environment.SetEnvironmentVariable("PATH", newPath);
+                       LogB.Information("path:", System.Environment.GetEnvironmentVariable("PATH"));
+                       
+                       //use this because we don't want to look at the registry
+                       //we don't want to force user to install R
+                       Environment.SetEnvironmentVariable ("R_HOME", baseDirectory);
+                       LogB.Information("R_HOME:", baseDirectory);
+               } else {
                        switch (UtilAll.GetOSEnum()) {
                                case UtilAll.OperatingSystems.MACOSX:
                                        LogB.Information(Environment.GetEnvironmentVariable("R_HOME"));
-                                       rBinPath = "/Library/Frameworks/R.Framework/Libraries";
-                                               Environment.SetEnvironmentVariable ("R_HOME", 
"/Library/Frameworks/R.Framework/Resources");
+                                       rBinPath = "/Library/Frameworks/R.Framework/Libraries";
+                                               Environment.SetEnvironmentVariable ("R_HOME", 
"/Library/Frameworks/R.Framework/Resources");
                                                Environment.SetEnvironmentVariable("PATH", rBinPath + 
Path.PathSeparator + envPath);
                                        LogB.Information("environments");
                                        LogB.Information(Environment.GetEnvironmentVariable("R_HOME"));
@@ -126,31 +126,31 @@ public class ChronoJump
                                        break;
                        }
                }
-               
+               
                LogB.Information("Platform:" + Environment.OSVersion.Platform);
                
-               LogB.Information("baseDir0:", System.AppDomain.CurrentDomain.BaseDirectory);
-               LogB.Information("baseDir1:", baseDirectory);
-               LogB.Information("envPath+rBinPath:", envPath + Path.PathSeparator + rBinPath);
-               
+               LogB.Information("baseDir0:", System.AppDomain.CurrentDomain.BaseDirectory);
+               LogB.Information("baseDir1:", baseDirectory);
+               LogB.Information("envPath+rBinPath:", envPath + Path.PathSeparator + rBinPath);
+               
        
                //UtilCSV.ReadValues("/tmp/chronojump-encoder-graph-input-multi.csv");  
                
                if(UtilAll.IsWindows())
                        
Environment.SetEnvironmentVariable("GST_PLUGIN_PATH",RelativeToPrefix("lib\\gstreamer-0.10"));
 
-               //this call has to be done to chronojump.prg
-               //chronojump.prg createBlankDB
-               //this creates a blank database and exists.
-               //Then new user will have an updated database without the need of creating in
-               if(args.Length > 0 && args[0] == "createBlankDB") {
-                       createBlankDB();
-                       Environment.Exit(1);
-               }
-
-               if(args.Length > 0 && args[0] == "createBlankDBServer") {
-                       createBlankDBServer();
-                       Environment.Exit(1);
+               //this call has to be done to chronojump.prg
+               //chronojump.prg createBlankDB
+               //this creates a blank database and exists.
+               //Then new user will have an updated database without the need of creating in
+               if(args.Length > 0 && args[0] == "createBlankDB") {
+                       createBlankDB();
+                       Environment.Exit(1);
+               }
+
+               if(args.Length > 0 && args[0] == "createBlankDBServer") {
+                       createBlankDBServer();
+                       Environment.Exit(1);
                }
 
 
@@ -191,16 +191,16 @@ public class ChronoJump
        new ChronoJump(args);
        }
 
-       bool createdSplashWin = false;
+       bool createdSplashWin = false;
 
        public static string RelativeToPrefix(string relativePath) {
                return System.IO.Path.Combine(baseDirectory, relativePath);
        }
-
-       public ChronoJump (string [] args) 
-       {
-               
-               Application.Init();
+
+       public ChronoJump (string [] args) 
+       {
+               
+               Application.Init();
 
                //start threading to show splash window
                SplashWindow.Show();
@@ -216,20 +216,20 @@ public class ChronoJump
                LogB.ThreadStart();
                thread.Start(); 
 
-               Application.Run();
-       }
-
-       //variables to manage the ping thread
-       string versionAvailable;
-       //bool pingStart;
-       //bool pingEnd;
-       bool pulseGTKPingShouldEnd;
+               Application.Run();
+       }
+
+       //variables to manage the ping thread
+       string versionAvailable;
+       //bool pingStart;
+       //bool pingEnd;
+       bool pulseGTKPingShouldEnd;
        bool allSQLCallsDoneOnSqliteThingsThread;
 
        //used when Chronojump is being running two or more times (quadriple-click on start)
        bool quitNow = false;   
-
-       protected void sqliteThings () {
+
+       protected void sqliteThings () {
                bool crashedBefore = checkIfChronojumpExitAbnormally();
                if(crashedBefore) {
                        if(chronojumpIsExecutingNTimes()) {
@@ -239,14 +239,14 @@ public class ChronoJump
                                return;
                        }
                        else
-                               chronojumpCrashedBefore();
+                               chronojumpCrashedBefore();
                }
 
-               //print version of chronojump
-               progVersion = UtilAll.ReadVersion();
-
-               LogB.Information("Chronojump version: {0}", progVersion);
-
+               //print version of chronojump
+               progVersion = UtilAll.ReadVersion();
+
+               LogB.Information("Chronojump version: {0}", progVersion);
+
                //to store user videos and photos
                Util.CreateMultimediaDirsIfNeeded();
                //to store encoder data and graphs
@@ -256,154 +256,154 @@ public class ChronoJump
 //TODO: encoder weight auto written depending on person loaded, and changes if it changes person or weight
 
                
-               //move database to new location if chronojump version is before 0.7
-               moveDatabaseToNewLocationIfNeeded();
-
-               LogB.Information("move? ended");
-
-               splashMessageChange(1);  //checking database
-
-               /*
-               splashMessage = "pre-connect";
-               needUpdateSplashMessage = true;
-               Console.ReadLine();             
-               */
-               
-               Sqlite.CreateDir();
-               bool defaultDBLocation = Sqlite.Connect();
-
-               LogB.SQL("sqlite connected");
-
-               /*      
-               splashMessage = "post-connect" + defaultDBLocation.ToString();
-               needUpdateSplashMessage = true;
-               Console.ReadLine();             
-               */
-               
-               //Chech if the DB file exists
-               if (!Sqlite.CheckTables(defaultDBLocation)) {
-                       LogB.SQL ( Catalog.GetString ("no tables, creating ...") );
-
-                       creatingDB = true;
-                       splashMessageChange(2);  //creating database
-
-
-
-                       /*
-                       splashMessage = "pre-create";
-                       needUpdateSplashMessage = true;
-                       Console.ReadLine();             
-                       */
-
-
-
-                       Sqlite.CreateDir();
-                       Sqlite.CreateFile();
-                       //Sqlite.CreateFile(defaultDBLocation);
-
-
-
-                       /*
-                       splashMessage = "post-create";
-                       needUpdateSplashMessage = true;
-                       Console.ReadLine();             
-                       */
-
-
-
+               //move database to new location if chronojump version is before 0.7
+               moveDatabaseToNewLocationIfNeeded();
+
+               LogB.Information("move? ended");
+
+               splashMessageChange(1);  //checking database
+
+               /*
+               splashMessage = "pre-connect";
+               needUpdateSplashMessage = true;
+               Console.ReadLine();             
+               */
+               
+               Sqlite.CreateDir();
+               bool defaultDBLocation = Sqlite.Connect();
+
+               LogB.SQL("sqlite connected");
+
+               /*      
+               splashMessage = "post-connect" + defaultDBLocation.ToString();
+               needUpdateSplashMessage = true;
+               Console.ReadLine();             
+               */
+               
+               //Chech if the DB file exists
+               if (!Sqlite.CheckTables(defaultDBLocation)) {
+                       LogB.SQL ( Catalog.GetString ("no tables, creating ...") );
+
+                       creatingDB = true;
+                       splashMessageChange(2);  //creating database
+
+
+
+                       /*
+                       splashMessage = "pre-create";
+                       needUpdateSplashMessage = true;
+                       Console.ReadLine();             
+                       */
+
+
+
+                       Sqlite.CreateDir();
+                       Sqlite.CreateFile();
+                       //Sqlite.CreateFile(defaultDBLocation);
+
+
+
+                       /*
+                       splashMessage = "post-create";
+                       needUpdateSplashMessage = true;
+                       Console.ReadLine();             
+                       */
+
+
+
                        createRunningFileName(runningFileName);
-                       Sqlite.CreateTables(false); //not server
-                       creatingDB = false;
-               } else {
-                       LogB.SQL("doing backup");
-                       //backup the database
-                       Util.BackupDirCreateIfNeeded();
-
-                       splashMessageChange(3);  //making db backup
-
-                       Util.BackupDatabase();
-                       LogB.SQL ("made a database backup"); //not compressed yet, it seems 
System.IO.Compression.DeflateStream and
-                       //System.IO.Compression.GZipStream are not in mono
-
-
-                       if(! Sqlite.IsSqlite3()) {
-                               bool ok = Sqlite.ConvertFromSqlite2To3();
-                               if (!ok) {
-                                       LogB.Error("problem with sqlite");
-                                       //check (spanish)
-                                       
//http://mail.gnome.org/archives/chronojump-devel-list/2008-March/msg00011.html
-                                       string errorMessage = Catalog.GetString("Failed database conversion, 
ensure you have libsqlite3-0 installed. \nIf problems persist ask in chronojump-list");
-                                       errorMessage += "\n\n" + string.Format(Catalog.GetString("If you have 
no data on your database (you just installed Chronojump), you can fix this problem deleting this file: {0}"), 
-                                                       Util.GetDatabaseDir() + Path.DirectorySeparatorChar + 
"chronojump.db") + 
-                                               "\n" + Catalog.GetString("And starting Chronojump again.");
-                                       LogB.Error(errorMessage);
-                                       messageToShowOnBoot += errorMessage;
-                                       chronojumpHasToExit = true;
+                       Sqlite.CreateTables(false); //not server
+                       creatingDB = false;
+               } else {
+                       LogB.SQL("doing backup");
+                       //backup the database
+                       Util.BackupDirCreateIfNeeded();
+
+                       splashMessageChange(3);  //making db backup
+
+                       Util.BackupDatabase();
+                       LogB.SQL ("made a database backup"); //not compressed yet, it seems 
System.IO.Compression.DeflateStream and
+                       //System.IO.Compression.GZipStream are not in mono
+
+
+                       if(! Sqlite.IsSqlite3()) {
+                               bool ok = Sqlite.ConvertFromSqlite2To3();
+                               if (!ok) {
+                                       LogB.Error("problem with sqlite");
+                                       //check (spanish)
+                                       
//http://mail.gnome.org/archives/chronojump-devel-list/2008-March/msg00011.html
+                                       string errorMessage = Catalog.GetString("Failed database conversion, 
ensure you have libsqlite3-0 installed. \nIf problems persist ask in chronojump-list");
+                                       errorMessage += "\n\n" + string.Format(Catalog.GetString("If you have 
no data on your database (you just installed Chronojump), you can fix this problem deleting this file: {0}"), 
+                                                       Util.GetDatabaseDir() + Path.DirectorySeparatorChar + 
"chronojump.db") + 
+                                               "\n" + Catalog.GetString("And starting Chronojump again.");
+                                       LogB.Error(errorMessage);
+                                       messageToShowOnBoot += errorMessage;
+                                       chronojumpHasToExit = true;
                                        return;
-                               }
-                               Sqlite.Connect();
-                       }
-
-                       splashMessageChange(4);  //updating DB
-                       updatingDB = true;
-
+                               }
+                               Sqlite.Connect();
+                       }
+
+                       splashMessageChange(4);  //updating DB
+                       updatingDB = true;
+
                        if(Sqlite.ChangeDjToDJna())
                                messageToShowOnBoot += Catalog.GetString("All DJ jumps have been renamed as 
'DJna' (Drop Jumps with No Arms).") + "\n\n"+ 
                                        Catalog.GetString("If your Drop Jumps were executed using the arms, 
please rename them manually as 'DJa'.") + "\n";
-
-                       bool softwareIsNew = Sqlite.ConvertToLastChronojumpDBVersion();
-                       updatingDB = false;
+
+                       bool softwareIsNew = Sqlite.ConvertToLastChronojumpDBVersion();
+                       updatingDB = false;
                        
                                
-                       if(! softwareIsNew) {
-                               //Console.Clear();
-                               string errorMessage = string.Format(Catalog.GetString ("Sorry, this 
Chronojump version ({0}) is too old for your database."), progVersion) + "\n" +  
-                                               Catalog.GetString("Please update Chronojump") + ":\n"; 
-                               errorMessage += "http://chronojump.org";; 
-                               //errorMessage += "\n\n" + Catalog.GetString("Press any key");
-                               LogB.Error(errorMessage);
-                               messageToShowOnBoot += errorMessage;
-                               chronojumpHasToExit = true;
-                       }
-
-                       LogB.Information ( Catalog.GetString ("tables already created") ); 
+                       if(! softwareIsNew) {
+                               //Console.Clear();
+                               string errorMessage = string.Format(Catalog.GetString ("Sorry, this 
Chronojump version ({0}) is too old for your database."), progVersion) + "\n" +  
+                                               Catalog.GetString("Please update Chronojump") + ":\n"; 
+                               errorMessage += "http://chronojump.org";; 
+                               //errorMessage += "\n\n" + Catalog.GetString("Press any key");
+                               LogB.Error(errorMessage);
+                               messageToShowOnBoot += errorMessage;
+                               chronojumpHasToExit = true;
+                       }
+
+                       LogB.Information ( Catalog.GetString ("tables already created") ); 
                
-
-                       //check for bad Rjs (activate if program crashes and you use it in the same db before 
v.0.41)
-                       //SqliteJump.FindBadRjs();
+
+                       //check for bad Rjs (activate if program crashes and you use it in the same db before 
v.0.41)
+                       //SqliteJump.FindBadRjs();
                
                        createRunningFileName(runningFileName);
-               }
-               
-               
-
-
-               //splashMessageChange(5);  //check for new version
-               splashMessageChange(5);  //connecting to server
-
-               messageToShowOnBoot += recuperateBrokenEvents();
-
-               //connect to server to Ping
-               versionAvailable = "";
+               }
+               
+               
+
+
+               //splashMessageChange(5);  //check for new version
+               splashMessageChange(5);  //connecting to server
+
+               messageToShowOnBoot += recuperateBrokenEvents();
+
+               //connect to server to Ping
+               versionAvailable = "";
                /*
-               pingStart = false;
-               pingEnd = false;
+               pingStart = false;
+               pingEnd = false;
                
                // disable server connection on start until server is not working on windows again 
                bool connectServerAtStart = false;
                if(connectServerAtStart) {
-                       thread = new Thread(new ThreadStart(findVersion));
-                       GLib.Idle.Add (new GLib.IdleHandler (PulseGTKPing));
-                       thread.Start(); 
+                       thread = new Thread(new ThreadStart(findVersion));
+                       GLib.Idle.Add (new GLib.IdleHandler (PulseGTKPing));
+                       thread.Start(); 
                
-                       //wait until pinging process start
-                       while(! pingStart) {
-                       }
+                       //wait until pinging process start
+                       while(! pingStart) {
+                       }
                }
                else
                        on_find_version_cancelled(new object(), new EventArgs());
                */
-               versionAvailable = Constants.ServerOffline;
+               versionAvailable = Constants.ServerOffline;
        
 
                //doing ping using json methods
@@ -421,14 +421,14 @@ public class ChronoJump
                
                allSQLCallsDoneOnSqliteThingsThread = false;
                        
-               //wait until pinging ends (or it's cancelled)
-               //while(! pingEnd) {
-               //}
+               //wait until pinging ends (or it's cancelled)
+               //while(! pingEnd) {
+               //}
 
                Sqlite.Open();
 
-               string versionAvailableKnown = SqlitePreferences.Select("versionAvailable", true);
-               if( versionAvailable != Constants.ServerOffline && new Version(versionAvailable) > new 
Version(progVersion) ) {
+               string versionAvailableKnown = SqlitePreferences.Select("versionAvailable", true);
+               if( versionAvailable != Constants.ServerOffline && new Version(versionAvailable) > new 
Version(progVersion) ) {
                        //check if available version is higher than known available version
                        Version versionAvailableAsV = new Version(versionAvailable);
 
@@ -443,122 +443,122 @@ public class ChronoJump
                        }
 
                        if(updateKnownVersion) {
-                               //is the first time we know about this new version
-                               //just write on db and show message to user
-                               SqlitePreferences.Update(Constants.PrefVersionAvailable, versionAvailable, 
true);
-                               versionAvailableKnown = versionAvailable;
-                               messageToShowOnBoot += string.Format(Catalog.GetString(
-                                                       "\nNew Chronojump version available on website.\nYour 
Chronojump version is: {1}"), 
-                                               versionAvailable, progVersion) + "\n\n" + 
-                                       Catalog.GetString("Please, update to new version.") + "\n";
-                       }
+                               //is the first time we know about this new version
+                               //just write on db and show message to user
+                               SqlitePreferences.Update(Constants.PrefVersionAvailable, versionAvailable, 
true);
+                               versionAvailableKnown = versionAvailable;
+                               messageToShowOnBoot += string.Format(Catalog.GetString(
+                                                       "\nNew Chronojump version available on website.\nYour 
Chronojump version is: {1}"), 
+                                               versionAvailable, progVersion) + "\n\n" + 
+                                       Catalog.GetString("Please, update to new version.") + "\n";
+                       }
                }
 
 
-               //if chronojump chrashed before
-               if(crashedBefore) {
-                       if( versionAvailableKnown.Length > 0 && new Version(versionAvailableKnown) > new 
Version(progVersion) ) 
-                               messageToShowOnBoot += "\n" + Catalog.GetString("Chronojump crashed before.") 
+ "\n" +
-                                      Catalog.GetString("Please, update to new version: ") + 
versionAvailableKnown + "\n";
+               //if chronojump chrashed before
+               if(crashedBefore) {
+                       if( versionAvailableKnown.Length > 0 && new Version(versionAvailableKnown) > new 
Version(progVersion) ) 
+                               messageToShowOnBoot += "\n" + Catalog.GetString("Chronojump crashed before.") 
+ "\n" +
+                                      Catalog.GetString("Please, update to new version: ") + 
versionAvailableKnown + "\n";
                        else {
-                               messageToShowOnBoot += messageCrashedBefore;
+                               messageToShowOnBoot += messageCrashedBefore;
                                //SqlitePreferences.Update("videoOn", "False", true);
                        }
-               }
-               
-               
-               splashMessageChange(6);  //preparing main window
-               
-
-               //start as "simulated"
-               SqlitePreferences.Update("simulated", "True", true); //dbcon opened
+               }
+               
+               
+               splashMessageChange(6);  //preparing main window
+               
+
+               //start as "simulated"
+               SqlitePreferences.Update("simulated", "True", true); //dbcon opened
 
                Sqlite.Close();
-
-               // Chronojump sqlite is in an initialized state, let's keep the Sqlite state here
-               // to be re-used
-               Sqlite.saveClassState ();
-
+
+               // Chronojump sqlite is in an initialized state, let's keep the Sqlite state here
+               // to be re-used
+               Sqlite.saveClassState ();
+
                allSQLCallsDoneOnSqliteThingsThread = true;
                LogB.SQL("all SQL calls done on sqliteThings thread");
                
-               UtilAll.IsWindows();    //only as additional info here
-               
-               //Application.Init();
-               
-               needEndSplashWin = true;
-
-       }
-
-       private void findVersion() {
-               LogB.Debug("--1--");
-               //pingStart = true;
-               pulseGTKPingShouldEnd = false;
-               splashShowButton = true;
-               
-               LogB.Debug("--2--");
-               //maybe other thread doesn't create at time the splash win
-               //then just wait
+               UtilAll.IsWindows();    //only as additional info here
+               
+               //Application.Init();
+               
+               needEndSplashWin = true;
+
+       }
+
+       private void findVersion() {
+               LogB.Debug("--1--");
+               //pingStart = true;
+               pulseGTKPingShouldEnd = false;
+               splashShowButton = true;
+               
+               LogB.Debug("--2--");
+               //maybe other thread doesn't create at time the splash win
+               //then just wait
                while(! createdSplashWin)
                        ;
                
                LogB.Debug("--2.1--");
                        
-               try {
-                       if(splashWin.FakeButtonCreated)
-                               LogB.Information("Created splashWin.FakeButton");
-                       else
-                               LogB.Warning("NOT Created splashWin.FakeButton, si es bloqueja, posar aquí un 
while (mentre no estigui creat)");
-
-                       splashWin.FakeButtonCancel.Clicked += new EventHandler(on_find_version_cancelled);
-
-                       LogB.Debug("--3--");
-               } catch {
-                       LogB.Warning("Problem with splash win");
-               }
-
-               versionAvailable = Server.Ping(true, progName, UtilAll.ReadVersion()); //doInsertion
-               
-               LogB.Debug("--4--");
-               splashShowButton = false;
-               LogB.Information(" version:  ", versionAvailable);
-               LogB.Debug("\n--5--");
-               //pingEnd = true;
-               LogB.Debug("--6--");
-       }
-               
-       private void on_find_version_cancelled(object o, EventArgs args) {
-               splashShowButton = false;
-               pulseGTKPingShouldEnd = true;
-               versionAvailable = Constants.ServerOffline;
-               //pingEnd = true;
-       }
-
-       protected void readMessageToStart() {
-               if(messageToShowOnBoot.Length > 0) {
-                       ErrorWindow errorWin;
-                       if(chronojumpHasToExit) {
-                               messageToShowOnBoot += "\n<b>" + string.Format(Catalog.GetString("Chronojump 
will exit now.")) + "</b>\n";
-
-                               errorWin = ErrorWindow.Show(messageToShowOnBoot);
+               try {
+                       if(splashWin.FakeButtonCreated)
+                               LogB.Information("Created splashWin.FakeButton");
+                       else
+                               LogB.Warning("NOT Created splashWin.FakeButton, si es bloqueja, posar aquí un 
while (mentre no estigui creat)");
+
+                       splashWin.FakeButtonCancel.Clicked += new EventHandler(on_find_version_cancelled);
+
+                       LogB.Debug("--3--");
+               } catch {
+                       LogB.Warning("Problem with splash win");
+               }
+
+               versionAvailable = Server.Ping(true, progName, UtilAll.ReadVersion()); //doInsertion
+               
+               LogB.Debug("--4--");
+               splashShowButton = false;
+               LogB.Information(" version:  ", versionAvailable);
+               LogB.Debug("\n--5--");
+               //pingEnd = true;
+               LogB.Debug("--6--");
+       }
+               
+       private void on_find_version_cancelled(object o, EventArgs args) {
+               splashShowButton = false;
+               pulseGTKPingShouldEnd = true;
+               versionAvailable = Constants.ServerOffline;
+               //pingEnd = true;
+       }
+
+       protected void readMessageToStart() {
+               if(messageToShowOnBoot.Length > 0) {
+                       ErrorWindow errorWin;
+                       if(chronojumpHasToExit) {
+                               messageToShowOnBoot += "\n<b>" + string.Format(Catalog.GetString("Chronojump 
will exit now.")) + "</b>\n";
+
+                               errorWin = ErrorWindow.Show(messageToShowOnBoot);
                                errorWin.Show_button_open_database_folder();
-                               errorWin.Button_accept.Clicked += new 
EventHandler(on_message_boot_accepted_quit);
-                       } else { 
-                               errorWin = ErrorWindow.Show(messageToShowOnBoot);
+                               errorWin.Button_accept.Clicked += new 
EventHandler(on_message_boot_accepted_quit);
+                       } else { 
+                               errorWin = ErrorWindow.Show(messageToShowOnBoot);
                                errorWin.Show_send_log();
                                errorWin.ProgVersion = progVersion;
                                errorWin.Button_accept_label(Catalog.GetString("Open Chronojump"));
-                               errorWin.Button_accept.Clicked += new 
EventHandler(on_message_boot_accepted_continue);
-                       }
-               } else {
-                       startChronojump();
-               }
-       }
-
-       private void on_message_boot_accepted_continue (object o, EventArgs args) {
-               startChronojump();
-       }
-
+                               errorWin.Button_accept.Clicked += new 
EventHandler(on_message_boot_accepted_continue);
+                       }
+               } else {
+                       startChronojump();
+               }
+       }
+
+       private void on_message_boot_accepted_continue (object o, EventArgs args) {
+               startChronojump();
+       }
+
        private void on_message_boot_accepted_quit (object o, EventArgs args) {
                try {
                        File.Delete(runningFileName);
@@ -569,7 +569,7 @@ public class ChronoJump
                //Log.Delete();
                Application.Quit();
        }
-
+
        private void startChronojump() {
 
                //wait until all sql calls are done in other thread
@@ -579,122 +579,122 @@ public class ChronoJump
                }
                LogB.SQL("all SQL done! starting Chronojump");
 
-               new ChronoJumpWindow(progVersion, progName, runningFileName);
-       }
-
-       private static void createBlankDB() {
-               LogB.SQL("Creating blank database");
-               Sqlite.ConnectBlank();
-               Sqlite.CreateFile();
-               Sqlite.CreateTables(false); //not server
-               LogB.SQL("Created blank database! Exiting");
-       }
-       
-       private static void createBlankDBServer() {
-               LogB.SQL("Creating blank database for server");
-               if(Sqlite.CheckFileServer())
-                       LogB.Error("File already exists. Cannot create.");
-               else {
-                       Sqlite.ConnectServer();
-                       Sqlite.CreateFile();
-                       Sqlite.CreateTables(true); //server
-                       LogB.SQL("Created blank database! Exiting");
-                       string myVersion = UtilAll.ReadVersion();
-                       LogB.Warning("CAUTION: client info about versionAvailable (on server): ", myVersion);
-                       SqlitePreferences.Update ("availableVersion", myVersion, false); 
-                       LogB.Information("Maybe you don't want to show this version on pings, change it to 
last stable published version");
-               }
-       }
-
-
-       /* --------------------
-       /* splash window things 
-        * --------------------*/
-
-       private bool splashShowButton = false;
-
-       private void splashMessageChange(int messageInt) {
-              splashMessage = Catalog.GetString(Constants.SplashMessages[messageInt]);
-               needUpdateSplashMessage = true;
-       }
-       
-       protected bool PulseGTK ()
-       {
+               new ChronoJumpWindow(progVersion, progName, runningFileName);
+       }
+
+       private static void createBlankDB() {
+               LogB.SQL("Creating blank database");
+               Sqlite.ConnectBlank();
+               Sqlite.CreateFile();
+               Sqlite.CreateTables(false); //not server
+               LogB.SQL("Created blank database! Exiting");
+       }
+       
+       private static void createBlankDBServer() {
+               LogB.SQL("Creating blank database for server");
+               if(Sqlite.CheckFileServer())
+                       LogB.Error("File already exists. Cannot create.");
+               else {
+                       Sqlite.ConnectServer();
+                       Sqlite.CreateFile();
+                       Sqlite.CreateTables(true); //server
+                       LogB.SQL("Created blank database! Exiting");
+                       string myVersion = UtilAll.ReadVersion();
+                       LogB.Warning("CAUTION: client info about versionAvailable (on server): ", myVersion);
+                       SqlitePreferences.Update ("availableVersion", myVersion, false); 
+                       LogB.Information("Maybe you don't want to show this version on pings, change it to 
last stable published version");
+               }
+       }
+
+
+       /* --------------------
+       /* splash window things 
+        * --------------------*/
+
+       private bool splashShowButton = false;
+
+       private void splashMessageChange(int messageInt) {
+              splashMessage = Catalog.GetString(Constants.SplashMessages[messageInt]);
+               needUpdateSplashMessage = true;
+       }
+       
+       protected bool PulseGTK ()
+       {
                if(quitNow) 
                        return false;
 
-               //if( ( needEndSplashWin && pingEnd ) 
-               //              || ! thread.IsAlive) {
-               if( needEndSplashWin || ! thread.IsAlive ) {
+               //if( ( needEndSplashWin && pingEnd ) 
+               //              || ! thread.IsAlive) {
+               if( needEndSplashWin || ! thread.IsAlive ) {
                        LogB.ThreadEnding();
                        fakeSplashButton.Click();
 
-                       LogB.Information("splash window ending here");
+                       LogB.Information("splash window ending here");
                        LogB.ThreadEnded();
-                       return false;
-               }
-               //need to do this, if not it crashes because chronopicWin gets died by thread ending
-               splashWin = SplashWindow.Show();
-               //Log.WriteLine("splash");
-       
-               if(updatingDB) {
-                       splashWin.ShowProgressbar("updating");
-                       splashWin.UpdateLabel(splashMessage + " " + Sqlite.PrintConversionText());
-               
-                       splashWin.UpdateProgressbar("version", Sqlite.PrintConversionVersion());
-                       splashWin.UpdateProgressbar("rate", Sqlite.PrintConversionRate());
-                       splashWin.UpdateProgressbar("subrate", Sqlite.PrintConversionSubRate());
-
-               } else if(creatingDB) {
-                       splashWin.ShowProgressbar("creating");
-                       splashWin.UpdateProgressbar("version", Sqlite.PrintCreation());
-                       
-                       //splashWin.UpdateProgressbar("rate", Sqlite.PrintConversionRate());
-                       splashWin.UpdateProgressbar("subrate", Sqlite.PrintConversionSubRate());
-               }
-
-               if(needUpdateSplashMessage) {
-                       splashWin.UpdateLabel(splashMessage);
-                       needUpdateSplashMessage = false;
-               }
-                       
-
-               Thread.Sleep (50);
-               //Log.Write(" (PulseGTK:" + thread.ThreadState.ToString() + ") ");
-               return true;
-       }
-       
-       private void on_splash_ended(object o, EventArgs args) {
-               LogB.Information("splash screen going to END");
-               fakeSplashButton.Clicked -= new EventHandler(on_splash_ended);
+                       return false;
+               }
+               //need to do this, if not it crashes because chronopicWin gets died by thread ending
+               splashWin = SplashWindow.Show();
+               //Log.WriteLine("splash");
+       
+               if(updatingDB) {
+                       splashWin.ShowProgressbar("updating");
+                       splashWin.UpdateLabel(splashMessage + " " + Sqlite.PrintConversionText());
+               
+                       splashWin.UpdateProgressbar("version", Sqlite.PrintConversionVersion());
+                       splashWin.UpdateProgressbar("rate", Sqlite.PrintConversionRate());
+                       splashWin.UpdateProgressbar("subrate", Sqlite.PrintConversionSubRate());
+
+               } else if(creatingDB) {
+                       splashWin.ShowProgressbar("creating");
+                       splashWin.UpdateProgressbar("version", Sqlite.PrintCreation());
+                       
+                       //splashWin.UpdateProgressbar("rate", Sqlite.PrintConversionRate());
+                       splashWin.UpdateProgressbar("subrate", Sqlite.PrintConversionSubRate());
+               }
+
+               if(needUpdateSplashMessage) {
+                       splashWin.UpdateLabel(splashMessage);
+                       needUpdateSplashMessage = false;
+               }
+                       
+
+               Thread.Sleep (50);
+               //Log.Write(" (PulseGTK:" + thread.ThreadState.ToString() + ") ");
+               return true;
+       }
+       
+       private void on_splash_ended(object o, EventArgs args) {
+               LogB.Information("splash screen going to END");
+               fakeSplashButton.Clicked -= new EventHandler(on_splash_ended);
                if(splashWin != null)
-                       splashWin.Destroy();
+                       splashWin.Destroy();
                else
-                       SplashWindow.Hide();
+                       SplashWindow.Hide();
 
-               LogB.Information("splash screen ENDED!");
-               readMessageToStart();
-       }
+               LogB.Information("splash screen ENDED!");
+               readMessageToStart();
+       }
 
        /*
-       protected bool PulseGTKPing ()
-       {
-               if(pulseGTKPingShouldEnd) {
-                       splashWin.CancelButtonShow(false);
-                       LogB.Information("ping going to END");
-                       return false;
-               }
-
-               if(splashShowButton)
-                       splashWin.CancelButtonShow(true); //show cancel button on splash win
-               else
-                       splashWin.CancelButtonShow(false);
-
-               Thread.Sleep (50);
-               LogB.Debug(" (PulseGTKPing:" + thread.ThreadState.ToString() + ") ");
-               if(thread.ThreadState == System.Threading.ThreadState.Stopped)
-                       pulseGTKPingShouldEnd = true;
-               return true;
+       protected bool PulseGTKPing ()
+       {
+               if(pulseGTKPingShouldEnd) {
+                       splashWin.CancelButtonShow(false);
+                       LogB.Information("ping going to END");
+                       return false;
+               }
+
+               if(splashShowButton)
+                       splashWin.CancelButtonShow(true); //show cancel button on splash win
+               else
+                       splashWin.CancelButtonShow(false);
+
+               Thread.Sleep (50);
+               LogB.Debug(" (PulseGTKPing:" + thread.ThreadState.ToString() + ") ");
+               if(thread.ThreadState == System.Threading.ThreadState.Stopped)
+                       pulseGTKPingShouldEnd = true;
+               return true;
        }
        */
        
@@ -743,40 +743,40 @@ public class ChronoJump
                        return;
        }
 
-       //recuperate temp jumpRj or RunI if chronojump hangs
-       private string recuperateBrokenEvents() 
-       {
-               string returnString = "";
-               
-               string tableName = "tempJumpRj";
-               int existsTempData = Sqlite.TempDataExists(tableName);
-               if(existsTempData > 0)
-               {
-                       JumpRj myJumpRj = SqliteJumpRj.SelectJumpData("tempJumpRj", existsTempData, false);
-                       try {
-                               myJumpRj.InsertAtDB (true, Constants.JumpRjTable);
-                       } catch {} //pitty, cannot insert
-
-                       Sqlite.DeleteTempEvents(tableName);
-                       returnString = "Recuperated last Reactive Jump";
-               }
-
-               tableName = "tempRunInterval";
-               existsTempData = Sqlite.TempDataExists(tableName);
-               if(existsTempData > 0)
-               {
-                       RunInterval myRun = SqliteRunInterval.SelectRunData("tempRunInterval", 
existsTempData, false);
-                       try {
-                               myRun.InsertAtDB (true, Constants.RunIntervalTable);
-                       } catch {} //pitty, cannot insert
-
-                       Sqlite.DeleteTempEvents(tableName);
-                       returnString = "Recuperated last Intervallic Run";
-               }
-               
-               return returnString;
-       }
-
+       //recuperate temp jumpRj or RunI if chronojump hangs
+       private string recuperateBrokenEvents() 
+       {
+               string returnString = "";
+               
+               string tableName = "tempJumpRj";
+               int existsTempData = Sqlite.TempDataExists(tableName);
+               if(existsTempData > 0)
+               {
+                       JumpRj myJumpRj = SqliteJumpRj.SelectJumpData("tempJumpRj", existsTempData, false);
+                       try {
+                               myJumpRj.InsertAtDB (true, Constants.JumpRjTable);
+                       } catch {} //pitty, cannot insert
+
+                       Sqlite.DeleteTempEvents(tableName);
+                       returnString = "Recuperated last Reactive Jump";
+               }
+
+               tableName = "tempRunInterval";
+               existsTempData = Sqlite.TempDataExists(tableName);
+               if(existsTempData > 0)
+               {
+                       RunInterval myRun = SqliteRunInterval.SelectRunData("tempRunInterval", 
existsTempData, false);
+                       try {
+                               myRun.InsertAtDB (true, Constants.RunIntervalTable);
+                       } catch {} //pitty, cannot insert
+
+                       Sqlite.DeleteTempEvents(tableName);
+                       returnString = "Recuperated last Intervallic Run";
+               }
+               
+               return returnString;
+       }
+
        private void createRunningFileName(string runningFileName) {
                TextWriter writer = File.CreateText(runningFileName);
                writer.WriteLine(Process.GetCurrentProcess().Id);
@@ -785,13 +785,13 @@ public class ChronoJump
                ((IDisposable)writer).Dispose();
        }
 
-       private bool checkIfChronojumpExitAbnormally() {
-               runningFileName = Util.GetDatabaseDir() + Path.DirectorySeparatorChar + "chronojump_running";
+       private bool checkIfChronojumpExitAbnormally() {
+               runningFileName = Util.GetDatabaseDir() + Path.DirectorySeparatorChar + "chronojump_running";
                if(File.Exists(runningFileName))
                        return true;
                else
                        return false;
-       }
+       }
 
        private bool chronojumpIsExecutingNTimesComparePids(string pidName, string pid) {
                Process [] pids = Process.GetProcessesByName(pidName);
@@ -835,89 +835,89 @@ public class ChronoJump
        }
 
 
-       //move database to new location if chronojump version is before 0.7
-       private void moveDatabaseToNewLocationIfNeeded() 
-       {
-               string reallyOldDB = Util.GetReallyOldDatabaseDir();
-               string oldDB = Util.GetOldDatabaseDir();
-               string newDB = Util.GetDatabaseDir();
-               string previous = "";
-               bool moveNeeded = false;
-
-               if(! Directory.Exists(newDB)) {
-                       if(Directory.Exists(oldDB)) {
-                               previous = oldDB;
-                               moveNeeded = true;
-                       } else if(Directory.Exists(reallyOldDB)){
-                               previous = reallyOldDB;
-                               moveNeeded = true;
-                       }
-               }
-
-               if(moveNeeded) {
-                       try {
-                               Directory.Move(previous, newDB);
-                       }
-                       catch {
-                               string feedback = "";
-                               feedback += string.Format(Catalog.GetString("Cannot move database directory 
from {0} to {1}"), 
-                                               previous, Path.GetFullPath(newDB)) + "\n";
-                               feedback += string.Format(Catalog.GetString("Trying to move/copy each file 
now")) + "\n";
-
-                               int fileMoveProblems = 0;
-                               int fileCopyProblems = 0;
-
-                               try {
-                                       Directory.CreateDirectory(newDB);
-                                       Directory.CreateDirectory(newDB + Path.DirectorySeparatorChar + 
"backup");
-
-                                       string [] filesToMove = Directory.GetFiles(previous);
-                                       foreach (string oldFile in filesToMove) {
-                                               string newFile = newDB + Path.DirectorySeparatorChar + 
oldFile.Substring(oldDB.Length);
-                                               try {
-                                                       File.Move(oldFile, newFile);
-                                               }
-                                               catch {
-                                                       fileMoveProblems ++;
-                                                       try {
-                                                               LogB.Warning(string.Format("{0}-{1}", 
oldFile, newFile));
-                                                               File.Copy(oldFile, newFile);
-                                                       }
-                                                       catch {
-                                                               fileCopyProblems ++;
-                                                       }
-                                               }
-                                       }
-
-                               }
-                               catch {
-                                       feedback += string.Format(Catalog.GetString("Cannot create directory 
{0}"), Path.GetFullPath(newDB)) + "\n";
-                                       feedback += string.Format(Catalog.GetString("Please, do it 
manually.")) + "\n"; 
-                                       feedback += string.Format(Catalog.GetString("Chronojump will exit 
now.")) + "\n";
-                                       messageToShowOnBoot += feedback;        
-                                       LogB.Error(feedback);
-                                       chronojumpHasToExit = true;
-                               }
-                               if(fileCopyProblems > 0) {
-                                       feedback += string.Format(Catalog.GetString("Cannot copy {0} files 
from {1} to {2}"), fileCopyProblems, previous, Path.GetFullPath(newDB)) + "\n";
-                                       feedback += string.Format(Catalog.GetString("Please, do it 
manually.")) + "\n"; 
-                                       feedback += string.Format(Catalog.GetString("Chronojump will exit 
now.")) + "\n";
-                                       messageToShowOnBoot += feedback;        
-                                       LogB.Error(feedback);
-                                       chronojumpHasToExit = true;
-                               }
-                               if(fileMoveProblems > 0) {
-                                       feedback += string.Format(Catalog.GetString("Cannot move {0} files 
from {1} to {2}"), fileMoveProblems, previous, Path.GetFullPath(newDB)) + "\n";
-                                       feedback += string.Format(Catalog.GetString("Please, do it 
manually")) + "\n";
-                                       messageToShowOnBoot += feedback;        
-                                       LogB.Error(feedback);
-                               }
-                       }
-                                       
-                       string dbMove = string.Format(Catalog.GetString("Database is now here: {0}"), 
Path.GetFullPath(newDB));
-                       messageToShowOnBoot += dbMove;  
-                       LogB.Warning(dbMove);
-               }
-       }
-
-}
+       //move database to new location if chronojump version is before 0.7
+       private void moveDatabaseToNewLocationIfNeeded() 
+       {
+               string reallyOldDB = Util.GetReallyOldDatabaseDir();
+               string oldDB = Util.GetOldDatabaseDir();
+               string newDB = Util.GetDatabaseDir();
+               string previous = "";
+               bool moveNeeded = false;
+
+               if(! Directory.Exists(newDB)) {
+                       if(Directory.Exists(oldDB)) {
+                               previous = oldDB;
+                               moveNeeded = true;
+                       } else if(Directory.Exists(reallyOldDB)){
+                               previous = reallyOldDB;
+                               moveNeeded = true;
+                       }
+               }
+
+               if(moveNeeded) {
+                       try {
+                               Directory.Move(previous, newDB);
+                       }
+                       catch {
+                               string feedback = "";
+                               feedback += string.Format(Catalog.GetString("Cannot move database directory 
from {0} to {1}"), 
+                                               previous, Path.GetFullPath(newDB)) + "\n";
+                               feedback += string.Format(Catalog.GetString("Trying to move/copy each file 
now")) + "\n";
+
+                               int fileMoveProblems = 0;
+                               int fileCopyProblems = 0;
+
+                               try {
+                                       Directory.CreateDirectory(newDB);
+                                       Directory.CreateDirectory(newDB + Path.DirectorySeparatorChar + 
"backup");
+
+                                       string [] filesToMove = Directory.GetFiles(previous);
+                                       foreach (string oldFile in filesToMove) {
+                                               string newFile = newDB + Path.DirectorySeparatorChar + 
oldFile.Substring(oldDB.Length);
+                                               try {
+                                                       File.Move(oldFile, newFile);
+                                               }
+                                               catch {
+                                                       fileMoveProblems ++;
+                                                       try {
+                                                               LogB.Warning(string.Format("{0}-{1}", 
oldFile, newFile));
+                                                               File.Copy(oldFile, newFile);
+                                                       }
+                                                       catch {
+                                                               fileCopyProblems ++;
+                                                       }
+                                               }
+                                       }
+
+                               }
+                               catch {
+                                       feedback += string.Format(Catalog.GetString("Cannot create directory 
{0}"), Path.GetFullPath(newDB)) + "\n";
+                                       feedback += string.Format(Catalog.GetString("Please, do it 
manually.")) + "\n"; 
+                                       feedback += string.Format(Catalog.GetString("Chronojump will exit 
now.")) + "\n";
+                                       messageToShowOnBoot += feedback;        
+                                       LogB.Error(feedback);
+                                       chronojumpHasToExit = true;
+                               }
+                               if(fileCopyProblems > 0) {
+                                       feedback += string.Format(Catalog.GetString("Cannot copy {0} files 
from {1} to {2}"), fileCopyProblems, previous, Path.GetFullPath(newDB)) + "\n";
+                                       feedback += string.Format(Catalog.GetString("Please, do it 
manually.")) + "\n"; 
+                                       feedback += string.Format(Catalog.GetString("Chronojump will exit 
now.")) + "\n";
+                                       messageToShowOnBoot += feedback;        
+                                       LogB.Error(feedback);
+                                       chronojumpHasToExit = true;
+                               }
+                               if(fileMoveProblems > 0) {
+                                       feedback += string.Format(Catalog.GetString("Cannot move {0} files 
from {1} to {2}"), fileMoveProblems, previous, Path.GetFullPath(newDB)) + "\n";
+                                       feedback += string.Format(Catalog.GetString("Please, do it 
manually")) + "\n";
+                                       messageToShowOnBoot += feedback;        
+                                       LogB.Error(feedback);
+                               }
+                       }
+                                       
+                       string dbMove = string.Format(Catalog.GetString("Database is now here: {0}"), 
Path.GetFullPath(newDB));
+                       messageToShowOnBoot += dbMove;  
+                       LogB.Warning(dbMove);
+               }
+       }
+
+}
diff --git a/src/commandLineEncoder.cs b/src/commandLineEncoder.cs
index 291fc0a..af2b81c 100644
--- a/src/commandLineEncoder.cs
+++ b/src/commandLineEncoder.cs
@@ -1,4 +1,4 @@
-// This file is copied and adapted from 
https://raw.githubusercontent.com/ericpopivker/Command-Line-Encoder/master/CommandLineEncoder/CommandLineEncoder/Utils.cs
+// This file is copied and adapted from 
https://raw.githubusercontent.com/ericpopivker/Command-Line-Encoder/master/CommandLineEncoder/CommandLineEncoder/Utils.cs
 
 using System;
 using System.Text.RegularExpressions;
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 21a605b..391ef84 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -1,7024 +1,7024 @@
-/*
- * This file is part of ChronoJump
- *
- * Chronojump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * Chronojump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
- */
-
-
-using System;
-using Gtk;
-using Gdk;
-using Glade;
-using System.IO.Ports;
-using Mono.Unix;
-using System.IO; //"File" things
-using System.Collections; //ArrayList
-using System.Collections.Generic; //List
-using LongoMatch.Gui;
-using LongoMatch.Video.Capturer;
-using LongoMatch.Video.Common;
-using LongoMatch.Video.Utils;
-using System.Threading;
-using System.Diagnostics;
-
-public partial class ChronoJumpWindow 
-{
-       [Widget] Gtk.Window app1;
-       [Widget] Gtk.MenuBar main_menu;
-       [Widget] Gtk.MenuItem menuitem_mode;
-       
-       [Widget] Gtk.HBox hbox_gui_tests;
-       [Widget] Gtk.SpinButton spin_gui_tests;
-       [Widget] Gtk.Button button_carles;
-       
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_jumps_simple;
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_jumps_reactive;
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_runs_simple;
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_runs_intervallic;
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_power_gravitatory;
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_power_inertial;
-       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_other;
-
-       [Widget] Gtk.MenuItem menuitem_mode_selected_jumps_simple;
-       [Widget] Gtk.MenuItem menuitem_mode_selected_jumps_reactive;
-       [Widget] Gtk.MenuItem menuitem_mode_selected_runs_simple;
-       [Widget] Gtk.MenuItem menuitem_mode_selected_runs_intervallic;
-       [Widget] Gtk.MenuItem menuitem_mode_selected_power_gravitatory;
-       [Widget] Gtk.MenuItem menuitem_mode_selected_power_inertial;
-       [Widget] Gtk.MenuItem menuitem_mode_selected_other;
-       
-       [Widget] Gtk.Notebook notebook_start; //use to display the start images to select different modes
-       [Widget] Gtk.Notebook notebook_sup;
-       [Widget] Gtk.HBox hbox_other;
-       [Widget] Gtk.Notebook notebook_capture_graph_table;
-       [Widget] Gtk.Notebook notebook_capture_analyze; //not encoder
-
-       
-       [Widget] Gtk.Label label_version;
-       [Widget] Gtk.Image image_logo;
-       [Widget] Gtk.Image image_selector_start_jumps;
-       [Widget] Gtk.Image image_selector_start_runs;
-       [Widget] Gtk.Image image_selector_start_encoder_gravitatory;
-       //[Widget] Gtk.Image image_selector_start_encoder_inertial;
-       
-       [Widget] Gtk.Notebook notebook_selector_start_jumps;
-       [Widget] Gtk.Viewport viewport_selector_start_jumps;
-       [Widget] Gtk.Label label_selector_start_jumps_simple;
-       [Widget] Gtk.Label label_selector_start_jumps_reactive;
-       [Widget] Gtk.Notebook notebook_selector_start_runs;
-       [Widget] Gtk.Viewport viewport_selector_start_runs;
-       [Widget] Gtk.Label label_selector_start_runs_simple;
-       [Widget] Gtk.Label label_selector_start_runs_intervallic;
-       [Widget] Gtk.Notebook notebook_selector_start_encoder;
-       [Widget] Gtk.Viewport viewport_selector_start_encoder;
-       [Widget] Gtk.Label label_selector_start_encoder_gravitatory;
-       [Widget] Gtk.Label label_selector_start_encoder_inertial;
-       
-       [Widget] Gtk.RadioButton radio_mode_reaction_times_small;
-       [Widget] Gtk.RadioButton radio_mode_pulses_small;
-       [Widget] Gtk.RadioButton radio_mode_multi_chronopic_small;
-       [Widget] Gtk.RadioButton radio_mode_encoder_capture_small;
-       [Widget] Gtk.RadioButton radio_mode_encoder_analyze_small;
-       [Widget] Gtk.Image image_mode_jumps_small;
-       [Widget] Gtk.Image image_mode_jumps_reactive_small;
-       [Widget] Gtk.Image image_mode_runs_small;
-       [Widget] Gtk.Image image_mode_runs_intervallic_small;
-       [Widget] Gtk.Image image_mode_reaction_times_small;
-       [Widget] Gtk.Image image_mode_pulses_small;
-       [Widget] Gtk.Image image_mode_multi_chronopic_small;
-       [Widget] Gtk.Label label_mode_jumps_small;
-       [Widget] Gtk.Label label_mode_jumps_reactive_small;
-       [Widget] Gtk.Label label_mode_runs_small;
-       [Widget] Gtk.Label label_mode_runs_intervallic_small;
-       [Widget] Gtk.Image image_mode_encoder_gravitatory;
-       [Widget] Gtk.Image image_mode_encoder_inertial;
-       [Widget] Gtk.Label label_mode_reaction_times_small;
-       [Widget] Gtk.Label label_mode_pulses_small;
-       [Widget] Gtk.Label label_mode_multi_chronopic_small;
-
-       [Widget] Gtk.Image image_persons_new_1;
-       [Widget] Gtk.Image image_persons_new_plus;
-       [Widget] Gtk.Image image_persons_open_1;
-       [Widget] Gtk.Image image_persons_open_plus;
-
-       [Widget] Gtk.Notebook notebook_session_person;
-       //[Widget] Gtk.Box vbox_persons;
-
-       [Widget] Gtk.TreeView treeview_persons;
-       [Widget] Gtk.TreeView treeview_jumps;
-       [Widget] Gtk.TreeView treeview_jumps_rj;
-       [Widget] Gtk.TreeView treeview_runs;
-       [Widget] Gtk.TreeView treeview_runs_interval;
-       [Widget] Gtk.TreeView treeview_reaction_times;
-       [Widget] Gtk.TreeView treeview_pulses;
-       [Widget] Gtk.TreeView treeview_multi_chronopic;
-       
-       [Widget] Gtk.Box hbox_combo_select_jumps;
-       [Widget] Gtk.Box hbox_combo_select_jumps_rj;
-       [Widget] Gtk.Box hbox_combo_select_runs;
-       [Widget] Gtk.Box hbox_combo_select_runs_interval;
-
-       //auto mode     
-       [Widget] Gtk.Box hbox_jump_types_options;
-       [Widget] Gtk.Box hbox_jump_auto_controls;
-       [Widget] Gtk.Image image_auto_person_skip;
-       [Widget] Gtk.Image image_auto_person_remove;
-       [Widget] Gtk.Button button_auto_start;
-       [Widget] Gtk.Label label_jump_auto_current_person;
-       [Widget] Gtk.Label label_jump_auto_current_test;
-               
-       [Widget] Gtk.Image image_line_session_avg;
-       [Widget] Gtk.Image image_line_session_max;
-       [Widget] Gtk.Image image_line_person_avg;
-       [Widget] Gtk.Image image_line_person_max;
-       [Widget] Gtk.Image image_line_person_max_all_sessions;
-
-       
-       [Widget] Gtk.Box hbox_combo_result_jumps;
-       [Widget] Gtk.Box hbox_combo_result_jumps_rj;
-       [Widget] Gtk.Box hbox_combo_result_runs;
-       [Widget] Gtk.Box hbox_combo_result_runs_interval;
-       
-       [Widget] Gtk.Box hbox_combo_pulses;
-       [Widget] Gtk.Box hbox_jumps;
-       [Widget] Gtk.Box hbox_jumps_test;
-       [Widget] Gtk.Box hbox_jumps_rj;
-       [Widget] Gtk.Box hbox_runs;
-       [Widget] Gtk.Box hbox_runs_interval;
-       [Widget] Gtk.Box hbox_pulses;
-       
-       [Widget] Gtk.ComboBox combo_select_jumps;
-       [Widget] Gtk.ComboBox combo_select_jumps_rj;
-       [Widget] Gtk.ComboBox combo_select_runs;
-       [Widget] Gtk.ComboBox combo_select_runs_interval;
-       
-       [Widget] Gtk.ComboBox combo_result_jumps;
-       [Widget] Gtk.ComboBox combo_result_jumps_rj;
-       [Widget] Gtk.ComboBox combo_result_runs;
-       [Widget] Gtk.ComboBox combo_result_runs_interval;
-       
-       [Widget] Gtk.ComboBox combo_pulses;
-
-       //menus
-       [Widget] Gtk.MenuItem session_menuitem;
-       [Widget] Gtk.MenuItem help_menuitem;
-
-       //menu session
-       [Widget] Gtk.MenuItem menuitem_edit_session;
-       [Widget] Gtk.MenuItem menuitem_delete_session;
-       [Widget] Gtk.MenuItem menuitem_export_csv;
-       [Widget] Gtk.MenuItem menuitem_export_xml;
-       [Widget] Gtk.MenuItem menuitem_encoder_session_overview;
-       [Widget] Gtk.MenuItem menuitem_import_chronojump_session;
-       [Widget] Gtk.Image image_session_open;
-               
-       //menu person
-       [Widget] Gtk.Button button_persons_up;
-       [Widget] Gtk.Button button_persons_down;
-       [Widget] Gtk.Button button_edit_current_person;
-       [Widget] Gtk.Button button_show_all_person_events;
-       [Widget] Gtk.Button button_delete_current_person;
-       [Widget] Gtk.Label label_current_person;
-       [Widget] Gtk.Label label_current_person_title;
-       
-       //tests
-       //jumps
-       [Widget] Gtk.Button button_edit_selected_jump;
-       [Widget] Gtk.Button button_video_play_selected_jump;
-       [Widget] Gtk.Button button_delete_selected_jump;
-       [Widget] Gtk.Button button_edit_selected_jump_rj;
-       [Widget] Gtk.Button button_video_play_selected_jump_rj;
-       [Widget] Gtk.Button button_delete_selected_jump_rj;
-       [Widget] Gtk.Button button_repair_selected_jump_rj;
-
-       [Widget] Gtk.Image extra_windows_jumps_image_dj_fall_calculate;
-       [Widget] Gtk.Image extra_windows_jumps_image_dj_fall_predefined;
-       [Widget] Gtk.HBox hbox_extra_window_jumps_fall_height;
-
-       [Widget] Gtk.Button button_jumps_result_help_power;
-       [Widget] Gtk.Button button_jumps_result_help_stiffness;
-       [Widget] Gtk.Button button_jumps_rj_result_help_power;
-       [Widget] Gtk.Button button_jumps_rj_result_help_stiffness;
-       
-       [Widget] Gtk.DrawingArea drawingarea_jumps_profile;
-       [Widget] Gtk.ScrolledWindow scrolledwindow_jumps_profile_help;
-       [Widget] Gtk.ScrolledWindow scrolledwindow_jumps_profile_training;
-       [Widget] Gtk.Image image_tab_jumps_profile;
-       
-       
-       //runs
-       [Widget] Gtk.MenuItem menu_execute_simple_runs1;
-       [Widget] Gtk.MenuItem menu_execute_intervallic_runs1;
-       [Widget] Gtk.Button button_edit_selected_run;
-       [Widget] Gtk.Button button_video_play_selected_run;
-       [Widget] Gtk.Button button_delete_selected_run;
-       [Widget] Gtk.Button button_edit_selected_run_interval;
-       [Widget] Gtk.Button button_video_play_selected_run_interval;
-       [Widget] Gtk.Button button_delete_selected_run_interval;
-       [Widget] Gtk.Button button_repair_selected_run_interval;
-
-
-       //other
-       //reaction time
-       [Widget] Gtk.Button button_edit_selected_reaction_time;
-       [Widget] Gtk.Button button_video_play_selected_reaction_time;
-       [Widget] Gtk.Button button_delete_selected_reaction_time;
-       [Widget] Gtk.SpinButton spinbutton_animation_lights_speed;
-       [Widget] Gtk.SpinButton spinbutton_flicker_lights_speed;
-       [Widget] Gtk.CheckButton check_reaction_time_disc_red;
-       [Widget] Gtk.CheckButton check_reaction_time_disc_yellow;
-       [Widget] Gtk.CheckButton check_reaction_time_disc_green;
-       [Widget] Gtk.CheckButton check_reaction_time_disc_buzzer;
-       [Widget] Gtk.SpinButton spinbutton_discriminative_lights_minimum;
-       [Widget] Gtk.SpinButton spinbutton_discriminative_lights_maximum;
-
-       //pulse
-       [Widget] Gtk.Button button_edit_selected_pulse;
-       [Widget] Gtk.Button button_video_play_selected_pulse;
-       [Widget] Gtk.Button button_delete_selected_pulse;
-       [Widget] Gtk.Button button_repair_selected_pulse;
-
-       [Widget] Gtk.Box vbox_execute_test;
-       [Widget] Gtk.Button button_execute_test;
-       [Widget] Gtk.Viewport viewport_chronopics;
-       [Widget] Gtk.Box hbox_chronopics;
-       [Widget] Gtk.Label label_chronopics;
-       [Widget] Gtk.Label label_connected_chronopics;
-       [Widget] Gtk.Label label_chronopics_multitest;
-       [Widget] Gtk.Image image_simulated_warning;
-       [Widget] Gtk.Box hbox_chronopic_detecting;
-       [Widget] Gtk.ProgressBar progressbar_chronopic_detecting;
-       [Widget] Gtk.Button button_chronopic_detecting_cancel;
-       [Widget] Gtk.Button button_chronopic_detecting_info;
-       [Widget] Gtk.Box hbox_chronopic_encoder_detecting;
-       [Widget] Gtk.ProgressBar progressbar_chronopic_encoder_detecting;
-       [Widget] Gtk.Button button_chronopic_encoder_detecting_cancel;
-       [Widget] Gtk.Button button_chronopic_encoder_detecting_info;
-       [Widget] Gtk.Viewport viewport_chronopic_encoder;
-       [Widget] Gtk.Label label_chronopic_encoder;
-       [Widget] Gtk.Image image_chronopic_encoder_no;
-       [Widget] Gtk.Image image_chronopic_encoder_yes;
-       
-       [Widget] Gtk.HBox hbox_video_capture;
-       [Widget] Gtk.Label label_video_feedback;
-       [Widget] Gtk.CheckButton checkbutton_video;
-       //[Widget] Gtk.Label label_video;
-       [Widget] Gtk.Image image_video_yes;
-       [Widget] Gtk.Image image_video_no;
-
-
-       //multiChronopic        
-       [Widget] Gtk.Button button_edit_selected_multi_chronopic;
-       [Widget] Gtk.Button button_video_play_selected_multi_chronopic;
-       [Widget] Gtk.Button button_delete_selected_multi_chronopic;
-//     [Widget] Gtk.Box hbox_multi_chronopic_buttons;
-//     [Widget] Gtk.Button button_multi_chronopic_start;
-//     [Widget] Gtk.Button button_run_analysis;
-//     [Widget] Gtk.Entry extra_window_spin_run_analysis_distance;
-//     [Widget] Gtk.CheckButton extra_window_check_multichronopic_sync;
-//     [Widget] Gtk.CheckButton extra_window_check_multichronopic_delete_first;
-//     [Widget] Gtk.Entry entry_multi_chronopic_cp2;
-
-       //widgets for enable or disable
-       [Widget] Gtk.Button button_new;
-       [Widget] Gtk.Button button_open;
-       [Widget] Gtk.Frame frame_persons;
-       [Widget] Gtk.Button button_recuperate_person;
-       [Widget] Gtk.Button button_recuperate_persons_from_session;
-       [Widget] Gtk.Button button_person_add_single;
-       [Widget] Gtk.Button button_person_add_multiple;
-
-       [Widget] Gtk.Button button_run_custom;
-       [Widget] Gtk.Button button_run_20m;
-       [Widget] Gtk.Button button_run_100m;
-       [Widget] Gtk.Button button_run_200m;
-       [Widget] Gtk.Button button_run_400m;
-       [Widget] Gtk.Button button_run_gesell;
-       [Widget] Gtk.Button button_run_20yard;
-       [Widget] Gtk.Button button_run_505;
-       [Widget] Gtk.Button button_run_illinois;
-       [Widget] Gtk.Button button_run_margaria;
-       [Widget] Gtk.Button button_run_shuttle;
-       [Widget] Gtk.Button button_run_zigzag;
-       [Widget] Gtk.Button button_run_interval_by_laps;
-       [Widget] Gtk.Button button_run_interval_by_time;
-       [Widget] Gtk.Button button_run_interval_unlimited;
-       [Widget] Gtk.Button button_run_interval_mtgug;
-       [Widget] Gtk.Button button_reaction_time_execute;
-
-       [Widget] Gtk.Notebook notebook_execute;
-       [Widget] Gtk.Notebook notebook_results;
-       [Widget] Gtk.Notebook notebook_options_top;
-               
-       [Widget] Gtk.Frame frame_share_data;
-       
-       [Widget] Gtk.EventBox eventbox_image_test;
-       [Widget] Gtk.Image image_test;
-       [Widget] Gtk.Button button_image_test_zoom;
-       [Widget] Gtk.Image image_test_zoom;
-       [Widget] Gtk.Box vbox_this_test_buttons;
-       [Widget] Gtk.Button button_video_play_this_test;
-       [Widget] Gtk.Button button_delete_this_test;
-               
-       [Widget] Gtk.Button button_upload_session;
-       [Widget] Gtk.Button button_activate_chronopics;
-
-       //non standard icons    
-       [Widget] Gtk.Image image_jump_reactive_bell;
-       [Widget] Gtk.Image image_run_interval_bell;
-       [Widget] Gtk.Image image_jump_reactive_repair;
-       [Widget] Gtk.Image image_run_interval_repair;
-       [Widget] Gtk.Image image_pulse_repair;
-       [Widget] Gtk.Image image_person_delete;
-       [Widget] Gtk.Image image_delete_this_test;
-       [Widget] Gtk.Image image_jump_delete;
-       [Widget] Gtk.Image image_jump_reactive_delete;
-       [Widget] Gtk.Image image_run_delete;
-       [Widget] Gtk.Image image_run_interval_delete;
-       [Widget] Gtk.Image image_reaction_time_delete;
-       [Widget] Gtk.Image image_pulse_delete;
-       [Widget] Gtk.Image image_multi_chronopic_delete;
-       [Widget] Gtk.Image image_jump_type_delete_simple;
-       [Widget] Gtk.Image image_jump_type_delete_reactive;
-       [Widget] Gtk.Image image_run_type_delete_simple;
-       [Widget] Gtk.Image image_run_type_delete_intervallic;
-
-       [Widget] Gtk.Image image_jumps_zoom;
-       [Widget] Gtk.Image image_jumps_rj_zoom;
-       [Widget] Gtk.Image image_runs_zoom;
-       [Widget] Gtk.Image image_runs_interval_zoom;
-       [Widget] Gtk.Image image_reaction_times_zoom;
-       [Widget] Gtk.Image image_pulses_zoom;
-       [Widget] Gtk.Image image_multi_chronopic_zoom;
-       
-       //encoder
-       [Widget] Gtk.Image image_encoder_capture_zoom;
-       //[Widget] Gtk.Image image_encoder_analyze_zoom;
-       [Widget] Gtk.Image image_encoder_analyze_stats;
-       [Widget] Gtk.Image image_encoder_analyze_image_save;
-       [Widget] Gtk.Image image_encoder_analyze_1RM_save;
-       [Widget] Gtk.Image image_encoder_analyze_table_save;
-       [Widget] Gtk.Image image_encoder_signal_delete;
-       [Widget] Gtk.Image image_encoder_inertial_instructions;
-
-
-       Random rand;
-
-       //persons
-       private TreeStore treeview_persons_store;
-       private TreeViewPersons myTreeViewPersons;
-       private Gtk.Button fakeButtonPersonUp;
-       private Gtk.Button fakeButtonPersonDown;
-       //normal jumps
-       private TreeStore treeview_jumps_store;
-       private TreeViewJumps myTreeViewJumps;
-       //rj jumps
-       private TreeStore treeview_jumps_rj_store;
-       private TreeViewJumpsRj myTreeViewJumpsRj;
-       //normal runs
-       private TreeStore treeview_runs_store;
-       private TreeViewRuns myTreeViewRuns;
-       //runs interval
-       private TreeStore treeview_runs_interval_store;
-       private TreeViewRunsInterval myTreeViewRunsInterval;
-       //reaction times
-       private TreeStore treeview_reaction_times_store;
-       private TreeViewReactionTimes myTreeViewReactionTimes;
-       //pulses
-       private TreeStore treeview_pulses_store;
-       private TreeViewPulses myTreeViewPulses;
-       //multiChronopic
-       private TreeStore treeview_multi_chronopic_store;
-       private TreeViewMultiChronopic myTreeViewMultiChronopic;
-       
-       private Preferences preferences;
-
-       private static Person currentPerson;
-       private static Session currentSession;
-       private static PersonSession currentPersonSession;
-       private static bool definedSession;
-       private static Jump currentJump;
-       private static JumpRj currentJumpRj;
-       private static Run currentRun;
-       private static RunInterval currentRunInterval;
-       private static ReactionTime currentReactionTime;
-       private static Pulse currentPulse;
-       private static MultiChronopic currentMultiChronopic;
-       
-       private static EventExecute currentEventExecute;
-
-       //Used by Cancel and Finish
-       private static EventType currentEventType;
-
-       private static JumpType currentJumpType;
-       private static JumpType currentJumpRjType;
-       bool thisJumpIsSimple;  //needed on updating
-       bool lastJumpIsSimple;  //needed on update
-       private static RunType currentRunType;
-       private static RunType currentRunIntervalType;
-       bool thisRunIsSimple;   //needed on updating
-       bool lastRunIsSimple;   //needed on update
-       private static PulseType currentPulseType;
-       private static ReactionTimeType currentReactionTimeType;
-       private static MultiChronopicType currentMultiChronopicType;
-       private static Report report;
-
-       //windows needed
-       PreferencesWindow preferencesWin;
-       SessionAddEditWindow sessionAddEditWin;
-       SessionLoadWindow sessionLoadWin;
-       PersonRecuperateWindow personRecuperateWin; 
-       PersonsRecuperateFromOtherSessionWindow personsRecuperateFromOtherSessionWin; 
-       PersonAddModifyWindow personAddModifyWin; 
-       PersonAddMultipleWindow personAddMultipleWin; 
-       PersonSelectWindow personSelectWin;
-       JumpsMoreWindow jumpsMoreWin;
-       JumpsRjMoreWindow jumpsRjMoreWin;
-       EditJumpWindow editJumpWin;
-       EditJumpRjWindow editJumpRjWin;
-       RepairJumpRjWindow repairJumpRjWin;
-       JumpTypeAddWindow jumpTypeAddWin;
-       
-       RunsMoreWindow runsMoreWin;
-       RunsIntervalMoreWindow runsIntervalMoreWin;
-       RunTypeAddWindow runTypeAddWin;
-       EditRunWindow editRunWin;
-       RepairRunIntervalWindow repairRunIntervalWin;
-       EditRunIntervalWindow editRunIntervalWin;
-
-       EditReactionTimeWindow editReactionTimeWin;
-
-       EditPulseWindow editPulseWin;
-       RepairPulseWindow repairPulseWin;
-       
-       EditMultiChronopicWindow editMultiChronopicWin;
-       
-       ConfirmWindowJumpRun confirmWinJumpRun; //for deleting jumps and RJ jumps (and runs)
-       ErrorWindow errorWin;
-       ReportWindow reportWin;
-       RepetitiveConditionsWindow repetitiveConditionsWin;
-       GenericWindow genericWin;
-               
-       EvaluatorWindow evalWin;
-       PersonNotUploadWindow personNotUploadWin; 
-       ExecuteAutoWindow executeAutoWin;
-       
-       ChronopicWindow chronopicWin;
-       ChronopicWizardWindow chronopicWizardWin;
-       string wizardPortContacts;
-       string wizardPortEncoder;
-               
-       static Thread pingThread;
-
-       
-       /*
-        * useful to not check for Chronopic if changing select_menuitem_mode_toggled from a 50 to a 50
-        * great for 1.6.3 where people change from simple jumps to reactive jumps and Chronopic don't need 
to change
-        *
-        * maybe it will be replaced by chronopic_wizard_window
-
-       private enum chronopicTypes { CONTACTS50, CONTACTS10, ENCODER }
-       private chronopicTypes lastChronopicType;
-        */
-       
-       private bool firstRjValue;
-       private double rjTcCount;
-       private double rjTvCount;
-       private string rjTcString;
-       private string rjTvString;
-       
-       private bool createdStatsWin;
-       
-       private string progVersion;
-       private string progName;
-
-       private string runningFileName; //useful for knowing if there are two chronojump instances
-
-       private bool normalGUI; //false means small gui
-
-       private bool debugMode; //currently only for encoder R
-
-       //int chronopicCancelledTimes = 0;
-
-
-       //only called the first time the software runs
-       //and only on windows
-       private void on_language_clicked(object o, EventArgs args) {
-               //languageChange();
-               //createMainWindow("");
-       }
-
-       private void on_button_image_test_zoom_clicked(object o, EventArgs args) {
-               EventType myType;
-               if(radio_menuitem_mode_jumps_simple.Active) 
-                       myType = currentJumpType;
-               else if(radio_menuitem_mode_jumps_reactive.Active) 
-                       myType = currentJumpRjType;
-               else if(radio_menuitem_mode_runs_simple.Active) 
-                       myType = currentRunType;
-               else if(radio_menuitem_mode_runs_intervallic.Active) 
-                       myType = currentRunIntervalType;
-               else if(radio_mode_reaction_times_small.Active) 
-                       myType = currentReactionTimeType;
-               else if(radio_mode_pulses_small.Active) 
-                       myType = currentPulseType;
-               else //if(radio_mode_multi_chronopic_small.Active) 
-                       myType = currentMultiChronopicType;
-                       
-               if(myType.Name == "DJa" && extra_window_jumps_check_dj_fall_calculate.Active)
-                       new DialogImageTest("", Util.GetImagePath(false) + "jump_dj_a_inside.png", 
DialogImageTest.ArchiveType.ASSEMBLY);
-               else if(myType.Name == "DJna" && extra_window_jumps_check_dj_fall_calculate.Active)
-                       new DialogImageTest("", Util.GetImagePath(false) + "jump_dj_inside.png", 
DialogImageTest.ArchiveType.ASSEMBLY);
-               else
-                       new DialogImageTest(myType);
-       }
-       
-       
-       public ChronoJumpWindow(string progVersion, string progName, string runningFileName)
-       {
-               this.progVersion = progVersion;
-               this.progName = progName;
-               this.runningFileName = runningFileName;
-               
-
-               Glade.XML gxml;
-               gxml = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", "app1", 
"chronojump");
-               gxml.Autoconnect(this);
-
-               //put an icon to window
-               UtilGtk.IconWindow(app1);
-       
-               //show chronojump logo on down-left area
-               changeTestImage("", "", "LOGO");
-       
-               //white bg
-               eventbox_image_test.ModifyBg(StateType.Normal, UtilGtk.WHITE);
-       
-               //start with the Mode selector  
-               notebook_start.CurrentPage = 0;
-
-               //new DialogMessage(Constants.MessageTypes.INFO, UtilGtk.ScreenHeightFitted(false).ToString() 
);
-               //UtilGtk.ResizeIfNeeded(stats_window);
-               
-               //app1.Maximize(); //this was for starting at fullscreen
-
-               report = new Report(-1); //when a session is loaded or created, it will change the 
report.SessionID value
-               //TODO: check what happens if a session it's deleted
-               //i think report it's deactivated until a new session is created or loaded, 
-               //but check what happens if report window is opened
-
-               //put videoOn as false before loading preferences to start always without the camera
-               //this is good if camera produces crash
-               SqlitePreferences.Update("videoOn", "False", false);
-               
-               //preferencesLoaded is a fix to a gtk#-net-windows-bug where radiobuttons raise signals
-               //at initialization of chronojump and gives problems if this signals are raised while 
preferences are loading
-               loadPreferences ();
-
-               createTreeView_persons (treeview_persons);
-
-               createTreeView_jumps (treeview_jumps);
-               createTreeView_jumps_rj (treeview_jumps_rj);
-               createTreeView_runs (treeview_runs);
-               createTreeView_runs_interval (treeview_runs_interval);
-               createTreeView_reaction_times (treeview_reaction_times);
-               createTreeView_pulses (treeview_pulses);
-               createTreeView_multi_chronopic (false, treeview_multi_chronopic);
-
-               createComboSelectJumps(true);
-               createComboSelectJumpsRj(true);
-               createComboSelectRuns(true);
-               createComboSelectRunsInterval(true);
-               
-               createComboResultJumps();
-               createComboResultJumpsRj();
-               createComboResultRuns();
-               createComboResultRunsInterval();
-
-               //reaction_times has no combo
-               createComboPulses();
-               //createComboMultiChronopic();
-               createdStatsWin = false;
-               
-               repetitiveConditionsWin = RepetitiveConditionsWindow.Create();
-               repetitiveConditionsWin.FakeButtonClose.Clicked += new 
EventHandler(on_repetitive_conditions_closed);
-
-               createChronopicWindow(false, "");
-               wizardPortContacts = "";
-               wizardPortEncoder = "";
-       
-               on_extra_window_multichronopic_test_changed(new object(), new EventArgs());
-               on_extra_window_pulses_test_changed(new object(), new EventArgs());
-               on_extra_window_reaction_times_test_changed(new object(), new EventArgs());
-               on_extra_window_runs_interval_test_changed(new object(), new EventArgs());
-               on_extra_window_runs_test_changed(new object(), new EventArgs());
-               on_extra_window_jumps_rj_test_changed(new object(), new EventArgs());
-               on_extra_window_jumps_test_changed(new object(), new EventArgs());
-               //changeTestImage("", "", "LOGO");
-
-               //We have no session, mark some widgets as ".Sensitive = false"
-               sensitiveGuiNoSession();
-               definedSession = false;
-               
-               rand = new Random(40);
-       
-               formatModeMenu();       
-               putNonStandardIcons();  
-               eventExecutePutNonStandardIcons();
-               //eventExecuteCreateComboGraphResultsSize();
-
-
-               /*
-       
-               if(chronopicPort != Constants.ChronopicDefaultPortWindows && 
-                               (chronopicPort != Constants.ChronopicDefaultPortLinux && 
File.Exists(chronopicPort))
-                 ) {
-                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Do you want to 
connect to Chronopic now?"), "", "");
-                       confirmWin.Button_accept.Clicked += new EventHandler(chronopicAtStart);
-               }
-               */
-
-               stats_win_create();
-               createdStatsWin = true;
-               //stats_win_initializeSession();
-
-               encoderInitializeStuff();       
-
-               //presentationInit();
-
-               videoCaptureInitialize();
-       
-               //leave empty on new releases   
-               //string buildDate = " (2016-07-27)";
-               string buildDate = " (d)";
-               label_version.Text = progVersion + buildDate;
-               LogB.Information("Build date:" + buildDate);
-
-               LeastSquares ls = new LeastSquares();
-               ls.Test();
-               LogB.Information(string.Format("coef = {0} {1} {2}", ls.Coef[0], ls.Coef[1], ls.Coef[2]));
-
-               /*
-                * start a ping in other thread
-                * http://www.mono-project.com/docs/gui/gtksharp/responsive-applications/
-                * Gtk.Application.Invoke
-                */
-               pingThread = new Thread (new ThreadStart (pingAtStart));
-               pingThread.Start();
-
-               //moveStartTestInitial();
-               
-               ChronopicRegister cr = new ChronopicRegister();
-       }
-
-
-/*
-       private void chronopicAtStart(object o, EventArgs args) {
-               //make active menuitem chronopic, and this
-               //will raise other things
-       }
-*/
-
-/*
-       private bool normalGUIOld = true; //to know if we changed state. Start as true
-       private void on_app1_size_allocate(object obj, SizeAllocatedArgs args) {
-               int width;
-               int height;
-               app1.GetSize(out width, out height);
-               if(width >= 1000)
-                       normalGUI = true;
-               else 
-                       normalGUI = false;
-               if(normalGUI != normalGUIOld) {
-                       Log.WriteLine("Change Size. New is normal? -> " + normalGUI.ToString());
-                       normalGUIOld = normalGUI;
-                       changeGUIAspect();
-               }
-       }
-       
-       private void changeGUIAspect() {
-               //QueryChildPacking(frame_test_options,
-               if(normalGUI) {
-                       //if change these values, change also in glade
-                       //frame_test_options.BoxChild.Expand(true);
-                       label_current_person_title.Text=Catalog.GetString("Current person");
-               } else {
-                       //frame_test_options.BoxChild.Expand(false);
-                       label_current_person_title.Text=Catalog.GetString("Current");
-               }
-       }
-*/
-
-       private void formatModeMenu() 
-       {
-               ((Label) radio_menuitem_mode_jumps_simple.Child).Text = 
-                       "   " + ((Label) radio_menuitem_mode_jumps_simple.Child).Text;
-               ((Label) radio_menuitem_mode_jumps_reactive.Child).Text = 
-                       "   " + ((Label) radio_menuitem_mode_jumps_reactive.Child).Text;
-
-               ((Label) radio_menuitem_mode_runs_simple.Child).Text = 
-                       "   " + ((Label) radio_menuitem_mode_runs_simple.Child).Text;
-               ((Label) radio_menuitem_mode_runs_intervallic.Child).Text = 
-                       "   " + ((Label) radio_menuitem_mode_runs_intervallic.Child).Text;
-               
-               ((Label) radio_menuitem_mode_power_gravitatory.Child).Text = 
-                       "   " + ((Label) radio_menuitem_mode_power_gravitatory.Child).Text;
-               ((Label) radio_menuitem_mode_power_inertial.Child).Text = 
-                       "   " + ((Label) radio_menuitem_mode_power_inertial.Child).Text;
-       }
-
-       private void putNonStandardIcons() {
-               Pixbuf pixbuf;
-       
-               //change colors of tests mode
-
-               /*
-                * gui for small screens
-                */
-               viewport_selector_start_jumps.ModifyBg(StateType.Normal, new Gdk.Color(0x0b,0x48,0x6b));
-               label_selector_start_jumps_simple.ModifyFg(StateType.Normal, new Gdk.Color(0xff,0xff,0xff));
-               label_selector_start_jumps_reactive.ModifyFg(StateType.Normal, new Gdk.Color(0xff,0xff,0xff));
-               
-               viewport_selector_start_runs.ModifyBg(StateType.Normal, new Gdk.Color(0x3b,0x86,0x86));
-               label_selector_start_runs_simple.ModifyFg(StateType.Normal, new Gdk.Color(0xff,0xff,0xff));
-               label_selector_start_runs_intervallic.ModifyFg(StateType.Normal, new 
Gdk.Color(0xff,0xff,0xff));
-               
-               viewport_selector_start_encoder.ModifyBg(StateType.Normal, new Gdk.Color(0x79,0xbd,0x98));
-               label_selector_start_encoder_gravitatory.ModifyFg(StateType.Normal, new 
Gdk.Color(0xff,0xff,0xff));
-               label_selector_start_encoder_inertial.ModifyFg(StateType.Normal, new 
Gdk.Color(0xff,0xff,0xff));
-
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumps);
-               image_mode_jumps_small.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumpsRJ);
-               image_mode_jumps_reactive_small.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameRuns);
-               image_mode_runs_small.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameRunsInterval);
-               image_mode_runs_intervallic_small.Pixbuf = pixbuf;
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameEncoderGravitatory);
-               image_mode_encoder_gravitatory.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameEncoderInertial);
-               image_mode_encoder_inertial.Pixbuf = pixbuf;
-       
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameReactionTime);
-               image_mode_reaction_times_small.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNamePulse);
-               image_mode_pulses_small.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameMultiChronopic);
-               image_mode_multi_chronopic_small.Pixbuf = pixbuf;
-               
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumpsFallCalculate);
-               extra_windows_jumps_image_dj_fall_calculate.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumpsFallPredefined);
-               extra_windows_jumps_image_dj_fall_predefined.Pixbuf = pixbuf;
-               
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_session_avg.png");
-               image_line_session_avg.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_session_max.png");
-               image_line_session_max.Pixbuf = pixbuf;
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_person_avg.png");
-               image_line_person_avg.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_person_max.png");
-               image_line_person_max.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_person_max_all_sessions.png");
-               image_line_person_max_all_sessions.Pixbuf = pixbuf;
-
-               //reaction times changes
-               //UtilGtk.ColorsTestLabel(viewport_chronopics, label_extra_window_radio_reaction_time);
-               //UtilGtk.ColorsTestLabel(viewport_chronopics, 
label_extra_window_radio_reaction_time_animation_lights);
-               //UtilGtk.ColorsTestLabel(viewport_chronopics, 
label_extra_window_radio_reaction_time_flicker);
-               //UtilGtk.ColorsTestLabel(viewport_chronopics, 
label_extra_window_radio_reaction_time_discriminative);
-               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_reaction_time);
-               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_reaction_time_animation_lights);
-               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_reaction_time_flicker);
-               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_reaction_time_discriminative);
-
-               //pulses changes
-               //UtilGtk.ColorsTestLabel(viewport_chronopics, label_extra_window_radio_pulses_free);
-               //UtilGtk.ColorsTestLabel(viewport_chronopics, label_extra_window_radio_pulses_custom);
-               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_pulses_free);
-               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_pulses_custom);
-
-               //multichronopic changes
-               //UtilGtk.ColorsTestLabel(viewport_chronopics, label_extra_window_radio_multichronopic_start);
-               //UtilGtk.ColorsTestLabel(viewport_chronopics, 
label_extra_window_radio_multichronopic_run_analysis);
-               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_multichronopic_start);
-               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_multichronopic_run_analysis);
-
-               //open buttons (this is shown better in windows than the default open icon)
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameOpen);
-               image_session_open.Pixbuf = pixbuf;
-               //not changed because it's small. TODO: do bigger
-               //image_encoder_capture_open.Pixbuf = pixbuf;
-
-               //persons buttons
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameNew1);
-               image_persons_new_1.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameNewPlus);
-               image_persons_new_plus.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameOpen1);
-               image_persons_open_1.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameOpenPlus);
-               image_persons_open_plus.Pixbuf = pixbuf;
-
-
-
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_bell.png");
-               image_jump_reactive_bell.Pixbuf = pixbuf;
-               image_run_interval_bell.Pixbuf = pixbuf;
-               image_encoder_bell.Pixbuf = pixbuf;
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "preferences-system.png");
-               image_jump_reactive_repair.Pixbuf = pixbuf;
-               image_run_interval_repair.Pixbuf = pixbuf;
-               image_pulse_repair.Pixbuf = pixbuf;
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_delete.png");
-               image_person_delete.Pixbuf = pixbuf;
-               image_delete_this_test.Pixbuf = pixbuf;
-               image_jump_delete.Pixbuf = pixbuf;
-               image_jump_reactive_delete.Pixbuf = pixbuf;
-               image_run_delete.Pixbuf = pixbuf;
-               image_run_interval_delete.Pixbuf = pixbuf;
-               image_reaction_time_delete.Pixbuf = pixbuf;
-               image_pulse_delete.Pixbuf = pixbuf;
-               image_multi_chronopic_delete.Pixbuf = pixbuf;
-               image_jump_type_delete_simple.Pixbuf = pixbuf;
-               image_jump_type_delete_reactive.Pixbuf = pixbuf;
-               image_run_type_delete_simple.Pixbuf = pixbuf;
-               image_run_type_delete_intervallic.Pixbuf = pixbuf;
-               
-               //zoom icons, done like this because there's one zoom icon created ad-hoc, 
-               //and is not nice that the other are different for an user theme change
-       
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameZoomFitIcon);
-               image_jumps_zoom.Pixbuf = pixbuf;
-               image_jumps_rj_zoom.Pixbuf = pixbuf;
-               image_runs_zoom.Pixbuf = pixbuf;
-               image_runs_interval_zoom.Pixbuf = pixbuf;
-               image_reaction_times_zoom.Pixbuf = pixbuf;
-               image_pulses_zoom.Pixbuf = pixbuf;
-               image_multi_chronopic_zoom.Pixbuf = pixbuf;
-               
-               //encoder
-               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_powerbars);
-               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_cross);
-               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_side);
-               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_single);
-               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_neuromuscular_profile);
-               
-               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_speed);
-               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_accel);
-               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_force);
-               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_power);
-               
-               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_range);
-               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_time_to_peak_power);
-
-
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "gpm-statistics.png");
-               image_encoder_analyze_stats.Pixbuf = pixbuf;
-               image_encoder_analyze_image_save.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_delete.png");
-               image_encoder_signal_delete.Pixbuf = pixbuf;
-       
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "spreadsheet.png");
-               image_encoder_analyze_table_save.Pixbuf = pixbuf;
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "jumps-profile-pie.png");
-               image_tab_jumps_profile.Pixbuf = pixbuf;
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualCurrentSetIcon);
-               image_encoder_analyze_individual_current_set.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualCurrentSessionIcon);
-               image_encoder_analyze_individual_current_session.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualAllSessionsIcon);
-               image_encoder_analyze_individual_all_sessions.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeGroupalCurrentSessionIcon);
-               image_encoder_analyze_groupal_current_session.Pixbuf = pixbuf;
-
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzePowerbarsIcon);
-               image_encoder_analyze_powerbars.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeCrossIcon);
-               image_encoder_analyze_cross.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyze1RMIcon);
-               image_encoder_analyze_1RM.Pixbuf = pixbuf;
-               image_encoder_analyze_1RM_save.Pixbuf = pixbuf;
-
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeSideIcon);
-               image_encoder_analyze_side.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeSingleIcon);
-               image_encoder_analyze_single.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeNmpIcon);
-               image_encoder_analyze_nmp.Pixbuf = pixbuf;
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeEcconTogetherIcon);
-               image_encoder_analyze_eccon_together.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeEcconSeparatedIcon);
-               image_encoder_analyze_eccon_separated.Pixbuf = pixbuf;
-
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeSpeedIcon);
-               image_encoder_analyze_speed.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeAccelIcon);
-               image_encoder_analyze_accel.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeForceIcon);
-               image_encoder_analyze_force.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzePowerIcon);
-               image_encoder_analyze_power.Pixbuf = pixbuf;
-               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeMeanIcon);
-               image_encoder_analyze_mean.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeMaxIcon);
-               image_encoder_analyze_max.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeRangeIcon);
-               image_encoder_analyze_range.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeTimeToPPIcon);
-               image_encoder_analyze_time_to_pp.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderInertialInstructions);
-               image_encoder_inertial_instructions.Pixbuf = pixbuf;
-               
-               //auto mode
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameAutoPersonSkipIcon);
-               image_auto_person_skip.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameAutoPersonRemoveIcon);
-               image_auto_person_remove.Pixbuf = pixbuf;
-                               
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameSelectorJumps);
-               image_selector_start_jumps.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameSelectorRuns);
-               image_selector_start_runs.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameSelectorEncoderGravitatory);
-               image_selector_start_encoder_gravitatory.Pixbuf = pixbuf;
-               //pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameSelectorEncoderInertial);
-               //image_selector_start_encoder_inertial.Pixbuf = pixbuf;
-
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo);
-               image_logo.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo320); //changed 
to 270 for the presentation
-               image_presentation_logo.Pixbuf = pixbuf;
-
-       }
-
-       private void loadPreferences () 
-       {
-               preferences = Preferences.LoadAllFromSqlite();
-
-               LogB.Information (string.Format(Catalog.GetString("Chronojump database version file: {0}"), 
-                                       preferences.databaseVersion));
-
-               checkbutton_allow_finish_rj_after_time.Active = preferences.allowFinishRjAfterTime;
-
-               //---- video ----
-
-               UtilGtk.ColorsCheckOnlyPrelight(checkbutton_video);
-               UtilGtk.ColorsCheckOnlyPrelight(checkbutton_video_encoder);
-               
-               //don't raise the signal        
-               checkbutton_video.Clicked -= new EventHandler(on_checkbutton_video_clicked);
-               checkbutton_video.Active = preferences.videoOn;
-               checkbutton_video.Clicked += new EventHandler(on_checkbutton_video_clicked);
-               //don't raise the signal        
-               checkbutton_video_encoder.Clicked -= new EventHandler(on_checkbutton_video_encoder_clicked);
-               checkbutton_video_encoder.Active = preferences.videoOn;
-               checkbutton_video_encoder.Clicked += new EventHandler(on_checkbutton_video_encoder_clicked);
-               
-               changeVideoButtons(preferences.videoOn);
-
-               //change language works on windows. On Linux let's change the locale
-               //if(UtilAll.IsWindows())
-               //      languageChange();
-
-               //pass to report
-               report.preferences = preferences;
-               report.Progversion = progVersion;
-
-               LogB.Information ( Catalog.GetString ("Preferences loaded") );
-       }
-
-       /*
-        * languageChange is not related to windows and linux, is related to .net or mono
-        * on .net (windows) we can change language. On mono, we use locale
-        * now since 0.53 svn, we use mono on windows and linux, then this is not used
-        *
-       private void languageChange () {
-               string myLanguage = SqlitePreferences.Select("language");
-               if ( myLanguage != "0") {
-                       try {
-                               Log.WriteLine("myLanguage: {0}", myLanguage);
-                               System.Threading.Thread.CurrentThread.CurrentCulture = new 
System.Globalization.CultureInfo(myLanguage);
-                               System.Threading.Thread.CurrentThread.CurrentUICulture = new 
System.Globalization.CultureInfo(myLanguage);
-                               //probably only works on newly created windows, if change, then say user has 
to restart
-                               Log.WriteLine ("Changed language to {0}", myLanguage );
-                       } catch {
-                               new DialogMessage(Catalog.GetString("There's a problem with this language on 
this computer. Please, choose another language."));
-                       }
-               }
-       }
-*/
-
-       /* ---------------------------------------------------------
-        * ----------------  test modes (small GUI) ----------------
-        *  --------------------------------------------------------
-        */
-
-
-       public void on_radio_mode_reaction_times_small_toggled (object obj, EventArgs args) {
-               if(radio_mode_reaction_times_small.Active) {
-                       notebooks_change(4);
-                       on_extra_window_reaction_times_test_changed(obj, args);
-                       hbox_results_legend.Visible = true;
-               }
-       }
-
-       public void on_radio_mode_pulses_small_toggled (object obj, EventArgs args) {
-               if(radio_mode_pulses_small.Active) {
-                       notebooks_change(5);
-                       on_extra_window_pulses_test_changed(obj, args);
-                       hbox_results_legend.Visible = false;
-               }
-       }
-
-       public void on_radio_mode_multi_chronopic_small_toggled (object obj, EventArgs args) {
-               if(radio_mode_multi_chronopic_small.Active) {
-                       notebooks_change(6);
-                       on_extra_window_multichronopic_test_changed(obj, args);
-                       hbox_results_legend.Visible = false;
-               }
-       }
-       
-       public void on_radio_mode_encoder_capture_small_toggled (object obj, EventArgs args) {
-               if(radio_mode_encoder_capture_small.Active) 
-                       notebook_encoder_sup.CurrentPage = 0;
-       }
-
-       public void on_radio_mode_encoder_analyze_small_toggled (object obj, EventArgs args) {
-               if(radio_mode_encoder_analyze_small.Active) 
-                       notebook_encoder_sup.CurrentPage = 1;
-       }
-
-       
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW (generic) --------------------
-        *  --------------------------------------------------------
-        */
-
-       private void expandOrMinimizeTreeView(TreeViewEvent tvEvent, TreeView tv) {
-               if(tvEvent.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED) 
-                       tv.CollapseAll();
-               else if (tvEvent.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
-                       tv.CollapseAll();
-                       tvEvent.ExpandOptimal();
-               } else   //MAXIMIZED
-                       tv.ExpandAll();
-
-               //Log.WriteLine("IS " + tvEvent.ExpandState);
-       }
-
-       private void on_treeview_button_release_event (object o, ButtonReleaseEventArgs args) {
-               Gdk.EventButton e = args.Event;
-               Gtk.TreeView myTv = (Gtk.TreeView) o;
-               if (e.Button == 3) {
-                       if(myTv == treeview_persons) {
-                               treeviewPersonsContextMenu(currentPerson);
-                       } else if(myTv == treeview_jumps) {
-                               if (myTreeViewJumps.EventSelectedID > 0) {
-                                       Jump myJump = SqliteJump.SelectJumpData( 
myTreeViewJumps.EventSelectedID, false );
-                                       treeviewJumpsContextMenu(myJump);
-                               }
-                       } else if(myTv == treeview_jumps_rj) {
-                               if (myTreeViewJumpsRj.EventSelectedID > 0) {
-                                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
-                                       treeviewJumpsRjContextMenu(myJump);
-                               }
-                       } else if(myTv == treeview_runs) {
-                               if (myTreeViewRuns.EventSelectedID > 0) {
-                                       Run myRun = SqliteRun.SelectRunData( myTreeViewRuns.EventSelectedID, 
false );
-                                       treeviewRunsContextMenu(myRun);
-                               }
-                       } else if(myTv == treeview_runs_interval) {
-                               if (myTreeViewRunsInterval.EventSelectedID > 0) {
-                                       RunInterval myRun = SqliteRunInterval.SelectRunData( 
Constants.RunIntervalTable, myTreeViewRunsInterval.EventSelectedID, false );
-                                       treeviewRunsIntervalContextMenu(myRun);
-                               }
-                       } else if(myTv == treeview_reaction_times) {
-                               if (myTreeViewReactionTimes.EventSelectedID > 0) {
-                                       ReactionTime myRt = SqliteReactionTime.SelectReactionTimeData( 
myTreeViewReactionTimes.EventSelectedID, false );
-                                       treeviewReactionTimesContextMenu(myRt);
-                               }
-                       } else if(myTv == treeview_pulses) {
-                               if (myTreeViewPulses.EventSelectedID > 0) {
-                                       Pulse myPulse = SqlitePulse.SelectPulseData( 
myTreeViewPulses.EventSelectedID, false );
-                                       treeviewPulsesContextMenu(myPulse);
-                               }
-                       } else if(myTv == treeview_multi_chronopic) {
-                               if (myTreeViewMultiChronopic.EventSelectedID > 0) {
-                                       MultiChronopic mc = SqliteMultiChronopic.SelectMultiChronopicData( 
myTreeViewMultiChronopic.EventSelectedID, false );
-                                       treeviewMultiChronopicContextMenu(mc);
-                               }
-                       } else
-                               LogB.Information(myTv.ToString());
-               }
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW PERSONS ----------------------
-        *  --------------------------------------------------------
-        */
-
-       private void createTreeView_persons (Gtk.TreeView tv) {
-               myTreeViewPersons = new TreeViewPersons( tv );
-               tv.Selection.Changed += onTreeviewPersonsSelectionEntry;
-       }
-
-       private void fillTreeView_persons () {
-               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
-                               currentSession.UniqueID, 
-                               false); //means: do not returnPersonAndPSlist
-
-               if(myPersons.Count > 0) {
-                       //fill treeview
-                       myTreeViewPersons.Fill(myPersons);
-               }
-       }
-
-       private void on_treeview_persons_up (object o, EventArgs args) {
-               myTreeViewPersons.SelectPreviousRow(currentPerson.UniqueID);
-       }
-       
-       private void on_treeview_persons_down (object o, EventArgs args) {
-               myTreeViewPersons.SelectNextRow(currentPerson.UniqueID);
-       }
-       
-       //return true if selection is done (there's any person)
-       private bool selectRowTreeView_persons(Gtk.TreeView tv, TreeStore store, int rowNum) 
-       {
-               myTreeViewPersons.SelectRow(rowNum);
-               
-               //the selection of row in treeViewPersons.SelectRow is not a real selection 
-               //and unfortunately doesn't raises the on_treeview_persons_cursor_changed ()
-               //for this reason we reproduce the method here
-               TreeModel model;
-               TreeIter iter;
-               if (tv.Selection.GetSelected (out model, out iter)) {
-                       string selectedID = (string) model.GetValue (iter, 0); //ID, Name
-                       currentPerson = SqlitePerson.Select(Convert.ToInt32(selectedID));
-                       currentPersonSession = SqlitePersonSession.Select(Convert.ToInt32(selectedID), 
currentSession.UniqueID);
-                       label_person_change();
-               
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       void label_person_change() {
-               label_current_person.Text = "<b>" + currentPerson.Name + "</b>"; 
-               label_current_person.UseMarkup = true; 
-               label_encoder_person_name.Text = "<b>" + currentPerson.Name + "</b>"; 
-               label_encoder_person_name.UseMarkup = true; 
-       }
-       
-       private void treeview_persons_storeReset() {
-               myTreeViewPersons.RemoveColumns();
-               myTreeViewPersons = new TreeViewPersons(treeview_persons);
-       }
-       
-       //private void on_treeview_persons_cursor_changed (object o, EventArgs args) {
-       private void onTreeviewPersonsSelectionEntry (object o, EventArgs args) {
-               TreeModel model;
-               TreeIter iter;
-
-               // you get the iter and the model if something is selected
-               if (((TreeSelection)o).GetSelected(out model, out iter)) {
-                       string selectedID = (string) model.GetValue (iter, 0); //ID, Name
-               
-                       currentPerson = SqlitePerson.Select(Convert.ToInt32(selectedID));
-                       currentPersonSession = SqlitePersonSession.Select(Convert.ToInt32(selectedID), 
currentSession.UniqueID);
-                       label_person_change();
-       
-                       personChanged();        
-               }
-       }
-
-       private void personChanged() {
-               //1) change on jumps, runs, pulse capture graph
-               if(radio_menuitem_mode_jumps_simple.Active) {
-                       updateGraphJumpsSimple();
-
-                       if(notebook_capture_analyze.CurrentPage == 2) //Jumps Profile
-                               jumpsProfileDo(true); //calculate data
-               }
-               else if(radio_menuitem_mode_runs_simple.Active) 
-                       updateGraphRunsSimple();
-               else if(radio_mode_reaction_times_small.Active) 
-                       updateGraphReactionTimes();
-               
-               //2) change on encoder
-               encoderPersonChanged();
-       }
-
-       private void treeviewPersonsContextMenu(Person myPerson) {
-               Menu myMenu = new Menu ();
-               Gtk.MenuItem myItem;
-
-               myItem = new MenuItem ( Catalog.GetString("Edit") + " " + myPerson.Name);
-               myItem.Activated += on_edit_current_person_clicked_from_main_gui;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-
-               myItem = new MenuItem ( Catalog.GetString("Show all tests of") + " " + myPerson.Name);
-               myItem.Activated += on_show_all_person_events_activate;
-               myMenu.Attach( myItem, 0, 1, 1, 2 );
-
-               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
-               myMenu.Attach( mySep, 0, 1, 2, 3 );
-
-               myItem = new MenuItem ( string.Format(Catalog.GetString("Delete {0} from this 
session"),myPerson.Name));
-               myItem.Activated += on_delete_current_person_from_session_clicked;
-               myMenu.Attach( myItem, 0, 1, 3, 4 );
-
-               myMenu.Popup();
-               myMenu.ShowAll();
-       }
-               
-
-       private void resetAllTreeViews( bool alsoPersons) {
-               if(alsoPersons) {
-                       //load the persons treeview
-                       treeview_persons_storeReset();
-                       fillTreeView_persons();
-               }
-
-               //Leave SQL opened in all this process
-               Sqlite.Open(); // ------------------------------
-
-               //load the jumps treeview
-               treeview_jumps_storeReset();
-               fillTreeView_jumps(Constants.AllJumpsName, true);
-
-               //load the jumps_rj treeview_rj
-               treeview_jumps_rj_storeReset();
-               fillTreeView_jumps_rj(Constants.AllJumpsName, true);
-
-               //load the runs treeview
-               treeview_runs_storeReset();
-               fillTreeView_runs(Constants.AllRunsName, true);
-
-               //load the runs_interval treeview
-               treeview_runs_interval_storeReset();
-               fillTreeView_runs_interval(Constants.AllRunsName, true);
-
-               //load the pulses treeview
-               treeview_pulses_storeReset();
-               fillTreeView_pulses(Constants.AllPulsesName, true);
-
-               //load the reaction_times treeview
-               treeview_reaction_times_storeReset();
-               fillTreeView_reaction_times("reactionTime", true);
-
-               //load the multiChronopic treeview
-               treeview_multi_chronopic_storeReset(true);
-               fillTreeView_multi_chronopic(true);
-               
-
-               //close SQL opened in all this process
-               Sqlite.Close(); // ------------------------------
-       }
-
-
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW JUMPS ------------------------
-        *  --------------------------------------------------------
-        */
-
-       private void createTreeView_jumps (Gtk.TreeView tv) {
-               //myTreeViewJumps is a TreeViewJumps instance
-               myTreeViewJumps = new TreeViewJumps(tv, preferences, TreeViewEvent.ExpandStates.MINIMIZED);
-
-               //the glade cursor_changed does not work on mono 1.2.5 windows
-               tv.CursorChanged += on_treeview_jumps_cursor_changed; 
-       
-               //show or hide help_power and help_stiffness depending on preferences
-               button_jumps_result_help_power.Visible = preferences.showPower;
-               button_jumps_result_help_stiffness.Visible = preferences.showStiffness;
-       }
-
-       private void fillTreeView_jumps (string filter) {
-               fillTreeView_jumps(filter, false);
-       }
-       private void fillTreeView_jumps (string filter, bool dbconOpened) {
-               string [] myJumps;
-       
-               myJumps = SqliteJump.SelectJumps(dbconOpened, currentSession.UniqueID, -1, "", "",
-                               Sqlite.Orders_by.DEFAULT, -1);
-
-               myTreeViewJumps.Fill(myJumps, filter);
-
-               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewJumps, treeview_jumps);
-       }
-
-       private void on_button_jumps_zoom_clicked (object o, EventArgs args) {
-               myTreeViewJumps.ExpandState = myTreeViewJumps.ZoomChange(myTreeViewJumps.ExpandState);
-               if(myTreeViewJumps.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
-                       treeview_jumps.CollapseAll();
-               else
-                       treeview_jumps.ExpandAll();
-       }
-       
-       private void treeview_jumps_storeReset() {
-               myTreeViewJumps.RemoveColumns();
-               
-               myTreeViewJumps = new TreeViewJumps(treeview_jumps, preferences, myTreeViewJumps.ExpandState);
-       }
-
-       private void on_treeview_jumps_cursor_changed (object o, EventArgs args) {
-               LogB.Information("Cursor changed");
-               // don't select if it's a person, 
-               // is for not confusing with the person treeviews that controls who jumps
-               if (myTreeViewJumps.EventSelectedID == 0) {
-                       myTreeViewJumps.Unselect();
-                       showHideActionEventButtons(false, "Jump"); //hide
-               } else {
-                       showHideActionEventButtons(true, "Jump"); //show
-               }
-       }
-
-       private void treeviewJumpsContextMenu(Jump myJump) {
-               Menu myMenu = new Menu ();
-               Gtk.MenuItem myItem;
-
-               /*
-               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
-                               myJump.Type + " (" + myJump.PersonName + ")");
-               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
-                               Constants.TestTypes.JUMP, myTreeViewJumps.EventSelectedID))) {
-                       myItem.Activated += on_video_play_selected_jump_clicked;
-                       myItem.Sensitive = true;
-               } else 
-                       myItem.Sensitive = false;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-               */
-
-               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
-               myItem.Activated += on_edit_selected_jump_clicked;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-       
-               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
-               myMenu.Attach( mySep, 0, 1, 1, 2 );
-
-               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
-               myItem.Activated += on_delete_selected_jump_clicked;
-               myMenu.Attach( myItem, 0, 1, 2, 3 );
-
-               myMenu.Popup();
-               myMenu.ShowAll();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW JUMPS RJ ---------------------
-        *  --------------------------------------------------------
-        */
-
-       private void createTreeView_jumps_rj (Gtk.TreeView tv) {
-               myTreeViewJumpsRj = new TreeViewJumpsRj (tv, preferences, 
TreeViewEvent.ExpandStates.MINIMIZED);
-
-               //the glade cursor_changed does not work on mono 1.2.5 windows
-               tv.CursorChanged += on_treeview_jumps_rj_cursor_changed; 
-       
-               //show or hide help_power and help_stiffness depending on preferences
-               button_jumps_rj_result_help_power.Visible = preferences.showPower;
-               button_jumps_rj_result_help_stiffness.Visible = preferences.showStiffness;
-       }
-
-       private void fillTreeView_jumps_rj (string filter) {
-               fillTreeView_jumps_rj (filter, false);
-       }
-       private void fillTreeView_jumps_rj (string filter, bool dbconOpened) {
-               string [] myJumps;
-               myJumps = SqliteJumpRj.SelectJumps(dbconOpened, currentSession.UniqueID, -1, "", "");
-               myTreeViewJumpsRj.Fill(myJumps, filter);
-
-               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewJumpsRj, treeview_jumps_rj);
-
-       }
-
-       private void on_button_jumps_rj_zoom_clicked (object o, EventArgs args) {
-               myTreeViewJumpsRj.ExpandState = myTreeViewJumpsRj.ZoomChange(myTreeViewJumpsRj.ExpandState);
-               if(myTreeViewJumpsRj.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
-                       treeview_jumps_rj.CollapseAll();
-               else if(myTreeViewJumpsRj.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
-                       treeview_jumps_rj.CollapseAll();
-                       myTreeViewJumpsRj.ExpandOptimal();
-               } else
-                       treeview_jumps_rj.ExpandAll();
-       }
-
-       private void treeview_jumps_rj_storeReset() {
-               myTreeViewJumpsRj.RemoveColumns();
-               myTreeViewJumpsRj = new TreeViewJumpsRj (treeview_jumps_rj, preferences, 
myTreeViewJumpsRj.ExpandState);
-       }
-
-       private void on_treeview_jumps_rj_cursor_changed (object o, EventArgs args) {
-               // don't select if it's a person, 
-               // is for not confusing with the person treeviews that controls who jumps
-               if (myTreeViewJumpsRj.EventSelectedID == 0) {
-                       myTreeViewJumpsRj.Unselect();
-                       showHideActionEventButtons(false, "JumpRj");
-               } else if (myTreeViewJumpsRj.EventSelectedID == -1) {
-                       myTreeViewJumpsRj.SelectHeaderLine();
-                       showHideActionEventButtons(true, "JumpRj");
-               } else {
-                       showHideActionEventButtons(true, "JumpRj");
-               }
-       }
-
-       private void treeviewJumpsRjContextMenu(JumpRj myJump) {
-               Menu myMenu = new Menu ();
-               Gtk.MenuItem myItem;
-
-               /*
-               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
-                               myJump.Type + " (" + myJump.PersonName + ")");
-               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
-                               Constants.TestTypes.JUMP_RJ, myTreeViewJumpsRj.EventSelectedID))) {
-                       myItem.Activated += on_video_play_selected_jump_rj_clicked;
-                       myItem.Sensitive = true;
-               } else 
-                       myItem.Sensitive = false;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-               */
-               
-               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
-               myItem.Activated += on_edit_selected_jump_rj_clicked;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-
-               myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
-               myItem.Activated += on_repair_selected_jump_rj_clicked;
-               myMenu.Attach( myItem, 0, 1, 1, 2 );
-               
-               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
-               myMenu.Attach( mySep, 0, 1, 2, 3 );
-
-               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
-               myItem.Activated += on_delete_selected_jump_rj_clicked;
-               myMenu.Attach( myItem, 0, 1, 3, 4 );
-
-               myMenu.Popup();
-               myMenu.ShowAll();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW RUNS -------------------------
-        *  --------------------------------------------------------
-        */
-
-       private void createTreeView_runs (Gtk.TreeView tv) {
-               //myTreeViewRuns is a TreeViewRuns instance
-               myTreeViewRuns = new TreeViewRuns (tv, preferences.digitsNumber, 
preferences.metersSecondsPreferred, TreeViewEvent.ExpandStates.MINIMIZED );
-
-               //the glade cursor_changed does not work on mono 1.2.5 windows
-               tv.CursorChanged += on_treeview_runs_cursor_changed; 
-       }
-
-       private void fillTreeView_runs (string filter) {
-               fillTreeView_runs (filter, false);
-       }
-       private void fillTreeView_runs (string filter, bool dbconOpened) {
-               string [] myRuns = SqliteRun.SelectRuns(dbconOpened, currentSession.UniqueID, -1, "",
-                               Sqlite.Orders_by.DEFAULT, -1);
-
-               myTreeViewRuns.Fill(myRuns, filter);
-
-               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewRuns, treeview_runs);
-       }
-       
-       private void on_button_runs_zoom_clicked (object o, EventArgs args) {
-               myTreeViewRuns.ExpandState = myTreeViewRuns.ZoomChange(myTreeViewRuns.ExpandState);
-               if(myTreeViewRuns.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
-                       treeview_runs.CollapseAll();
-               else
-                       treeview_runs.ExpandAll();
-       }
-       
-       private void treeview_runs_storeReset() {
-               myTreeViewRuns.RemoveColumns();
-               myTreeViewRuns = new TreeViewRuns(treeview_runs, preferences.digitsNumber, 
preferences.metersSecondsPreferred, myTreeViewRuns.ExpandState);
-       }
-
-       private void on_treeview_runs_cursor_changed (object o, EventArgs args) {
-               // don't select if it's a person, 
-               // is for not confusing with the person treeviews that controls who runs
-               if (myTreeViewRuns.EventSelectedID == 0) {
-                       myTreeViewRuns.Unselect();
-                       showHideActionEventButtons(false, "Run");
-               } else {
-                       showHideActionEventButtons(true, "Run");
-               }
-       }
-
-       private void treeviewRunsContextMenu(Run myRun) {
-               Menu myMenu = new Menu ();
-               Gtk.MenuItem myItem;
-
-               /*
-               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
-                               myRun.Type + " (" + myRun.PersonName + ")");
-               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
-                               Constants.TestTypes.RUN, myTreeViewRuns.EventSelectedID))) {
-                       myItem.Activated += on_video_play_selected_run_clicked;
-                       myItem.Sensitive = true;
-               } else 
-                       myItem.Sensitive = false;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-               */
-
-               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
-               myItem.Activated += on_edit_selected_run_clicked;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-
-               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
-               myMenu.Attach( mySep, 0, 1, 1, 2 );
-
-               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
-               myItem.Activated += on_delete_selected_run_clicked;
-               myMenu.Attach( myItem, 0, 1, 2, 3 );
-
-               myMenu.Popup();
-               myMenu.ShowAll();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW RUN INTERVAL -----------------
-        *  --------------------------------------------------------
-        */
-
-       private void createTreeView_runs_interval (Gtk.TreeView tv) {
-               //myTreeViewRunsInterval is a TreeViewRunsInterval instance
-               myTreeViewRunsInterval = new TreeViewRunsInterval (tv, preferences.digitsNumber, 
preferences.metersSecondsPreferred, TreeViewEvent.ExpandStates.MINIMIZED);
-
-               //the glade cursor_changed does not work on mono 1.2.5 windows
-               tv.CursorChanged += on_treeview_runs_interval_cursor_changed; 
-       }
-
-       private void fillTreeView_runs_interval (string filter) {
-               fillTreeView_runs_interval (filter, false);
-       }
-       private void fillTreeView_runs_interval (string filter, bool dbconOpened) {
-               string [] myRuns = SqliteRunInterval.SelectRuns(dbconOpened, currentSession.UniqueID, -1, "");
-               myTreeViewRunsInterval.Fill(myRuns, filter);
-               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewRunsInterval, treeview_runs_interval);
-       }
-       
-       private void on_button_runs_interval_zoom_clicked (object o, EventArgs args) {
-               myTreeViewRunsInterval.ExpandState = 
myTreeViewRunsInterval.ZoomChange(myTreeViewRunsInterval.ExpandState);
-               if(myTreeViewRunsInterval.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
-                       treeview_runs_interval.CollapseAll();
-               else if(myTreeViewRunsInterval.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
-                       treeview_runs_interval.CollapseAll();
-                       myTreeViewRunsInterval.ExpandOptimal();
-               } else
-                       treeview_runs_interval.ExpandAll();
-       }
-
-       private void treeview_runs_interval_storeReset() {
-               myTreeViewRunsInterval.RemoveColumns();
-               myTreeViewRunsInterval = new TreeViewRunsInterval (treeview_runs_interval,  
-                               preferences.digitsNumber, preferences.metersSecondsPreferred, 
myTreeViewRunsInterval.ExpandState);
-       }
-
-       private void on_treeview_runs_interval_cursor_changed (object o, EventArgs args) {
-               // don't select if it's a person, 
-               // is for not confusing with the person treeviews that controls who runs
-               if (myTreeViewRunsInterval.EventSelectedID == 0) {
-                       myTreeViewRunsInterval.Unselect();
-                       showHideActionEventButtons(false, "RunInterval");
-               } else if (myTreeViewRunsInterval.EventSelectedID == -1) {
-                       myTreeViewRunsInterval.SelectHeaderLine();
-                       showHideActionEventButtons(true, "RunInterval");
-               } else {
-                       showHideActionEventButtons(true, "RunInterval");
-               }
-       }
-
-       private void treeviewRunsIntervalContextMenu(RunInterval myRun) {
-               Menu myMenu = new Menu ();
-               Gtk.MenuItem myItem;
-
-               /*
-               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
-                               myRun.Type + " (" + myRun.PersonName + ")");
-               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
-                               Constants.TestTypes.RUN_I, myTreeViewRunsInterval.EventSelectedID))) {
-                       myItem.Activated += on_video_play_selected_run_interval_clicked;
-                       myItem.Sensitive = true;
-               } else 
-                       myItem.Sensitive = false;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-               */
-
-               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
-               myItem.Activated += on_edit_selected_run_interval_clicked;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-
-               myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
-               myItem.Activated += on_repair_selected_run_interval_clicked;
-               myMenu.Attach( myItem, 0, 1, 1, 2 );
-               
-               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
-               myMenu.Attach( mySep, 0, 1, 2, 3 );
-
-               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
-               myItem.Activated += on_delete_selected_run_interval_clicked;
-               myMenu.Attach( myItem, 0, 1, 3, 4 );
-
-               myMenu.Popup();
-               myMenu.ShowAll();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW REACTION TIMES ---------------
-        *  --------------------------------------------------------
-        */
-
-       private void createTreeView_reaction_times (Gtk.TreeView tv) {
-               //myTreeViewReactionTimes is a TreeViewReactionTimes instance
-               myTreeViewReactionTimes = new TreeViewReactionTimes( tv, preferences.digitsNumber, 
TreeViewEvent.ExpandStates.MINIMIZED);
-
-               //the glade cursor_changed does not work on mono 1.2.5 windows
-               tv.CursorChanged += on_treeview_reaction_times_cursor_changed; 
-       }
-
-       private void fillTreeView_reaction_times (string filter) {
-               fillTreeView_reaction_times (filter, false);
-       }
-       private void fillTreeView_reaction_times (string filter, bool dbconOpened) {
-               string [] myRTs = SqliteReactionTime.SelectReactionTimes(dbconOpened, 
currentSession.UniqueID, -1, "", 
-                               Sqlite.Orders_by.DEFAULT, -1);
-
-               myTreeViewReactionTimes.Fill(myRTs, filter);
-               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewReactionTimes, treeview_reaction_times);
-       }
-       
-       private void on_button_reaction_times_zoom_clicked (object o, EventArgs args) {
-               myTreeViewReactionTimes.ExpandState = myTreeViewReactionTimes.ZoomChange(
-                               myTreeViewReactionTimes.ExpandState);
-               if(myTreeViewReactionTimes.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
-                       treeview_reaction_times.CollapseAll();
-               else
-                       treeview_reaction_times.ExpandAll();
-       }
-       
-       private void treeview_reaction_times_storeReset() {
-               myTreeViewReactionTimes.RemoveColumns();
-               myTreeViewReactionTimes = new TreeViewReactionTimes( treeview_reaction_times, 
preferences.digitsNumber, myTreeViewReactionTimes.ExpandState );
-       }
-
-       private void on_treeview_reaction_times_cursor_changed (object o, EventArgs args) {
-               // don't select if it's a person, 
-               // is for not confusing with the person treeviews that controls who is executing
-               if (myTreeViewReactionTimes.EventSelectedID == 0) {
-                       myTreeViewReactionTimes.Unselect();
-                       showHideActionEventButtons(false, "ReactionTime");
-               } else {
-                       showHideActionEventButtons(true, "ReactionTime");
-               }
-       }
-
-       private void treeviewReactionTimesContextMenu(ReactionTime myRt) {
-               Menu myMenu = new Menu ();
-               Gtk.MenuItem myItem;
-
-               /*
-               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
-                               myRt.Type + " (" + myRt.PersonName + ")");
-               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
-                               Constants.TestTypes.RT, myTreeViewReactionTimes.EventSelectedID))) {
-                       myItem.Activated += on_video_play_selected_reaction_time_clicked;
-                       myItem.Sensitive = true;
-               } else 
-                       myItem.Sensitive = false;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-               */
-
-               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myRt.Type + " (" + 
myRt.PersonName + ")");
-               myItem.Activated += on_edit_selected_reaction_time_clicked;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-
-               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
-               myMenu.Attach( mySep, 0, 1, 1, 2 );
-
-               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myRt.Type + " (" + 
myRt.PersonName + ")");
-               myItem.Activated += on_delete_selected_reaction_time_clicked;
-               myMenu.Attach( myItem, 0, 1, 2, 3 );
-
-               myMenu.Popup();
-               myMenu.ShowAll();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW PULSES -----------------------
-        *  --------------------------------------------------------
-        */
-
-       private void createTreeView_pulses (Gtk.TreeView tv) {
-               //myTreeViewPulses is a TreeViewPulses instance
-               myTreeViewPulses = new TreeViewPulses( tv, preferences.digitsNumber, 
TreeViewEvent.ExpandStates.MINIMIZED );
-
-               //the glade cursor_changed does not work on mono 1.2.5 windows
-               tv.CursorChanged += on_treeview_pulses_cursor_changed; 
-       }
-
-       private void fillTreeView_pulses (string filter) {
-               fillTreeView_pulses (filter, false);
-       }
-       private void fillTreeView_pulses (string filter, bool dbconOpened) {
-               string [] myPulses = SqlitePulse.SelectPulses(dbconOpened, currentSession.UniqueID, -1);
-               myTreeViewPulses.Fill(myPulses, filter);
-               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewPulses, treeview_pulses);
-       }
-       
-       private void on_button_pulses_zoom_clicked (object o, EventArgs args) {
-               myTreeViewPulses.ExpandState = myTreeViewPulses.ZoomChange(myTreeViewPulses.ExpandState);
-               if(myTreeViewPulses.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
-                       treeview_pulses.CollapseAll();
-               else if(myTreeViewPulses.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
-                       treeview_pulses.CollapseAll();
-                       myTreeViewPulses.ExpandOptimal();
-               } else
-                       treeview_pulses.ExpandAll();
-       }
-
-       private void treeview_pulses_storeReset() {
-               myTreeViewPulses.RemoveColumns();
-               myTreeViewPulses = new TreeViewPulses( treeview_pulses, preferences.digitsNumber, 
myTreeViewPulses.ExpandState );
-       }
-
-       private void on_treeview_pulses_cursor_changed (object o, EventArgs args) {
-               // don't select if it's a person, 
-               // is for not confusing with the person treeviews that controls who is executing
-               if (myTreeViewPulses.EventSelectedID == 0) {
-                       myTreeViewPulses.Unselect();
-                       showHideActionEventButtons(false, "Pulse");
-               } else if (myTreeViewPulses.EventSelectedID == -1) {
-                       myTreeViewPulses.SelectHeaderLine();
-                       showHideActionEventButtons(true, "Pulse");
-               } else {
-                       showHideActionEventButtons(true, "Pulse");
-               }
-       }
-
-       private void treeviewPulsesContextMenu(Pulse myPulse) {
-               Menu myMenu = new Menu ();
-               Gtk.MenuItem myItem;
-
-               /*
-               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
-                               myPulse.Type + " (" + myPulse.PersonName + ")");
-               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
-                               Constants.TestTypes.PULSE, myTreeViewPulses.EventSelectedID))) {
-                       myItem.Activated += on_video_play_selected_pulse_clicked;
-                       myItem.Sensitive = true;
-               } else 
-                       myItem.Sensitive = false;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-               */
-
-               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myPulse.Type + " (" + 
myPulse.PersonName + ")");
-               myItem.Activated += on_edit_selected_pulse_clicked;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-
-               myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myPulse.Type + " (" + 
myPulse.PersonName + ")");
-               myItem.Activated += on_repair_selected_pulse_clicked;
-               myMenu.Attach( myItem, 0, 1, 1, 2 );
-               
-               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
-               myMenu.Attach( mySep, 0, 1, 2, 3 );
-
-               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myPulse.Type + " (" + 
myPulse.PersonName + ")");
-               myItem.Activated += on_delete_selected_pulse_clicked;
-               myMenu.Attach( myItem, 0, 1, 3, 4 );
-
-               myMenu.Popup();
-               myMenu.ShowAll();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  TREEVIEW MULTI CHRONOPIC --------------
-        *  --------------------------------------------------------
-        */
-
-       private void createTreeView_multi_chronopic (bool dbconOpened, Gtk.TreeView tv) {
-               //myTreeViewMultiChronopic is a TreeViewMultiChronopic instance
-               if(definedSession)
-                       myTreeViewMultiChronopic = new TreeViewMultiChronopic( tv, preferences.digitsNumber, 
-                                       TreeViewEvent.ExpandStates.MINIMIZED, 
SqliteMultiChronopic.MaxCPs(dbconOpened, currentSession.UniqueID) );
-               else
-                       myTreeViewMultiChronopic = new TreeViewMultiChronopic( tv, preferences.digitsNumber, 
-                                       TreeViewEvent.ExpandStates.MINIMIZED, 2);
-
-               //the glade cursor_changed does not work on mono 1.2.5 windows
-               tv.CursorChanged += on_treeview_multi_chronopic_cursor_changed; 
-       }
-       
-       private void fillTreeView_multi_chronopic () {
-               fillTreeView_multi_chronopic (false);
-       }
-       private void fillTreeView_multi_chronopic (bool dbconOpened) {
-               string [] mcs = SqliteMultiChronopic.SelectTests(dbconOpened, currentSession.UniqueID, -1);
-               myTreeViewMultiChronopic.Fill(mcs, "");
-               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewMultiChronopic, treeview_multi_chronopic);
-       }
-       
-       private void on_button_multi_chronopic_zoom_clicked (object o, EventArgs args) {
-               myTreeViewMultiChronopic.ExpandState = 
myTreeViewMultiChronopic.ZoomChange(myTreeViewMultiChronopic.ExpandState);
-               if(myTreeViewMultiChronopic.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
-                       treeview_multi_chronopic.CollapseAll();
-               else if(myTreeViewMultiChronopic.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
-                       treeview_multi_chronopic.CollapseAll();
-                       myTreeViewMultiChronopic.ExpandOptimal();
-               } else
-                       treeview_multi_chronopic.ExpandAll();
-       }
-       
-       private void treeview_multi_chronopic_storeReset(bool dbconOpened) {
-               myTreeViewMultiChronopic.RemoveColumns();
-               if(definedSession)
-                       myTreeViewMultiChronopic = new TreeViewMultiChronopic( treeview_multi_chronopic, 
preferences.digitsNumber, 
-                                       myTreeViewMultiChronopic.ExpandState, 
SqliteMultiChronopic.MaxCPs(dbconOpened, currentSession.UniqueID) );
-               else
-                       myTreeViewMultiChronopic = new TreeViewMultiChronopic( treeview_multi_chronopic, 
preferences.digitsNumber, 
-                                       myTreeViewMultiChronopic.ExpandState, 2);
-       }
-
-       private void on_treeview_multi_chronopic_cursor_changed (object o, EventArgs args) {
-               LogB.Information("Cursor changed");
-               // don't select if it's a person, 
-               // is for not confusing with the person treeviews that controls who does events
-               if (myTreeViewMultiChronopic.EventSelectedID == 0) {
-                       myTreeViewMultiChronopic.Unselect();
-                       showHideActionEventButtons(false, Constants.MultiChronopicName); //hide
-               } else if (myTreeViewMultiChronopic.EventSelectedID == -1) {
-                       myTreeViewMultiChronopic.SelectHeaderLine();
-                       showHideActionEventButtons(true, Constants.MultiChronopicName);
-               } else {
-                       showHideActionEventButtons(true, Constants.MultiChronopicName); //show
-               }
-       }
-
-       private void treeviewMultiChronopicContextMenu(MultiChronopic mc) {
-               Menu myMenu = new Menu ();
-               Gtk.MenuItem myItem;
-
-               /*
-               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
-                               mc.Type + " (" + mc.PersonName + ")");
-               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
-                               Constants.TestTypes.MULTICHRONOPIC, 
myTreeViewMultiChronopic.EventSelectedID))) {
-                       myItem.Activated += on_video_play_selected_multi_chronopic_clicked;
-                       myItem.Sensitive = true;
-               } else 
-                       myItem.Sensitive = false;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-               */
-
-               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + mc.Type + " (" + 
mc.PersonName + ")");
-               myItem.Activated += on_edit_selected_multi_chronopic_clicked;
-               myMenu.Attach( myItem, 0, 1, 0, 1 );
-
-               /*
-               myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + mc.Type + " (" + 
mc.PersonName + ")");
-               myItem.Activated += on_repair_selected_multi_chronopic_clicked;
-               myMenu.Attach( myItem, 0, 1, 2, 3 );
-               */
-               
-               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
-               myMenu.Attach( mySep, 0, 1, 1, 2 );
-
-               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + mc.Type + " (" + 
mc.PersonName + ")");
-               myItem.Activated += on_delete_selected_multi_chronopic_clicked;
-               myMenu.Attach( myItem, 0, 1, 2, 3 );
-
-               myMenu.Popup();
-               myMenu.ShowAll();
-       }
-
-
-
-
-       /* ---------------------------------------------------------
-        * ----------------  CREATE AND UPDATE COMBOS ---------------
-        *  --------------------------------------------------------
-        */
-       
-       string [] selectJumpsString;
-       string [] selectJumpsRjString;
-       string [] selectRunsString;
-       string [] selectRunsIntervalString;
-
-       // ---------------- combo_select ----------------------
-
-       private void createComboSelectJumps(bool create) {
-               if(create)
-                       combo_select_jumps = ComboBox.NewText ();
-
-               string [] jumpTypes = SqliteJumpType.SelectJumpTypes(false, "", "", false); //without 
alljumpsname, without filter, not only name
-               selectJumpsString = new String [jumpTypes.Length];
-               string [] jumpNamesToCombo = new String [jumpTypes.Length];
-               int i =0;
-               foreach(string jumpType in jumpTypes) {
-                       string [] j = jumpType.Split(new char[] {':'});
-                       string nameTranslated = Catalog.GetString(j[1]);
-                       selectJumpsString[i] = 
-                               j[0] + ":" + j[1] + ":" + nameTranslated + ":" +        //uniqueID, name, 
nameTranslated
-                               j[2] + ":" + j[3] + ":" + j[4];                         //startIn, weight, 
description
-                       jumpNamesToCombo[i] = nameTranslated;
-                       i++;
-               }
-
-               UtilGtk.ComboUpdate(combo_select_jumps, jumpNamesToCombo, "");
-               combo_select_jumps.Active = 0;
-               combo_select_jumps.Changed += new EventHandler (on_combo_select_jumps_changed);
-
-               if(create) {
-                       hbox_combo_select_jumps.PackStart(combo_select_jumps, true, true, 0);
-                       hbox_combo_select_jumps.ShowAll();
-                       combo_select_jumps.Sensitive = false;
-               }
-       }
-       
-       private void createComboSelectJumpsRj(bool create) {
-               if(create)
-                       combo_select_jumps_rj = ComboBox.NewText ();
-
-               string [] jumpTypes = SqliteJumpType.SelectJumpRjTypes("", false); //without alljumpsname, 
not only name
-               selectJumpsRjString = new String [jumpTypes.Length];
-               string [] jumpNamesToCombo = new String [jumpTypes.Length];
-               int i =0;
-               foreach(string jumpType in jumpTypes) {
-                       string [] j = jumpType.Split(new char[] {':'});
-                       string nameTranslated = Catalog.GetString(j[1]);
-                       selectJumpsRjString[i] = 
-                               j[0] + ":" + j[1] + ":" + nameTranslated + ":" +        //uniqueID, name, 
nameTranslated
-                               j[2] + ":" + j[3] + ":" + j[4] + ":" +                  //startIn, weight, 
jumpsLimited
-                               j[5] + ":" + j[6];                                      //fixedValue, 
description
-                       jumpNamesToCombo[i] = nameTranslated;
-                       i++;
-               }
-
-               UtilGtk.ComboUpdate(combo_select_jumps_rj, jumpNamesToCombo, "");
-               combo_select_jumps_rj.Active = 0;
-               combo_select_jumps_rj.Changed += new EventHandler (on_combo_select_jumps_rj_changed);
-
-               if(create) {
-                       hbox_combo_select_jumps_rj.PackStart(combo_select_jumps_rj, true, true, 0);
-                       hbox_combo_select_jumps_rj.ShowAll();
-                       combo_select_jumps_rj.Sensitive = false;
-               }
-       }
-       
-       private void createComboSelectRuns(bool create) {
-               if(create)
-                       combo_select_runs = ComboBox.NewText ();
-
-               string [] runTypes = SqliteRunType.SelectRunTypes("", false); //without allrunsname, not only 
name
-               selectRunsString = new String [runTypes.Length];
-               string [] runNamesToCombo = new String [runTypes.Length];
-               int i =0;
-               foreach(string runType in runTypes) {
-                       string [] j = runType.Split(new char[] {':'});
-                       string nameTranslated = Catalog.GetString(j[1]);
-                       selectRunsString[i] = 
-                               j[0] + ":" + j[1] + ":" + nameTranslated + ":" +        //uniqueID, name, 
nameTranslated
-                               j[2] + ":" + j[3];                                      //distance, 
description
-                       runNamesToCombo[i] = nameTranslated;
-                       i++;
-               }
-
-               UtilGtk.ComboUpdate(combo_select_runs, runNamesToCombo, "");
-               combo_select_runs.Active = 0;
-               combo_select_runs.Changed += new EventHandler (on_combo_select_runs_changed);
-
-               if(create) {
-                       hbox_combo_select_runs.PackStart(combo_select_runs, true, true, 0);
-                       hbox_combo_select_runs.ShowAll();
-                       combo_select_runs.Sensitive = false;
-               }
-       }
-
-       private void createComboSelectRunsInterval(bool create) {
-               if(create)
-                       combo_select_runs_interval = ComboBox.NewText ();
-
-               string [] runTypes = SqliteRunIntervalType.SelectRunIntervalTypes("", false); //without 
allrunsname, not only name
-               selectRunsIntervalString = new String [runTypes.Length];
-               string [] runNamesToCombo = new String [runTypes.Length];
-               int i =0;
-               foreach(string runType in runTypes) {
-                       string [] j = runType.Split(new char[] {':'});
-                       string nameTranslated = Catalog.GetString(j[1]);
-                       selectRunsIntervalString[i] = 
-                               j[0] + ":" + j[1] + ":" + nameTranslated + ":" +        //uniqueID, name, 
nameTranslated
-                               j[2] + ":" + j[3] + ":" + j[4] + ":" +                  //distance, 
tracksLimited, fixedValue
-                               j[5] + ":" + j[6] + ":" + j[6];                         //unlimited, 
description, distancesString
-                       runNamesToCombo[i] = nameTranslated;
-                       i++;
-               }
-
-               UtilGtk.ComboUpdate(combo_select_runs_interval, runNamesToCombo, "");
-               combo_select_runs_interval.Active = 0;
-               combo_select_runs_interval.Changed += new EventHandler 
(on_combo_select_runs_interval_changed);
-
-               if(create) {
-                       hbox_combo_select_runs_interval.PackStart(combo_select_runs_interval, true, true, 0);
-                       hbox_combo_select_runs_interval.ShowAll();
-                       combo_select_runs_interval.Sensitive = false;
-               }
-       }
-
-
-       // ---------------- combo_result ----------------------
-
-       private void createComboResultJumps() {
-               combo_result_jumps = ComboBox.NewText ();
-               UtilGtk.ComboUpdate(combo_result_jumps,
-                               SqliteJumpType.SelectJumpTypes(false, Constants.AllJumpsName, "", true), 
//with alljumpsname, without filter, only select name
-                               "");
-               
-               combo_result_jumps.Active = 0;
-               combo_result_jumps.Changed += new EventHandler (on_combo_result_jumps_changed);
-
-               hbox_combo_result_jumps.PackStart(combo_result_jumps, true, true, 0);
-               hbox_combo_result_jumps.ShowAll();
-               combo_result_jumps.Sensitive = false;
-       }
-       
-       private void createComboResultJumpsRj() {
-               combo_result_jumps_rj = ComboBox.NewText();
-               UtilGtk.ComboUpdate(combo_result_jumps_rj, 
SqliteJumpType.SelectJumpRjTypes(Constants.AllJumpsName, true), ""); //only select name
-               
-               combo_result_jumps_rj.Active = 0;
-               combo_result_jumps_rj.Changed += new EventHandler (on_combo_result_jumps_rj_changed);
-
-               hbox_combo_result_jumps_rj.PackStart(combo_result_jumps_rj, true, true, 0);
-               hbox_combo_result_jumps_rj.ShowAll();
-               combo_result_jumps_rj.Sensitive = false;
-       }
-       
-       private void createComboResultRuns() {
-               combo_result_runs = ComboBox.NewText();
-               UtilGtk.ComboUpdate(combo_result_runs, SqliteRunType.SelectRunTypes(Constants.AllRunsName, 
true), ""); //without filter, only select name
-               
-               combo_result_runs.Active = 0;
-               combo_result_runs.Changed += new EventHandler (on_combo_result_runs_changed);
-
-               hbox_combo_result_runs.PackStart(combo_result_runs, true, true, 0);
-               hbox_combo_result_runs.ShowAll();
-               combo_result_runs.Sensitive = false;
-       }
-
-       private void createComboResultRunsInterval() {
-               combo_result_runs_interval = ComboBox.NewText();
-               UtilGtk.ComboUpdate(combo_result_runs_interval, 
SqliteRunIntervalType.SelectRunIntervalTypes(Constants.AllRunsName, true), ""); //without filter, only select 
name
-               
-               combo_result_runs_interval.Active = 0;
-               combo_result_runs_interval.Changed += new EventHandler 
(on_combo_result_runs_interval_changed);
-
-               hbox_combo_result_runs_interval.PackStart(combo_result_runs_interval, true, true, 0);
-               hbox_combo_result_runs_interval.ShowAll();
-               combo_result_runs_interval.Sensitive = false;
-       }
-       
-       //no need of reationTimes
-
-       private void createComboPulses() {
-               combo_pulses = ComboBox.NewText();
-               UtilGtk.ComboUpdate(combo_pulses, SqlitePulseType.SelectPulseTypes(Constants.AllPulsesName, 
true), ""); //without filter, only select name
-               
-               combo_pulses.Active = 0;
-               combo_pulses.Changed += new EventHandler (on_combo_pulses_changed);
-
-               hbox_combo_pulses.PackStart(combo_pulses, true, true, 0);
-               hbox_combo_pulses.ShowAll();
-               combo_pulses.Sensitive = false;
-       }
-
-       /*
-       private void createComboMultiChronopic() 
-       {
-               button_multi_chronopic_start.Sensitive = false;
-               button_run_analysis.Sensitive = false;
-               extra_window_spin_run_analysis_distance.Sensitive = false;
-       }
-       */
-
-
-       // -------------- combo select tests changed --------
-
-       private void on_combo_select_jumps_changed(object o, EventArgs args) {
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-               LogB.Information("Selected: " + myText); 
-
-               //show extra window options
-               on_extra_window_jumps_test_changed(o, args);
-       }
-       
-       private void on_combo_select_jumps_rj_changed(object o, EventArgs args) {
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-               LogB.Information("Selected: " + myText); 
-
-               //show extra window options
-               on_extra_window_jumps_rj_test_changed(o, args);
-       }
-       
-       private void on_combo_select_runs_changed(object o, EventArgs args) {
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-               LogB.Information("Selected: " + myText); 
-
-               //show extra window options
-               on_extra_window_runs_test_changed(o, args);
-       }
-       
-       private void on_combo_select_runs_interval_changed(object o, EventArgs args) {
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-               LogB.Information("Selected: " + myText); 
-
-               //show extra window options
-               on_extra_window_runs_interval_test_changed(o, args);
-       }
-       
-       // -------------- combo result tests changed --------
-       
-       private void on_combo_result_jumps_changed(object o, EventArgs args) {
-               //combo_result_jumps.Changed -= new EventHandler (on_combo_result_jumps_changed);
-
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-
-               treeview_jumps_storeReset();
-               fillTreeView_jumps(myText);
-       }
-       
-       
-       private void on_combo_result_jumps_rj_changed(object o, EventArgs args) {
-               //combo_result_jumps_rj.Changed -= new EventHandler (on_combo_result_jumps_rj_changed);
-
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-
-               treeview_jumps_rj_storeReset();
-               fillTreeView_jumps_rj(myText);
-       }
-
-       private void on_combo_result_runs_changed(object o, EventArgs args) {
-               //combo_result_runs.Changed -= new EventHandler (on_combo_result_runs_changed);
-
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-
-               treeview_runs_storeReset();
-               fillTreeView_runs(myText);
-       }
-
-       private void on_combo_result_runs_interval_changed(object o, EventArgs args) {
-               //combo_result_runs_interval.Changed -= new EventHandler 
(on_combo_result_runs_interval_changed);
-
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-
-               treeview_runs_interval_storeReset();
-               fillTreeView_runs_interval(myText);
-       }
-
-       //no need of reationTimes because is done in:
-       //gui/reactionTime on_extra_window_reaction_times_test_changed()
-       
-       private void on_combo_pulses_changed(object o, EventArgs args) {
-               //combo_pulses.Changed -= new EventHandler (on_combo_pulses_changed);
-
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-               string myText = UtilGtk.ComboGetActive(combo);
-
-               treeview_pulses_storeReset();
-               fillTreeView_pulses(myText);
-       }
-
-
-       /* ---------------------------------------------------------
-        * ----------------  DELETE EVENT, QUIT  -----------------------
-        *  --------------------------------------------------------
-        */
-       
-       private void on_delete_event (object o, DeleteEventArgs args) {
-               args.RetVal = true;
-               
-               //cannot terminate chronojump untile press 'cancel' if  autodetect encoder is working
-               if(cpDetect != null && cpDetect.Detecting == true)
-                       return;
-    
-               on_quit1_activate (new object(), new EventArgs ());
-       }
-
-
-       private void on_quit1_activate (object o, EventArgs args) {
-               /*
-               if(chronopicCancelledTimes > 0 && UtilAll.IsWindows()) {
-                       confirmWinJumpRun = ConfirmWindowJumpRun.Show( 
-                                       Catalog.GetString("Attention, current version of Chronojump gets 
hanged on exit\nif user has cancelled detection of Chronopic."),
-                                       Catalog.GetString("Sorry, you will have to close Chronojump using 
CTRL + ALT + DEL."));
-                       confirmWinJumpRun.Button_accept.Clicked += new EventHandler(on_quit2_activate);
-               } else
-                       on_quit2_activate(new object(), new EventArgs());
-               
-               */
-               on_quit2_activate(new object(), new EventArgs());
-       }
-               
-
-       private void on_quit2_activate (object o, EventArgs args) {
-               LogB.Information("Bye!");
-
-               if(chronopicWin.Connected == true) {
-                       chronopicWin.SerialPortsCloseIfNeeded();
-               }
-       
-               try {   
-                       File.Delete(runningFileName);
-               } catch {
-                       new DialogMessage(Constants.MessageTypes.WARNING, 
-                                       string.Format(Catalog.GetString("Could not delete file:\n{0}"), 
runningFileName));
-               }
-               
-               if(File.Exists(Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar + 
"chronojump.db"))
-                       File.Move(Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar + 
"chronojump.db",
-                               Util.GetDatabaseDir() + System.IO.Path.DirectorySeparatorChar + 
"chronojump.db");
-               
-               LogB.Information("Bye2!");
-               
-               encoderRProcCapture.SendEndProcess();
-               encoderRProcAnalyze.SendEndProcess();
-
-               LogB.Information("Bye3!");
-
-               //exit start ping if has not ended
-               if(pingThread.IsAlive)
-                       pingThread.Abort();
-               
-               Log.End();
-
-               Application.Quit();
-               
-               //Environment.Exit(Environment.ExitCode);
-       }
-       
-       /* ---------------------------------------------------------
-        * ----------------  SESSION NEW, LOAD, EXPORT, DELETE -----
-        *  --------------------------------------------------------
-        */
-
-       private void on_new_activate (object o, EventArgs args) {
-               LogB.Information("new session");
-               sessionAddEditWin = SessionAddEditWindow.Show(app1, new Session());
-               sessionAddEditWin.FakeButtonAccept.Clicked -= new EventHandler(on_new_session_accepted);
-               sessionAddEditWin.FakeButtonAccept.Clicked += new EventHandler(on_new_session_accepted);
-       }
-       
-       private void on_new_session_accepted (object o, EventArgs args) {
-               if(sessionAddEditWin.CurrentSession != null) 
-               {
-                       currentSession = sessionAddEditWin.CurrentSession;
-                       sessionAddEditWin.HideAndNull();
-
-                       //serverUniqueID is undefined until session is updated
-                       currentSession.ServerUniqueID = Constants.ServerUndefinedID;
-
-                       app1.Title = progName + " - " + currentSession.Name;
-
-                       if(createdStatsWin) {
-                               stats_win_initializeSession();
-                       }
-               
-                       resetAllTreeViews(true); //boolean means: "also persons"
-
-                       //show hidden widgets
-                       sensitiveGuiNoSession();
-                       sensitiveGuiYesSession();
-                       definedSession = true;
-
-                       //for sure, jumpsExists is false, because we create a new session
-
-                       button_edit_current_person.Sensitive = false;
-                       button_show_all_person_events.Sensitive = false;
-                       button_delete_current_person.Sensitive = false;
-               
-                       //update report
-                       report.SessionID = currentSession.UniqueID;
-                       report.StatisticsRemove();
-                       try {
-                               reportWin.FillTreeView();
-                       } catch {} //reportWin is still not created, not need to Fill again
-       
-                       //feedback (more in 1st session created)
-                       string feedbackLoadUsers = Catalog.GetString ("Session created, now add or load 
persons.");
-                       new DialogMessage(Constants.MessageTypes.INFO, feedbackLoadUsers);
-               }
-       }
-       
-       private void on_edit_session_activate (object o, EventArgs args) 
-       {
-               LogB.Information("edit session");
-               
-               if(currentSession.Name == Constants.SessionSimulatedName)
-                       new DialogMessage(Constants.MessageTypes.INFO, Constants.SessionProtected);
-               else {
-                       sessionAddEditWin = SessionAddEditWindow.Show(app1, currentSession);
-                       sessionAddEditWin.FakeButtonAccept.Clicked -= new 
EventHandler(on_edit_session_accepted);
-                       sessionAddEditWin.FakeButtonAccept.Clicked += new 
EventHandler(on_edit_session_accepted);
-               }
-       }
-       
-       private void on_edit_session_accepted (object o, EventArgs args) {
-               if(sessionAddEditWin.CurrentSession != null) 
-               {
-                       currentSession = sessionAddEditWin.CurrentSession;
-                       sessionAddEditWin.HideAndNull();
-                       
-                       app1.Title = progName + " - " + currentSession.Name;
-
-                       if(createdStatsWin) {
-                               stats_win_initializeSession();
-                       }
-               }
-       }
-
-       private void on_button_encoder_import_chronojump_session(object o, EventArgs args)
-       {
-               sessionLoadWin = SessionLoadWindow.Show (app1, SessionLoadWindow.WindowType.IMPORT_SESSION);
-               sessionLoadWin.Button_accept.Clicked += new EventHandler(on_load_session_accepted_to_import);
-       }
-
-       //from import session
-       private void on_load_session_accepted_to_import(object o, EventArgs args)
-       {
-               int sessionNumber = sessionLoadWin.CurrentSessionId();
-               string databasePath = sessionLoadWin.DatabasePath();
-               LogB.Information (databasePath);
-
-               ImportSessionFromDatabase (databasePath, sessionNumber);
-       }
-
-       private void ImportSessionFromDatabase(string databasePath, int sessionNumber)
-       {
-               string source_filename = databasePath;
-               string destination_filename = Sqlite.DatabaseFilePath;
-               string session = Convert.ToString (sessionNumber);
-
-               ChronojumpImporter chronojumpImporter = new ChronojumpImporter (source_filename, 
destination_filename, session);
-
-               ChronojumpImporter.Result result = chronojumpImporter.import ();
-
-               if (result.success) {
-                       updateComboStats ();
-                       new DialogMessage (Constants.MessageTypes.INFO, Catalog.GetString ("Session 
imported."));
-               } else {
-                       LogB.Debug ("Chronojump Importer error: ", result.error);
-                       new DialogMessage (Constants.MessageTypes.WARNING, result.error);
-               }
-       }
-
-       private void on_open_activate (object o, EventArgs args) 
-       {
-               LogB.Information("open session");
-               sessionLoadWin = SessionLoadWindow.Show(app1, SessionLoadWindow.WindowType.LOAD_SESSION);
-               sessionLoadWin.Button_accept.Clicked += new EventHandler(on_load_session_accepted_from_open);
-       }
-
-       //from open session
-       private void on_load_session_accepted_from_open (object o, EventArgs args) 
-       {
-               currentSession = sessionLoadWin.CurrentSession;
-               on_load_session_accepted();
-       }
-       //called from open session OR from gui/networks configInit when config.SessionMode == 
Config.SessionModeEnum.UNIQUE
-       private void on_load_session_accepted () 
-       {
-               app1.Title = progName + " - " + currentSession.Name;
-       
-               if(createdStatsWin) {
-                       stats_win_initializeSession();
-               }
-               
-               resetAllTreeViews(true); //boolean means: "also persons"
-
-               bool foundPersons = selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0);
-               
-               //show hidden widgets
-               sensitiveGuiNoSession();
-               sensitiveGuiYesSession();
-               definedSession = true;
-               
-               button_edit_current_person.Sensitive = false;
-               button_show_all_person_events.Sensitive = false;
-               button_delete_current_person.Sensitive = false;
-
-               //if there are persons
-               if(foundPersons) {
-                       //activate the gui for persons in main window
-                       sensitiveGuiYesPerson();
-               }
-
-               //update report
-               report.SessionID = currentSession.UniqueID;
-               report.StatisticsRemove();
-
-               if(reportWin != null)
-                       reportWin.FillTreeView();
-               
-               chronojumpWindowTestsNext();
-       }
-       
-       
-       private void on_delete_session_activate (object o, EventArgs args) 
-       {
-               LogB.Information("--- delete session ---");
-               
-               if(currentSession.Name == Constants.SessionSimulatedName)
-                       new DialogMessage(Constants.MessageTypes.INFO, Constants.SessionProtected);
-               else {
-                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are you sure you 
want to delete the current session"), "", Catalog.GetString("and all the session tests?"));
-                       confirmWin.Button_accept.Clicked += new EventHandler(on_delete_session_accepted);
-               }
-       }
-       
-       private void on_delete_session_accepted (object o, EventArgs args) 
-       {
-               new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Deleted session and all its 
tests."));
-               SqliteSession.DeleteAllStuff(currentSession.UniqueID.ToString());
-               
-               sensitiveGuiNoSession();
-               definedSession = false;
-               app1.Title = progName + "";
-       }
-
-       
-       private void on_export_session_activate(object o, EventArgs args) {
-               ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Encoder data will not be 
exported."), "", "");
-               confirmWin.Button_accept.Clicked += new EventHandler(on_export_session_accepted);
-       }
-
-       private void on_export_session_accepted(object o, EventArgs args) {
-               new ExportSessionCSV(currentSession, app1, preferences);
-       }
-
-       
-       /* ---------------------------------------------------------
-        * ----------------  PERSON RECUPERATE, LOAD, EDIT, DELETE -
-        *  --------------------------------------------------------
-        */
-       
-       private void on_recuperate_person_clicked (object o, EventArgs args) {
-               LogB.Information("recuperate person");
-               personRecuperateWin = PersonRecuperateWindow.Show(app1, currentSession, 
preferences.digitsNumber);
-               personRecuperateWin.FakeButtonDone.Clicked += new EventHandler(on_recuperate_person_accepted);
-       }
-
-       private void on_recuperate_person_accepted (object o, EventArgs args) {
-               LogB.Information("here!!!");
-               currentPerson = personRecuperateWin.CurrentPerson;
-               currentPersonSession = personRecuperateWin.CurrentPersonSession;
-               label_person_change();
-               
-               myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);
-
-               int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
-               if(rowToSelect != -1) {
-                       selectRowTreeView_persons(treeview_persons,
-                                       treeview_persons_store, 
-                                       rowToSelect);
-                       sensitiveGuiYesPerson();
-               }
-       }
-               
-       private void on_recuperate_persons_from_session_clicked (object o, EventArgs args) {
-               LogB.Information("recuperate persons from other session");
-               personsRecuperateFromOtherSessionWin = PersonsRecuperateFromOtherSessionWindow.Show(app1, 
currentSession);
-               personsRecuperateFromOtherSessionWin.FakeButtonDone.Clicked += new 
EventHandler(on_recuperate_persons_from_session_accepted);
-       }
-       
-       private void on_recuperate_persons_from_session_accepted (object o, EventArgs args) {
-               currentPerson = personsRecuperateFromOtherSessionWin.CurrentPerson;
-               currentPersonSession = personsRecuperateFromOtherSessionWin.CurrentPersonSession;
-               label_person_change();
-
-               treeview_persons_storeReset();
-               fillTreeView_persons();
-               int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
-               if(rowToSelect != -1) {
-                       selectRowTreeView_persons(treeview_persons,
-                                       treeview_persons_store, 
-                                       rowToSelect);
-                       sensitiveGuiYesPerson();
-               }
-       }
-       
-       bool person_add_single_called_from_person_select_window;
-       private void on_person_add_single_from_main_gui (object o, EventArgs args) {
-               person_add_single_called_from_person_select_window = false;
-               person_add_single();
-       }
-
-       private void person_add_single () {
-               personAddModifyWin = PersonAddModifyWindow.Show(app1, 
-                               currentSession, new Person(-1), 
-                               preferences.digitsNumber, checkbutton_video, useVideo
-                               );
-               //-1 means we are adding a new person
-               //if we were modifying it will be it's uniqueID
-               
-               personAddModifyWin.FakeButtonAccept.Clicked += new 
EventHandler(on_person_add_single_accepted);
-       }
-       
-       private void on_person_add_single_accepted (object o, EventArgs args) {
-               if (personAddModifyWin.CurrentPerson != null)
-               {
-                       currentPerson = personAddModifyWin.CurrentPerson;
-                       currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
-                       label_person_change();
-                       myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);
-
-                       //when adding new person, photos cannot be recorded as currentPerson.UniqueID
-                       //because it was undefined. Copy them now
-                       if(File.Exists(Util.GetPhotoTempFileName(false)) && 
File.Exists(Util.GetPhotoTempFileName(true))) {
-                               try {
-                                       File.Move(Util.GetPhotoTempFileName(false), 
-                                                       Util.GetPhotoFileName(false, currentPerson.UniqueID));
-                               } catch {
-                                       File.Copy(Util.GetPhotoTempFileName(false), 
-                                                       Util.GetPhotoFileName(false, currentPerson.UniqueID), 
true);
-                               }
-                               try {
-                                       File.Move(Util.GetPhotoTempFileName(true), 
-                                                       Util.GetPhotoFileName(true, currentPerson.UniqueID));
-                               } catch {
-                                       File.Copy(Util.GetPhotoTempFileName(true), 
-                                                       Util.GetPhotoFileName(true, currentPerson.UniqueID), 
true);
-                               }
-                       }
-                       
-                       int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
-                       if(rowToSelect != -1) {
-                               selectRowTreeView_persons(treeview_persons,
-                                               treeview_persons_store, 
-                                               rowToSelect);
-                               sensitiveGuiYesPerson();
-                               //appbar2.Push( 1, Catalog.GetString("Successfully added") + " " + 
currentPerson.Name );
-                       }
-                       
-                       if(person_add_single_called_from_person_select_window) {
-                               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
-                                               currentSession.UniqueID, 
-                                               false); //means: do not returnPersonAndPSlist
-                               personSelectWin.Update(myPersons);
-                       }
-               }
-       }
-
-       //show spinbutton window asking for how many people to create   
-       private void on_person_add_multiple_clicked (object o, EventArgs args) {
-               personAddMultipleWin = PersonAddMultipleWindow.Show(app1, currentSession);
-               personAddMultipleWin.Button_accept.Clicked += new 
EventHandler(on_person_add_multiple_accepted);
-       }
-       
-       private void on_person_add_multiple_accepted (object o, EventArgs args) {
-               if (personAddMultipleWin.CurrentPerson != null)
-               {
-                       currentPerson = personAddMultipleWin.CurrentPerson;
-                       currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
-                       label_person_change();
-                       treeview_persons_storeReset();
-                       fillTreeView_persons();
-                       int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
-                       if(rowToSelect != -1) {
-                               selectRowTreeView_persons(treeview_persons,
-                                               treeview_persons_store, 
-                                               rowToSelect);
-                               sensitiveGuiYesPerson();
-                       
-                               string myString = string.Format(
-                                               Catalog.GetPluralString(
-                                                       "Successfully added one person.", 
-                                                       "Successfully added {0} persons.", 
-                                                       personAddMultipleWin.PersonsCreatedCount),
-                                               personAddMultipleWin.PersonsCreatedCount);
-                               //appbar2.Push( 1, Catalog.GetString(myString) );
-                       }
-               }
-       }
-       
-       bool person_edit_single_called_from_person_select_window;
-       private void on_edit_current_person_clicked_from_main_gui (object o, EventArgs args) {
-               person_edit_single_called_from_person_select_window = false;
-               person_edit_single();
-       }
-
-       private void person_edit_single() {
-               LogB.Information("modify person");
-
-               personAddModifyWin = PersonAddModifyWindow.Show(app1, currentSession, currentPerson, 
-                               preferences.digitsNumber, checkbutton_video, useVideo
-                               ); 
-               personAddModifyWin.FakeButtonAccept.Clicked += new 
EventHandler(on_edit_current_person_accepted);
-       }
-       
-       private void on_edit_current_person_accepted (object o, EventArgs args) {
-               if (personAddModifyWin.CurrentPerson != null)
-               {
-                       currentPerson = personAddModifyWin.CurrentPerson;
-                       currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
-                       label_person_change();
-                       treeview_persons_storeReset();
-                       fillTreeView_persons();
-                       
-                       int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
-                       if(rowToSelect != -1) {
-                               selectRowTreeView_persons(treeview_persons,
-                                               treeview_persons_store, 
-                                               rowToSelect);
-                               sensitiveGuiYesPerson();
-                       }
-
-                       on_combo_result_jumps_changed(combo_result_jumps, args);
-                       on_combo_result_jumps_rj_changed(combo_result_jumps_rj, args);
-                       on_combo_result_runs_changed(combo_result_runs, args);
-                       on_combo_result_runs_interval_changed(combo_result_runs_interval, args);
-                       on_combo_pulses_changed(combo_pulses, args);
-
-                       if(createdStatsWin) {
-                               stats_win_fillTreeView_stats(false, true);
-                       }
-
-//                     personAddModifyWin.Destroy();
-                       
-                       if(person_edit_single_called_from_person_select_window) {
-                               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
-                                               currentSession.UniqueID, 
-                                               false); //means: do not returnPersonAndPSlist
-                               personSelectWin.Update(myPersons);
-                       }
-               }
-       }
-
-       
-       private void on_show_all_person_events_activate (object o, EventArgs args) {
-               PersonShowAllEventsWindow.Show(app1, currentSession.UniqueID, currentPerson);
-       }
-       
-       
-       private void on_delete_current_person_from_session_clicked (object o, EventArgs args) {
-               LogB.Information("delete current person from this session");
-               ConfirmWindow confirmWin = ConfirmWindow.Show(
-                               Catalog.GetString("Are you sure you want to delete the current person and all 
his/her tests (jumps, runs, pulses, ...) from this session?\n(His/her personal data and tests in other 
sessions will remain intact.)"), "", 
-                               Catalog.GetString("Current Person: ") + currentPerson.Name);
-
-               confirmWin.Button_accept.Clicked += new 
EventHandler(on_delete_current_person_from_session_accepted);
-       }
-       
-       private void on_delete_current_person_from_session_accepted (object o, EventArgs args) 
-       {
-               new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Deleted person and all 
his/her tests on this session."));
-               SqlitePersonSession.DeletePersonFromSessionAndTests(
-                               currentSession.UniqueID.ToString(), currentPerson.UniqueID.ToString());
-               
-               resetAllTreeViews(true); //boolean means: "also persons"
-               bool foundPersons = selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0);
-                       
-               if(createdStatsWin) {
-                       stats_win_fillTreeView_stats(false, true);
-               }
-               
-               //if there are no persons
-               if(!foundPersons) {
-                       sensitiveGuiNoPerson ();
-                       if(createdStatsWin) {
-                               stats_win_hide();
-                       }
-               }
-       }
-
-       private void on_button_encoder_person_change_clicked (object o, EventArgs args) 
-       {
-               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
-                               currentSession.UniqueID, 
-                               false); //means: do not returnPersonAndPSlist
-
-               personSelectWin = PersonSelectWindow.Show(app1, myPersons);
-               personSelectWin.FakeButtonAddPerson.Clicked += new 
EventHandler(on_button_encoder_person_add_person);
-               personSelectWin.FakeButtonEditPerson.Clicked += new 
EventHandler(on_button_encoder_person_edit_person);
-               personSelectWin.FakeButtonDeletePerson.Clicked += new 
EventHandler(on_button_encoder_person_delete_person);
-               personSelectWin.FakeButtonDone.Clicked += new 
EventHandler(on_button_encoder_person_change_done);
-       }
-       private void on_button_encoder_person_add_person(object o, EventArgs args)
-       {
-               person_add_single_called_from_person_select_window = true;
-               person_add_single();
-       }
-       private void on_button_encoder_person_edit_person(object o, EventArgs args)
-       {
-               currentPerson = personSelectWin.SelectedPerson; 
-               
-               person_edit_single_called_from_person_select_window = true;
-               person_edit_single();
-       }
-       private void on_button_encoder_person_delete_person(object o, EventArgs args)
-       {
-               currentPerson = personSelectWin.SelectedPerson;
-               
-               //without confirm, because it's already confirmed on PersonSelect
-               on_delete_current_person_from_session_accepted (o, args);
-                               
-               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
-                               currentSession.UniqueID, 
-                               false); //means: do not returnPersonAndPSlist
-               personSelectWin.Update(myPersons);
-               personSelectWin.Button_delete_confirm_focus(false, false);
-       }
-       private void on_button_encoder_person_change_done(object o, EventArgs args) 
-       {
-               currentPerson = personSelectWin.SelectedPerson; 
-               currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
-               label_person_change();
-
-               personChanged();
-       }
-
-
-
-       /* ---------------------------------------------------------
-        * ----------------  SOME CALLBACKS ------------------------
-        *  --------------------------------------------------------
-        */
-
-       //edit
-       private void on_cut1_activate (object o, EventArgs args) {
-       }
-       
-       private void on_copy1_activate (object o, EventArgs args) {
-       }
-       
-       private void on_paste1_activate (object o, EventArgs args) {
-       }
-
-
-       private void on_preferences_activate (object o, EventArgs args) 
-       {
-               preferencesWin = PreferencesWindow.Show(preferences, getMenuItemMode());
-               
-               preferencesWin.FakeButtonImported.Clicked += new 
EventHandler(on_preferences_import_configuration);
-               preferencesWin.FakeButtonDebugModeStart.Clicked += new 
EventHandler(on_preferences_debug_mode_start);
-               preferencesWin.Button_accept.Clicked += new EventHandler(on_preferences_accepted);
-       }
-               
-       private void on_preferences_import_configuration (object o, EventArgs args) {
-               preferencesWin.FakeButtonImported.Clicked -= new 
EventHandler(on_preferences_import_configuration);
-               
-               configInit();
-               LogB.Information("Initialized configuration");
-       }
-
-       private void on_preferences_accepted (object o, EventArgs args) 
-       {
-               preferences = preferencesWin.GetPreferences;
-
-               if(checkbutton_video.Active) {
-                       videoCapturePrepare(false); //if error, show message
-               }
-
-               //change language works on windows. On Linux let's change the locale
-               //if(UtilAll.IsWindows()) 
-               //      languageChange();
-               
-
-               if(repetitiveConditionsWin != null)
-                       repetitiveConditionsWin.VolumeOn = preferences.volumeOn;
-
-               try {
-                       if(createdStatsWin) {
-                               //statsWin.PrefsDigitsNumber = preferences.digitsNumber;
-                               //statsWin.WeightStatsPercent = preferences.weightStatsPercent;
-                               //statsWin.HeightPreferred = preferences.heightPreferred;
-
-                               stats_win_fillTreeView_stats(false, true);
-                       }
-
-                       //pass to report
-                       report.preferences = preferences;
-                       
-                       
-                       createTreeView_jumps (treeview_jumps);
-                       createTreeView_jumps_rj (treeview_jumps_rj);
-                       createTreeView_runs (treeview_runs);
-                       createTreeView_runs_interval (treeview_runs_interval);
-                       createTreeView_pulses(treeview_pulses);
-                       createTreeView_reaction_times(treeview_reaction_times);
-                       createTreeView_multi_chronopic(false, treeview_multi_chronopic);
-                       
-                       on_combo_result_jumps_changed(combo_result_jumps, args);
-                       on_combo_result_jumps_rj_changed(combo_result_jumps_rj, args);
-                       on_combo_result_runs_changed(combo_result_runs, args);
-                       on_combo_result_runs_interval_changed(combo_result_runs_interval, args);
-                       on_combo_pulses_changed(combo_pulses, args);
-
-                       //currently no combo_reaction_times
-                       treeview_reaction_times_storeReset();
-                       fillTreeView_reaction_times("reactionTime");
-
-                       //currently no combo_multi_chronopic
-                       treeview_multi_chronopic_storeReset(false);
-                       fillTreeView_multi_chronopic();
-               }
-               catch 
-               {
-               }
-       }
-
-
-       /*
-        * menu test selectors
-        */
-
-       private void on_menuitem_mode_main_menu_activate (object o, EventArgs args) 
-       {
-               reset_buttons_selector_start();
-               notebook_start.CurrentPage = 0;
-               
-               //don't show menu bar on start page
-               main_menu.Visible = false;
-       }       
-       
-       private void select_menuitem_mode_toggled(Constants.Menuitem_modes m) 
-       {
-               menuitem_mode_selected_jumps_simple.Visible = false;
-               menuitem_mode_selected_jumps_reactive.Visible = false;
-               menuitem_mode_selected_runs_simple.Visible = false;
-               menuitem_mode_selected_runs_intervallic.Visible = false;
-               menuitem_mode_selected_power_gravitatory.Visible = false;
-               menuitem_mode_selected_power_inertial.Visible = false;
-               menuitem_mode_selected_other.Visible = false;
-                       
-               LogB.Information("MODE", m.ToString());
-               
-               //default for everythong except encoder 
-               menuitem_encoder_session_overview.Visible = false;
-               menuitem_export_encoder_signal.Visible = false;
-               menuitem_export_csv.Visible = true;
-               menuitem_import_chronojump_session.Visible = true;
-
-               hbox_other.Visible = false;
-
-               if(m == Constants.Menuitem_modes.JUMPSSIMPLE || m == Constants.Menuitem_modes.JUMPSREACTIVE)
-               {
-                       notebook_sup.CurrentPage = 0;
-                       notebook_capture_analyze.ShowTabs = true;
-                       if(m == Constants.Menuitem_modes.JUMPSSIMPLE) 
-                       {
-                               menuitem_mode_selected_jumps_simple.Visible = true;
-                               notebooks_change(0);
-                               on_extra_window_jumps_test_changed(new object(), new EventArgs());
-                               hbox_results_legend.Visible = true;
-                               notebook_capture_analyze.GetNthPage(2).Show(); //show jumpsProfile on jumps 
simple
-                       } else 
-                       {
-                               menuitem_mode_selected_jumps_reactive.Visible = true;
-                               notebooks_change(1);
-                               on_extra_window_jumps_rj_test_changed(new object(), new EventArgs());
-                               hbox_results_legend.Visible = false;
-                               notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on jumps 
reactive
-                       }
-               }
-               else if(m == Constants.Menuitem_modes.RUNSSIMPLE || m == 
Constants.Menuitem_modes.RUNSINTERVALLIC)
-               {
-                       notebook_sup.CurrentPage = 0;
-                       notebook_capture_analyze.ShowTabs = true;
-
-                       menuitem_import_chronojump_session.Visible = false;     // not implemented yet
-
-                       if(m == Constants.Menuitem_modes.RUNSSIMPLE) 
-                       {
-                               menuitem_mode_selected_runs_simple.Visible = true;
-                               notebooks_change(2);
-                               on_extra_window_runs_test_changed(new object(), new EventArgs());
-                               hbox_results_legend.Visible = true;
-                       }
-                       else
-                       {
-                               menuitem_mode_selected_runs_intervallic.Visible = true;
-                               notebooks_change(3);
-                               on_extra_window_runs_interval_test_changed(new object(), new EventArgs());
-                               hbox_results_legend.Visible = false;
-                       }
-                       notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on runs
-               }
-               else if(m == Constants.Menuitem_modes.POWERGRAVITATORY || m == 
Constants.Menuitem_modes.POWERINERTIAL) 
-               {
-                       menuitem_encoder_session_overview.Visible = true;
-                       menuitem_export_encoder_signal.Visible = true;
-                       menuitem_export_csv.Visible = false;
-
-                       menuitem_import_chronojump_session.Visible = false;     // not implemented yet
-                       
-                       //on OSX R is not installed by default. Check if it's installed. Needed for encoder
-                       if( UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX &&
-                                       ! Util.FileExists(Constants.ROSX) )
-                       {
-                               new DialogMessage(Constants.MessageTypes.WARNING,
-                                               Catalog.GetString("Sorry, R software is not installed.") +
-                                               "\n" + Catalog.GetString("Please, install it from here:") +
-                                               "\n\nhttp://cran.cnr.berkeley.edu/bin/macosx/R-latest.pkg";);
-                               return;
-                       }
-
-                       notebook_sup.CurrentPage = 1;
-
-
-                       /*
-                        * If there's a signal on gravitatory and we move to inertial, 
-                        * interface has to change to YESPERSON (meaning no_signal).
-                        * But, if there's no person shoud continue on NOPERSON
-                        */
-                       if(selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0))
-                               encoderButtonsSensitive(encoderSensEnum.YESPERSON);
-                       
-                       blankEncoderInterface();
-
-                       bool changed = false;
-                       if(m == Constants.Menuitem_modes.POWERGRAVITATORY) {
-                               menuitem_mode_selected_power_gravitatory.Visible = true;
-
-                               //change encoderConfigurationCurrent if needed
-                               if(encoderConfigurationCurrent.has_inertia) {
-                                       encoderConfigurationCurrent = new EncoderConfiguration(); //LINEAR, 
not INERTIAL
-                                       changed = true;
-                               }
-                               
-                               currentEncoderGI = Constants.EncoderGI.GRAVITATORY;
-                               hbox_capture_1RM.Visible = true;
-                               notebook_encoder_capture_extra_mass.CurrentPage = 0;
-                               if(radio_encoder_analyze_individual_current_set.Active || 
radio_encoder_analyze_individual_current_session.Active) {
-                                       radiobutton_encoder_analyze_1RM.Visible = true;
-                                       radiobutton_encoder_analyze_neuromuscular_profile.Visible = true;
-                               }
-                               hbox_encoder_capture_1_or_cont.Visible = true;
-                       } else {
-                               menuitem_mode_selected_power_inertial.Visible = true;
-
-                               //change encoderConfigurationCurrent if needed
-                               if(! encoderConfigurationCurrent.has_inertia) {
-                                       encoderConfigurationCurrent = new EncoderConfiguration(
-                                                       
Constants.EncoderConfigurationNames.ROTARYAXISINERTIAL);        
-                                       encoderConfigurationCurrent.SetInertialDefaultOptions();
-                                       changed = true;
-                               }
-                               
-                               currentEncoderGI = Constants.EncoderGI.INERTIAL;
-                               hbox_capture_1RM.Visible = false;
-                               notebook_encoder_capture_extra_mass.CurrentPage = 1;
-                               radiobutton_encoder_analyze_1RM.Visible = false;
-                               radiobutton_encoder_analyze_neuromuscular_profile.Visible = false;
-                               
-                               radio_encoder_capture_1set.Active = true;
-                               hbox_encoder_capture_1_or_cont.Visible = false;
-                       }
-                       encoderGuiChangesAfterEncoderConfigurationWin(true);
-                       if(changed) {
-                               prepareAnalyzeRepetitions ();
-                       }
-               } 
-               else {  //m == Constants.Menuitem_modes.OTHER (contacts / other)
-                       notebook_sup.CurrentPage = 0;
-                       hbox_other.Visible = true;
-                       menuitem_mode_selected_other.Visible = true;
-                       radio_mode_reaction_times_small.Active = true;
-
-                       notebook_capture_analyze.CurrentPage = 0;
-                       notebook_capture_analyze.ShowTabs = false; //only capture tab is shown (only valid 
for "OTHER" tests)
-                       //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
-               }
-
-               //show the program
-               notebook_start.CurrentPage = 1;
-
-               //it's not visible at startup
-               main_menu.Visible = true;
-
-
-               //if wizard has been used mark Chronopic as connected or disconnected depending if port exists
-               if(Constants.Menuitem_mode_IsContacts(m) && wizardPortContacts != "")
-                       chronopicWin.Connected =
-                               Util.FoundInStringArray(ChronopicPorts.GetPorts(), wizardPortContacts);
-               else if(! Constants.Menuitem_mode_IsContacts(m) && wizardPortEncoder != "")
-                       chronopicWin.Connected =
-                               Util.FoundInStringArray(ChronopicPorts.GetPorts(), wizardPortEncoder);
-
-
-               //change multitest firmware or autoDetectChronopic
-               if(Constants.Menuitem_mode_IsContacts(m))
-               {
-                       if(chronopicWin.Connected)
-                               change_multitest_firmware(m);
-                       else
-                               autoDetectChronopic(m); //on contacts will perform change_multitest_firmware 
at the end
-               }
-               else if(wizardPortEncoder == "")
-                       autoDetectChronopic(m);
-
-               chronojumpWindowTestsNext();
-       }
-       
-       ChronopicDetect cpDetect;
-       private void autoDetectChronopic(Constants.Menuitem_modes m)
-       {
-               main_menu.Sensitive = false;
-
-               if(m == Constants.Menuitem_modes.POWERGRAVITATORY || m == 
Constants.Menuitem_modes.POWERINERTIAL) 
-               {
-                       hbox_chronopic_encoder_detecting.Visible = true;
-                       viewport_chronopic_encoder.Visible = false;
-
-                       cpDetect = new ChronopicDetect(
-                                       chronopicWin.SP,
-                                       progressbar_chronopic_encoder_detecting, 
-                                       button_chronopic_encoder_detecting_cancel,
-                                       button_chronopic_encoder_detecting_info,
-                                       configAutodetectPort
-                                       );
-                       
-                       cpDetect.Detect("ENCODER");
-
-                       cpDetect.FakeButtonDone.Clicked += new 
EventHandler(on_autoDetectChronopic_encoder_done);
-               } 
-               else {
-                       //disabled on Windows until is fixed //TODO
-                       if(UtilAll.IsWindows()) {
-                               main_menu.Sensitive = true;
-                               return;
-                       }
-
-                       hbox_chronopic_detecting.Visible = true;
-                       viewport_chronopics.Visible = false;
-
-                       cpDetect = new ChronopicDetect(
-                                       chronopicWin.SP,
-                                       progressbar_chronopic_detecting, 
-                                       button_chronopic_detecting_cancel,
-                                       button_chronopic_detecting_info,
-                                       configAutodetectPort
-                                       );
-                       
-                       cpDetect.Detect("NORMAL");
-
-                       cpDetect.FakeButtonDone.Clicked += new 
EventHandler(on_autoDetectChronopic_normal_done);
-               }
-       }
-       private void on_autoDetectChronopic_encoder_done(object o, EventArgs args) 
-       {
-               cpDetect.FakeButtonDone.Clicked -= new EventHandler(on_autoDetectChronopic_encoder_done);
-                       
-               hbox_chronopic_encoder_detecting.Visible = false;
-               viewport_chronopic_encoder.Visible = true;
-               
-               string str = cpDetect.Detected;
-
-               if(str != null && str != "") {
-                       LogB.Information("Detected at port: " + str);
-                       createChronopicWindow(true, str);
-               }
-               else {
-                       LogB.Information("Not detected.");
-                       createChronopicWindow(true, Util.GetDefaultPort());
-               }
-       
-               on_autoDetectChronopic_all_done();
-       }
-       private void on_autoDetectChronopic_normal_done(object o, EventArgs args) 
-       {
-               cpDetect.FakeButtonDone.Clicked -= new EventHandler(on_autoDetectChronopic_normal_done);
-                       
-               hbox_chronopic_detecting.Visible = false;
-               viewport_chronopics.Visible = true;
-       
-               string str = cpDetect.Detected;
-
-               if(str != null && str != "") {
-                       LogB.Information("Detected at port: " + str);
-
-                       //set connected stuff for chronopicWin
-                       chronopicWin.Connected = true;
-               
-                       //set cpd for chronopicWin
-                       ChronopicPortData cpd = new ChronopicPortData(1, str, true);
-                       ArrayList cpdArray = new ArrayList();
-                       cpdArray.Add(cpd);
-                       
-                       LogB.Debug("chronopicWin is null? " + (chronopicWin == null).ToString());
-                       LogB.Debug("chronopicWin.CP is null? " + (chronopicWin.CP == null).ToString());
-                       
-                       createChronopicWindow(cpDetect.getCP(), cpdArray, true, str);
-                       
-                       LogB.Debug("chronopicWin.CP is null? " + (chronopicWin.CP == null).ToString());
-               
-                       change_multitest_firmware(getMenuItemMode());
-               }
-               else {
-                       LogB.Information("Not detected.");
-                       createChronopicWindow(true, Util.GetDefaultPort());
-               }
-       
-               on_autoDetectChronopic_all_done();
-       }
-       private void on_autoDetectChronopic_all_done() 
-       {
-               main_menu.Sensitive = true;
-       }
-               
-       private bool previousMultitestFirmwareDefined = false;
-       private Constants.Menuitem_modes previousMultitestFirmware;
-
-       //change debounce time automatically on change menuitem mode (if multitest firmware)
-       private void change_multitest_firmware(Constants.Menuitem_modes m) 
-       {
-               LogB.Information("change_multitest_firmware");
-
-               //---- 1 if don't need to change, return
-               if(previousMultitestFirmwareDefined && 
-                               ! Constants.Menuitem_mode_multitest_should_change(previousMultitestFirmware, 
m)) 
-               {
-                       LogB.Information("don't need to change multitest firmware");
-                       return;
-               }
-
-               label_chronopics_multitest.Text = "";
-               
-               //---- 2 if is not connected, return
-               
-               if(! chronopicWin.Connected)
-                       return;
-
-               //---- 3 if port does not exists, show cp window and return
-
-               //http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
-               //https://bugzilla.xamarin.com/show_bug.cgi?id=15514
-               if(! UtilAll.IsWindows ()) {
-                       if(! File.Exists(chronopicWin.GetContactsFirstPort())) {
-                               LogB.Information("Chronopic has been disconnected");
-                               createChronopicWindow(true, "");
-                               chronopicWin.Connected = false;
-                               return;
-                       }
-               }
-
-               LogB.Information("change_multitest_firmware 1");
-               
-               LogB.Debug("chronopicWin is null? " + (chronopicWin == null).ToString());
-
-               int cps = chronopicWin.NumConnected();
-               LogB.Debug("cps: " + cps.ToString());
-               
-               LogB.Debug("chronopicWin.Connected? " + chronopicWin.Connected.ToString());
-               
-               Chronopic.Plataforma ps;
-               bool ok = (chronopicWin.CP).Read_platform(out ps);
-               if(!ok) {
-                       LogB.Information("Chronopic has been disconnected");
-                       createChronopicWindow(true, "");
-                       chronopicWin.Connected = false;
-                       return;
-               }
-
-       
-               LogB.Information("change_multitest_firmware 2");
-               ChronopicAuto ca;
-       
-               /*      
-               try {
-                       ca = new ChronopicAutoCheck();
-                       //problems with windows using this:
-                       string chronopicVersion = ca.Read(chronopicWin.SP);
-                       LogB.Debug("version: " + chronopicVersion);
-               } catch {
-                       LogB.Information("Could not read from Chronopic with method 1");
-                       return;
-               }
-               */
-
-               //---- 4 try to communicate with multitest firmware (return if cannot connect)
-               
-               LogB.Information("Trying method 2");
-               bool isChronopicAuto = false;
-               try {
-                       string result = chronopicWin.CheckAuto(out isChronopicAuto);
-                       LogB.Debug("version: " + result);
-               } catch {
-                       LogB.Information("Could not read from Chronopic with method 2");
-                       return;
-               }
-               
-               //---- 5 change 10 <-> 50 ms
-
-               LogB.Information("change_multitest_firmware 3");
-               if(isChronopicAuto) {
-                       int debounceChange = 50;
-                       if(m == Constants.Menuitem_modes.RUNSSIMPLE || m == 
Constants.Menuitem_modes.RUNSINTERVALLIC)
-                               debounceChange = 10;
-
-                       int msChanged = chronopicWin.ChangeMultitestFirmware(debounceChange);
-                       if(msChanged != -1) {
-                               if(msChanged == 50)
-                                       label_chronopics_multitest.Text = "[" + Catalog.GetString("Jumps") + 
"]";
-                               else if(msChanged == 10)
-                                       label_chronopics_multitest.Text = "[" + Catalog.GetString("Runs") + 
"]";
-                               else
-                                       label_chronopics_multitest.Text = "";
-                       } else
-                               label_chronopics_multitest.Text = "";
-               }
-       
-               previousMultitestFirmwareDefined = true;
-               previousMultitestFirmware = m;
-       }
-
-       private Constants.Menuitem_modes getMenuItemMode() 
-       {
-               if(radio_menuitem_mode_jumps_simple.Active)
-                       return Constants.Menuitem_modes.JUMPSSIMPLE;
-               else if(radio_menuitem_mode_jumps_reactive.Active)
-                       return Constants.Menuitem_modes.JUMPSREACTIVE;
-               else if(radio_menuitem_mode_runs_simple.Active)
-                       return Constants.Menuitem_modes.RUNSSIMPLE;
-               else if(radio_menuitem_mode_runs_intervallic.Active)
-                       return Constants.Menuitem_modes.RUNSINTERVALLIC;
-               else if(radio_menuitem_mode_power_gravitatory.Active)
-                       return Constants.Menuitem_modes.POWERGRAVITATORY;
-               else if(radio_menuitem_mode_power_inertial.Active)
-                       return Constants.Menuitem_modes.POWERINERTIAL;
-               else // if(radio_menuitem_mode_other.Active)
-                       return Constants.Menuitem_modes.OTHER;
-       }
-
-       private void reset_buttons_selector_start_from_gui(object o, EventArgs args) {
-               reset_buttons_selector_start();
-       }
-       private void reset_buttons_selector_start()
-       {
-               notebook_selector_start_jumps.CurrentPage = 0;
-               notebook_selector_start_runs.CurrentPage = 0;
-               notebook_selector_start_encoder.CurrentPage = 0;
-       }
-
-       private void on_radio_menuitem_mode_activate(object o, EventArgs args) 
-       {
-               //togglebutton sends signal two times (deactivate/activate), just get the good signal
-               //http://stackoverflow.com/questions/10755541/mono-gtk-radiobutton-clicked-event-firing-twice
-               if( ! (o as Gtk.RadioMenuItem).Active )
-                       return;
-               
-               select_menuitem_mode_toggled(getMenuItemMode());
-       }
-
-       private void on_button_selector_start_jumps_clicked(object o, EventArgs args) 
-       {
-               notebook_selector_start_jumps.CurrentPage = 1;
-               notebook_selector_start_runs.CurrentPage = 0;
-               notebook_selector_start_encoder.CurrentPage = 0;
-       }
-       private void on_button_selector_start_jumps_simple_clicked(object o, EventArgs args) 
-       {
-               if(radio_menuitem_mode_jumps_simple.Active) {
-                       //needed if people select again the same option
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.JUMPSSIMPLE);
-               }
-               else
-                       radio_menuitem_mode_jumps_simple.Active = true;
-       }
-       private void on_button_selector_start_jumps_reactive_clicked(object o, EventArgs args) 
-       {
-               if(radio_menuitem_mode_jumps_reactive.Active)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.JUMPSREACTIVE);
-               else
-                       radio_menuitem_mode_jumps_reactive.Active = true;
-       }
-       
-       private void on_button_selector_start_runs_clicked(object o, EventArgs args) 
-       {
-               notebook_selector_start_jumps.CurrentPage = 0;
-               notebook_selector_start_runs.CurrentPage = 1;
-               notebook_selector_start_encoder.CurrentPage = 0;
-       }
-       private void on_button_selector_start_runs_simple_clicked(object o, EventArgs args)
-       {
-               if(radio_menuitem_mode_runs_simple.Active)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSSIMPLE);
-               else
-                       radio_menuitem_mode_runs_simple.Active = true;
-       }
-       private void on_button_selector_start_runs_intervallic_clicked(object o, EventArgs args) 
-       {
-               if(radio_menuitem_mode_runs_intervallic.Active)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSINTERVALLIC);
-               else
-                       radio_menuitem_mode_runs_intervallic.Active = true;
-       }
-       
-       private void on_button_selector_start_encoder_clicked(object o, EventArgs args) 
-       {
-               notebook_selector_start_jumps.CurrentPage = 0;
-               notebook_selector_start_runs.CurrentPage = 0;
-               notebook_selector_start_encoder.CurrentPage = 1;
-       }
-       private void on_button_selector_start_encoder_gravitatory_clicked(object o, EventArgs args) 
-       {
-               if(radio_menuitem_mode_power_gravitatory.Active)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY);
-               else
-                       radio_menuitem_mode_power_gravitatory.Active = true;
-       }
-       private void on_button_selector_start_encoder_inertial_clicked(object o, EventArgs args) 
-       {
-               if(radio_menuitem_mode_power_inertial.Active)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERINERTIAL);
-               else
-                       radio_menuitem_mode_power_inertial.Active = true;
-       }
-       
-       private void on_button_selector_start_other_clicked(object o, EventArgs args) 
-       {
-               if(radio_menuitem_mode_other.Active)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.OTHER);
-               else
-                       radio_menuitem_mode_other.Active = true;
-       }
-       
-       /*
-        * end of menu test selectors
-        */
-
-       
-
-       /*
-        * videoOn
-        */
-       
-
-       //at what tab of notebook_sup there's the video_capture
-       private int video_capture_notebook_sup = 0;
-
-       //changed by user clicking on notebook tabs
-       private void on_notebook_sup_switch_page (object o, SwitchPageArgs args) {
-               if( 
-                               (notebook_sup.CurrentPage == 0 && video_capture_notebook_sup == 1) ||
-                               (notebook_sup.CurrentPage == 1 && video_capture_notebook_sup == 0)) 
-               {
-                       //first stop showing video
-                       bool wasActive = false;
-                       if(checkbutton_video.Active) {
-                               wasActive = true;
-                               checkbutton_video.Active = false;
-                       }
-
-                       if(notebook_sup.CurrentPage == 0) {
-                               //remove video capture from encoder tab
-                               viewport_video_capture_encoder.Remove(capturer);
-                               //add in contacts tab
-                               hbox_video_capture.PackStart(capturer, true, true, 0);
-                       } else {
-                               //remove video capture from contacts tab
-                               hbox_video_capture.Remove(capturer);
-                               //add in encoder tab
-
-                               //switch to capture tab                 
-                               radiobutton_video_encoder_capture.Active = true;
-
-                               //sometimes it seems is not removed and then cannot be added again
-                               //just add if not exists
-                               //maybe this error was because before we were not doing the:
-                               //radiobutton_video_encoder_capture.Active = true;
-                               if(viewport_video_capture_encoder.Child == null)
-                                       viewport_video_capture_encoder.Add(capturer);
-                       }
-               
-                       if(wasActive) 
-                               checkbutton_video.Active = true;
-               
-                       video_capture_notebook_sup = notebook_sup.CurrentPage;
-               }
-       }
-
-       CapturerBin capturer;
-       private void videoCaptureInitialize() 
-       {
-               capturer = new CapturerBin();
-               
-               hbox_video_capture.PackStart(capturer, true, true, 0);
-               
-               videoCapturePrepare(false); //if error, show message
-       }
-
-       int videoDeviceNum = 0; 
-       private void videoCapturePrepare(bool showErrorMessage) {
-               LogB.Information("videoCapturePPPPPPPPPPPPPPPPPrepare");
-               List<LongoMatch.Video.Utils.Device> devices = 
LongoMatch.Video.Utils.Device.ListVideoDevices();
-               if(devices.Count == 0) {
-                       if(showErrorMessage)
-                               new DialogMessage(Constants.MessageTypes.WARNING, Constants.CameraNotFound);
-                       return;
-               }
-
-
-               CapturePropertiesStruct s = new CapturePropertiesStruct();
-
-               s.OutputFile = Util.GetVideoTempFileName();
-
-               s.VideoBitrate =  1000;
-               s.AudioBitrate =  128;
-               s.CaptureSourceType = CaptureSourceType.System;
-               s.Width = 360;
-               s.Height = 288;
-               
-               foreach(LongoMatch.Video.Utils.Device dev in devices){
-                       LogB.Information(dev.ID.ToString());
-                       LogB.Information(dev.IDProperty.ToString());
-                       LogB.Information(dev.DeviceType.ToString());
-               }
-                       
-               s.DeviceID = devices[videoDeviceNum].ID;
-               
-
-               capturer.CaptureProperties = s;
-
-               //checkbutton_video and checkbutton_video_encoder are synchronized
-               if(checkbutton_video.Active)
-                       capturer.Type = CapturerType.Live;
-               else
-                       capturer.Type = CapturerType.Fake;
-               capturer.Visible=true;
-
-               try {
-                       capturer.Stop();
-               } catch {}
-               capturer.Run();
-       }
-       
-       
-       private void changeVideoButtons(bool myVideo) {
-               image_video_yes.Visible = myVideo;
-               image_video_no.Visible = ! myVideo;
-       }
-       
-       private void on_checkbutton_video_clicked(object o, EventArgs args) {
-               if(checkbutton_video.Active) {
-                       preferences.videoOn = true;
-                       SqlitePreferences.Update("videoOn", "True", false);
-               } else {
-                       preferences.videoOn = false;
-                       SqlitePreferences.Update("videoOn", "False", false);
-               }
-               //change encoder checkbox but don't raise the signal    
-               checkbutton_video_encoder.Clicked -= new EventHandler(on_checkbutton_video_encoder_clicked);
-               checkbutton_video_encoder.Active = preferences.videoOn;
-               checkbutton_video_encoder.Clicked += new EventHandler(on_checkbutton_video_encoder_clicked);
-               
-               changeVideoButtons(preferences.videoOn);
-               
-               videoCapturePrepare(true); //if error, show message
-       }
-
-       private void on_checkbutton_video_encoder_clicked(object o, EventArgs args) {
-               if(checkbutton_video_encoder.Active) {
-                       preferences.videoOn = true;
-                       SqlitePreferences.Update("videoOn", "True", false);
-               } else {
-                       preferences.videoOn = false;
-                       SqlitePreferences.Update("videoOn", "False", false);
-               }
-               //change contacts checkbox but don't raise the signal   
-               checkbutton_video.Clicked -= new EventHandler(on_checkbutton_video_clicked);
-               checkbutton_video.Active = preferences.videoOn;
-               checkbutton_video.Clicked += new EventHandler(on_checkbutton_video_clicked);
-               
-               //changeVideoButtons(preferences.videoOn);
-       
-               //will start on record  
-               videoCapturePrepare(true); //if error, show message
-       }
-
-
-       /*
-        * cancel and finish
-        */
-
-
-       private void on_cancel_clicked (object o, EventArgs args) 
-       {
-               event_execute_ButtonCancel.Clicked -= new EventHandler(on_cancel_clicked);
-
-               LogB.Information("cancel clicked one");
-
-               //this will cancel jumps or runs
-               currentEventExecute.Cancel = true;
-
-               if(chronopicWin.Connected)
-                       checkCancelTotally(o, args);
-
-               //let update stats
-               //nothing changed, but stats update button cannot be insensitive,
-               //because probably some jump type has changed it's jumper
-               //the unsensitive of button stats is for showing the user, that he has to update manually
-               //because it's not automatically updated
-               //because it crashes in some thread problem
-               //that will be fixed in other release
-               //if(createdStatsWin)
-               //      showUpdateStatsAndHideData(true);
-       }
-       
-       private void on_cancel_multi_clicked (object o, EventArgs args) 
-       {
-               LogB.Information("cancel multi clicked one");
-
-               //this will cancel jumps or runs
-               currentEventExecute.Cancel = true;
-
-               if(chronopicWin.Connected)
-                       checkCancelMultiTotally(o, args);
-       }
-
-
-       //if user doesn't touch the platform after pressing "cancel", sometimes it gets waiting a Read_event
-       //now the event cancels ok, and next will be ok, also   
-       private void checkCancelTotally (object o, EventArgs args) 
-       {
-               if(currentEventExecute.TotallyCancelled) 
-                       LogB.Information("totallyCancelled");
-               else {
-                       LogB.Information("NOT-totallyCancelled ");
-                       errorWin = ErrorWindow.Show(Catalog.GetString("Please, touch the contact platform for 
full cancelling.") + "\n" +
-                                       Catalog.GetString("Then press Accept") + "\n");
-                       errorWin.Button_accept.Clicked -= new EventHandler(checkCancelTotally);
-                       errorWin.Button_accept.Clicked += new EventHandler(checkCancelTotally);
-                       
-                       //abort test when there are problems with USB disconnected      
-                       errorWin.Show_button_abort();
-                       errorWin.Button_abort.Clicked += new EventHandler(abortTest);
-               }
-       }
-       
-       private void checkCancelMultiTotally (object o, EventArgs args) 
-       {
-               bool needCancel1 = false;
-               bool needCancel2 = false;
-               bool needCancel3 = false;
-               bool needCancel4 = false;
-                       
-               needCancel1 = !currentEventExecute.TotallyCancelledMulti1;
-               if(currentEventExecute.Chronopics > 1) {
-                       needCancel2 = !currentEventExecute.TotallyCancelledMulti2;
-                       if(currentEventExecute.Chronopics > 2) {
-                               needCancel3 = !currentEventExecute.TotallyCancelledMulti3;
-                               if(currentEventExecute.Chronopics > 3)
-                                       needCancel4 = !currentEventExecute.TotallyCancelledMulti4;
-                       }
-               }
-
-               if(needCancel1 || needCancel2 || needCancel3 || needCancel4) {
-//                     LogB.Information("NOT-totallyCancelled ");
-                       string cancelStr = "";
-                       string sep = "";
-                       if(needCancel1) {
-                               cancelStr += sep + "1";
-                               sep = ", ";
-                       }
-                       if(needCancel2) {
-                               cancelStr += sep + "2";
-                               sep = ", ";
-                       }
-                       if(needCancel3) {
-                               cancelStr += sep + "3";
-                               sep = ", ";
-                       }
-                       if(needCancel4) {
-                               cancelStr += sep + "4";
-                               sep = ", ";
-                       }
-
-                       errorWin = ErrorWindow.Show(string.Format(Catalog.GetString("Please, touch the 
contact platform on Chronopic/s [{0}] for full cancelling.\nThen press button\n"), cancelStr));
-                       errorWin.Button_accept.Clicked += new EventHandler(checkCancelMultiTotally);
-               }
-       }
-               
-               
-       private void on_finish_clicked (object o, EventArgs args) 
-       {
-               currentEventExecute.Finish = true;
-       
-               if(chronopicWin.Connected)
-                       checkFinishTotally(o, args);
-               
-               //let update stats
-               if(createdStatsWin)
-                       showUpdateStatsAndHideData(true);
-       }
-               
-       //mark to only get inside on_multi_chronopic_finished one time
-       //static bool multiFinishingByClickFinish;
-       private void on_finish_multi_clicked (object o, EventArgs args) 
-       {
-               /*
-               if(multiFinishingByClickFinish)
-                       return;
-               else
-                       multiFinishingByClickFinish =  true;
-                       */
-
-               currentEventExecute.Finish = true;
-               
-               //runA is not called for this, because it ends different
-               //and there's a message on gui/eventExecute.cs for runA 
-               LogB.Debug("RR1");
-               if(currentMultiChronopicType.Name != Constants.RunAnalysisName && chronopicWin.Connected) {
-                       checkFinishMultiTotally(o, args);
-               }
-               LogB.Debug("RR2");
-               
-               //let update stats
-               //if(createdStatsWin)
-               //      showUpdateStatsAndHideData(true);
-       }
-               
-       //if user doesn't touch the platform after pressing "finish", sometimes it gets waiting a Read_event
-       //now the event finishes ok, and next will be ok
-       //
-       //not for multiChronopic:
-       
-       private void checkFinishTotally (object o, EventArgs args) 
-       {
-               if(currentEventExecute.TotallyFinished) 
-                       LogB.Information("totallyFinished");
-               else {
-                       LogB.Information("NOT-totallyFinished ");
-                       errorWin = ErrorWindow.Show(Catalog.GetString("Please, touch the contact platform for 
full finishing.") + "\n" +
-                                       Catalog.GetString("Then press Accept") + "\n");
-                       errorWin.Button_accept.Clicked -= new EventHandler(checkFinishTotally);
-                       errorWin.Button_accept.Clicked += new EventHandler(checkFinishTotally);
-               
-                       //abort test when there are problems with USB disconnected      
-                       errorWin.Show_button_abort();
-                       errorWin.Button_abort.Clicked += new EventHandler(abortTest);
-               }
-       }
-       
-       private void abortTest (object o, EventArgs args) {
-               errorWin.Button_abort.Clicked -= new EventHandler(abortTest);
-               
-               LogB.Warning("Destroying error window");
-               errorWin.HideAndNull();
-               
-               LogB.Warning("Going to abort thread");
-               currentEventExecute.ThreadAbort();
-               LogB.Warning("Aborted");
-               
-               sensitiveGuiEventDone();
-               LogB.Warning("Sensitivity restored");
-       }
-
-       //runA is not called for this, because it ends different
-       //and there's a message on gui/eventExecute.cs for runA 
-       private void checkFinishMultiTotally (object o, EventArgs args) 
-       {
-               bool needFinish1 = false;
-               bool needFinish2 = false;
-               bool needFinish3 = false;
-               bool needFinish4 = false;
-                       
-               LogB.Information("cfmt 0");
-               needFinish1 = !currentEventExecute.TotallyFinishedMulti1;
-               if(currentEventExecute.Chronopics > 1) {
-                       LogB.Information("cfmt 1");
-                       needFinish2 = !currentEventExecute.TotallyFinishedMulti2;
-                       if(currentEventExecute.Chronopics > 2) {
-                               LogB.Information("cfmt 2");
-                               needFinish3 = !currentEventExecute.TotallyFinishedMulti3;
-                               if(currentEventExecute.Chronopics > 3) {
-                                       LogB.Information("cfmt 3");
-                                       needFinish4 = !currentEventExecute.TotallyFinishedMulti4;
-                               }
-                       }
-               }
-               LogB.Information("cfmt 4");
-
-               if(needFinish1 || needFinish2 || needFinish3 || needFinish4) {
-//                     LogB.Information("NOT-totallyFinishled ");
-                       string cancelStr = "";
-                       string sep = "";
-                       if(needFinish1) {
-                               cancelStr += sep + "1";
-                               sep = ", ";
-                       }
-                       if(needFinish2) {
-                               cancelStr += sep + "2";
-                               sep = ", ";
-                       }
-                       if(needFinish3) {
-                               cancelStr += sep + "3";
-                               sep = ", ";
-                       }
-                       if(needFinish4) {
-                               cancelStr += sep + "4";
-                               sep = ", ";
-                       }
-               
-                       LogB.Information("cfmt 5");
-                       //try here because maybe solves problems in runAnalysis when seem to update the 
eventExecuteWindow at the same time as tries to show this errorWindow
-                               errorWin = ErrorWindow.Show(string.Format(
-                                                       Catalog.GetString("Please, touch the contact platform 
on Chronopic/s [{0}] for full finishing.") + 
-                                                       "\n" + Catalog.GetString("Then press this 
button:\n"), cancelStr));
-                               LogB.Information("cfmt 6");
-                               errorWin.Button_accept.Clicked += new EventHandler(checkFinishMultiTotally);
-                               LogB.Information("cfmt 7");
-                       //}
-               } else {
-                       LogB.Information("totallyFinished");
-                       /*
-                       //call write here, because if done in execute/MultiChronopic, will be called n times 
if n chronopics are working
-                       currentEventExecute.MultiChronopicWrite(false);
-                       currentMultiChronopic = (MultiChronopic) currentEventExecute.EventDone;
-               
-
-                       //if this multichronopic has more chronopics than other in session, then reload 
treeview, else simply add
-                       if(currentMultiChronopic.CPs() != 
SqliteMultiChronopic.MaxCPs(currentSession.UniqueID)) {
-                               treeview_multi_chronopic_storeReset(false);
-                               fillTreeView_multi_chronopic();
-                       } else
-                               myTreeViewMultiChronopic.Add(currentPerson.Name, currentMultiChronopic);
-                       
-                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
-                       showHideActionEventButtons(true, Constants.MultiChronopicName); //show
-               
-                       //unhide buttons for delete last test
-                       sensitiveGuiYesEvent();
-                       */
-               }
-       }
-
-
-       void on_button_execute_test_clicked (object o, EventArgs args) 
-       {
-               //http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
-               //https://bugzilla.xamarin.com/show_bug.cgi?id=15514
-               if(! UtilAll.IsWindows() && chronopicWin.Connected) {
-                       if(! File.Exists(chronopicWin.GetContactsFirstPort())) {
-                               LogB.Information("Chronopic has been disconnected");
-                               createChronopicWindow(true, "");
-                               chronopicWin.Connected = false;
-                               return;
-                       }
-               }
-
-               on_button_execute_test_accepted(o, args);
-       }
-       
-       void on_button_execute_test_accepted (object o, EventArgs args) 
-       {
-               //simulated tests are only allowed on SIMULATED session
-               if(currentSession.Name != Constants.SessionSimulatedName && ! chronopicWin.Connected) {
-                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.SimulatedTestsNotAllowed);
-                       return;
-               }
-               
-               if(radio_menuitem_mode_jumps_simple.Active) 
-               {
-                       LogB.Debug("radio_menuitem_mode_jumps_simple");
-                       on_normal_jump_activate(o, args);
-               }
-               else if(radio_menuitem_mode_jumps_reactive.Active) 
-               {
-                       LogB.Debug("radio_menuitem_mode_jumps_reactive");
-                       on_rj_activate(o, args);
-               }
-               else if(radio_menuitem_mode_runs_simple.Active) {
-                       LogB.Debug("radio_menuitem_mode_runs_simple");
-                       extra_window_runs_distance = (double) extra_window_runs_spinbutton_distance.Value;
-                       
-                       on_normal_run_activate(o, args);
-               }
-               else if(radio_menuitem_mode_runs_intervallic.Active) {
-                       LogB.Debug("radio_mode_runs_i_small");
-                       //RSA runs cannot be simulated because it's complicated to manage the countdown 
event...
-                       if(currentRunIntervalType.IsRSA && !chronopicWin.Connected) {
-                               new DialogMessage(Constants.MessageTypes.WARNING, 
-                                               Catalog.GetString("Sorry, RSA tests cannot be simulated."));
-                               return;
-                       }
-
-                       extra_window_runs_interval_distance = (double) 
extra_window_runs_interval_spinbutton_distance.Value;
-                       extra_window_runs_interval_limit = extra_window_runs_interval_spinbutton_limit.Value;
-                       
-                       on_run_interval_activate(o, args);
-               }
-               else if(radio_mode_reaction_times_small.Active) {
-                       LogB.Debug("radio_mode_rt");
-       
-                       if(extra_window_radio_reaction_time_discriminative.Active)
-                               reaction_time_discriminative_lights_prepare();
-
-                       on_reaction_time_activate (o, args);
-               }
-               else if(radio_mode_pulses_small.Active) {
-                       LogB.Debug("radio_mode_pulses");
-                       on_pulse_activate (o, args);
-               }
-               else if(radio_mode_multi_chronopic_small.Active) {
-                       LogB.Debug("radio_mode_mc");
-                       on_multi_chronopic_start_clicked(o, args);
-               }
-
-               //if a test has been deleted
-               //notebook_results_data changes to page 3: "deleted test"
-               //when a new test is done
-               //this notebook has to poing again to data of it's test
-               change_notebook_results_data();
-       }
-
-       private void change_notebook_results_data()
-       {
-               //there are some notebook_execut pages that have not notebook_results_data pages
-               //like jump simple (0), run simple (2), reaction time (4)
-               if(notebook_execute.CurrentPage == 1) //reactive jump
-                       notebook_results_data.CurrentPage = 0;
-               else if(notebook_execute.CurrentPage == 3) //interval run
-                       notebook_results_data.CurrentPage = 1;
-               else if(notebook_execute.CurrentPage == 5) //pulse
-                       notebook_results_data.CurrentPage = 2;
-       }
-
-       private void changeTestImage(string eventTypeString, string eventName, string fileNameString) {
-               Pixbuf pixbuf; //main image
-               Pixbuf pixbufZoom; //icon of zoom image (if shown can have two different images)
-
-               switch (fileNameString) {
-                       case "LOGO":
-                               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo);
-                               button_image_test_zoom.Hide();
-                       break;
-                       case "":
-                               pixbuf = new Pixbuf (null, Util.GetImagePath(true) + "no_image.png");
-                               button_image_test_zoom.Hide();
-                       break;
-                       default:
-                               pixbuf = new Pixbuf (null, Util.GetImagePath(true) + fileNameString);
-
-                               //button image test zoom will have a different image depending on if there's 
text
-                               //future: change tooltip also
-                               if(eventTypeString != "" && eventName != "" && eventTypeHasLongDescription 
(eventTypeString, eventName))
-                                       pixbufZoom = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameZoomInWithTextIcon);
-                               else 
-                                       pixbufZoom = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameZoomInIcon);
-
-                               image_test_zoom.Pixbuf = pixbufZoom;
-                               button_image_test_zoom.Show();
-                       break;
-               }
-               image_test.Pixbuf = pixbuf;
-       }
-
-       private bool eventTypeHasLongDescription (string eventTypeString, string eventName) {
-               if(eventTypeString != "" && eventName != "")
-               {
-                       EventType myType = new EventType ();
-
-                       if(eventTypeString == EventType.Types.JUMP.ToString()) 
-                               myType = new JumpType(eventName);
-                       else if (eventTypeString == EventType.Types.RUN.ToString()) 
-                               myType = new RunType(eventName);
-                       else if (eventTypeString == EventType.Types.REACTIONTIME.ToString()) 
-                               myType = new ReactionTimeType(eventName);
-                       else if (eventTypeString == EventType.Types.PULSE.ToString()) 
-                               myType = new PulseType(eventName);
-                       else if (eventTypeString == EventType.Types.MULTICHRONOPIC.ToString()) 
-                               myType = new MultiChronopicType(eventName);
-                       else LogB.Error("Error on eventTypeHasLongDescription");
-
-                       if(myType.HasLongDescription)
-                               return true;
-               }
-               return false;
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  JUMPS EXECUTION (no RJ) ----------------
-        *  --------------------------------------------------------
-        */
-
-       
-       //suitable for all jumps not repetitive
-       private void on_normal_jump_activate (object o, EventArgs args) 
-       {
-               if(execute_auto_doing)
-                       sensitiveGuiAutoExecuteOrWait (true);
-               
-               //currentJumpType is already defined in selecting name from combo or from jumpsMoreWin
-               //string jumpEnglishName = Util.FindOnArray(':',2,1, 
UtilGtk.ComboGetActive(combo_select_jumps), selectJumpsString);
-               //currentJumpType = new JumpType(jumpEnglishName);
-
-               double jumpWeight = 0;
-               if(currentJumpType.HasWeight) {
-                       if(extra_window_jumps_option == "%") 
-                               jumpWeight = (double) extra_window_jumps_spinbutton_weight.Value;
-                       else 
-                               jumpWeight = Util.WeightFromKgToPercent(
-                                               (double) extra_window_jumps_spinbutton_weight.Value, 
-                                               currentPersonSession.Weight);
-               }
-               double myFall = 0;
-               if(currentJumpType.HasFall) {
-                       if(extra_window_jumps_check_dj_fall_calculate.Active)
-                               myFall = -1;
-                       else
-                               myFall = (double) extra_window_jumps_spinbutton_fall.Value;
-               }
-
-               string description = "";
-               if(currentJumpType.Name == "slCMJleft" || currentJumpType.Name == "slCMJright") {
-                       description = slCMJString(); 
-
-                       extra_window_jumps_spin_single_leg_distance.Value = 0;
-                       extra_window_jumps_spin_single_leg_angle.Value = 90;
-               }
-                       
-               //used by cancel and finish
-               //currentEventType = new JumpType();
-               currentEventType = currentJumpType;
-                       
-               //hide jumping buttons
-               if(! execute_auto_doing)
-                       sensitiveGuiEventDoing();
-
-               //show the event doing window
-               double progressbarLimit = 3; //3 phases for show the Dj
-               if(myFall == -1)
-                       progressbarLimit = 4; //4 if there's a pre-jump
-               else if( currentJumpType.StartIn || 
-                               currentJumpType.Name == Constants.TakeOffName || 
-                               currentJumpType.Name == Constants.TakeOffWeightName)
-                       progressbarLimit = 2; //2 for normal jump (or take off)
-                       
-               //don't let update until test finishes
-               if(createdStatsWin)
-                       showUpdateStatsAndHideData(false);
-
-               event_execute_initializeVariables(
-                       ! chronopicWin.Connected,       //is simulated
-                       currentPerson.UniqueID, 
-                       currentPerson.Name, 
-                       Catalog.GetString("Phases"),      //name of the different moments
-                       Constants.JumpTable, //tableName
-                       currentJumpType.Name 
-                       );
-               ExecutingGraphData egd = event_execute_prepareForTest ();
-
-               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
-               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
-
-               //when user clicks on update the eventExecute window 
-               //(for showing with his new confgured values: max, min and guides
-               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
-               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
-
-               currentEventExecute = new JumpExecute(currentPerson.UniqueID, currentPerson.Name, 
-                               currentSession.UniqueID, currentJumpType.Name, myFall, jumpWeight,
-                               chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber, 
preferences.volumeOn,
-                               progressbarLimit, egd, description);
-
-
-               UtilGtk.ChronopicColors(viewport_chronopics, label_chronopics, label_connected_chronopics, 
chronopicWin.Connected);
-
-
-               if (!chronopicWin.Connected) 
-                       currentEventExecute.SimulateInitValues(rand);
-               
-               if( currentJumpType.StartIn ) 
-                       currentEventExecute.Manage();
-               else 
-                       currentEventExecute.ManageFall();
-               
-               thisJumpIsSimple = true; //used by: on_event_execute_update_graph_in_progress_clicked
-               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
-                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
-               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
-
-               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_jump_finished);
-               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
-       }       
-       
-
-       private void on_jump_finished (object o, EventArgs args)
-       {
-               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_jump_finished);
-       
-               //test can be deleted if not cancelled
-               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
-
-               if ( ! currentEventExecute.Cancel ) {
-                       currentJump = (Jump) currentEventExecute.EventDone;
-               
-                       if(currentJumpType.Name == "slCMJleft" || currentJumpType.Name == "slCMJright") {
-                               if(extra_window_jumps_radiobutton_single_leg_mode_vertical.Active)
-                                       currentJump.Description += " 0 90";
-                               else {
-                                       currentJump.Description += " 0 90";
-                                       
-                                       //unsensitive slCMJ options 
-                                       hbox_extra_window_jumps_single_leg_radios.Sensitive = false;
-                                       //but show the input cm
-                                       notebook_options_after_execute.CurrentPage = 1;
-                               }
-                               SqliteJump.UpdateDescription(Constants.JumpTable, 
-                                               currentJump.UniqueID, currentJump.Description);
-                       }
-
-                       //move video file if exists
-                       if(preferences.videoOn)
-                               if (! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP, 
currentJump.UniqueID))
-                                       new DialogMessage(Constants.MessageTypes.WARNING, 
-                                                       Catalog.GetString("Sorry, video cannot be stored."));
-
-                       myTreeViewJumps.PersonWeight = currentPersonSession.Weight;
-                       myTreeViewJumps.Add(currentPerson.Name, currentJump);
-                       
-                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
-                       showHideActionEventButtons(true, "Jump"); //show
-               
-                       if(createdStatsWin) {
-                               showUpdateStatsAndHideData(true);
-                       }
-               
-                       lastJumpIsSimple = true;
-               
-                       //unhide buttons for delete last jump
-                       if(! execute_auto_doing)
-                               sensitiveGuiYesEvent();
-               } 
-               else if( currentEventExecute.ChronopicDisconnected )
-                       chronopicDisconnectedWhileExecuting();
-               
-               //unhide buttons that allow jumping
-               if(execute_auto_doing) {
-                       execute_auto_order_pos ++;
-                       execute_auto_select();
-                       sensitiveGuiAutoExecuteOrWait (false);
-               }
-       }
-
-       private void chronopicDisconnectedWhileExecuting() {
-               LogB.Error("DISCONNECTED gui/cj");
-               createChronopicWindow(true, "");
-               chronopicWin.Connected = false;
-       }
-               
-       private void on_test_finished_can_touch_gtk (object o, EventArgs args)
-       {
-               currentEventExecute.FakeButtonThreadDyed.Clicked -= new 
EventHandler(on_test_finished_can_touch_gtk);
-               LogB.Information(" cantouch1 ");
-               if(! execute_auto_doing)
-                       sensitiveGuiEventDone();
-               LogB.Information(" cantouch3 ");
-
-               if ( ! currentEventExecute.Cancel )
-                       event_execute_progressbar_time.Fraction = 1; 
-       }
-
-
-
-       /* ---------------------------------------------------------
-        * ----------------  JUMPS RJ EXECUTION  ------------------
-        *  --------------------------------------------------------
-        */
-       
-       private void on_rj_activate (object o, EventArgs args) 
-       {
-               //currentJumpRjType is already defined in selecting name from combo or from jumpsMoreWin
-               //string jumpEnglishName = Util.FindOnArray(':',2,1, 
UtilGtk.ComboGetActive(combo_select_jumps_rj), selectJumpsRjString);
-               //currentJumpRjType = new JumpType(jumpEnglishName);
-
-               double progressbarLimit = 0;
-               
-               //if it's a unlimited interval run, put -1 as limit value
-               if(currentJumpRjType.Unlimited) {
-                       progressbarLimit = -1;
-               } else {
-                       if(currentJumpRjType.FixedValue > 0) {
-                               progressbarLimit = currentJumpRjType.FixedValue;
-                       } else {
-                               progressbarLimit = (double) extra_window_jumps_rj_spinbutton_limit.Value;
-                       }
-               }
-
-               double jumpWeight = 0;
-               if(currentJumpRjType.HasWeight) {
-                       if(extra_window_jumps_rj_option == "%") {
-                               jumpWeight = (double) extra_window_jumps_rj_spinbutton_weight.Value;
-                       } else {
-                               jumpWeight = Util.WeightFromKgToPercent(
-                                               (double) extra_window_jumps_rj_spinbutton_weight.Value,
-                                               currentPersonSession.Weight);
-                       }
-               }
-               double myFall = 0;
-               if( currentJumpRjType.HasFall || currentJumpRjType.Name == Constants.RunAnalysisName)
-                       myFall = (double) extra_window_jumps_rj_spinbutton_fall.Value;
-                       
-               //used by cancel and finish
-               //currentEventType = new JumpRjType();
-               currentEventType = currentJumpRjType;
-                       
-               //hide jumping buttons
-               sensitiveGuiEventDoing();
-       
-               //don't let update until test finishes
-               if(createdStatsWin)
-                       showUpdateStatsAndHideData(false);
-
-               //show the event doing window
-               event_execute_initializeVariables(
-                       ! chronopicWin.Connected,       //is simulated
-                       currentPerson.UniqueID, 
-                       currentPerson.Name, 
-                       Catalog.GetString("Jumps"),       //name of the different moments
-                       Constants.JumpRjTable, //tableName
-                       currentJumpRjType.Name
-                       );
-               ExecutingGraphData egd = event_execute_prepareForTest ();
-               
-               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
-               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
-               
-               //when user clicks on update the eventExecute window 
-               //(for showing with his new configured values: max, min and guides
-               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
-               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
-       
-               currentEventExecute = new JumpRjExecute(currentPerson.UniqueID, currentPerson.Name, 
-                               currentSession.UniqueID, currentJumpRjType.Name, myFall, jumpWeight, 
-                               progressbarLimit, currentJumpRjType.JumpsLimited, 
-                               chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber,
-                               checkbutton_allow_finish_rj_after_time.Active, preferences.volumeOn, 
-                               repetitiveConditionsWin, progressbarLimit, egd
-                               );
-               
-               
-               //suitable for limited by jump and time
-               //simulated always simulate limited by jumps
-               if(!chronopicWin.Connected) 
-                       currentEventExecute.SimulateInitValues(rand);
-               
-               currentEventExecute.Manage();
-               
-               thisJumpIsSimple = false; //used by: on_event_execute_update_graph_in_progress_clicked
-               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
-                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
-               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
-               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_jump_rj_finished);
-               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
-       }
-               
-       private void on_jump_rj_finished (object o, EventArgs args) 
-       {
-               LogB.Information("ON JUMP RJ FINISHED");
-               
-               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_jump_rj_finished);
-               
-               //test can be deleted if not cancelled
-               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
-
-               if ( ! currentEventExecute.Cancel ) {
-                       currentJumpRj = (JumpRj) currentEventExecute.EventDone;
-                       
-                       //move video file if exists
-                       if(preferences.videoOn)
-                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP_RJ, 
currentJumpRj.UniqueID))
-                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
-
-                       //if user clicked in finish earlier
-                       if(currentEventExecute.Finish) {
-                               currentJumpRj.Jumps = Util.GetNumberOfJumps(currentJumpRj.TvString, false);
-                               if(currentJumpRj.JumpsLimited) {
-                                       currentJumpRj.Limited = currentJumpRj.Jumps.ToString() + "J";
-                               } else {
-                                       currentJumpRj.Limited = Util.GetTotalTime(
-                                                       currentJumpRj.TcString, currentJumpRj.TvString) + "T";
-                               }
-                       }
-
-                       myTreeViewJumpsRj.PersonWeight = currentPersonSession.Weight;
-                       myTreeViewJumpsRj.Add(currentPerson.Name, currentJumpRj);
-                       
-                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
-                       showHideActionEventButtons(true, "JumpRj"); //show
-
-                       if(createdStatsWin) {
-                               showUpdateStatsAndHideData(true);
-                       }
-
-                       lastJumpIsSimple = false;
-
-                       //unhide buttons for delete last jump
-                       sensitiveGuiYesEvent();
-
-                       //put correct time value in eventWindow (put the time from chronopic and not onTimer 
soft chronometer)
-                       event_execute_LabelTimeValue = Util.GetTotalTime(currentJumpRj.TcString, 
currentJumpRj.TvString);
-                       //possible deletion of last jump can make the jumps on event window be false
-                       event_execute_LabelEventValue = currentJumpRj.Jumps;
-               } 
-               else if( currentEventExecute.ChronopicDisconnected )
-                       chronopicDisconnectedWhileExecuting();
-               
-               //delete the temp tables if exists
-               Sqlite.DeleteTempEvents("tempJumpRj");
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  RUNS EXECUTION (no interval) ----------
-        *  --------------------------------------------------------
-        */
-
-       //suitable for all runs not repetitive
-       private void on_normal_run_activate (object o, EventArgs args) 
-       {
-               //if distance can be always different in this run,
-               //show values selected in runExtraWin
-               double myDistance = 0;          
-               if(currentRunType.Distance == 0) {
-                       myDistance = extra_window_runs_distance;
-               } else {
-                       myDistance = currentRunType.Distance;
-               }
-               
-               //used by cancel and finish
-               //currentEventType = new RunType();
-               currentEventType = currentRunType;
-                       
-               //hide jumping (running) buttons
-               sensitiveGuiEventDoing();
-       
-               //show the event doing window
-               
-               double progressbarLimit = 3; //same for startingIn than out (before)
-               
-               //don't let update until test finishes
-               if(createdStatsWin)
-                       showUpdateStatsAndHideData(false);
-
-               event_execute_initializeVariables(
-                       ! chronopicWin.Connected,       //is simulated
-                       currentPerson.UniqueID, 
-                       currentPerson.Name, 
-                       Catalog.GetString("Phases"),      //name of the different moments
-                       Constants.RunTable, //tableName
-                       currentRunType.Name 
-                       );
-               ExecutingGraphData egd = event_execute_prepareForTest ();
-               
-               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
-               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
-
-
-               //when user clicks on update the eventExecute window 
-               //(for showing with his new confgured values: max, min and guides
-               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
-               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
-
-
-               currentEventExecute = new RunExecute(
-                               currentPerson.UniqueID, currentSession.UniqueID, 
-                               currentRunType.Name, myDistance, 
-                               chronopicWin.CP, event_execute_label_message, app1,
-                               preferences.digitsNumber, preferences.metersSecondsPreferred, 
preferences.volumeOn, 
-                               progressbarLimit, egd,
-                               preferences.runDoubleContactsMode,
-                               preferences.runDoubleContactsMS,
-                               preferences.runSpeedStartArrival
-                               );
-               
-               if (!chronopicWin.Connected) 
-                       currentEventExecute.SimulateInitValues(rand);
-                       
-               currentEventExecute.Manage();
-
-               thisRunIsSimple = true; //used by: on_event_execute_update_graph_in_progress_clicked
-               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
-                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
-               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
-               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_run_finished);
-               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
-       }
-       
-       private void on_run_finished (object o, EventArgs args)
-       {
-               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_run_finished);
-               
-               //test can be deleted if not cancelled
-               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
-
-               if ( ! currentEventExecute.Cancel ) {
-                       currentRun = (Run) currentEventExecute.EventDone;
-                       
-                       //move video file if exists
-                       if(preferences.videoOn)
-                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN, 
currentRun.UniqueID))
-                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
-                       
-                       currentRun.MetersSecondsPreferred = preferences.metersSecondsPreferred;
-
-                       myTreeViewRuns.Add(currentPerson.Name, currentRun);
-                       
-                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
-                       showHideActionEventButtons(true, "Run"); //show
-               
-                       if(createdStatsWin) {
-                               showUpdateStatsAndHideData(true);
-                       }
-               
-                       lastRunIsSimple = true;
-
-                       //unhide buttons for delete last jump
-                       sensitiveGuiYesEvent();
-
-                       //put correct time value in eventWindow (put the time from chronopic and not onTimer 
soft chronometer)
-                       event_execute_LabelTimeValue = currentRun.Time;
-               }
-               else if( currentEventExecute.ChronopicDisconnected )
-                       chronopicDisconnectedWhileExecuting();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  RUNS EXECUTION (interval) ----------
-        *  --------------------------------------------------------
-        */
-
-       
-       private void on_run_interval_activate (object o, EventArgs args)
-       {
-               LogB.Information("run interval accepted");
-               
-               //if distance can be always different in this run,
-               //show values selected in runExtraWin
-               double distanceInterval = 0;            
-               if(currentRunIntervalType.Distance == 0) {
-                       distanceInterval = extra_window_runs_interval_distance;
-               } else {
-                       distanceInterval = currentRunIntervalType.Distance;
-               }
-               
-               double progressbarLimit = 0;
-               //if it's a unlimited interval run, put -1 as limit value
-               if(currentRunIntervalType.Unlimited) {
-                       progressbarLimit = -1;
-               } else {
-                       if(currentRunIntervalType.FixedValue > 0) {
-                               progressbarLimit = currentRunIntervalType.FixedValue;
-                       } else {
-                               progressbarLimit = extra_window_runs_interval_limit;
-                       }
-               }
-
-
-               //used by cancel and finish
-               //currentEventType = new RunType();
-               currentEventType = currentRunIntervalType;
-                       
-               //hide running buttons
-               sensitiveGuiEventDoing();
-               
-               //don't let update until test finishes
-               if(createdStatsWin)
-                       showUpdateStatsAndHideData(false);
-
-               //show the event doing window
-               event_execute_initializeVariables(
-                       ! chronopicWin.Connected,       //is simulated
-                       currentPerson.UniqueID, 
-                       currentPerson.Name, 
-                       Catalog.GetString("Tracks"),      //name of the different moments
-                       Constants.RunIntervalTable, //tableName
-                       currentRunIntervalType.Name
-                       );
-               ExecutingGraphData egd = event_execute_prepareForTest ();
-
-               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
-               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
-
-               //when user clicks on update the eventExecute window 
-               //(for showing with his new confgured values: max, min and guides
-               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
-               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
-       
-               currentEventExecute = new RunIntervalExecute(
-                               currentPerson.UniqueID, currentSession.UniqueID, currentRunIntervalType.Name, 
-                               distanceInterval, progressbarLimit, currentRunIntervalType.TracksLimited, 
-                               chronopicWin.CP, event_execute_label_message, app1,
-                               preferences.digitsNumber, preferences.metersSecondsPreferred, 
preferences.volumeOn, repetitiveConditionsWin, 
-                               progressbarLimit, egd,
-                               preferences.runIDoubleContactsMode,
-                               preferences.runIDoubleContactsMS,
-                               preferences.runSpeedStartArrival
-                               );
-               
-               
-               //suitable for limited by tracks and time
-               if(!chronopicWin.Connected)
-                       currentEventExecute.SimulateInitValues(rand);
-                       
-               currentEventExecute.Manage();
-               
-               thisRunIsSimple = false; //used by: on_event_execute_update_graph_in_progress_clicked
-               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
-                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
-               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
-               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_run_interval_finished);
-               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
-       }
-
-
-       private void on_run_interval_finished (object o, EventArgs args) 
-       {
-               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_run_interval_finished);
-               
-               //test can be deleted if not cancelled
-               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
-
-               if ( ! currentEventExecute.Cancel ) {
-                       currentRunInterval = (RunInterval) currentEventExecute.EventDone;
-
-                       //move video file if exists
-                       if(preferences.videoOn)
-                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN_I, 
currentRunInterval.UniqueID))
-                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
-
-                       currentRunInterval.MetersSecondsPreferred = preferences.metersSecondsPreferred;
-
-                       //if user clicked in finish earlier
-                       if(currentEventExecute.Finish) {
-                               currentRunInterval.Tracks = 
Util.GetNumberOfJumps(currentRunInterval.IntervalTimesString, false);
-                               if(currentRunInterval.TracksLimited) {
-                                       currentRunInterval.Limited = currentRunInterval.Tracks.ToString() + 
"R";
-                               } else {
-                                       currentRunInterval.Limited = Util.GetTotalTime(
-                                                       currentRunInterval.IntervalTimesString) + "T";
-                               }
-                       }
-                       myTreeViewRunsInterval.Add(currentPerson.Name, currentRunInterval);
-                       
-                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
-                       showHideActionEventButtons(true, "RunInterval"); //show
-
-                       if(createdStatsWin) {
-                               showUpdateStatsAndHideData(true);
-                       }
-
-                       lastRunIsSimple = false;
-
-                       //unhide buttons for delete last jump
-                       sensitiveGuiYesEvent();
-
-                       //put correct time value in eventWindow (put the time from chronopic and not onTimer 
soft chronometer)
-                       event_execute_LabelTimeValue = currentRunInterval.TimeTotal;
-                       //possible deletion of last run can make the runs on event window be false
-                       event_execute_LabelEventValue = currentRunInterval.Tracks;
-               }
-               else if( currentEventExecute.ChronopicDisconnected )
-                       chronopicDisconnectedWhileExecuting();
-               
-               //delete the temp tables if exists
-               Sqlite.DeleteTempEvents("tempRunInterval");
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  REACTION TIMES EXECUTION --------------
-        *  --------------------------------------------------------
-        */
-
-       
-       //suitable for reaction times
-       private void on_reaction_time_activate (object o, EventArgs args) 
-       {
-               //used by cancel and finish
-               currentEventType = new ReactionTimeType();
-                       
-               //hide jumping buttons
-               sensitiveGuiEventDoing();
-
-               //show the event doing window
-               double progressbarLimit = 2;
-                       
-               //don't let update until test finishes
-               if(createdStatsWin)
-                       showUpdateStatsAndHideData(false);
-
-               event_execute_initializeVariables(
-                       ! chronopicWin.Connected,       //is simulated
-                       currentPerson.UniqueID, 
-                       currentPerson.Name, 
-                       Catalog.GetString("Phases"),      //name of the different moments
-                       Constants.ReactionTimeTable, //tableName
-                       "" 
-                       );
-               ExecutingGraphData egd = event_execute_prepareForTest ();
-
-               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
-               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
-
-               //when user clicks on update the eventExecute window 
-               //(for showing with his new confgured values: max, min and guides
-               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
-               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
-
-               string sep = "";
-               string description = "";
-               if(extra_window_radio_reaction_time_discriminative.Active) {
-                       if(check_reaction_time_disc_red.Active == true) {
-                               description += sep + Catalog.GetString("red");
-                               sep = " + ";
-                       }
-                       if(check_reaction_time_disc_yellow.Active == true) {
-                               description += sep + Catalog.GetString("yellow");
-                               sep = " + ";
-                       }
-                       if(check_reaction_time_disc_green.Active == true) {
-                               description += sep + Catalog.GetString("green");
-                               sep = " + ";
-                       }
-                       if(check_reaction_time_disc_buzzer.Active == true) {
-                               description += sep + Catalog.GetString("buzzer");
-                               sep = " + ";
-                       }
-               }
-               else if(extra_window_radio_reaction_time_animation_lights.Active)
-                       description = spinbutton_flicker_lights_speed.Value.ToString() + " - " + 
label_animation_lights_interval.Text;
-
-               currentEventExecute = new ReactionTimeExecute(currentPerson.UniqueID, currentPerson.Name, 
-                               currentSession.UniqueID, currentReactionTimeType.Name, 
-                               chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber, 
preferences.volumeOn,
-                               progressbarLimit, egd, description
-                               );
-
-               if (!chronopicWin.Connected) 
-                       currentEventExecute.SimulateInitValues(rand);
-       
-               //not on simulated because results would be always 0
-               if( chronopicWin.Connected &&
-                               (extra_window_radio_reaction_time_discriminative.Active || 
-                                extra_window_radio_reaction_time_animation_lights.Active) )
-                       //TODO: do also for flickr
-                       currentEventExecute.StartIn = false;
-               
-               currentEventExecute.FakeButtonReactionTimeStart.Clicked += new 
EventHandler(on_event_execute_reaction_time_start);
-
-               currentEventExecute.Manage(); //check that platform is ok
-               
-               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
-                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
-               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
-               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_reaction_time_finished);
-               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
-       }       
-
-       private void on_event_execute_reaction_time_start (object o, EventArgs args) 
-       {
-               currentEventExecute.FakeButtonReactionTimeStart.Clicked -= new 
EventHandler(on_event_execute_reaction_time_start);
-
-               //Fire leds or buzzer on discriminative (if not simulated)
-               if(chronopicWin.Connected) {            
-                       if(extra_window_radio_reaction_time_discriminative.Active) {
-                               Thread.Sleep(Convert.ToInt32(discriminativeStartTime * 1000)); //in ms
-
-                               ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
-                               cs.CharToSend = discriminativeCharToSend;
-                               cs.Write(chronopicWin.SP, 0);
-                       }
-                       else if(extra_window_radio_reaction_time_animation_lights.Active) {
-                               int speed = Convert.ToInt32(spinbutton_animation_lights_speed.Value);
-                               ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
-                               cs.CharToSend = "l";
-                               cs.Write(chronopicWin.SP,speed);
-                       }
-
-                       LogB.Information("opening port at gui/chronojump.cs");  
-                       chronopicWin.SP.Open();
-
-                       /*
-                        * some machines needed to flush
-                        * - my Linux laptop two bytes
-                        * - a linux guest on windows host (virtual box) don't need
-                        * Note this will not allow reaction time be lower than 100 ms (DefaultTimeout on 
chronopic.cs)
-                        */
-                       LogB.Information("Going to flush by time out"); //needed on some machines
-                       chronopicWin.CP.FlushByTimeOut();
-                       LogB.Information("flushed!");   
-               }
-
-               currentEventExecute.Manage2();
-       }
-
-
-       private void on_reaction_time_finished (object o, EventArgs args)
-       {
-               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_reaction_time_finished);
-               
-               //test can be deleted if not cancelled
-               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
-
-               if ( ! currentEventExecute.Cancel ) {
-
-                       currentReactionTime = (ReactionTime) currentEventExecute.EventDone;
-                       
-                       //move video file if exists
-                       if(preferences.videoOn)
-                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.RT, 
currentReactionTime.UniqueID))
-                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
-                       
-                       myTreeViewReactionTimes.Add(currentPerson.Name, currentReactionTime);
-                       
-                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
-                       showHideActionEventButtons(true, "ReactionTime"); //show
-               
-                       if(createdStatsWin) {
-                               showUpdateStatsAndHideData(true);
-                       }
-               
-                       //unhide buttons for delete last reaction time
-                       sensitiveGuiYesEvent();
-               }
-               else if( currentEventExecute.ChronopicDisconnected )
-                       chronopicDisconnectedWhileExecuting();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  PULSES EXECUTION ----------------------
-        *  --------------------------------------------------------
-        */
-
-       private void on_pulse_activate (object o, EventArgs args)
-       {
-               LogB.Information("pulse accepted");
-       
-               double pulseStep = 0;
-               int totalPulses = 0;
-
-               if(currentPulseType.Name == "Free") {
-                       pulseStep = currentPulseType.FixedPulse; // -1
-                       totalPulses = currentPulseType.TotalPulsesNum; //-1
-               } else { //custom (info comes from Extra Window
-                       pulseStep = extra_window_pulses_spinbutton_pulse_step.Value;
-                       if(extra_window_pulses_checkbutton_unlimited.Active)
-                               totalPulses = currentPulseType.TotalPulsesNum; //-1
-                       else
-                               totalPulses = Convert.ToInt32(
-                                               extra_window_pulses_spinbutton_total_pulses.Value); //-1: 
unlimited; or 'n': limited by 'n' pulses
-               }
-
-               //used by cancel and finish
-               //currentEventType = new PulseType();
-               currentEventType = currentPulseType;
-                       
-               //hide pulse buttons
-               sensitiveGuiEventDoing();
-               
-               //don't let update until test finishes
-               if(createdStatsWin)
-                       showUpdateStatsAndHideData(false);
-
-               //show the event doing window
-               event_execute_initializeVariables(
-                       ! chronopicWin.Connected,       //is simulated
-                       currentPerson.UniqueID, 
-                       currentPerson.Name, 
-                       Catalog.GetString("Pulses"),      //name of the different moments
-                       Constants.PulseTable, //tableName
-                       currentPulseType.Name 
-                       );
-               ExecutingGraphData egd = event_execute_prepareForTest ();
-
-               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
-               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
-               
-               //when user clicks on update the eventExecute window 
-               //(for showing with his new confgured values: max, min and guides
-               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
-               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
-
-               currentEventExecute = new PulseExecute(currentPerson.UniqueID, currentPerson.Name, 
-                               currentSession.UniqueID, currentPulseType.Name, pulseStep, totalPulses, 
-                               chronopicWin.CP, event_execute_label_message, 
-                               app1, preferences.digitsNumber, preferences.volumeOn, egd
-                               );
-               
-               if(!chronopicWin.Connected)     
-                       currentEventExecute.SimulateInitValues(rand);
-               
-               currentEventExecute.Manage();
-               
-               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
-                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
-               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
-               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_pulse_finished);
-               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
-       }
-
-       private void on_pulse_finished (object o, EventArgs args) 
-       {
-               LogB.Information("pulse finished");
-               
-               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_pulse_finished);
-               
-               //test can be deleted if not cancelled
-               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
-
-               if ( ! currentEventExecute.Cancel ) {
-                       /*
-                        * CURRENTLY NOT NEEDED... check
-                       //if user clicked in finish earlier
-                       if(currentPulse.Finish) {
-                               currentRunInterval.Tracks = 
Util.GetNumberOfJumps(currentRunInterval.IntervalTimesString, false);
-                               if(currentRunInterval.TracksLimited) {
-                                       currentRunInterval.Limited = currentRunInterval.Tracks.ToString() + 
"R";
-                               } else {
-                                       currentRunInterval.Limited = Util.GetTotalTime(
-                                                       currentRunInterval.IntervalTimesString) + "T";
-                               }
-                       }
-                       */
-                       
-                       currentPulse = (Pulse) currentEventExecute.EventDone;
-                       
-                       //move video file if exists
-                       if(preferences.videoOn)
-                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.PULSE, 
currentPulse.UniqueID))
-                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
-
-                       myTreeViewPulses.Add(currentPerson.Name, currentPulse);
-                       
-                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
-                       showHideActionEventButtons(true, "Pulse"); //show
-                       
-                       if(createdStatsWin) {
-                               showUpdateStatsAndHideData(true);
-                       }
-                       
-                       //unhide buttons for delete last jump
-                       sensitiveGuiYesEvent();
-
-                       //put correct time value in eventWindow (put the time from chronopic and not onTimer 
soft chronometer)
-                       event_execute_LabelTimeValue = Util.GetTotalTime(currentPulse.TimesString);
-               }
-               else if( currentEventExecute.ChronopicDisconnected )
-                       chronopicDisconnectedWhileExecuting();
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  MULTI CHRONOPIC EXECUTION -------------
-        *  --------------------------------------------------------
-        */
-
-       //recreate is used when a Chronopic was disconnected
-       //
-       //encoderPort is usually "" and will be Util.GetDefaultPort
-       //but, since 1.5.1 when selecting encoder option from main menu,
-       //then encoderPort will be found and send here
-       
-       //normal call
-       private void createChronopicWindow(bool recreate, string encoderPort) 
-       {
-               ArrayList cpd = new ArrayList();
-               for(int i=1; i<=4;i++) {
-                       ChronopicPortData cpdata = new ChronopicPortData(i,"",false);
-                       cpd.Add(cpdata);
-               }
-               createChronopicWindow(null, cpd, recreate, encoderPort);
-       }
-       //called directly on autodetect (detected cp and cpd is send)
-       private void createChronopicWindow(Chronopic cp, ArrayList cpd, bool recreate, string encoderPort) 
-       {
-               if(encoderPort == "")
-                       encoderPort = Util.GetDefaultPort();
-
-               chronopicWin = ChronopicWindow.Create(cp, cpd, encoderPort, recreate, preferences.volumeOn);
-               //chronopicWin.FakeButtonCancelled.Clicked += new EventHandler(on_chronopic_window_cancelled);
-               
-               if(notebook_sup.CurrentPage == 0) {
-                       int cps = chronopicWin.NumConnected();
-                       LogB.Debug("cps: " + cps.ToString());
-                       chronopicContactsLabels(cps, recreate);
-               }
-               else //(notebook_sup.CurrentPage == 1)
-                       chronopicEncoderLabels(recreate);
-               
-               if(recreate)    
-                       label_chronopics_multitest.Text = "";
-       }
-
-       private void on_chronopic_contacts_clicked (object o, EventArgs args) {
-               ChronopicWindow.ChronojumpMode cmode = ChronopicWindow.ChronojumpMode.JUMPORRUN;
-               if(radio_menuitem_mode_other.Active)
-                       cmode = ChronopicWindow.ChronojumpMode.OTHER;
-
-               chronopicWin = ChronopicWindow.View(cmode, preferences.volumeOn);
-               //chronopicWin.FakeWindowReload.Clicked += new EventHandler(chronopicWindowReload);
-               chronopicWin.FakeWindowDone.Clicked += new 
EventHandler(on_chronopic_window_contacts_connected_or_done);
-       }
-
-       private void on_chronopic_encoder_clicked (object o, EventArgs args) {
-               chronopicWin = ChronopicWindow.View(ChronopicWindow.ChronojumpMode.ENCODER, 
preferences.volumeOn);
-               //chronopicWin.FakeWindowReload.Clicked += new EventHandler(chronopicWindowReload);
-               chronopicWin.FakeWindowDone.Clicked += new 
EventHandler(on_chronopic_window_encoder_connected_or_done);
-       }
-
-       
-       /*      
-       private void on_chronopic_window_cancelled (object o, EventArgs ags) {
-               chronopicWin.FakeButtonCancelled.Clicked -= new EventHandler(on_chronopic_window_cancelled);
-               chronopicCancelledTimes ++;
-       }
-       */
-
-       /*      
-       private void chronopicWindowReload(object o, EventArgs args) {
-               //chronopicWin.FakeWindowReload.Clicked -= new EventHandler(chronopicWindowReload);
-
-               //store ports info and update labels if necessary
-               on_chronopic_window_connected_or_done (o, args);
-
-               //create chronopic window again (maybe new ports)
-               //createChronopicWindow(true);
-
-               //show it
-               chronopicWin = ChronopicWindow.View(preferences.volumeOn);
-       }
-       */
-
-       private void on_chronopic_window_contacts_connected_or_done (object o, EventArgs args) {
-               chronopicWin.FakeWindowDone.Clicked -= new 
EventHandler(on_chronopic_window_contacts_connected_or_done);
-               int cps = chronopicWin.NumConnected();
-
-               if(radio_mode_multi_chronopic_small.Active)     
-                       on_extra_window_multichronopic_test_changed(new object(), new EventArgs());
-               
-               if(cps > 0)
-                       change_multitest_firmware(getMenuItemMode());
-               else 
-                       label_chronopics_multitest.Text = "";
-               
-               chronopicContactsLabels(cps, true);
-       }
-       
-       private void on_chronopic_window_encoder_connected_or_done (object o, EventArgs args) {
-               chronopicWin.FakeWindowDone.Clicked -= new 
EventHandler(on_chronopic_window_encoder_connected_or_done);
-
-               chronopicEncoderLabels(true);
-       }
-
-
-       private void chronopicContactsLabels(int cps, bool colorize) {
-               //string text = "<b>" + cps.ToString() + "</b>";
-               string text = cps.ToString();
-               
-               label_connected_chronopics.Text = text;
-               //label_connected_chronopics.UseMarkup = true; 
-               
-               LogB.Debug("cpwin connected: " + chronopicWin.Connected.ToString());    
-               if(colorize)
-                       UtilGtk.ChronopicColors(viewport_chronopics, 
-                                       label_chronopics, label_connected_chronopics, 
-                                       chronopicWin.Connected);
-       }
-
-       private void chronopicEncoderLabels(bool colorize) {
-               LogB.Information("at chronopicEncoderLabels");
-               string encoderPort = chronopicWin.GetEncoderPort();
-               LogB.Debug("gui/chronojump.cs encoderPort:", encoderPort);
-
-               if(encoderPort != null && encoderPort != "" && encoderPort != Util.GetDefaultPort())
-               {
-                       label_chronopic_encoder.Text = Catalog.GetString("Encoder connected");
-                       image_chronopic_encoder_no.Visible = false;
-                       image_chronopic_encoder_yes.Visible = true;
-               }
-               else {
-                       label_chronopic_encoder.Text = Catalog.GetString("Encoder disconnected");
-                       image_chronopic_encoder_no.Visible = true;
-                       image_chronopic_encoder_yes.Visible = false;
-               }
-               
-               if(colorize)
-                       UtilGtk.ChronopicColors(viewport_chronopic_encoder, 
-                                       label_chronopic_encoder, new Gtk.Label(),
-                                       encoderPort != "");
-
-               LogB.Information("at chronopicEncoderLabels end");
-       }
-
-
-       private void on_multi_chronopic_start_clicked (object o, EventArgs args) {
-               LogB.Information("multi chronopic accepted");
-               
-               bool syncAvailable = false;
-               if(currentMultiChronopicType.SyncAvailable && extra_window_check_multichronopic_sync.Active)
-                       syncAvailable = true;
-
-
-               //used by cancel and finish
-               currentEventType = new MultiChronopicType();
-                       
-               //hide pulse buttons
-               sensitiveGuiEventDoing();
-               
-               //don't let update until test finishes
-               if(createdStatsWin)
-                       showUpdateStatsAndHideData(false);
-
-               //show the event doing window
-               event_execute_initializeVariables(
-                       ! chronopicWin.Connected,       //is simulated
-                       currentPerson.UniqueID, 
-                       currentPerson.Name, 
-                       Catalog.GetString("Changes"),     //name of the different moments
-                       Constants.MultiChronopicTable, //tableName
-                       currentMultiChronopicType.Name
-                       ); 
-               ExecutingGraphData egd = event_execute_prepareForTest ();
-
-               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_multi_clicked);
-               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_multi_clicked);
-               
-               //when user clicks on update the eventExecute window 
-               //(for showing with his new confgured values: max, min and guides
-               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
-               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
-
-
-               /*
-               bool syncAvailable = false;
-               if(currentMultiChronopicType.SyncAvailable && extra_window_check_multichronopic_sync.Active)
-                       syncAvailable = true;
-                       */
-
-               int numConnected = chronopicWin.NumConnected();
-
-               if(numConnected == 1)
-                       currentEventExecute = new MultiChronopicExecute(
-                                       currentPerson.UniqueID, currentPerson.Name, 
-                                       currentSession.UniqueID, currentMultiChronopicType.Name, 
-                                       chronopicWin.CP, 
-                                       syncAvailable, extra_window_check_multichronopic_delete_first.Active, 
-                                       extra_window_spin_run_analysis_distance.Value.ToString(),
-                                       app1, egd
-                                       );
-               else if(numConnected == 2)
-                       currentEventExecute = new MultiChronopicExecute(
-                                       currentPerson.UniqueID, currentPerson.Name, 
-                                       currentSession.UniqueID, currentMultiChronopicType.Name,  
-                                       chronopicWin.CP, chronopicWin.CP2, 
-                                       syncAvailable, extra_window_check_multichronopic_delete_first.Active, 
-                                       extra_window_spin_run_analysis_distance.Value.ToString(),
-                                       app1, egd
-                                       );
-               else if(numConnected == 3)
-                       currentEventExecute = new MultiChronopicExecute(
-                                       currentPerson.UniqueID, currentPerson.Name, 
-                                       currentSession.UniqueID, currentMultiChronopicType.Name,
-                                       chronopicWin.CP, chronopicWin.CP2, chronopicWin.CP3, 
-                                       syncAvailable, extra_window_check_multichronopic_delete_first.Active, 
-                                       extra_window_spin_run_analysis_distance.Value.ToString(),
-                                       app1, egd
-                                       );
-               else if(numConnected == 4)
-                       currentEventExecute = new MultiChronopicExecute(
-                                       currentPerson.UniqueID, currentPerson.Name, 
-                                       currentSession.UniqueID, currentMultiChronopicType.Name,
-                                       chronopicWin.CP, chronopicWin.CP2, chronopicWin.CP3, chronopicWin.CP4,
-                                       syncAvailable, extra_window_check_multichronopic_delete_first.Active, 
-                                       extra_window_spin_run_analysis_distance.Value.ToString(),
-                                       app1, egd
-                                       );
-
-               //if(!chronopicWin.Connected)   
-               //      currentEventExecute.SimulateInitValues(rand);
-
-
-               //mark to only get inside on_multi_chronopic_finished one time
-               multiFinishing = false;
-               currentEventExecute.Manage();
-
-               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
-                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
-               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
-//             currentEventExecute.FakeButtonRunATouchPlatform.Clicked += new 
EventHandler(on_event_execute_RunATouchPlatform);
-               currentEventExecute.FakeButtonFinished.Clicked += new 
EventHandler(on_multi_chronopic_finished);
-               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
-       }
-
-       bool multiFinishing;
-       private void on_multi_chronopic_finished (object o, EventArgs args) {
-               if(multiFinishing)
-                       return;
-               else
-                       multiFinishing = true;
-
-               currentEventExecute.FakeButtonFinished.Clicked -= new 
EventHandler(on_multi_chronopic_finished);
-
-               //test can be deleted if not cancelled
-               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
-
-               if(currentMultiChronopicType.Name == Constants.RunAnalysisName && ! 
currentEventExecute.MultiChronopicRunAUsedCP2()) 
-                       //new DialogMessage(Constants.MessageTypes.WARNING, 
-                       //              Catalog.GetString("This Run Analysis is not valid because there are 
no strides."));
-                       currentEventExecute.RunANoStrides();
-               else if ( ! currentEventExecute.Cancel ) {
-LogB.Debug("T");
-                       /*
-                          on runAnalysis test, when cp1 ends, run ends,
-                          but cp2 is still waiting event
-                          with this will ask cp2 to press button
-                          solves problem with threads at ending
-                          */
-
-                       //on_finish_multi_clicked(o, args);
-                       //this produces also a crash:
-                       //new DialogMessage(Constants.MessageTypes.INFO, "Please, touch a platform now.");
-LogB.Debug("U");
-                       //call write here, because if done in execute/MultiChronopic, will be called n times 
if n chronopics are working
-                       currentEventExecute.MultiChronopicWrite(false);
-LogB.Debug("V");
-                       currentMultiChronopic = (MultiChronopic) currentEventExecute.EventDone;
-LogB.Debug("W");
-                       //move video file if exists
-                       if(preferences.videoOn)
-                               if(! Util.CopyTempVideo(currentSession.UniqueID, 
-                                                       Constants.TestTypes.MULTICHRONOPIC, 
currentMultiChronopic.UniqueID))
-                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
-
-                       //this produces also a crash:
-                       //new DialogMessage(Constants.MessageTypes.INFO, "Please, touch a platform now.");
-
-LogB.Debug("W2");
-                       
-                       //if this multichronopic has more chronopics than other in session, then reload 
treeview, else simply add
-                       if(currentMultiChronopic.CPs() != SqliteMultiChronopic.MaxCPs(false, 
currentSession.UniqueID)) {
-                               treeview_multi_chronopic_storeReset(false);
-                               fillTreeView_multi_chronopic();
-                       } else
-                               myTreeViewMultiChronopic.Add(currentPerson.Name, currentMultiChronopic);
-LogB.Debug("X");
-                       
-                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
-                       showHideActionEventButtons(true, Constants.MultiChronopicName); //show
-               
-                       //unhide buttons for delete last test
-                       sensitiveGuiYesEvent();
-               }
-               else if( currentEventExecute.ChronopicDisconnected )
-                       chronopicDisconnectedWhileExecuting();
-       }
-               
-
-       /*
-        * update button is clicked on eventWindow, chronojump.cs delegate points here
-        */
-       
-       private void on_update_clicked (object o, EventArgs args) {
-               LogB.Information("--On_update_clicked--");
-               try {
-                       switch (currentEventType.Type) {
-                               case EventType.Types.JUMP:
-                                       if(lastJumpIsSimple && radio_menuitem_mode_jumps_simple.Active) 
-                                               
PrepareJumpSimpleGraph(currentEventExecute.PrepareEventGraphJumpSimpleObject, false);
-                                       else if (radio_menuitem_mode_jumps_reactive.Active)
-                                               PrepareJumpReactiveGraph(
-                                                               Util.GetLast(currentJumpRj.TvString), 
Util.GetLast(currentJumpRj.TcString),
-                                                               currentJumpRj.TvString, 
currentJumpRj.TcString, preferences.volumeOn, repetitiveConditionsWin);
-                                       break;
-                               case EventType.Types.RUN:
-                                       if(lastRunIsSimple && radio_menuitem_mode_runs_simple.Active) 
-                                               
PrepareRunSimpleGraph(currentEventExecute.PrepareEventGraphRunSimpleObject, false);
-                                       else if(radio_menuitem_mode_runs_intervallic.Active) {
-                                               RunType runType = 
SqliteRunIntervalType.SelectAndReturnRunIntervalType(currentRunInterval.Type, false);
-                                               double distanceTotal = 
Util.GetRunITotalDistance(currentRunInterval.DistanceInterval, 
-                                                               runType.DistancesString, 
currentRunInterval.Tracks);
-
-                                               double distanceInterval = currentRunInterval.DistanceInterval;
-                                               if(distanceInterval == -1) //variable distances
-                                                       distanceInterval = 
Util.GetRunIVariableDistancesStringRow(
-                                                                       runType.DistancesString, (int) 
currentRunInterval.Tracks -1);
-                                               
-                                               PrepareRunIntervalGraph(distanceInterval, 
-                                                               
Util.GetLast(currentRunInterval.IntervalTimesString), 
-                                                               currentRunInterval.IntervalTimesString, 
-                                                               distanceTotal,
-                                                               runType.DistancesString,
-                                                               currentRunInterval.StartIn,
-                                                               preferences.volumeOn, 
repetitiveConditionsWin);
-                                       }
-                                       break;
-                               case EventType.Types.PULSE:
-                                       if(radio_mode_pulses_small.Active)
-                                               PreparePulseGraph(Util.GetLast(currentPulse.TimesString), 
currentPulse.TimesString);
-                                       break;
-                               case EventType.Types.REACTIONTIME:
-                                       if(radio_mode_reaction_times_small.Active)
-                                               
PrepareReactionTimeGraph(currentEventExecute.PrepareEventGraphReactionTimeObject, false);
-                                       break;
-                               case EventType.Types.MULTICHRONOPIC:
-                                       if(radio_mode_multi_chronopic_small.Active)
-                                               PrepareMultiChronopicGraph(
-                                                               //currentMultiChronopic.timestamp, 
-                                                               
Util.IntToBool(currentMultiChronopic.Cp1StartedIn), 
-                                                               
Util.IntToBool(currentMultiChronopic.Cp2StartedIn), 
-                                                               
Util.IntToBool(currentMultiChronopic.Cp3StartedIn), 
-                                                               
Util.IntToBool(currentMultiChronopic.Cp4StartedIn), 
-                                                               currentMultiChronopic.Cp1InStr, 
-                                                               currentMultiChronopic.Cp1OutStr,
-                                                               currentMultiChronopic.Cp2InStr, 
-                                                               currentMultiChronopic.Cp2OutStr,
-                                                               currentMultiChronopic.Cp3InStr, 
-                                                               currentMultiChronopic.Cp3OutStr,
-                                                               currentMultiChronopic.Cp4InStr, 
-                                                               currentMultiChronopic.Cp4OutStr);
-                                       break;
-                       }
-               }
-               catch {
-                       errorWin = ErrorWindow.Show(Catalog.GetString("Cannot update. Probably this test was 
deleted."));
-               }
-       
-       }
-
-
-
-       /* ---------------------------------------------------------
-        * ----------------  EVENTS EDIT ---------------------------
-        *  --------------------------------------------------------
-        */
-
-       int eventOldPerson;
-
-       private void on_edit_selected_jump_clicked (object o, EventArgs args) {
-               //notebooks_change(0); see "notebooks_change sqlite problem"
-               LogB.Information("Edit selected jump (normal)");
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
-               if (myTreeViewJumps.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected jump
-                       Jump myJump = SqliteJump.SelectJumpData( myTreeViewJumps.EventSelectedID, false );
-                       eventOldPerson = myJump.PersonID;
-               
-                       //4.- edit this jump
-                       editJumpWin = EditJumpWindow.Show(app1, myJump, preferences.weightStatsPercent, 
preferences.digitsNumber);
-                       editJumpWin.Button_accept.Clicked += new EventHandler(on_edit_selected_jump_accepted);
-               }
-       }
-       
-       private void on_edit_selected_jump_rj_clicked (object o, EventArgs args) {
-               //notebooks_change(1); see "notebooks_change sqlite problem"
-               LogB.Information("Edit selected jump (RJ)");
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
-               if (myTreeViewJumpsRj.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected jump
-                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
-                       eventOldPerson = myJump.PersonID;
-               
-                       //4.- edit this jump
-                       editJumpRjWin = EditJumpRjWindow.Show(app1, myJump, preferences.weightStatsPercent, 
preferences.digitsNumber);
-                       editJumpRjWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_jump_rj_accepted);
-               }
-       }
-       
-       private void on_edit_selected_jump_accepted (object o, EventArgs args) {
-               LogB.Information("edit selected jump accepted");
-       
-               Jump myJump = SqliteJump.SelectJumpData( myTreeViewJumps.EventSelectedID, false );
-
-               //if person changed, fill treeview again, if not, only update it's line
-               if(eventOldPerson == myJump.PersonID) {
-                       if(! preferences.weightStatsPercent) {
-                               double personWeight = SqlitePersonSession.SelectAttribute(
-                                               false, myJump.PersonID, currentSession.UniqueID, 
Constants.Weight);
-                               myJump.Weight = Util.WeightFromPercentToKg(myJump.Weight, personWeight);
-                       }
-                       myTreeViewJumps.Update(myJump);
-               }
-               else {
-                       treeview_jumps_storeReset();
-                       fillTreeView_jumps(UtilGtk.ComboGetActive(combo_result_jumps));
-               }
-               
-               updateGraphJumpsSimple();
-
-               if(createdStatsWin) 
-                       stats_win_fillTreeView_stats(false, false);
-       }
-       
-       private void on_edit_selected_jump_rj_accepted (object o, EventArgs args) {
-               LogB.Information("edit selected jump RJ accepted");
-       
-               JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", myTreeViewJumpsRj.EventSelectedID, 
false );
-               
-               //if person changed, fill treeview again, if not, only update it's line
-               if(eventOldPerson == myJump.PersonID) {
-                       if(! preferences.weightStatsPercent) {
-                               double personWeight = SqlitePersonSession.SelectAttribute(
-                                               false, myJump.PersonID, currentSession.UniqueID, 
Constants.Weight);
-                               myJump.Weight = Util.WeightFromPercentToKg(myJump.Weight, personWeight);
-                       }
-                       myTreeViewJumpsRj.Update(myJump);
-               }
-               else {
-                       treeview_jumps_rj_storeReset();
-                       fillTreeView_jumps_rj(UtilGtk.ComboGetActive(combo_result_jumps_rj));
-               }
-
-               if(createdStatsWin) 
-                       stats_win_fillTreeView_stats(false, false);
-       }
-       
-       private void on_edit_selected_run_clicked (object o, EventArgs args) {
-               //notebooks_change(2); see "notebooks_change sqlite problem"
-               LogB.Information("Edit selected run (normal)");
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
-               if (myTreeViewRuns.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected run
-                       Run myRun = SqliteRun.SelectRunData( myTreeViewRuns.EventSelectedID, false );
-                       myRun.MetersSecondsPreferred = preferences.metersSecondsPreferred;
-                       eventOldPerson = myRun.PersonID;
-               
-                       //4.- edit this run
-                       editRunWin = EditRunWindow.Show(app1, myRun, preferences.digitsNumber, 
preferences.metersSecondsPreferred);
-                       editRunWin.Button_accept.Clicked += new EventHandler(on_edit_selected_run_accepted);
-               }
-       }
-       
-       private void on_edit_selected_run_interval_clicked (object o, EventArgs args) {
-               //notebooks_change(3); see "notebooks_change sqlite problem"
-               LogB.Information("Edit selected run interval");
-               //1.- check that there's a line selected
-               //2.- check that this line is a run and not a person (check also if it's not a individual 
subrun, the pass the parent run)
-               if (myTreeViewRunsInterval.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected run
-                       RunInterval myRun = SqliteRunInterval.SelectRunData( Constants.RunIntervalTable, 
myTreeViewRunsInterval.EventSelectedID, false );
-                       eventOldPerson = myRun.PersonID;
-               
-                       //4.- edit this run
-                       editRunIntervalWin = EditRunIntervalWindow.Show(app1, myRun, 
preferences.digitsNumber, preferences.metersSecondsPreferred);
-                       editRunIntervalWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_run_interval_accepted);
-               }
-       }
-       
-       private void on_edit_selected_run_accepted (object o, EventArgs args) {
-               LogB.Information("edit selected run accepted");
-               
-               Run myRun = SqliteRun.SelectRunData( myTreeViewRuns.EventSelectedID, false );
-               
-               //if person changed, fill treeview again, if not, only update it's line
-               if(eventOldPerson == myRun.PersonID)
-                       myTreeViewRuns.Update(myRun);
-               else {
-                       treeview_runs_storeReset();
-                       fillTreeView_runs(UtilGtk.ComboGetActive(combo_result_runs));
-               }
-               
-               updateGraphRunsSimple();
-
-               if(createdStatsWin) 
-                       stats_win_fillTreeView_stats(false, false);
-       }
-       
-       private void on_edit_selected_run_interval_accepted (object o, EventArgs args) {
-               LogB.Information("edit selected run interval accepted");
-               
-               RunInterval myRun = SqliteRunInterval.SelectRunData( Constants.RunIntervalTable, 
myTreeViewRunsInterval.EventSelectedID, false );
-
-               //if person changed, fill treeview again, if not, only update it's line
-               if(eventOldPerson == myRun.PersonID)
-                       myTreeViewRunsInterval.Update(myRun);
-               else {
-                       treeview_runs_interval_storeReset();
-                       fillTreeView_runs_interval(UtilGtk.ComboGetActive(combo_result_runs_interval));
-               }
-               
-               if(createdStatsWin)
-                       stats_win_fillTreeView_stats(false, false);
-       }
-
-       private void on_edit_selected_reaction_time_clicked (object o, EventArgs args) {
-               //notebooks_change(4); see "notebooks_change sqlite problem"
-               LogB.Information("Edit selected reaction time");
-               //1.- check that there's a line selected
-               //2.- check that this line is a event and not a person
-               if (myTreeViewReactionTimes.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected event
-                       ReactionTime myRT = SqliteReactionTime.SelectReactionTimeData( 
myTreeViewReactionTimes.EventSelectedID, false );
-                       eventOldPerson = myRT.PersonID;
-               
-                       //4.- edit this event
-                       editReactionTimeWin = EditReactionTimeWindow.Show(app1, myRT, 
preferences.digitsNumber);
-                       editReactionTimeWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_reaction_time_accepted);
-               }
-       }
-       
-       private void on_edit_selected_reaction_time_accepted (object o, EventArgs args) {
-               LogB.Information("edit selected reaction time accepted");
-               
-               ReactionTime myRT = SqliteReactionTime.SelectReactionTimeData( 
myTreeViewReactionTimes.EventSelectedID, false);
-
-               //if person changed, fill treeview again, if not, only update it's line
-               if(eventOldPerson == myRT.PersonID)
-                       myTreeViewReactionTimes.Update(myRT);
-               else {
-                       treeview_reaction_times_storeReset();
-                       fillTreeView_reaction_times(currentReactionTimeType.Name);
-               }
-               
-               updateGraphReactionTimes();
-       }
-       
-       private void on_edit_selected_pulse_clicked (object o, EventArgs args) {
-               //notebooks_change(5); see "notebooks_change sqlite problem"
-               LogB.Information("Edit selected pulse");
-               //1.- check that there's a line selected
-               //2.- check that this line is a event and not a person
-               if (myTreeViewPulses.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected event
-                       Pulse myPulse = SqlitePulse.SelectPulseData( myTreeViewPulses.EventSelectedID, false 
);
-                       eventOldPerson = myPulse.PersonID;
-               
-                       //4.- edit this event
-                       editPulseWin = EditPulseWindow.Show(app1, myPulse, preferences.digitsNumber);
-                       editPulseWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_pulse_accepted);
-               }
-       }
-       
-       private void on_edit_selected_pulse_accepted (object o, EventArgs args) {
-               LogB.Information("edit selected pulse accepted");
-               
-               Pulse myPulse = SqlitePulse.SelectPulseData( myTreeViewPulses.EventSelectedID, false );
-
-               //if person changed, fill treeview again, if not, only update it's line
-               if(eventOldPerson == myPulse.PersonID)
-                       myTreeViewPulses.Update(myPulse);
-               else {
-                       treeview_pulses_storeReset();
-                       fillTreeView_pulses(UtilGtk.ComboGetActive(combo_pulses));
-               }
-       }
-       
-       private void on_edit_selected_multi_chronopic_clicked (object o, EventArgs args) {
-               //notebooks_change(6); see "notebooks_change sqlite problem"
-               LogB.Information("Edit selected multi chronopic");
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
-               if (myTreeViewMultiChronopic.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected test
-                       MultiChronopic mc = SqliteMultiChronopic.SelectMultiChronopicData( 
myTreeViewMultiChronopic.EventSelectedID, false );
-                       eventOldPerson = mc.PersonID;
-               
-                       //4.- edit this jump
-                       editMultiChronopicWin = EditMultiChronopicWindow.Show(app1, mc, 
preferences.digitsNumber);
-                       editMultiChronopicWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_multi_chronopic_accepted);
-               }
-       }
-
-       private void on_edit_selected_multi_chronopic_accepted (object o, EventArgs args) {
-               LogB.Information("edit selected multi chronopic accepted");
-       
-               MultiChronopic mc = SqliteMultiChronopic.SelectMultiChronopicData( 
myTreeViewMultiChronopic.EventSelectedID, false );
-               
-               //if person changed, fill treeview again, if not, only update it's line
-               if(eventOldPerson == mc.PersonID) 
-                       myTreeViewMultiChronopic.Update(mc);
-               else {
-                       treeview_multi_chronopic_storeReset(false);
-                       fillTreeView_multi_chronopic();
-               }
-       }
-       
-       /* ---------------------------------------------------------
-        * ----------------  EVENTS PLAY VIDEO ---------------------
-        *  --------------------------------------------------------
-        */
-
-       //Not used on encoder   
-       private bool playVideo(string fileName, bool play) 
-       {
-               if(File.Exists(fileName)) {
-                       LogB.Information("Play video starting...");
-                       PlayerBin player = new PlayerBin();
-                       player.Open(fileName);
-
-                       //without these lines works also but has less functionalities (speed, go to ms)
-                       Gtk.Window d = new Gtk.Window(Catalog.GetString("Playing video"));
-                       d.Add(player);
-                       d.Modal = true;
-                       d.SetDefaultSize(500,400);
-                       d.ShowAll();
-                       d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {player.Close(); 
player.Dispose();};
-
-                       if(play) {
-                               LogB.Information("Play video playing...");
-                               player.Play();
-                       }
-                       return true;    
-               }
-               return false;   
-       }
-
-
-       private void on_video_play_this_test_clicked (object o, EventArgs args) {
-               Constants.TestTypes type = Constants.TestTypes.JUMP;
-               int id = 0;
-               switch (currentEventType.Type) {
-                       case EventType.Types.JUMP:
-                               if(lastJumpIsSimple) {
-                                       type = Constants.TestTypes.JUMP;
-                                       id = currentJump.UniqueID;
-                               }
-                               else {
-                                       type = Constants.TestTypes.JUMP_RJ;
-                                       id = currentJumpRj.UniqueID;
-                               } break;
-                       case EventType.Types.RUN:
-                               if(lastRunIsSimple) {
-                                       type = Constants.TestTypes.RUN;
-                                       id = currentRun.UniqueID;
-                               } else {
-                                       type = Constants.TestTypes.RUN_I;
-                                       id = currentRunInterval.UniqueID;
-                               }
-                               break;
-                       case EventType.Types.PULSE:
-                               type = Constants.TestTypes.PULSE;
-                               id = currentPulse.UniqueID;
-                               break;
-                       case EventType.Types.REACTIONTIME:
-                               type = Constants.TestTypes.RT;
-                               id = currentReactionTime.UniqueID;
-                               break;
-                       case EventType.Types.MULTICHRONOPIC:
-                               type = Constants.TestTypes.MULTICHRONOPIC;
-                               id = currentMultiChronopic.UniqueID;
-                               break;
-               }
-
-               playVideo(Util.GetVideoFileName(currentSession.UniqueID, type, id), true);
-       }
-
-       private void on_video_play_selected_jump_clicked (object o, EventArgs args) {
-               if (myTreeViewJumps.EventSelectedID > 0) 
-                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
-                                               Constants.TestTypes.JUMP,
-                                               myTreeViewJumps.EventSelectedID), true);
-       }
-
-       private void on_video_play_selected_jump_rj_clicked (object o, EventArgs args) {
-               if (myTreeViewJumpsRj.EventSelectedID > 0) 
-                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
-                                               Constants.TestTypes.JUMP_RJ,
-                                               myTreeViewJumpsRj.EventSelectedID), true);
-       }
-
-       private void on_video_play_selected_run_clicked (object o, EventArgs args) {
-               if (myTreeViewRuns.EventSelectedID > 0) 
-                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
-                                               Constants.TestTypes.RUN,
-                                               myTreeViewRuns.EventSelectedID), true);
-       }
-
-       private void on_video_play_selected_run_interval_clicked (object o, EventArgs args) {
-               if (myTreeViewRunsInterval.EventSelectedID > 0) 
-                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
-                                               Constants.TestTypes.RUN_I,
-                                               myTreeViewRunsInterval.EventSelectedID), true);
-       }
-
-       private void on_video_play_selected_reaction_time_clicked (object o, EventArgs args) {
-               if (myTreeViewReactionTimes.EventSelectedID > 0) 
-                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
-                                               Constants.TestTypes.RT,
-                                               myTreeViewReactionTimes.EventSelectedID), true);
-       }
-
-       private void on_video_play_selected_pulse_clicked (object o, EventArgs args) {
-               if (myTreeViewPulses.EventSelectedID > 0) 
-                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
-                                               Constants.TestTypes.PULSE,
-                                               myTreeViewPulses.EventSelectedID), true);
-       }
-
-       private void on_video_play_selected_multi_chronopic_clicked (object o, EventArgs args) {
-               if (myTreeViewMultiChronopic.EventSelectedID > 0) 
-                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
-                                               Constants.TestTypes.MULTICHRONOPIC,
-                                               myTreeViewMultiChronopic.EventSelectedID), true);
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  EVENTS DELETE -------------------------
-        *  --------------------------------------------------------
-        */
-       
-       private void on_delete_this_test_clicked (object o, EventArgs args) {
-               switch (currentEventType.Type) {
-                       case EventType.Types.JUMP:
-                               if(lastJumpIsSimple) {
-                                       //maybe, after executing the test, user has selected other test on 
treeview
-                                       //delete this is called on execute
-                                       //we should ensure we are deleting last jump and not the selected jump
-                                       //force selection of last jump
-                                       if(currentJump.UniqueID != myTreeViewJumps.EventSelectedID)
-                                               myTreeViewJumps.SelectEvent(currentJump.UniqueID);
-                                       on_delete_selected_jump_clicked(o, args);
-                               } else {
-                                       if(currentJumpRj.UniqueID != myTreeViewJumpsRj.EventSelectedID)
-                                               myTreeViewJumpsRj.SelectEvent(currentJumpRj.UniqueID);
-                                       on_delete_selected_jump_rj_clicked(o, args);
-                               }
-                               break;
-                       case EventType.Types.RUN:
-                               if(lastRunIsSimple) {
-                                       if(currentRun.UniqueID != myTreeViewRuns.EventSelectedID)
-                                               myTreeViewRuns.SelectEvent(currentRun.UniqueID);
-                                       on_delete_selected_run_clicked(o, args);
-                               } else {
-                                       if(currentRunInterval.UniqueID != 
myTreeViewRunsInterval.EventSelectedID)
-                                               
myTreeViewRunsInterval.SelectEvent(currentRunInterval.UniqueID);
-                                       on_delete_selected_run_interval_clicked(o, args);
-                               }
-                               break;
-                       case EventType.Types.PULSE:
-                               if(currentPulse.UniqueID != myTreeViewPulses.EventSelectedID)
-                                       myTreeViewPulses.SelectEvent(currentPulse.UniqueID);
-                               on_delete_selected_pulse_clicked(o, args);
-                               break;
-                       case EventType.Types.REACTIONTIME:
-                               if(currentReactionTime.UniqueID != myTreeViewReactionTimes.EventSelectedID)
-                                       myTreeViewReactionTimes.SelectEvent(currentReactionTime.UniqueID);
-                               on_delete_selected_reaction_time_clicked(o, args);
-                               break;
-                       case EventType.Types.MULTICHRONOPIC:
-                               if(currentMultiChronopic.UniqueID != myTreeViewMultiChronopic.EventSelectedID)
-                                       myTreeViewMultiChronopic.SelectEvent(currentMultiChronopic.UniqueID);
-                               on_delete_selected_multi_chronopic_clicked(o, args);
-                               break;
-               }
-       }
-
-       private void deleted_last_test_update_widgets() {
-               vbox_this_test_buttons.Sensitive = false;
-               UtilGtk.ClearDrawingArea(event_execute_drawingarea, event_execute_pixmap);
-               notebook_results_data.CurrentPage = 3; //shows "deleted test"
-       }
-       
-       private void on_delete_selected_jump_clicked (object o, EventArgs args) {
-               //notebooks_change(0); see "notebooks_change sqlite problem"
-               LogB.Information("delete this jump (normal)");
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person
-               LogB.Information(myTreeViewJumps.EventSelectedID.ToString());
-               if (myTreeViewJumps.EventSelectedID > 0) {
-                       //3.- display confirmwindow of deletion 
-                       if (preferences.askDeletion) {
-                               confirmWinJumpRun = ConfirmWindowJumpRun.Show(Catalog.GetString("Do you want 
to delete this jump?"), "");
-                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_jump_accepted);
-                       } else {
-                               on_delete_selected_jump_accepted(o, args);
-                       }
-               }
-       }
-       
-       private void on_delete_selected_jump_rj_clicked (object o, EventArgs args) {
-               //notebooks_change(1); see "notebooks_change sqlite problem"
-               LogB.Information("delete this reactive jump");
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
-               if (myTreeViewJumpsRj.EventSelectedID > 0) {
-                       //3.- display confirmwindow of deletion 
-                       if (preferences.askDeletion) {
-                               confirmWinJumpRun = ConfirmWindowJumpRun.Show( Catalog.GetString("Do you want 
to delete this jump?"), 
-                                                Catalog.GetString("Attention: Deleting a Reactive subjump 
will delete the whole jump"));
-                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_jump_rj_accepted);
-                       } else {
-                               on_delete_selected_jump_rj_accepted(o, args);
-                       }
-               }
-       }
-       
-       private void on_delete_selected_jump_accepted (object o, EventArgs args) {
-               LogB.Information("accept delete this jump");
-               int id = myTreeViewJumps.EventSelectedID;
-               
-               Sqlite.Delete(false, Constants.JumpTable, id);
-               
-               myTreeViewJumps.DelEvent(id);
-               showHideActionEventButtons(false, "Jump");
-               
-               if(createdStatsWin) {
-                       stats_win_fillTreeView_stats(false, false);
-               }
-               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.JUMP, id );
-               //we can be here being called from jump treeview (not from execute tab)
-               //then what we are deleting is selected jump, not last jump 
-               //only if selected is last, then
-               //change executing window: drawingarea, button_delete, "deleted test" message
-               try {
-                       if(currentJump.UniqueID == id)
-                               deleted_last_test_update_widgets();
-               } catch {
-                       //there's no currentJump (no one jumped), then it crashed,
-                       //but don't need to update widgets
-               }
-               
-               updateGraphJumpsSimple();
-
-               //if auto mode, show last person/test again
-               if(execute_auto_doing) {
-                       execute_auto_order_pos --;
-                       execute_auto_select();
-               }
-       }
-
-       private void on_delete_selected_jump_rj_accepted (object o, EventArgs args) {
-               LogB.Information("accept delete this jump");
-               int id = myTreeViewJumpsRj.EventSelectedID;
-               
-               Sqlite.Delete(false, Constants.JumpRjTable, id);
-               
-               myTreeViewJumpsRj.DelEvent(id);
-               showHideActionEventButtons(false, "JumpRj");
-
-               if(createdStatsWin) {
-                       stats_win_fillTreeView_stats(false, false);
-               }
-               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.JUMP_RJ, id );
-               try {
-                       if(currentJumpRj.UniqueID == id)
-                               deleted_last_test_update_widgets();
-               } catch {
-                       //there's no currentJumpRj (no one jumped), then it crashed,
-                       //but don't need to update widgets
-               }
-       }
-       
-       private void on_delete_selected_run_clicked (object o, EventArgs args) {
-               //notebooks_change(2); see "notebooks_change sqlite problem"
-               LogB.Information("delete this run (normal)");
-               
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person
-               if (myTreeViewRuns.EventSelectedID > 0) {
-                       //3.- display confirmwindow of deletion 
-                       if (preferences.askDeletion) {
-                               confirmWinJumpRun = ConfirmWindowJumpRun.Show(Catalog.GetString("Do you want 
to delete this run?"), "");
-                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_run_accepted);
-                       } else {
-                               on_delete_selected_run_accepted(o, args);
-                       }
-               }
-       }
-               
-       
-       private void on_delete_selected_run_interval_clicked (object o, EventArgs args) {
-               //notebooks_change(3); see "notebooks_change sqlite problem"
-               LogB.Information("delete this run interval");
-               //1.- check that there's a line selected
-               //2.- check that this line is a run and not a person (check also if it's a subrun, pass the 
parent run)
-               if (myTreeViewRunsInterval.EventSelectedID > 0) {
-                       //3.- display confirmwindow of deletion 
-                       if (preferences.askDeletion) {
-                               confirmWinJumpRun = ConfirmWindowJumpRun.Show( Catalog.GetString("Do you want 
to delete this run?"), 
-                                                Catalog.GetString("Attention: Deleting a Intervallic subrun 
will delete the whole run"));
-                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_run_interval_accepted);
-                       } else {
-                               on_delete_selected_run_interval_accepted(o, args);
-                       }
-               }
-       }
-
-       private void on_delete_selected_run_accepted (object o, EventArgs args) {
-               LogB.Information("accept delete this run");
-               int id = myTreeViewRuns.EventSelectedID;
-               
-               Sqlite.Delete(false, Constants.RunTable, id);
-               
-               myTreeViewRuns.DelEvent(id);
-               showHideActionEventButtons(false, "Run");
-               
-               if(createdStatsWin) {
-                       stats_win_fillTreeView_stats(false, false);
-               }
-               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.RUN, id );
-               try {
-                       if(currentRun.UniqueID == id)
-                               deleted_last_test_update_widgets();
-               } catch {
-                       //there's no currentRun (no one done it now), then it crashed,
-                       //but don't need to update widgets
-               }
-               
-               updateGraphRunsSimple();
-       }
-
-       private void on_delete_selected_run_interval_accepted (object o, EventArgs args) {
-               LogB.Information("accept delete this run");
-               int id = myTreeViewRunsInterval.EventSelectedID;
-               
-               Sqlite.Delete(false, Constants.RunIntervalTable, id);
-               
-               myTreeViewRunsInterval.DelEvent(id);
-               showHideActionEventButtons(false, "RunInterval");
-
-               if(createdStatsWin) {
-                       stats_win_fillTreeView_stats(false, false);
-               }
-               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.RUN_I, id );
-               try {
-                       if(currentRunInterval.UniqueID == id)
-                               deleted_last_test_update_widgets();
-               } catch {
-                       //there's no currentRunInterval (no one done it now), then it crashed,
-                       //but don't need to update widgets
-               }
-       }
-       
-       private void on_delete_selected_reaction_time_clicked (object o, EventArgs args) {
-               //notebooks_change(4); see "notebooks_change sqlite problem"
-               LogB.Information("delete this reaction time");
-               
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person
-               LogB.Information(myTreeViewReactionTimes.EventSelectedID.ToString());
-               if (myTreeViewReactionTimes.EventSelectedID > 0) {
-                       //3.- display confirmwindow of deletion 
-                       if (preferences.askDeletion) {
-                               confirmWinJumpRun = ConfirmWindowJumpRun.Show("Do you want to delete this 
test?", "");
-                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_reaction_time_accepted);
-                       } else {
-                               on_delete_selected_reaction_time_accepted(o, args);
-                       }
-               }
-       }
-               
-       private void on_delete_selected_reaction_time_accepted (object o, EventArgs args) {
-               LogB.Information("accept delete this reaction time");
-               int id = myTreeViewReactionTimes.EventSelectedID;
-               
-               Sqlite.Delete(false, Constants.ReactionTimeTable, id);
-               
-               myTreeViewReactionTimes.DelEvent(id);
-               showHideActionEventButtons(false, "ReactionTime");
-
-               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.RT, id );
-               try {
-                       if(currentReactionTime.UniqueID == id)
-                               deleted_last_test_update_widgets();
-               } catch {
-                       //there's no currentReactionTime (no one done it now), then it crashed,
-                       //but don't need to update widgets
-               }
-
-               updateGraphReactionTimes();
-       }
-
-       private void on_delete_selected_pulse_clicked (object o, EventArgs args) {
-               //notebooks_change(5); see "notebooks_change sqlite problem"
-               LogB.Information("delete this pulse");
-               
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person
-               LogB.Information(myTreeViewPulses.EventSelectedID.ToString());
-               if (myTreeViewPulses.EventSelectedID > 0) {
-                       //3.- display confirmwindow of deletion 
-                       if (preferences.askDeletion) {
-                               confirmWinJumpRun = ConfirmWindowJumpRun.Show("Do you want to delete this 
test?", "");
-                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_pulse_accepted);
-                       } else {
-                               on_delete_selected_pulse_accepted(o, args);
-                       }
-               }
-       }
-               
-       private void on_delete_selected_pulse_accepted (object o, EventArgs args) {
-               LogB.Information("accept delete this pulse");
-               int id = myTreeViewPulses.EventSelectedID;
-               
-               Sqlite.Delete(false, Constants.PulseTable, id);
-               
-               myTreeViewPulses.DelEvent(id);
-               showHideActionEventButtons(false, "Pulse");
-
-               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.PULSE, id );
-               try {
-                       if(currentPulse.UniqueID == id)
-                               deleted_last_test_update_widgets();
-               } catch {
-                       //there's no currentPulse (no one done it now), then it crashed,
-                       //but don't need to update widgets
-               }
-       }
-
-       private void on_delete_selected_multi_chronopic_clicked (object o, EventArgs args) {
-               //notebooks_change(6); see "notebooks_change sqlite problem"
-               LogB.Information("delete this multi chronopic");
-               //1.- check that there's a line selected
-               //2.- check that this line is a test and not a person (check also if it's not a individual 
mc, then pass the parent mc)
-               if (myTreeViewMultiChronopic.EventSelectedID > 0) {
-                       //3.- display confirmwindow of deletion 
-                       if (preferences.askDeletion) {
-                               confirmWinJumpRun = ConfirmWindowJumpRun.Show( Catalog.GetString("Do you want 
to delete this test?"), "");
-                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_multi_chronopic_accepted);
-                       } else {
-                               on_delete_selected_multi_chronopic_accepted(o, args);
-                       }
-               }
-       }
-       
-       private void on_delete_selected_multi_chronopic_accepted (object o, EventArgs args) {
-               LogB.Information("accept delete this multi chronopic");
-               int id = myTreeViewMultiChronopic.EventSelectedID;
-               
-               Sqlite.Delete(false, Constants.MultiChronopicTable, id);
-               
-               myTreeViewMultiChronopic.DelEvent(id);
-               showHideActionEventButtons(false, Constants.MultiChronopicName);
-               
-               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.MULTICHRONOPIC, id );
-               try {
-                       if(currentMultiChronopic.UniqueID == id)
-                               deleted_last_test_update_widgets();
-               } catch {
-                       //there's no currentMultiChronopic (no one done it now), then it crashed,
-                       //but don't need to update widgets
-               }
-       }
-       
-
-
-
-       /* ---------------------------------------------------------
-        * ----------------  EVENTS TYPE ADD -----------------------
-        *  --------------------------------------------------------
-        */
-
-       
-       private void on_jump_simple_type_add_clicked (object o, EventArgs args) {
-               LogB.Information("Add simple new jump type");
-                       
-               jumpTypeAddWin = JumpTypeAddWindow.Show(app1, true); //is simple
-               jumpTypeAddWin.FakeButtonAccept.Clicked += new EventHandler(on_jump_type_add_accepted);
-       }
-       
-       private void on_jump_reactive_type_add_clicked (object o, EventArgs args) {
-               LogB.Information("Add reactive new jump type");
-                       
-               jumpTypeAddWin = JumpTypeAddWindow.Show(app1, false); //is reactive
-               jumpTypeAddWin.FakeButtonAccept.Clicked += new EventHandler(on_jump_type_add_accepted);
-       }
-       
-       private void on_jump_type_add_accepted (object o, EventArgs args) {
-               LogB.Information("ACCEPTED Add new jump type");
-               if(jumpTypeAddWin.InsertedSimple) {
-                       createComboSelectJumps(false); //this will update also the selectJumpsString
-
-                       UtilGtk.ComboUpdate(combo_result_jumps, 
-                                       SqliteJumpType.SelectJumpTypes(false, Constants.AllJumpsName, "", 
true), ""); //without filter, only select name
-                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added simple 
jump."));
-               } else {
-                       createComboSelectJumpsRj(false); //this will update also the selectJumpsRjString
-                       
-                       UtilGtk.ComboUpdate(combo_result_jumps_rj, 
-                                       SqliteJumpType.SelectJumpRjTypes(Constants.AllJumpsName, true), ""); 
//without filter, only select name
-                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added reactive 
jump."));
-               }
-               updateComboStats();
-               combo_select_jumps.Active = 0;
-               combo_select_jumps_rj.Active = 0;
-               combo_result_jumps.Active = 0;
-               combo_result_jumps_rj.Active = 0;
-       }
-
-       private void on_run_simple_type_add_activate (object o, EventArgs args) {
-               LogB.Information("Add simple new run type");
-                       
-               runTypeAddWin = RunTypeAddWindow.Show(app1, true); //is simple
-               runTypeAddWin.FakeButtonAccept.Clicked += new EventHandler(on_run_type_add_accepted);
-       }
-       
-       private void on_run_intervallic_type_add_activate (object o, EventArgs args) {
-               LogB.Information("Add intervallic new run type");
-                       
-               runTypeAddWin = RunTypeAddWindow.Show(app1, false); //is intervallic
-               runTypeAddWin.FakeButtonAccept.Clicked += new EventHandler(on_run_type_add_accepted);
-       }
-       
-       private void on_run_type_add_accepted (object o, EventArgs args) {
-               LogB.Information("ACCEPTED Add new run type");
-               if(runTypeAddWin.InsertedSimple) {
-                       createComboSelectRuns(false); //this will update also the selectRunsString
-
-                       UtilGtk.ComboUpdate(combo_result_runs, 
-                                       SqliteRunType.SelectRunTypes(Constants.AllRunsName, true), ""); 
//without filter, only select name
-                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added simple 
run."));
-               } else {
-                       createComboSelectRunsInterval(false); //this will update also the 
selectRunsIntervalString
-                       
-                       UtilGtk.ComboUpdate(combo_result_runs_interval, 
-                                       SqliteRunIntervalType.SelectRunIntervalTypes(Constants.AllRunsName, 
true), ""); //without filter, only select name
-                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added intervallic 
run."));
-               }
-               updateComboStats();
-               combo_select_runs.Active = 0;
-               combo_select_runs_interval.Active = 0;
-               combo_result_runs.Active = 0;
-               combo_result_runs_interval.Active = 0;
-       }
-
-       //reactiontime has no types
-
-       private void on_pulse_type_add_activate (object o, EventArgs args) {
-               LogB.Information("Add new pulse type");
-       }
-       
-       private void on_pulse_type_add_accepted (object o, EventArgs args) {
-               LogB.Information("ACCEPTED Add new pulse type");
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  EVENTS TYPE DELETE --------------------
-        *  --------------------------------------------------------
-        */
-
-       private void on_jump_type_delete_simple (object o, EventArgs args) {
-               jumpsMoreWin = JumpsMoreWindow.Show(app1, false); //delete jump type
-               jumpsMoreWin.Button_deleted_test.Clicked += new EventHandler(on_deleted_jump_type);
-       }
-       
-       private void on_jump_type_delete_reactive (object o, EventArgs args) {
-               jumpsRjMoreWin = JumpsRjMoreWindow.Show(app1, false); //delete jump type
-               jumpsRjMoreWin.Button_deleted_test.Clicked += new EventHandler(on_deleted_jump_rj_type);
-       }
-       
-       private void on_run_type_delete_simple (object o, EventArgs args) {
-               runsMoreWin = RunsMoreWindow.Show(app1, false); //delete run type
-               runsMoreWin.Button_deleted_test.Clicked += new EventHandler(on_deleted_run_type);
-       }
-       
-       private void on_run_type_delete_intervallic (object o, EventArgs args) {
-               runsIntervalMoreWin = RunsIntervalMoreWindow.Show(app1, false); //delete run type
-               runsIntervalMoreWin.Button_deleted_test.Clicked += new EventHandler(on_deleted_run_i_type);
-       }
-       
-       //----
-       
-       private void on_deleted_jump_type (object o, EventArgs args) {
-               //first delete if from combos
-               string translatedName = Util.FindOnArray(':', 2, 1, jumpsMoreWin.SelectedEventName, 
selectJumpsString);
-               UtilGtk.ComboDelThisValue(combo_select_jumps, translatedName);
-               UtilGtk.ComboDelThisValue(combo_result_jumps, translatedName);
-               
-               //2nd delete if from global string. -1 selects all row
-               string row = Util.FindOnArray(':',1, -1, jumpsMoreWin.SelectedEventName, selectJumpsString);
-               selectJumpsString = Util.DeleteString(selectJumpsString, row);
-
-               combo_select_jumps.Active = 0;
-               combo_result_jumps.Active = 0;
-
-               extra_window_jumps_initialize(new JumpType("Free"));
-       }
-
-       private void on_deleted_jump_rj_type (object o, EventArgs args) {
-               //first delete if from combos
-               string translatedName = Util.FindOnArray(':', 2, 1, jumpsRjMoreWin.SelectedEventName, 
selectJumpsRjString);
-               UtilGtk.ComboDelThisValue(combo_select_jumps_rj, translatedName);
-               UtilGtk.ComboDelThisValue(combo_result_jumps_rj, translatedName);
-               
-               //2nd delete if from global string. -1 selects all row
-               string row = Util.FindOnArray(':',1, -1, jumpsRjMoreWin.SelectedEventName, 
selectJumpsRjString);
-               selectJumpsRjString = Util.DeleteString(selectJumpsRjString, row);
-
-               combo_select_jumps_rj.Active = 0;
-               combo_result_jumps_rj.Active = 0;
-
-               extra_window_jumps_rj_initialize(new JumpType("RJ(j)"));
-       }
-
-       private void on_deleted_run_type (object o, EventArgs args) {
-               extra_window_runs_initialize(new RunType("Custom"));
-       }
-       private void on_deleted_run_i_type (object o, EventArgs args) {
-               extra_window_runs_interval_initialize(new RunType("byLaps"));
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  EVENTS REPAIR -------------------------
-        *  --------------------------------------------------------
-        */
-       
-       private void on_repair_selected_jump_rj_clicked (object o, EventArgs args) {
-               //notebooks_change(1); see "notebooks_change sqlite problem"
-               LogB.Information("Repair selected subjump");
-               //1.- check that there's a line selected
-               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
-               if (myTreeViewJumpsRj.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected jump
-                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
-               
-                       //4.- edit this jump
-                       repairJumpRjWin = RepairJumpRjWindow.Show(app1, myJump, preferences.digitsNumber);
-                       repairJumpRjWin.Button_accept.Clicked += new 
EventHandler(on_repair_selected_jump_rj_accepted);
-               }
-       }
-       
-       private void on_repair_selected_jump_rj_accepted (object o, EventArgs args) {
-               LogB.Information("Repair selected reactive jump accepted");
-               
-               treeview_jumps_rj_storeReset();
-               fillTreeView_jumps_rj(UtilGtk.ComboGetActive(combo_result_jumps_rj));
-               
-               if(createdStatsWin) {
-                       stats_win_fillTreeView_stats(false, false);
-               }
-       }
-       
-       private void on_repair_selected_run_interval_clicked (object o, EventArgs args) {
-               //notebooks_change(3); see "notebooks_change sqlite problem"
-               LogB.Information("Repair selected subrun");
-               //1.- check that there's a line selected
-               //2.- check that this line is a run and not a person 
-               //(check also if it's not a individual run interval, then pass the parent run interval)
-               if (myTreeViewRunsInterval.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected run
-                       RunInterval myRun = SqliteRunInterval.SelectRunData( Constants.RunIntervalTable, 
myTreeViewRunsInterval.EventSelectedID, false );
-               
-                       //4.- edit this run
-                       repairRunIntervalWin = RepairRunIntervalWindow.Show(app1, myRun, 
preferences.digitsNumber);
-                       repairRunIntervalWin.Button_accept.Clicked += new 
EventHandler(on_repair_selected_run_interval_accepted);
-               }
-       }
-       
-       private void on_repair_selected_run_interval_accepted (object o, EventArgs args) {
-               LogB.Information("repair selected run interval accepted");
-               
-               treeview_runs_interval_storeReset();
-               fillTreeView_runs_interval(UtilGtk.ComboGetActive(combo_result_runs_interval));
-               
-               if(createdStatsWin) {
-                       stats_win_fillTreeView_stats(false, false);
-               }
-       }
-
-       private void on_repair_selected_pulse_clicked (object o, EventArgs args) {
-               //notebooks_change(5); see "notebooks_change sqlite problem"
-               LogB.Information("Repair selected pulse");
-               //1.- check that there's a line selected
-               //2.- check that this line is a pulse and not a person 
-               //(check also if it's not a individual pulse, then pass the parent pulse)
-               if (myTreeViewPulses.EventSelectedID > 0) {
-                       //3.- obtain the data of the selected pulse
-                       Pulse myPulse = SqlitePulse.SelectPulseData( myTreeViewPulses.EventSelectedID, false 
);
-               
-                       //4.- edit this pulse
-                       repairPulseWin = RepairPulseWindow.Show(app1, myPulse, preferences.digitsNumber);
-                       repairPulseWin.Button_accept.Clicked += new 
EventHandler(on_repair_selected_pulse_accepted);
-               }
-       }
-       
-       private void on_repair_selected_pulse_accepted (object o, EventArgs args) {
-               LogB.Information("repair selected pulse accepted");
-               
-               treeview_pulses_storeReset();
-               fillTreeView_pulses(UtilGtk.ComboGetActive(combo_pulses));
-       }
-
-       private void on_repair_selected_multi_chronopic_clicked (object o, EventArgs args) {
-               //notebooks_change(6); see "notebooks_change sqlite problem"
-               LogB.Information("Repair selected multichronopic");
-       }
-
-       /* ---------------------------------------------------------
-        * ----------------  Info on power and stiffness -----------
-        *  --------------------------------------------------------
-        */
-
-
-       private void on_button_jumps_jumpsRj_result_help_power_clicked (object o, EventArgs args) {
-               new DialogMessage(Constants.MessageTypes.INFO, Constants.HelpPower);
-       }
-       private void on_button_jumps_jumpsRj_result_help_stiffness_clicked (object o, EventArgs args) {
-               new DialogMessage(Constants.MessageTypes.INFO, Constants.HelpStiffness, 
"hbox_stiffness_formula");
-       }
-
-       
-       /* ---------------------------------------------------------
-        * ----------------  AUTO MODE -----------------------------
-        *  --------------------------------------------------------
-        */
-
-       private void on_button_auto_start_clicked (object o, EventArgs args) {
-
-//TODO: put five buttons in a viewport than can be colorified
-
-               executeAutoWin = ExecuteAutoWindow.Show(app1, currentSession.UniqueID);
-               executeAutoWin.FakeButtonAccept.Clicked += new EventHandler(on_button_auto_start_accepted);
-       }
-
-       ArrayList execute_auto_order;
-       int execute_auto_order_pos;
-       bool execute_auto_doing = false;
-       private void on_button_auto_start_accepted (object o, EventArgs args) {
-               executeAutoWin.FakeButtonAccept.Clicked -= new EventHandler(on_button_auto_start_accepted);
-
-               sensitiveGuiAutoStartEnd (true);
-       
-               execute_auto_order = executeAutoWin.GetOrderedData();
-               execute_auto_order_pos = 0;
-               execute_auto_doing = true;
-
-               executeAutoWin.Close();
-
-               execute_auto_select();
-       }
-
-       private void execute_auto_select() 
-       {
-               if(execute_auto_order_pos >= execute_auto_order.Count) {
-                       on_button_auto_end_clicked (new object (), new EventArgs());
-                       return;
-               }
-
-               ExecuteAuto ea = (ExecuteAuto) execute_auto_order[execute_auto_order_pos];
-               int rowToSelect = myTreeViewPersons.FindRow(ea.personUniqueID);
-               if(rowToSelect != -1) {
-                       //this will update also currentPerson
-                       selectRowTreeView_persons(treeview_persons, treeview_persons_store, rowToSelect);
-                       label_jump_auto_current_person.Text = currentPerson.Name;
-
-                       //select the test
-                       int rowTest = Convert.ToInt32(Util.FindOnArray(':', 0, -2, 
ea.testUniqueID.ToString(), selectJumpsString));
-                       combo_select_jumps.Active = rowTest;
-                       label_jump_auto_current_test.Text = "(" + ea.testTrName + ")";
-                       
-                       //put GUI on auto_waiting
-                       sensitiveGuiAutoExecuteOrWait (false);
-               }
-       }
-
-       private void on_button_auto_end_clicked (object o, EventArgs args) 
-       {
-               sensitiveGuiAutoStartEnd (false);
-               execute_auto_doing = false;
-       }
-       
-       private void on_button_auto_order_clicked (object o, EventArgs args) {
-               executeAutoWin = ExecuteAutoWindow.ShowJustOrder(app1, execute_auto_order, 
execute_auto_order_pos);
-       }
-
-       private void on_button_auto_skip_person_clicked (object o, EventArgs args) {
-               execute_auto_order = ExecuteAuto.SkipPerson(execute_auto_order, execute_auto_order_pos, 
currentPerson);
-               
-               //update currentPerson and labels from current position
-               execute_auto_select();
-       }
-
-       private void on_button_auto_remove_person_clicked (object o, EventArgs args) {
-               execute_auto_order = ExecuteAuto.RemovePerson(execute_auto_order, execute_auto_order_pos, 
currentPerson);
-               
-               //update currentPerson and labels from current position
-               execute_auto_select();
-       }
-
-
-       /* ---------------------------------------------------------
-        * ----------------  SOME MORE CALLBACKS---------------------
-        *  --------------------------------------------------------
-        */
-
-       //changed by chronojump when it's needed
-       private void notebooks_change(int desiredPage) {
-               LogB.Information("notebooks_change");
-               //LogB.Debug(new StackFrame(1).GetMethod().Name);
-
-               //LogB.Information("currentPage" + notebook_execute.CurrentPage.ToString());
-               //LogB.Information("desiredPage" + desiredPage.ToString());
-
-               while(notebook_execute.CurrentPage < desiredPage) 
-                       notebook_execute.NextPage();
-               while(notebook_execute.CurrentPage > desiredPage) 
-                       notebook_execute.PrevPage();
-               
-               //delete capture graph 
-               UtilGtk.ClearDrawingArea(event_execute_drawingarea, event_execute_pixmap);
-               //change table under graph
-               change_notebook_results_data();
-
-               while(notebook_results.CurrentPage < desiredPage) 
-                       notebook_results.NextPage();
-               while(notebook_results.CurrentPage > desiredPage) 
-                       notebook_results.PrevPage();
-
-               while(notebook_options_top.CurrentPage < desiredPage) 
-                       notebook_options_top.NextPage();
-               while(notebook_options_top.CurrentPage > desiredPage) 
-                       notebook_options_top.PrevPage();
-               
-       
-               //change test image according to notebook_execute       
-               if(notebook_execute.CurrentPage == 0)
-                       changeTestImage(EventType.Types.JUMP.ToString(), 
-                                       currentJumpType.Name, currentJumpType.ImageFileName);
-               else if(notebook_execute.CurrentPage == 1)
-                       changeTestImage(EventType.Types.JUMP.ToString(), 
-                                       currentJumpRjType.Name, currentJumpRjType.ImageFileName);
-               else if(notebook_execute.CurrentPage == 2)
-                       changeTestImage(EventType.Types.RUN.ToString(), 
-                                       currentRunType.Name, currentRunType.ImageFileName);
-               else if(notebook_execute.CurrentPage == 3)
-                       changeTestImage(EventType.Types.RUN.ToString(), 
-                                       currentRunIntervalType.Name, currentRunIntervalType.ImageFileName);
-               else if(notebook_execute.CurrentPage == 4)
-                       changeTestImage(EventType.Types.REACTIONTIME.ToString(), 
-                                       currentReactionTimeType.Name, currentReactionTimeType.ImageFileName);
-               else if(notebook_execute.CurrentPage == 5)
-                       changeTestImage(EventType.Types.PULSE.ToString(), 
-                                       currentPulseType.Name, currentPulseType.ImageFileName);
-               else if(notebook_execute.CurrentPage == 6) {
-                       changeTestImage(EventType.Types.MULTICHRONOPIC.ToString(), 
-                                       currentMultiChronopicType.Name, 
currentMultiChronopicType.ImageFileName);
-               }
-       
-               //button_execute_test have to be non sensitive in multichronopic without two cps
-               //else has to be sensitive
-
-               //if there are persons
-               if (notebook_execute.CurrentPage == 6) {
-                       if (chronopicWin.NumConnected() >= 2)
-                               extra_window_multichronopic_can_do(true);
-                       else 
-                               extra_window_multichronopic_can_do(false);
-               } else {
-                       button_execute_test.Sensitive = myTreeViewPersons.IsThereAnyRecord();
-               }
-
-               //Attention: "notebooks_change sqlite problem"
-               //This will call stats_win_change_test_type
-               //that will call on_combo_stats_type_changed
-               //that will call updateComboStats
-               //and that will call Sqlite.
-               //This is dangerous because it can crash when notebooks_change is called after deleting a test
-               //just disable notebooks change in that situation
-               stats_win_change_test_type(notebook_execute.CurrentPage);
-       }
-       
-       //changed by user clicking on notebook tabs
-       private void on_notebook_change_by_user (object o, SwitchPageArgs args) {
-               //show chronojump logo on down-left area
-               //changeTestImage("", "", "LOGO");
-       }
-
-       //help
-       private void on_menuitem_manual_activate (object o, EventArgs args) {
-               /*
-               new DialogMessage(Constants.MessageTypes.HELP, 
-                               Catalog.GetString("There's a copy of Chronojump Manual at:") + "\n" + 
-                               "<i>" + Path.GetFullPath(Util.GetManualDir()) + "</i>\n\n" + 
-                               Catalog.GetString("Newer versions will be on this site:") +"\n" + 
-                               "<i>http://www.chronojump.org/multimedia.html</i>");
-                               */
-               LogB.Information("Opening manual at: " + System.IO.Path.GetFullPath(Util.GetManualDir())); 
-               try {
-                       System.Diagnostics.Process.Start(System.IO.Path.GetFullPath(Util.GetManualDir())); 
-               } catch {
-                       new DialogMessage(Constants.MessageTypes.WARNING, "Sorry, manual folder does not 
exist.");
-               }
-       }
-
-       private void on_menuitem_formulas_activate (object o, EventArgs args) {
-               new DialogMessage(Constants.MessageTypes.INFO, "Here there will be bibliographic information 
about formulas and some notes.\n\nProbably this will be a window and not a dialog\n\nNote text is 
selectable");
-       }
-
-       private void on_menuitem_accelerators_activate (object o, EventArgs args) {
-               new DialogMessage(
-                               Catalog.GetString("Accelerators help"),
-                               Constants.MessageTypes.INFO, 
-                               Catalog.GetString("Use these keys in order to work faster.") + "\n\n" +
-                               "- " + Catalog.GetString("On execute test tab:") + "\n\n" +
-                               "<tt><b>CTRL+p</b></tt> " + Catalog.GetString("Edit selected person") + "\n" +
-                               "<tt><b>CTRL+" + Catalog.GetString("CURSOR_UP") + "</b></tt> " + 
Catalog.GetString("Select previous person") + "\n" +
-                               "<tt><b>CTRL+" + Catalog.GetString("CURSOR_DOWN") + "</b></tt> " + 
Catalog.GetString("Select next person") + "\n" +
-                               "<tt><b>(space)</b></tt> " + Catalog.GetString("Execute test") + "\n" +
-                               "<tt><b>v</b></tt> " + Catalog.GetString("Play video of this test") + " " + 
Catalog.GetString("(if available)")+ "\n" +
-                               "<tt><b>d</b></tt> " + Catalog.GetString("Delete this test") + "\n" +
-                               "\n" + "- " + Catalog.GetString("On results tab:") + "\n\n" +
-                               "<tt><b>z</b></tt> " + Catalog.GetString("Zoom change") + "\n" +
-                               "<tt><b>v</b></tt> " + Catalog.GetString("Play video of selected test") + " " 
+ Catalog.GetString("(if available)")+ "\n" +
-                               "<tt><b>e</b></tt> " + Catalog.GetString("Edit selected test") + "\n" +
-                               "<tt><b>d</b></tt> " + Catalog.GetString("Delete selected test") + "\n" +
-                               "<tt><b>r</b></tt> " + Catalog.GetString("Repair selected test") + " " + 
Catalog.GetString("(if available)")
-                               );
-       }
-       
-       private void on_menuitem_check_last_version_activate (object o, EventArgs args) 
-       {
-               Json js = new Json();
-               bool success = js.GetLastVersion(progVersion);
-
-               if(success) {
-                       LogB.Information(js.ResultMessage);
-                       new DialogMessage(
-                                       "Chronojump",
-                                       Constants.MessageTypes.INFO, 
-                                       js.ResultMessage
-                                       );
-               }
-               else {
-                       LogB.Error(js.ResultMessage);
-                       new DialogMessage(
-                                       "Chronojump",
-                                       Constants.MessageTypes.WARNING, 
-                                       js.ResultMessage);
-               }
-       }
-
-       private void on_menuitem_ping_activate (object o, EventArgs args) 
-       {
-               pingDo(true);
-       }
-       private void pingAtStart()
-       {
-               pingDo(false);
-       }
-       private void pingDo(bool showInWindow)
-       {
-               Json js = new Json();
-               bool success = js.Ping(UtilAll.GetOS(), UtilAll.ReadVersion(), preferences.machineID);
-
-               if(success) {
-                       LogB.Information(js.ResultMessage);
-                       if(showInWindow)
-                               new DialogMessage(
-                                               "Chronojump",
-                                               Constants.MessageTypes.INFO, 
-                                               js.ResultMessage);
-               }
-               else {
-                       LogB.Error(js.ResultMessage);
-                       if(showInWindow)
-                               new DialogMessage(
-                                               "Chronojump",
-                                               Constants.MessageTypes.WARNING, 
-                                               js.ResultMessage);
-               }
-
-               /*
-               new DialogMessage(
-                               "Chronojump",
-                               Constants.MessageTypes.INFO, 
-                               "Temporarily Disabled");
-               */
-       }
-       
-       
-       private void on_preferences_debug_mode_start (object o, EventArgs args) {
-               //first delete debug file
-               Util.FileDelete(System.IO.Path.GetTempPath() + "chronojump-debug.txt");
-
-               encoderRProcCapture.Debug = true;
-               encoderRProcAnalyze.Debug = true;
-       
-               hbox_gui_tests.Visible = true;
-               button_carles.Visible = true;
-
-               preferencesWin.DebugActivated();
-       }
-
-       private void on_button_gui_tests_clicked (object o, EventArgs args) {
-               chronojumpWindowTestsStart(Convert.ToInt32(spin_gui_tests.Value -1));
-       }
-       
-       private void on_button_carles_clicked (object o, EventArgs args) {
-               //carles stuff
-       }
-
-
-       private void on_about1_activate (object o, EventArgs args) {
-               string translator_credits = Catalog.GetString ("translator-credits");
-               //only print if exist (don't print 'translator-credits' word
-               if(translator_credits == "translator-credits") 
-                       translator_credits = "";
-
-               new About(progVersion, translator_credits);
-       }
-               
-       private void on_button_rj_bells_clicked(object o, EventArgs args) {
-               repetitiveConditionsWin.View(Constants.BellModes.JUMPS, preferences.volumeOn);
-       }
-
-       private void on_button_time_bells_clicked(object o, EventArgs args) {
-               repetitiveConditionsWin.View(Constants.BellModes.RUNS, preferences.volumeOn);
-       }
-       
-       private void on_repetitive_conditions_closed(object o, EventArgs args) {
-               //treeview_encoder should be updated (to colorize some cells)
-               //only if there was data
-               //this avoids misbehaviour when bell is pressed and there's no data in treeview
-               EncoderCurve curve = treeviewEncoderCaptureCurvesGetCurve(1, false);
-               if(curve.N != null) {
-                       List<string> contents = 
Util.ReadFileAsStringList(UtilEncoder.GetEncoderCurvesTempFileName());
-                       encoderUpdateTreeViewCapture(contents); //this updates encoderCaptureCurves
-                       
-                       findAndMarkSavedCurves(false, false); //SQL closed; don't update curve SQL records 
(like future1: meanPower)
-                       
-                       //also update the bars plot (to show colors depending on bells changes)
-                       if(captureCurvesBarsData.Count > 0) {
-                               string mainVariable = 
Constants.GetEncoderVariablesCapture(preferences.encoderCaptureMainVariable);
-                               double mainVariableHigher = 
repetitiveConditionsWin.GetMainVariableHigher(mainVariable);
-                               double mainVariableLower = 
repetitiveConditionsWin.GetMainVariableLower(mainVariable);
-                               plotCurvesGraphDoPlot(mainVariable, mainVariableHigher, mainVariableLower, 
captureCurvesBarsData,
-                                               repetitiveConditionsWin.EncoderInertialDiscardFirstThree,
-                                               false); //not capturing
-                       } else
-                               UtilGtk.ErasePaint(encoder_capture_curves_bars_drawingarea, 
encoder_capture_curves_bars_pixmap);
-               }
-       }
-       
-
-       JumpsProfile jumpsProfile;
-
-       private void jumpsProfileDo (bool calculateData)
-       {
-               if(currentPerson == null || currentSession == null)
-                       return;
-               
-               if(jumpsProfile == null) {
-                       jumpsProfile = new JumpsProfile();
-                       calculateData = true;
-               }
-
-               if(calculateData)
-                       jumpsProfile.Calculate(currentPerson.UniqueID, currentSession.UniqueID);
-
-               JumpsProfileGraph.Do(jumpsProfile.GetIndexes(), drawingarea_jumps_profile);
-       }
-       private void on_drawingarea_jumps_profile_expose_event (object o, ExposeEventArgs args) 
-       {
-               jumpsProfileDo(false); //do not calculate data
-               //data is calculated on switch page (at notebook_capture_analyze) or on change person
-       }
-       
-       private void on_notebook_capture_analyze_switch_page (object o, SwitchPageArgs args) {
-               if(notebook_capture_analyze.CurrentPage == 2)
-                       jumpsProfileDo(true);
-       }
-
-       private void on_button_jumps_profile_help_clicked (object o, EventArgs args) {
-               scrolledwindow_jumps_profile_training.Visible = false;
-               scrolledwindow_jumps_profile_help.Visible = ! scrolledwindow_jumps_profile_help.Visible;
-       }
-
-       private void on_button_jumps_profile_training_clicked (object o, EventArgs args) {
-               scrolledwindow_jumps_profile_help.Visible = false;
-               scrolledwindow_jumps_profile_training.Visible = ! 
scrolledwindow_jumps_profile_training.Visible;
-       }
-
-
-       /* ---------------------------------------------------------
-        * ----------------  SENSITIVE GUI METHODS-------------------
-        *  --------------------------------------------------------
-        */
-
-       private void menuSessionSensitive(bool option)
-       {
-               menuitem_edit_session.Sensitive = option;
-               menuitem_delete_session.Sensitive = option;
-               menuitem_export_csv.Sensitive = option;
-               //menuitem_export_xml.Sensitive = option; not implemented yet
-               menuitem_encoder_session_overview.Sensitive = option;
-
-       }
-       
-       private void menuPersonSelectedSensitive(bool option)
-       {
-               button_persons_up.Sensitive = option;
-               button_persons_down.Sensitive = option;
-               button_edit_current_person.Sensitive = option;
-               button_show_all_person_events.Sensitive = option;
-               button_delete_current_person.Sensitive = option;
-       }
-
-       private void sensitiveGuiNoSession () 
-       {
-               notebook_session_person.CurrentPage = 0;
-
-               treeview_persons.Sensitive = false;
-               
-               //menuitems
-               menuSessionSensitive(false);
-               menuPersonSelectedSensitive(false);
-               
-               button_image_test_zoom.Sensitive = false;
-               frame_persons.Sensitive = false;
-               button_recuperate_person.Sensitive = false;
-               button_recuperate_persons_from_session.Sensitive = false;
-               button_person_add_single.Sensitive = false;
-               button_person_add_multiple.Sensitive = false;
-               button_edit_current_person.Sensitive = false;
-               button_delete_current_person.Sensitive = false;
-       
-               button_encoder_person_change.Sensitive = false;
-               
-               //notebooks
-               notebook_execute.Sensitive = false;
-               //hbox_chronopics.Sensitive = false;
-               notebook_results.Sensitive = false;
-               notebook_options_top.Sensitive = false;
-               notebook_encoder_sup.Sensitive = false;
-               vbox_stats.Sensitive = false;
-               frame_share_data.Sensitive = false;
-               
-               vbox_this_test_buttons.Sensitive = false;
-               vbox_execute_test.Sensitive = false;
-               button_execute_test.Sensitive = false;
-
-               encoderButtonsSensitive(encoderSensEnum.NOSESSION);
-               
-               eventExecuteHideAllTables();
-       }
-       
-       private void sensitiveGuiYesSession () 
-       {
-               notebook_session_person.CurrentPage = 1;
-
-               button_image_test_zoom.Sensitive = true;
-               frame_persons.Sensitive = true;
-               button_recuperate_person.Sensitive = true;
-               button_recuperate_persons_from_session.Sensitive = true;
-               button_person_add_single.Sensitive = true;
-               button_person_add_multiple.Sensitive = true;
-               
-               button_encoder_person_change.Sensitive = true;
-               
-               menuSessionSensitive(true);
-               vbox_stats.Sensitive = true;
-               frame_share_data.Sensitive = true;
-               
-               //changeTestImage("", "", "LOGO");
-       }
-
-       //only called by delete person functions (if we run out of persons)
-       private void sensitiveGuiNoPerson () {
-               hbox_jumps.Sensitive = false;
-               hbox_jumps_rj.Sensitive = false;
-               button_execute_test.Sensitive = false;
-               
-               encoderButtonsSensitive(encoderSensEnum.NOPERSON);
-               personChanged();
-               
-               notebook_execute.Sensitive = false;
-               //hbox_chronopics.Sensitive = false;
-               notebook_results.Sensitive = false;
-               notebook_options_top.Sensitive = false;
-               notebook_encoder_sup.Sensitive = false;
-               treeview_persons.Sensitive = false;
-               
-               menuPersonSelectedSensitive(false);
-               vbox_execute_test.Sensitive = false;
-
-               label_encoder_person_name.Text = "";
-       }
-       
-       private void sensitiveGuiYesPerson () {
-               hbox_jumps.Sensitive = true;
-               hbox_jumps_rj.Sensitive = true;
-               button_execute_test.Sensitive = true;
-
-               encoderButtonsSensitive(encoderSensEnum.YESPERSON);
-               personChanged();
-               
-               notebook_execute.Sensitive = true;
-               //hbox_chronopics.Sensitive = true;
-               notebook_results.Sensitive = true;
-               notebook_options_top.Sensitive = true;
-               notebook_encoder_sup.Sensitive = true;
-               treeview_persons.Sensitive = true;
-               
-               menuPersonSelectedSensitive(true);
-       
-               //unsensitive edit, delete, repair events because no event is initially selected
-               showHideActionEventButtons(false, "ALL");
-
-               combo_select_jumps.Sensitive = true;
-               combo_result_jumps.Sensitive = true;
-               combo_select_jumps_rj.Sensitive = true;
-               combo_result_jumps_rj.Sensitive = true;
-               combo_select_runs.Sensitive = true;
-               combo_result_runs.Sensitive = true;
-               combo_select_runs_interval.Sensitive = true;
-               combo_result_runs_interval.Sensitive = true;
-               combo_pulses.Sensitive = true;
-               
-               vbox_execute_test.Sensitive = true;
-       }
-       
-       private void sensitiveGuiYesEvent () {
-       }
-       
-       private void sensitiveGuiEventDoing () {
-               session_menuitem.Sensitive = false;
-               menuitem_mode.Sensitive = false;
-               
-               //jumpsProfile has Sqlite calls. Don't do them while jumping
-               //but don't unsensitive the notebook because user need to "finish" or cancel"
-               //notebook_capture_analyze.Sensitive = true; 
-               notebook_capture_analyze.GetNthPage(1).Hide();
-               if(radio_menuitem_mode_jumps_simple.Active)
-                       notebook_capture_analyze.GetNthPage(2).Hide();
-               
-               
-               help_menuitem.Sensitive = false;
-               frame_persons.Sensitive = false;
-               
-               button_execute_test.Sensitive = false;
-               
-               button_encoder_person_change.Sensitive = false;
-
-               encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
-               
-               //hbox
-               hbox_jumps_test.Sensitive = false;
-               hbox_jump_types_options.Sensitive = false;
-               
-               hbox_jumps_rj.Sensitive = false;
-               hbox_runs.Sensitive = false;
-               hbox_runs_interval.Sensitive = false;
-               hbox_pulses.Sensitive = false;
-               vbox_this_test_buttons.Sensitive = false;
-               
-               button_upload_session.Sensitive = false;
-               button_activate_chronopics.Sensitive = false;
-               notebook_options_top.Sensitive = false;
-               event_execute_button_update.Sensitive = false;
-               
-               //hbox_multi_chronopic_buttons.Sensitive = false;
-       }
-   
-       private void sensitiveGuiEventDone () {
-               LogB.Information(" sensitiveGuiEventDone start ");
-
-               session_menuitem.Sensitive = true;
-               menuitem_mode.Sensitive = true;
-
-               //jumpsProfile has Sqlite calls. Don't do them while jumping
-               //but don't unsensitive the notebook because user need to "finish" or cancel"
-               //notebook_capture_analyze.Sensitive = true; 
-               notebook_capture_analyze.GetNthPage(1).Show();
-               if(radio_menuitem_mode_jumps_simple.Active)
-                       notebook_capture_analyze.GetNthPage(2).Show();
-               
-               help_menuitem.Sensitive = true;
-               frame_persons.Sensitive = true;
-
-               button_execute_test.Sensitive = true;
-               
-               button_encoder_person_change.Sensitive = true;
-       
-               if(encoderCaptureCurves != null && encoderCaptureCurves.Count > 0)
-                       encoderButtonsSensitive(encoderSensEnum.DONEYESSIGNAL);
-               else
-                       encoderButtonsSensitive(encoderSensEnum.DONENOSIGNAL);
-
-               //hbox
-               hbox_jumps_test.Sensitive = true;
-               hbox_jump_types_options.Sensitive = true;
-               
-               hbox_jumps_rj.Sensitive = true;
-               hbox_runs.Sensitive = true;
-               hbox_runs_interval.Sensitive = true;
-               hbox_pulses.Sensitive = true;
-               //hbox_multi_chronopic_buttons.Sensitive = true;
-               vbox_this_test_buttons.Sensitive = true;
-               
-               button_upload_session.Sensitive = true;
-               button_activate_chronopics.Sensitive = true;
-               notebook_options_top.Sensitive = true;
-               event_execute_button_update.Sensitive = true;
-
-               //allow repeat last jump or run (check also if it wasn't cancelled)
-               if(currentEventExecute != null && ! currentEventExecute.Cancel) {
-                       switch (currentEventType.Type) {
-                               case EventType.Types.REACTIONTIME:
-                                       LogB.Information("sensitiveGuiEventDone reaction time");
-                                       break;
-                               case EventType.Types.PULSE:
-                                       LogB.Information("sensitiveGuiEventDone pulse");
-                                       break;
-                               case EventType.Types.MULTICHRONOPIC:
-                                       LogB.Information("sensitiveGuiEventDone multichronopic");
-                                       break;
-                               default:
-                                       LogB.Information("sensitiveGuiEventDone default");
-                                       break;
-                       }
-               }
-               LogB.Information(" sensitiveGuiEventDone end ");
-       }
-       
-       /*
-        * sensitive GUI on executeAuto methods 
-        */
-
-       private void on_autodetect_help_clicked (object o, EventArgs args) {
-               new DialogMessage(
-                               Catalog.GetString("Help on auto-detect"),
-                               Constants.MessageTypes.INFO, 
-                               Catalog.GetString("Modes:") + "\n\n" +
-                               "- <b>" + Catalog.GetString("Active") + "</b>:  " +
-                                       Catalog.GetString("Auto-detection on hardware is active.") + " " + 
Catalog.GetString("Default mode") + ".\n\n" +
-                               "- <b>" + Catalog.GetString("Active, discarding first port") + "</b>:  " + 
-                                       Catalog.GetString("Use this option on computers where first port 
fails.") + "\n\n" +
-                               "- <b>" + Catalog.GetString("Inactive") + "</b>:  " + 
-                                       Catalog.GetString("Auto-detection on hardware is inactive.") + " " + 
Catalog.GetString("Use it if you have problems at start or at capture.")
-                               );
-       }
-       
-       private void on_button_chronopic_wizard_clicked (object o, EventArgs args) 
-       {
-               chronopicWizardWin = ChronopicWizardWindow.Show();
-       
-               chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked -= 
-                       new EventHandler(chronopic_wizard_finished);
-               chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked += new 
-                       EventHandler(chronopic_wizard_finished);
-       }
-       private void chronopic_wizard_finished (object o, EventArgs args) 
-       {
-               chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked -= 
-                       new EventHandler(chronopic_wizard_finished);
-               
-               wizardPortContacts = chronopicWizardWin.PortContacts;
-               wizardPortEncoder = chronopicWizardWin.PortEncoder;
-               
-               LogB.Information("wizardPortContacts: " + wizardPortContacts);
-               LogB.Information("wizardPortEncoder: " + wizardPortEncoder);
-       
-               /*
-                * createChronopicWindow (pass cp,...)
-                * recreate is true because it has been created on first ChronojumpWindow call
-                */
-               //contacts and encoder
-               if(wizardPortContacts != "")
-               {
-                       Chronopic cpW; //cp Wizard
-                       chronopicWin.CreateSPifNeeded(wizardPortContacts);
-                       cpW = new Chronopic(chronopicWin.SP);
-                       ChronopicPortData cpdata = new ChronopicPortData(1, wizardPortContacts, true);
-                       ArrayList cpd = new ArrayList();
-                       cpd.Add(cpdata);
-
-                       if(wizardPortEncoder == "") //no encoder
-                               createChronopicWindow(cpW, cpd, true, "");
-                       else
-                               createChronopicWindow(cpW, cpd, true, wizardPortEncoder);
-               }
-               else { //only encoder
-                       createChronopicWindow(true, wizardPortEncoder);
-               }
-               
-               //need to do this because createChronopicWindow does it but relying on menuitem_mode, and now 
we are on start page      
-               if(wizardPortEncoder != "")
-                       chronopicEncoderLabels(true);
-
-               //all the needed info is take. Can destroy wizard window 
-               chronopicWizardWin.HideAndNull();
-       }
-
-       //start/end auto mode
-       private void sensitiveGuiAutoStartEnd (bool start) {
-               //if automode, sensitiveGuiEventDoing, sensitiveGuiEventDone don't work
-               session_menuitem.Sensitive      = ! start;
-               menuitem_mode.Sensitive         = ! start;
-               help_menuitem.Sensitive         = ! start;
-               frame_persons.Sensitive         = ! start;
-
-               hbox_jumps_test.Visible         = ! start;
-               button_auto_start.Visible       = ! start;      
-               hbox_jump_types_options.Visible = ! start;
-               hbox_jump_auto_controls.Visible  = start;
-               
-               notebook_capture_analyze.GetNthPage(1).Visible = ! start;
-               if(radio_menuitem_mode_jumps_simple.Active)
-                       notebook_capture_analyze.GetNthPage(2).Visible = ! start;
-
-               //when start, put button delete_this_test as not sensitive
-               //(just for the test previous to the auto process)
-               if(start)
-                       button_delete_this_test.Sensitive = false;
-       }
-       
-       //true: executing a test; false: waiting a test to be executed
-       private void sensitiveGuiAutoExecuteOrWait (bool execute) {
-               //if automode, sensitiveGuiEventDoing, sensitiveGuiEventDone don't work
-               button_activate_chronopics.Sensitive    = ! execute;
-               button_execute_test.Sensitive           = ! execute;
-               notebook_options_top.Sensitive          = ! execute;
-               vbox_this_test_buttons.Sensitive        = ! execute;
-       }
-
-
-       private void showHideActionEventButtons(bool show, string type) {
-               bool success = false;
-               bool recordedVideo = false;
-               if(type == "ALL" || type == "Jump") {
-                       button_edit_selected_jump.Sensitive = show;
-                       button_delete_selected_jump.Sensitive = show;
-
-                       button_video_play_selected_jump.Sensitive = false;
-                       if (myTreeViewJumps.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
-                                                       currentSession.UniqueID, 
-                                                       Constants.TestTypes.JUMP,
-                                                       myTreeViewJumps.EventSelectedID))) {
-                               button_video_play_selected_jump.Sensitive = true;
-                               recordedVideo = true;
-                       }
-
-
-                       success = true;
-               } 
-               if (type == "ALL" || type == "JumpRj") {
-                       button_edit_selected_jump_rj.Sensitive = show;
-                       button_delete_selected_jump_rj.Sensitive = show;
-                       button_repair_selected_jump_rj.Sensitive = show;
-
-                       button_video_play_selected_jump_rj.Sensitive = false;
-                       if (myTreeViewJumpsRj.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
-                                                       currentSession.UniqueID, 
-                                                       Constants.TestTypes.JUMP_RJ,
-                                                       myTreeViewJumpsRj.EventSelectedID))) {
-                               button_video_play_selected_jump_rj.Sensitive = true;
-                               recordedVideo = true;
-                       }
-
-                       success = true;
-               } 
-               if (type == "ALL" || type == "Run") {
-                       button_edit_selected_run.Sensitive = show;
-                       button_delete_selected_run.Sensitive = show;
-
-                       button_video_play_selected_run.Sensitive = false;
-                       if (myTreeViewRuns.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
-                                                       currentSession.UniqueID, 
-                                                       Constants.TestTypes.RUN,
-                                                       myTreeViewRuns.EventSelectedID))) {
-                               button_video_play_selected_run.Sensitive = true;
-                               recordedVideo = true;
-                       }
-
-                       success = true;
-               } 
-               if (type == "ALL" || type == "RunInterval") {
-                       button_edit_selected_run_interval.Sensitive = show;
-                       button_delete_selected_run_interval.Sensitive = show;
-                       button_repair_selected_run_interval.Sensitive = show;
-                       
-                       button_video_play_selected_run_interval.Sensitive = false;
-                       if (myTreeViewRunsInterval.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
-                                                       currentSession.UniqueID, 
-                                                       Constants.TestTypes.RUN_I,
-                                                       myTreeViewRunsInterval.EventSelectedID))) {
-                               button_video_play_selected_run_interval.Sensitive = true;
-                               recordedVideo = true;
-                       }
-
-                       success = true;
-               } 
-               if (type == "ALL" || type == "ReactionTime") {
-                       button_edit_selected_reaction_time.Sensitive = show;
-                       button_delete_selected_reaction_time.Sensitive = show;
-                       
-                       button_video_play_selected_reaction_time.Sensitive = false;
-                       if (myTreeViewReactionTimes.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
-                                                       currentSession.UniqueID, 
-                                                       Constants.TestTypes.RT,
-                                                       myTreeViewReactionTimes.EventSelectedID))) {
-                               button_video_play_selected_reaction_time.Sensitive = true;
-                               recordedVideo = true;
-                       }
-
-                       success = true;
-               } 
-               if (type == "ALL" || type == "Pulse") {
-                       // menuitem_edit_selected_pulse.Sensitive = show;
-                       // menuitem_delete_selected_pulse.Sensitive = show;
-                       button_edit_selected_pulse.Sensitive = show;
-                       button_delete_selected_pulse.Sensitive = show;
-                       button_repair_selected_pulse.Sensitive = show;
-                       
-                       button_video_play_selected_pulse.Sensitive = false;
-                       if (myTreeViewPulses.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
-                                                       currentSession.UniqueID, 
-                                                       Constants.TestTypes.PULSE,
-                                                       myTreeViewPulses.EventSelectedID))) {
-                               button_video_play_selected_pulse.Sensitive = true;
-                               recordedVideo = true;
-                       }
-
-                       success = true;
-               } 
-               if (type == "ALL" || type == Constants.MultiChronopicName) {
-                       button_edit_selected_multi_chronopic.Sensitive = show;
-                       button_delete_selected_multi_chronopic.Sensitive = show;
-                       
-                       button_video_play_selected_multi_chronopic.Sensitive = false;
-                       if (myTreeViewMultiChronopic.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
-                                                       currentSession.UniqueID, 
-                                                       Constants.TestTypes.MULTICHRONOPIC,
-                                                       myTreeViewMultiChronopic.EventSelectedID))) {
-                               button_video_play_selected_multi_chronopic.Sensitive = true;
-                               recordedVideo = true;
-                       }
-
-                       success = true;
-               } 
-               if (!success)
-                       LogB.Error(string.Format("Error in showHideActionEventButtons, type: {0}", type));
-
-               button_video_play_this_test.Sensitive = recordedVideo;
-       }
-       
-       
-       /*
-        * voluntary crash for testing purposes 
-        */
-
-       private void on_debug_crash_activate (object o, EventArgs args) {
-               bool voluntaryCrashAllowed = true;
-               if(voluntaryCrashAllowed) {
-                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Done for testing 
purposes. Chronojump will exit badly"), "", "Are you sure you want to crash application?");
-                       confirmWin.Button_accept.Clicked += new EventHandler(crashing);
-               } else {
-                       new DialogMessage(Constants.MessageTypes.INFO, "Currently disabled.");
-               }
-       }
-
-       private void crashing (object o, EventArgs args) {
-               string [] myString = new String [3];
-               LogB.Error(myString[5]);
-       }
-
-       private void on_menuitem_server_activate (object o, EventArgs args) {
-               LogB.Information("SERVER");
-       }
-
-
-}
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+
+using System;
+using Gtk;
+using Gdk;
+using Glade;
+using System.IO.Ports;
+using Mono.Unix;
+using System.IO; //"File" things
+using System.Collections; //ArrayList
+using System.Collections.Generic; //List
+using LongoMatch.Gui;
+using LongoMatch.Video.Capturer;
+using LongoMatch.Video.Common;
+using LongoMatch.Video.Utils;
+using System.Threading;
+using System.Diagnostics;
+
+public partial class ChronoJumpWindow 
+{
+       [Widget] Gtk.Window app1;
+       [Widget] Gtk.MenuBar main_menu;
+       [Widget] Gtk.MenuItem menuitem_mode;
+       
+       [Widget] Gtk.HBox hbox_gui_tests;
+       [Widget] Gtk.SpinButton spin_gui_tests;
+       [Widget] Gtk.Button button_carles;
+       
+       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_jumps_simple;
+       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_jumps_reactive;
+       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_runs_simple;
+       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_runs_intervallic;
+       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_power_gravitatory;
+       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_power_inertial;
+       [Widget] Gtk.RadioMenuItem radio_menuitem_mode_other;
+
+       [Widget] Gtk.MenuItem menuitem_mode_selected_jumps_simple;
+       [Widget] Gtk.MenuItem menuitem_mode_selected_jumps_reactive;
+       [Widget] Gtk.MenuItem menuitem_mode_selected_runs_simple;
+       [Widget] Gtk.MenuItem menuitem_mode_selected_runs_intervallic;
+       [Widget] Gtk.MenuItem menuitem_mode_selected_power_gravitatory;
+       [Widget] Gtk.MenuItem menuitem_mode_selected_power_inertial;
+       [Widget] Gtk.MenuItem menuitem_mode_selected_other;
+       
+       [Widget] Gtk.Notebook notebook_start; //use to display the start images to select different modes
+       [Widget] Gtk.Notebook notebook_sup;
+       [Widget] Gtk.HBox hbox_other;
+       [Widget] Gtk.Notebook notebook_capture_graph_table;
+       [Widget] Gtk.Notebook notebook_capture_analyze; //not encoder
+
+       
+       [Widget] Gtk.Label label_version;
+       [Widget] Gtk.Image image_logo;
+       [Widget] Gtk.Image image_selector_start_jumps;
+       [Widget] Gtk.Image image_selector_start_runs;
+       [Widget] Gtk.Image image_selector_start_encoder_gravitatory;
+       //[Widget] Gtk.Image image_selector_start_encoder_inertial;
+       
+       [Widget] Gtk.Notebook notebook_selector_start_jumps;
+       [Widget] Gtk.Viewport viewport_selector_start_jumps;
+       [Widget] Gtk.Label label_selector_start_jumps_simple;
+       [Widget] Gtk.Label label_selector_start_jumps_reactive;
+       [Widget] Gtk.Notebook notebook_selector_start_runs;
+       [Widget] Gtk.Viewport viewport_selector_start_runs;
+       [Widget] Gtk.Label label_selector_start_runs_simple;
+       [Widget] Gtk.Label label_selector_start_runs_intervallic;
+       [Widget] Gtk.Notebook notebook_selector_start_encoder;
+       [Widget] Gtk.Viewport viewport_selector_start_encoder;
+       [Widget] Gtk.Label label_selector_start_encoder_gravitatory;
+       [Widget] Gtk.Label label_selector_start_encoder_inertial;
+       
+       [Widget] Gtk.RadioButton radio_mode_reaction_times_small;
+       [Widget] Gtk.RadioButton radio_mode_pulses_small;
+       [Widget] Gtk.RadioButton radio_mode_multi_chronopic_small;
+       [Widget] Gtk.RadioButton radio_mode_encoder_capture_small;
+       [Widget] Gtk.RadioButton radio_mode_encoder_analyze_small;
+       [Widget] Gtk.Image image_mode_jumps_small;
+       [Widget] Gtk.Image image_mode_jumps_reactive_small;
+       [Widget] Gtk.Image image_mode_runs_small;
+       [Widget] Gtk.Image image_mode_runs_intervallic_small;
+       [Widget] Gtk.Image image_mode_reaction_times_small;
+       [Widget] Gtk.Image image_mode_pulses_small;
+       [Widget] Gtk.Image image_mode_multi_chronopic_small;
+       [Widget] Gtk.Label label_mode_jumps_small;
+       [Widget] Gtk.Label label_mode_jumps_reactive_small;
+       [Widget] Gtk.Label label_mode_runs_small;
+       [Widget] Gtk.Label label_mode_runs_intervallic_small;
+       [Widget] Gtk.Image image_mode_encoder_gravitatory;
+       [Widget] Gtk.Image image_mode_encoder_inertial;
+       [Widget] Gtk.Label label_mode_reaction_times_small;
+       [Widget] Gtk.Label label_mode_pulses_small;
+       [Widget] Gtk.Label label_mode_multi_chronopic_small;
+
+       [Widget] Gtk.Image image_persons_new_1;
+       [Widget] Gtk.Image image_persons_new_plus;
+       [Widget] Gtk.Image image_persons_open_1;
+       [Widget] Gtk.Image image_persons_open_plus;
+
+       [Widget] Gtk.Notebook notebook_session_person;
+       //[Widget] Gtk.Box vbox_persons;
+
+       [Widget] Gtk.TreeView treeview_persons;
+       [Widget] Gtk.TreeView treeview_jumps;
+       [Widget] Gtk.TreeView treeview_jumps_rj;
+       [Widget] Gtk.TreeView treeview_runs;
+       [Widget] Gtk.TreeView treeview_runs_interval;
+       [Widget] Gtk.TreeView treeview_reaction_times;
+       [Widget] Gtk.TreeView treeview_pulses;
+       [Widget] Gtk.TreeView treeview_multi_chronopic;
+       
+       [Widget] Gtk.Box hbox_combo_select_jumps;
+       [Widget] Gtk.Box hbox_combo_select_jumps_rj;
+       [Widget] Gtk.Box hbox_combo_select_runs;
+       [Widget] Gtk.Box hbox_combo_select_runs_interval;
+
+       //auto mode     
+       [Widget] Gtk.Box hbox_jump_types_options;
+       [Widget] Gtk.Box hbox_jump_auto_controls;
+       [Widget] Gtk.Image image_auto_person_skip;
+       [Widget] Gtk.Image image_auto_person_remove;
+       [Widget] Gtk.Button button_auto_start;
+       [Widget] Gtk.Label label_jump_auto_current_person;
+       [Widget] Gtk.Label label_jump_auto_current_test;
+               
+       [Widget] Gtk.Image image_line_session_avg;
+       [Widget] Gtk.Image image_line_session_max;
+       [Widget] Gtk.Image image_line_person_avg;
+       [Widget] Gtk.Image image_line_person_max;
+       [Widget] Gtk.Image image_line_person_max_all_sessions;
+
+       
+       [Widget] Gtk.Box hbox_combo_result_jumps;
+       [Widget] Gtk.Box hbox_combo_result_jumps_rj;
+       [Widget] Gtk.Box hbox_combo_result_runs;
+       [Widget] Gtk.Box hbox_combo_result_runs_interval;
+       
+       [Widget] Gtk.Box hbox_combo_pulses;
+       [Widget] Gtk.Box hbox_jumps;
+       [Widget] Gtk.Box hbox_jumps_test;
+       [Widget] Gtk.Box hbox_jumps_rj;
+       [Widget] Gtk.Box hbox_runs;
+       [Widget] Gtk.Box hbox_runs_interval;
+       [Widget] Gtk.Box hbox_pulses;
+       
+       [Widget] Gtk.ComboBox combo_select_jumps;
+       [Widget] Gtk.ComboBox combo_select_jumps_rj;
+       [Widget] Gtk.ComboBox combo_select_runs;
+       [Widget] Gtk.ComboBox combo_select_runs_interval;
+       
+       [Widget] Gtk.ComboBox combo_result_jumps;
+       [Widget] Gtk.ComboBox combo_result_jumps_rj;
+       [Widget] Gtk.ComboBox combo_result_runs;
+       [Widget] Gtk.ComboBox combo_result_runs_interval;
+       
+       [Widget] Gtk.ComboBox combo_pulses;
+
+       //menus
+       [Widget] Gtk.MenuItem session_menuitem;
+       [Widget] Gtk.MenuItem help_menuitem;
+
+       //menu session
+       [Widget] Gtk.MenuItem menuitem_edit_session;
+       [Widget] Gtk.MenuItem menuitem_delete_session;
+       [Widget] Gtk.MenuItem menuitem_export_csv;
+       [Widget] Gtk.MenuItem menuitem_export_xml;
+       [Widget] Gtk.MenuItem menuitem_encoder_session_overview;
+       [Widget] Gtk.MenuItem menuitem_import_chronojump_session;
+       [Widget] Gtk.Image image_session_open;
+               
+       //menu person
+       [Widget] Gtk.Button button_persons_up;
+       [Widget] Gtk.Button button_persons_down;
+       [Widget] Gtk.Button button_edit_current_person;
+       [Widget] Gtk.Button button_show_all_person_events;
+       [Widget] Gtk.Button button_delete_current_person;
+       [Widget] Gtk.Label label_current_person;
+       [Widget] Gtk.Label label_current_person_title;
+       
+       //tests
+       //jumps
+       [Widget] Gtk.Button button_edit_selected_jump;
+       [Widget] Gtk.Button button_video_play_selected_jump;
+       [Widget] Gtk.Button button_delete_selected_jump;
+       [Widget] Gtk.Button button_edit_selected_jump_rj;
+       [Widget] Gtk.Button button_video_play_selected_jump_rj;
+       [Widget] Gtk.Button button_delete_selected_jump_rj;
+       [Widget] Gtk.Button button_repair_selected_jump_rj;
+
+       [Widget] Gtk.Image extra_windows_jumps_image_dj_fall_calculate;
+       [Widget] Gtk.Image extra_windows_jumps_image_dj_fall_predefined;
+       [Widget] Gtk.HBox hbox_extra_window_jumps_fall_height;
+
+       [Widget] Gtk.Button button_jumps_result_help_power;
+       [Widget] Gtk.Button button_jumps_result_help_stiffness;
+       [Widget] Gtk.Button button_jumps_rj_result_help_power;
+       [Widget] Gtk.Button button_jumps_rj_result_help_stiffness;
+       
+       [Widget] Gtk.DrawingArea drawingarea_jumps_profile;
+       [Widget] Gtk.ScrolledWindow scrolledwindow_jumps_profile_help;
+       [Widget] Gtk.ScrolledWindow scrolledwindow_jumps_profile_training;
+       [Widget] Gtk.Image image_tab_jumps_profile;
+       
+       
+       //runs
+       [Widget] Gtk.MenuItem menu_execute_simple_runs1;
+       [Widget] Gtk.MenuItem menu_execute_intervallic_runs1;
+       [Widget] Gtk.Button button_edit_selected_run;
+       [Widget] Gtk.Button button_video_play_selected_run;
+       [Widget] Gtk.Button button_delete_selected_run;
+       [Widget] Gtk.Button button_edit_selected_run_interval;
+       [Widget] Gtk.Button button_video_play_selected_run_interval;
+       [Widget] Gtk.Button button_delete_selected_run_interval;
+       [Widget] Gtk.Button button_repair_selected_run_interval;
+
+
+       //other
+       //reaction time
+       [Widget] Gtk.Button button_edit_selected_reaction_time;
+       [Widget] Gtk.Button button_video_play_selected_reaction_time;
+       [Widget] Gtk.Button button_delete_selected_reaction_time;
+       [Widget] Gtk.SpinButton spinbutton_animation_lights_speed;
+       [Widget] Gtk.SpinButton spinbutton_flicker_lights_speed;
+       [Widget] Gtk.CheckButton check_reaction_time_disc_red;
+       [Widget] Gtk.CheckButton check_reaction_time_disc_yellow;
+       [Widget] Gtk.CheckButton check_reaction_time_disc_green;
+       [Widget] Gtk.CheckButton check_reaction_time_disc_buzzer;
+       [Widget] Gtk.SpinButton spinbutton_discriminative_lights_minimum;
+       [Widget] Gtk.SpinButton spinbutton_discriminative_lights_maximum;
+
+       //pulse
+       [Widget] Gtk.Button button_edit_selected_pulse;
+       [Widget] Gtk.Button button_video_play_selected_pulse;
+       [Widget] Gtk.Button button_delete_selected_pulse;
+       [Widget] Gtk.Button button_repair_selected_pulse;
+
+       [Widget] Gtk.Box vbox_execute_test;
+       [Widget] Gtk.Button button_execute_test;
+       [Widget] Gtk.Viewport viewport_chronopics;
+       [Widget] Gtk.Box hbox_chronopics;
+       [Widget] Gtk.Label label_chronopics;
+       [Widget] Gtk.Label label_connected_chronopics;
+       [Widget] Gtk.Label label_chronopics_multitest;
+       [Widget] Gtk.Image image_simulated_warning;
+       [Widget] Gtk.Box hbox_chronopic_detecting;
+       [Widget] Gtk.ProgressBar progressbar_chronopic_detecting;
+       [Widget] Gtk.Button button_chronopic_detecting_cancel;
+       [Widget] Gtk.Button button_chronopic_detecting_info;
+       [Widget] Gtk.Box hbox_chronopic_encoder_detecting;
+       [Widget] Gtk.ProgressBar progressbar_chronopic_encoder_detecting;
+       [Widget] Gtk.Button button_chronopic_encoder_detecting_cancel;
+       [Widget] Gtk.Button button_chronopic_encoder_detecting_info;
+       [Widget] Gtk.Viewport viewport_chronopic_encoder;
+       [Widget] Gtk.Label label_chronopic_encoder;
+       [Widget] Gtk.Image image_chronopic_encoder_no;
+       [Widget] Gtk.Image image_chronopic_encoder_yes;
+       
+       [Widget] Gtk.HBox hbox_video_capture;
+       [Widget] Gtk.Label label_video_feedback;
+       [Widget] Gtk.CheckButton checkbutton_video;
+       //[Widget] Gtk.Label label_video;
+       [Widget] Gtk.Image image_video_yes;
+       [Widget] Gtk.Image image_video_no;
+
+
+       //multiChronopic        
+       [Widget] Gtk.Button button_edit_selected_multi_chronopic;
+       [Widget] Gtk.Button button_video_play_selected_multi_chronopic;
+       [Widget] Gtk.Button button_delete_selected_multi_chronopic;
+//     [Widget] Gtk.Box hbox_multi_chronopic_buttons;
+//     [Widget] Gtk.Button button_multi_chronopic_start;
+//     [Widget] Gtk.Button button_run_analysis;
+//     [Widget] Gtk.Entry extra_window_spin_run_analysis_distance;
+//     [Widget] Gtk.CheckButton extra_window_check_multichronopic_sync;
+//     [Widget] Gtk.CheckButton extra_window_check_multichronopic_delete_first;
+//     [Widget] Gtk.Entry entry_multi_chronopic_cp2;
+
+       //widgets for enable or disable
+       [Widget] Gtk.Button button_new;
+       [Widget] Gtk.Button button_open;
+       [Widget] Gtk.Frame frame_persons;
+       [Widget] Gtk.Button button_recuperate_person;
+       [Widget] Gtk.Button button_recuperate_persons_from_session;
+       [Widget] Gtk.Button button_person_add_single;
+       [Widget] Gtk.Button button_person_add_multiple;
+
+       [Widget] Gtk.Button button_run_custom;
+       [Widget] Gtk.Button button_run_20m;
+       [Widget] Gtk.Button button_run_100m;
+       [Widget] Gtk.Button button_run_200m;
+       [Widget] Gtk.Button button_run_400m;
+       [Widget] Gtk.Button button_run_gesell;
+       [Widget] Gtk.Button button_run_20yard;
+       [Widget] Gtk.Button button_run_505;
+       [Widget] Gtk.Button button_run_illinois;
+       [Widget] Gtk.Button button_run_margaria;
+       [Widget] Gtk.Button button_run_shuttle;
+       [Widget] Gtk.Button button_run_zigzag;
+       [Widget] Gtk.Button button_run_interval_by_laps;
+       [Widget] Gtk.Button button_run_interval_by_time;
+       [Widget] Gtk.Button button_run_interval_unlimited;
+       [Widget] Gtk.Button button_run_interval_mtgug;
+       [Widget] Gtk.Button button_reaction_time_execute;
+
+       [Widget] Gtk.Notebook notebook_execute;
+       [Widget] Gtk.Notebook notebook_results;
+       [Widget] Gtk.Notebook notebook_options_top;
+               
+       [Widget] Gtk.Frame frame_share_data;
+       
+       [Widget] Gtk.EventBox eventbox_image_test;
+       [Widget] Gtk.Image image_test;
+       [Widget] Gtk.Button button_image_test_zoom;
+       [Widget] Gtk.Image image_test_zoom;
+       [Widget] Gtk.Box vbox_this_test_buttons;
+       [Widget] Gtk.Button button_video_play_this_test;
+       [Widget] Gtk.Button button_delete_this_test;
+               
+       [Widget] Gtk.Button button_upload_session;
+       [Widget] Gtk.Button button_activate_chronopics;
+
+       //non standard icons    
+       [Widget] Gtk.Image image_jump_reactive_bell;
+       [Widget] Gtk.Image image_run_interval_bell;
+       [Widget] Gtk.Image image_jump_reactive_repair;
+       [Widget] Gtk.Image image_run_interval_repair;
+       [Widget] Gtk.Image image_pulse_repair;
+       [Widget] Gtk.Image image_person_delete;
+       [Widget] Gtk.Image image_delete_this_test;
+       [Widget] Gtk.Image image_jump_delete;
+       [Widget] Gtk.Image image_jump_reactive_delete;
+       [Widget] Gtk.Image image_run_delete;
+       [Widget] Gtk.Image image_run_interval_delete;
+       [Widget] Gtk.Image image_reaction_time_delete;
+       [Widget] Gtk.Image image_pulse_delete;
+       [Widget] Gtk.Image image_multi_chronopic_delete;
+       [Widget] Gtk.Image image_jump_type_delete_simple;
+       [Widget] Gtk.Image image_jump_type_delete_reactive;
+       [Widget] Gtk.Image image_run_type_delete_simple;
+       [Widget] Gtk.Image image_run_type_delete_intervallic;
+
+       [Widget] Gtk.Image image_jumps_zoom;
+       [Widget] Gtk.Image image_jumps_rj_zoom;
+       [Widget] Gtk.Image image_runs_zoom;
+       [Widget] Gtk.Image image_runs_interval_zoom;
+       [Widget] Gtk.Image image_reaction_times_zoom;
+       [Widget] Gtk.Image image_pulses_zoom;
+       [Widget] Gtk.Image image_multi_chronopic_zoom;
+       
+       //encoder
+       [Widget] Gtk.Image image_encoder_capture_zoom;
+       //[Widget] Gtk.Image image_encoder_analyze_zoom;
+       [Widget] Gtk.Image image_encoder_analyze_stats;
+       [Widget] Gtk.Image image_encoder_analyze_image_save;
+       [Widget] Gtk.Image image_encoder_analyze_1RM_save;
+       [Widget] Gtk.Image image_encoder_analyze_table_save;
+       [Widget] Gtk.Image image_encoder_signal_delete;
+       [Widget] Gtk.Image image_encoder_inertial_instructions;
+
+
+       Random rand;
+
+       //persons
+       private TreeStore treeview_persons_store;
+       private TreeViewPersons myTreeViewPersons;
+       private Gtk.Button fakeButtonPersonUp;
+       private Gtk.Button fakeButtonPersonDown;
+       //normal jumps
+       private TreeStore treeview_jumps_store;
+       private TreeViewJumps myTreeViewJumps;
+       //rj jumps
+       private TreeStore treeview_jumps_rj_store;
+       private TreeViewJumpsRj myTreeViewJumpsRj;
+       //normal runs
+       private TreeStore treeview_runs_store;
+       private TreeViewRuns myTreeViewRuns;
+       //runs interval
+       private TreeStore treeview_runs_interval_store;
+       private TreeViewRunsInterval myTreeViewRunsInterval;
+       //reaction times
+       private TreeStore treeview_reaction_times_store;
+       private TreeViewReactionTimes myTreeViewReactionTimes;
+       //pulses
+       private TreeStore treeview_pulses_store;
+       private TreeViewPulses myTreeViewPulses;
+       //multiChronopic
+       private TreeStore treeview_multi_chronopic_store;
+       private TreeViewMultiChronopic myTreeViewMultiChronopic;
+       
+       private Preferences preferences;
+
+       private static Person currentPerson;
+       private static Session currentSession;
+       private static PersonSession currentPersonSession;
+       private static bool definedSession;
+       private static Jump currentJump;
+       private static JumpRj currentJumpRj;
+       private static Run currentRun;
+       private static RunInterval currentRunInterval;
+       private static ReactionTime currentReactionTime;
+       private static Pulse currentPulse;
+       private static MultiChronopic currentMultiChronopic;
+       
+       private static EventExecute currentEventExecute;
+
+       //Used by Cancel and Finish
+       private static EventType currentEventType;
+
+       private static JumpType currentJumpType;
+       private static JumpType currentJumpRjType;
+       bool thisJumpIsSimple;  //needed on updating
+       bool lastJumpIsSimple;  //needed on update
+       private static RunType currentRunType;
+       private static RunType currentRunIntervalType;
+       bool thisRunIsSimple;   //needed on updating
+       bool lastRunIsSimple;   //needed on update
+       private static PulseType currentPulseType;
+       private static ReactionTimeType currentReactionTimeType;
+       private static MultiChronopicType currentMultiChronopicType;
+       private static Report report;
+
+       //windows needed
+       PreferencesWindow preferencesWin;
+       SessionAddEditWindow sessionAddEditWin;
+       SessionLoadWindow sessionLoadWin;
+       PersonRecuperateWindow personRecuperateWin; 
+       PersonsRecuperateFromOtherSessionWindow personsRecuperateFromOtherSessionWin; 
+       PersonAddModifyWindow personAddModifyWin; 
+       PersonAddMultipleWindow personAddMultipleWin; 
+       PersonSelectWindow personSelectWin;
+       JumpsMoreWindow jumpsMoreWin;
+       JumpsRjMoreWindow jumpsRjMoreWin;
+       EditJumpWindow editJumpWin;
+       EditJumpRjWindow editJumpRjWin;
+       RepairJumpRjWindow repairJumpRjWin;
+       JumpTypeAddWindow jumpTypeAddWin;
+       
+       RunsMoreWindow runsMoreWin;
+       RunsIntervalMoreWindow runsIntervalMoreWin;
+       RunTypeAddWindow runTypeAddWin;
+       EditRunWindow editRunWin;
+       RepairRunIntervalWindow repairRunIntervalWin;
+       EditRunIntervalWindow editRunIntervalWin;
+
+       EditReactionTimeWindow editReactionTimeWin;
+
+       EditPulseWindow editPulseWin;
+       RepairPulseWindow repairPulseWin;
+       
+       EditMultiChronopicWindow editMultiChronopicWin;
+       
+       ConfirmWindowJumpRun confirmWinJumpRun; //for deleting jumps and RJ jumps (and runs)
+       ErrorWindow errorWin;
+       ReportWindow reportWin;
+       RepetitiveConditionsWindow repetitiveConditionsWin;
+       GenericWindow genericWin;
+               
+       EvaluatorWindow evalWin;
+       PersonNotUploadWindow personNotUploadWin; 
+       ExecuteAutoWindow executeAutoWin;
+       
+       ChronopicWindow chronopicWin;
+       ChronopicWizardWindow chronopicWizardWin;
+       string wizardPortContacts;
+       string wizardPortEncoder;
+               
+       static Thread pingThread;
+
+       
+       /*
+        * useful to not check for Chronopic if changing select_menuitem_mode_toggled from a 50 to a 50
+        * great for 1.6.3 where people change from simple jumps to reactive jumps and Chronopic don't need 
to change
+        *
+        * maybe it will be replaced by chronopic_wizard_window
+
+       private enum chronopicTypes { CONTACTS50, CONTACTS10, ENCODER }
+       private chronopicTypes lastChronopicType;
+        */
+       
+       private bool firstRjValue;
+       private double rjTcCount;
+       private double rjTvCount;
+       private string rjTcString;
+       private string rjTvString;
+       
+       private bool createdStatsWin;
+       
+       private string progVersion;
+       private string progName;
+
+       private string runningFileName; //useful for knowing if there are two chronojump instances
+
+       private bool normalGUI; //false means small gui
+
+       private bool debugMode; //currently only for encoder R
+
+       //int chronopicCancelledTimes = 0;
+
+
+       //only called the first time the software runs
+       //and only on windows
+       private void on_language_clicked(object o, EventArgs args) {
+               //languageChange();
+               //createMainWindow("");
+       }
+
+       private void on_button_image_test_zoom_clicked(object o, EventArgs args) {
+               EventType myType;
+               if(radio_menuitem_mode_jumps_simple.Active) 
+                       myType = currentJumpType;
+               else if(radio_menuitem_mode_jumps_reactive.Active) 
+                       myType = currentJumpRjType;
+               else if(radio_menuitem_mode_runs_simple.Active) 
+                       myType = currentRunType;
+               else if(radio_menuitem_mode_runs_intervallic.Active) 
+                       myType = currentRunIntervalType;
+               else if(radio_mode_reaction_times_small.Active) 
+                       myType = currentReactionTimeType;
+               else if(radio_mode_pulses_small.Active) 
+                       myType = currentPulseType;
+               else //if(radio_mode_multi_chronopic_small.Active) 
+                       myType = currentMultiChronopicType;
+                       
+               if(myType.Name == "DJa" && extra_window_jumps_check_dj_fall_calculate.Active)
+                       new DialogImageTest("", Util.GetImagePath(false) + "jump_dj_a_inside.png", 
DialogImageTest.ArchiveType.ASSEMBLY);
+               else if(myType.Name == "DJna" && extra_window_jumps_check_dj_fall_calculate.Active)
+                       new DialogImageTest("", Util.GetImagePath(false) + "jump_dj_inside.png", 
DialogImageTest.ArchiveType.ASSEMBLY);
+               else
+                       new DialogImageTest(myType);
+       }
+       
+       
+       public ChronoJumpWindow(string progVersion, string progName, string runningFileName)
+       {
+               this.progVersion = progVersion;
+               this.progName = progName;
+               this.runningFileName = runningFileName;
+               
+
+               Glade.XML gxml;
+               gxml = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", "app1", 
"chronojump");
+               gxml.Autoconnect(this);
+
+               //put an icon to window
+               UtilGtk.IconWindow(app1);
+       
+               //show chronojump logo on down-left area
+               changeTestImage("", "", "LOGO");
+       
+               //white bg
+               eventbox_image_test.ModifyBg(StateType.Normal, UtilGtk.WHITE);
+       
+               //start with the Mode selector  
+               notebook_start.CurrentPage = 0;
+
+               //new DialogMessage(Constants.MessageTypes.INFO, UtilGtk.ScreenHeightFitted(false).ToString() 
);
+               //UtilGtk.ResizeIfNeeded(stats_window);
+               
+               //app1.Maximize(); //this was for starting at fullscreen
+
+               report = new Report(-1); //when a session is loaded or created, it will change the 
report.SessionID value
+               //TODO: check what happens if a session it's deleted
+               //i think report it's deactivated until a new session is created or loaded, 
+               //but check what happens if report window is opened
+
+               //put videoOn as false before loading preferences to start always without the camera
+               //this is good if camera produces crash
+               SqlitePreferences.Update("videoOn", "False", false);
+               
+               //preferencesLoaded is a fix to a gtk#-net-windows-bug where radiobuttons raise signals
+               //at initialization of chronojump and gives problems if this signals are raised while 
preferences are loading
+               loadPreferences ();
+
+               createTreeView_persons (treeview_persons);
+
+               createTreeView_jumps (treeview_jumps);
+               createTreeView_jumps_rj (treeview_jumps_rj);
+               createTreeView_runs (treeview_runs);
+               createTreeView_runs_interval (treeview_runs_interval);
+               createTreeView_reaction_times (treeview_reaction_times);
+               createTreeView_pulses (treeview_pulses);
+               createTreeView_multi_chronopic (false, treeview_multi_chronopic);
+
+               createComboSelectJumps(true);
+               createComboSelectJumpsRj(true);
+               createComboSelectRuns(true);
+               createComboSelectRunsInterval(true);
+               
+               createComboResultJumps();
+               createComboResultJumpsRj();
+               createComboResultRuns();
+               createComboResultRunsInterval();
+
+               //reaction_times has no combo
+               createComboPulses();
+               //createComboMultiChronopic();
+               createdStatsWin = false;
+               
+               repetitiveConditionsWin = RepetitiveConditionsWindow.Create();
+               repetitiveConditionsWin.FakeButtonClose.Clicked += new 
EventHandler(on_repetitive_conditions_closed);
+
+               createChronopicWindow(false, "");
+               wizardPortContacts = "";
+               wizardPortEncoder = "";
+       
+               on_extra_window_multichronopic_test_changed(new object(), new EventArgs());
+               on_extra_window_pulses_test_changed(new object(), new EventArgs());
+               on_extra_window_reaction_times_test_changed(new object(), new EventArgs());
+               on_extra_window_runs_interval_test_changed(new object(), new EventArgs());
+               on_extra_window_runs_test_changed(new object(), new EventArgs());
+               on_extra_window_jumps_rj_test_changed(new object(), new EventArgs());
+               on_extra_window_jumps_test_changed(new object(), new EventArgs());
+               //changeTestImage("", "", "LOGO");
+
+               //We have no session, mark some widgets as ".Sensitive = false"
+               sensitiveGuiNoSession();
+               definedSession = false;
+               
+               rand = new Random(40);
+       
+               formatModeMenu();       
+               putNonStandardIcons();  
+               eventExecutePutNonStandardIcons();
+               //eventExecuteCreateComboGraphResultsSize();
+
+
+               /*
+       
+               if(chronopicPort != Constants.ChronopicDefaultPortWindows && 
+                               (chronopicPort != Constants.ChronopicDefaultPortLinux && 
File.Exists(chronopicPort))
+                 ) {
+                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Do you want to 
connect to Chronopic now?"), "", "");
+                       confirmWin.Button_accept.Clicked += new EventHandler(chronopicAtStart);
+               }
+               */
+
+               stats_win_create();
+               createdStatsWin = true;
+               //stats_win_initializeSession();
+
+               encoderInitializeStuff();       
+
+               //presentationInit();
+
+               videoCaptureInitialize();
+       
+               //leave empty on new releases   
+               //string buildDate = " (2016-07-27)";
+               string buildDate = " (d)";
+               label_version.Text = progVersion + buildDate;
+               LogB.Information("Build date:" + buildDate);
+
+               LeastSquares ls = new LeastSquares();
+               ls.Test();
+               LogB.Information(string.Format("coef = {0} {1} {2}", ls.Coef[0], ls.Coef[1], ls.Coef[2]));
+
+               /*
+                * start a ping in other thread
+                * http://www.mono-project.com/docs/gui/gtksharp/responsive-applications/
+                * Gtk.Application.Invoke
+                */
+               pingThread = new Thread (new ThreadStart (pingAtStart));
+               pingThread.Start();
+
+               //moveStartTestInitial();
+               
+               ChronopicRegister cr = new ChronopicRegister();
+       }
+
+
+/*
+       private void chronopicAtStart(object o, EventArgs args) {
+               //make active menuitem chronopic, and this
+               //will raise other things
+       }
+*/
+
+/*
+       private bool normalGUIOld = true; //to know if we changed state. Start as true
+       private void on_app1_size_allocate(object obj, SizeAllocatedArgs args) {
+               int width;
+               int height;
+               app1.GetSize(out width, out height);
+               if(width >= 1000)
+                       normalGUI = true;
+               else 
+                       normalGUI = false;
+               if(normalGUI != normalGUIOld) {
+                       Log.WriteLine("Change Size. New is normal? -> " + normalGUI.ToString());
+                       normalGUIOld = normalGUI;
+                       changeGUIAspect();
+               }
+       }
+       
+       private void changeGUIAspect() {
+               //QueryChildPacking(frame_test_options,
+               if(normalGUI) {
+                       //if change these values, change also in glade
+                       //frame_test_options.BoxChild.Expand(true);
+                       label_current_person_title.Text=Catalog.GetString("Current person");
+               } else {
+                       //frame_test_options.BoxChild.Expand(false);
+                       label_current_person_title.Text=Catalog.GetString("Current");
+               }
+       }
+*/
+
+       private void formatModeMenu() 
+       {
+               ((Label) radio_menuitem_mode_jumps_simple.Child).Text = 
+                       "   " + ((Label) radio_menuitem_mode_jumps_simple.Child).Text;
+               ((Label) radio_menuitem_mode_jumps_reactive.Child).Text = 
+                       "   " + ((Label) radio_menuitem_mode_jumps_reactive.Child).Text;
+
+               ((Label) radio_menuitem_mode_runs_simple.Child).Text = 
+                       "   " + ((Label) radio_menuitem_mode_runs_simple.Child).Text;
+               ((Label) radio_menuitem_mode_runs_intervallic.Child).Text = 
+                       "   " + ((Label) radio_menuitem_mode_runs_intervallic.Child).Text;
+               
+               ((Label) radio_menuitem_mode_power_gravitatory.Child).Text = 
+                       "   " + ((Label) radio_menuitem_mode_power_gravitatory.Child).Text;
+               ((Label) radio_menuitem_mode_power_inertial.Child).Text = 
+                       "   " + ((Label) radio_menuitem_mode_power_inertial.Child).Text;
+       }
+
+       private void putNonStandardIcons() {
+               Pixbuf pixbuf;
+       
+               //change colors of tests mode
+
+               /*
+                * gui for small screens
+                */
+               viewport_selector_start_jumps.ModifyBg(StateType.Normal, new Gdk.Color(0x0b,0x48,0x6b));
+               label_selector_start_jumps_simple.ModifyFg(StateType.Normal, new Gdk.Color(0xff,0xff,0xff));
+               label_selector_start_jumps_reactive.ModifyFg(StateType.Normal, new Gdk.Color(0xff,0xff,0xff));
+               
+               viewport_selector_start_runs.ModifyBg(StateType.Normal, new Gdk.Color(0x3b,0x86,0x86));
+               label_selector_start_runs_simple.ModifyFg(StateType.Normal, new Gdk.Color(0xff,0xff,0xff));
+               label_selector_start_runs_intervallic.ModifyFg(StateType.Normal, new 
Gdk.Color(0xff,0xff,0xff));
+               
+               viewport_selector_start_encoder.ModifyBg(StateType.Normal, new Gdk.Color(0x79,0xbd,0x98));
+               label_selector_start_encoder_gravitatory.ModifyFg(StateType.Normal, new 
Gdk.Color(0xff,0xff,0xff));
+               label_selector_start_encoder_inertial.ModifyFg(StateType.Normal, new 
Gdk.Color(0xff,0xff,0xff));
+
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumps);
+               image_mode_jumps_small.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumpsRJ);
+               image_mode_jumps_reactive_small.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameRuns);
+               image_mode_runs_small.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameRunsInterval);
+               image_mode_runs_intervallic_small.Pixbuf = pixbuf;
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameEncoderGravitatory);
+               image_mode_encoder_gravitatory.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameEncoderInertial);
+               image_mode_encoder_inertial.Pixbuf = pixbuf;
+       
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameReactionTime);
+               image_mode_reaction_times_small.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNamePulse);
+               image_mode_pulses_small.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameMultiChronopic);
+               image_mode_multi_chronopic_small.Pixbuf = pixbuf;
+               
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumpsFallCalculate);
+               extra_windows_jumps_image_dj_fall_calculate.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameJumpsFallPredefined);
+               extra_windows_jumps_image_dj_fall_predefined.Pixbuf = pixbuf;
+               
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_session_avg.png");
+               image_line_session_avg.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_session_max.png");
+               image_line_session_max.Pixbuf = pixbuf;
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_person_avg.png");
+               image_line_person_avg.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_person_max.png");
+               image_line_person_max.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "line_person_max_all_sessions.png");
+               image_line_person_max_all_sessions.Pixbuf = pixbuf;
+
+               //reaction times changes
+               //UtilGtk.ColorsTestLabel(viewport_chronopics, label_extra_window_radio_reaction_time);
+               //UtilGtk.ColorsTestLabel(viewport_chronopics, 
label_extra_window_radio_reaction_time_animation_lights);
+               //UtilGtk.ColorsTestLabel(viewport_chronopics, 
label_extra_window_radio_reaction_time_flicker);
+               //UtilGtk.ColorsTestLabel(viewport_chronopics, 
label_extra_window_radio_reaction_time_discriminative);
+               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_reaction_time);
+               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_reaction_time_animation_lights);
+               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_reaction_time_flicker);
+               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_reaction_time_discriminative);
+
+               //pulses changes
+               //UtilGtk.ColorsTestLabel(viewport_chronopics, label_extra_window_radio_pulses_free);
+               //UtilGtk.ColorsTestLabel(viewport_chronopics, label_extra_window_radio_pulses_custom);
+               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_pulses_free);
+               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_pulses_custom);
+
+               //multichronopic changes
+               //UtilGtk.ColorsTestLabel(viewport_chronopics, label_extra_window_radio_multichronopic_start);
+               //UtilGtk.ColorsTestLabel(viewport_chronopics, 
label_extra_window_radio_multichronopic_run_analysis);
+               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_multichronopic_start);
+               UtilGtk.ColorsRadio(viewport_chronopics, extra_window_radio_multichronopic_run_analysis);
+
+               //open buttons (this is shown better in windows than the default open icon)
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameOpen);
+               image_session_open.Pixbuf = pixbuf;
+               //not changed because it's small. TODO: do bigger
+               //image_encoder_capture_open.Pixbuf = pixbuf;
+
+               //persons buttons
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameNew1);
+               image_persons_new_1.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameNewPlus);
+               image_persons_new_plus.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameOpen1);
+               image_persons_open_1.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameOpenPlus);
+               image_persons_open_plus.Pixbuf = pixbuf;
+
+
+
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_bell.png");
+               image_jump_reactive_bell.Pixbuf = pixbuf;
+               image_run_interval_bell.Pixbuf = pixbuf;
+               image_encoder_bell.Pixbuf = pixbuf;
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "preferences-system.png");
+               image_jump_reactive_repair.Pixbuf = pixbuf;
+               image_run_interval_repair.Pixbuf = pixbuf;
+               image_pulse_repair.Pixbuf = pixbuf;
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_delete.png");
+               image_person_delete.Pixbuf = pixbuf;
+               image_delete_this_test.Pixbuf = pixbuf;
+               image_jump_delete.Pixbuf = pixbuf;
+               image_jump_reactive_delete.Pixbuf = pixbuf;
+               image_run_delete.Pixbuf = pixbuf;
+               image_run_interval_delete.Pixbuf = pixbuf;
+               image_reaction_time_delete.Pixbuf = pixbuf;
+               image_pulse_delete.Pixbuf = pixbuf;
+               image_multi_chronopic_delete.Pixbuf = pixbuf;
+               image_jump_type_delete_simple.Pixbuf = pixbuf;
+               image_jump_type_delete_reactive.Pixbuf = pixbuf;
+               image_run_type_delete_simple.Pixbuf = pixbuf;
+               image_run_type_delete_intervallic.Pixbuf = pixbuf;
+               
+               //zoom icons, done like this because there's one zoom icon created ad-hoc, 
+               //and is not nice that the other are different for an user theme change
+       
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameZoomFitIcon);
+               image_jumps_zoom.Pixbuf = pixbuf;
+               image_jumps_rj_zoom.Pixbuf = pixbuf;
+               image_runs_zoom.Pixbuf = pixbuf;
+               image_runs_interval_zoom.Pixbuf = pixbuf;
+               image_reaction_times_zoom.Pixbuf = pixbuf;
+               image_pulses_zoom.Pixbuf = pixbuf;
+               image_multi_chronopic_zoom.Pixbuf = pixbuf;
+               
+               //encoder
+               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_powerbars);
+               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_cross);
+               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_side);
+               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_single);
+               UtilGtk.ColorsRadio(viewport_chronopics, radiobutton_encoder_analyze_neuromuscular_profile);
+               
+               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_speed);
+               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_accel);
+               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_force);
+               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_power);
+               
+               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_range);
+               UtilGtk.ColorsCheckbox(viewport_chronopics, check_encoder_analyze_show_time_to_peak_power);
+
+
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "gpm-statistics.png");
+               image_encoder_analyze_stats.Pixbuf = pixbuf;
+               image_encoder_analyze_image_save.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "stock_delete.png");
+               image_encoder_signal_delete.Pixbuf = pixbuf;
+       
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "spreadsheet.png");
+               image_encoder_analyze_table_save.Pixbuf = pixbuf;
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "jumps-profile-pie.png");
+               image_tab_jumps_profile.Pixbuf = pixbuf;
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualCurrentSetIcon);
+               image_encoder_analyze_individual_current_set.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualCurrentSessionIcon);
+               image_encoder_analyze_individual_current_session.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeIndividualAllSessionsIcon);
+               image_encoder_analyze_individual_all_sessions.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeGroupalCurrentSessionIcon);
+               image_encoder_analyze_groupal_current_session.Pixbuf = pixbuf;
+
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzePowerbarsIcon);
+               image_encoder_analyze_powerbars.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeCrossIcon);
+               image_encoder_analyze_cross.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyze1RMIcon);
+               image_encoder_analyze_1RM.Pixbuf = pixbuf;
+               image_encoder_analyze_1RM_save.Pixbuf = pixbuf;
+
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeSideIcon);
+               image_encoder_analyze_side.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeSingleIcon);
+               image_encoder_analyze_single.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeNmpIcon);
+               image_encoder_analyze_nmp.Pixbuf = pixbuf;
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeEcconTogetherIcon);
+               image_encoder_analyze_eccon_together.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeEcconSeparatedIcon);
+               image_encoder_analyze_eccon_separated.Pixbuf = pixbuf;
+
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeSpeedIcon);
+               image_encoder_analyze_speed.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeAccelIcon);
+               image_encoder_analyze_accel.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeForceIcon);
+               image_encoder_analyze_force.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzePowerIcon);
+               image_encoder_analyze_power.Pixbuf = pixbuf;
+               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeMeanIcon);
+               image_encoder_analyze_mean.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeMaxIcon);
+               image_encoder_analyze_max.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeRangeIcon);
+               image_encoder_analyze_range.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderAnalyzeTimeToPPIcon);
+               image_encoder_analyze_time_to_pp.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameEncoderInertialInstructions);
+               image_encoder_inertial_instructions.Pixbuf = pixbuf;
+               
+               //auto mode
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameAutoPersonSkipIcon);
+               image_auto_person_skip.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameAutoPersonRemoveIcon);
+               image_auto_person_remove.Pixbuf = pixbuf;
+                               
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameSelectorJumps);
+               image_selector_start_jumps.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameSelectorRuns);
+               image_selector_start_runs.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameSelectorEncoderGravitatory);
+               image_selector_start_encoder_gravitatory.Pixbuf = pixbuf;
+               //pixbuf = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameSelectorEncoderInertial);
+               //image_selector_start_encoder_inertial.Pixbuf = pixbuf;
+
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo);
+               image_logo.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo320); //changed 
to 270 for the presentation
+               image_presentation_logo.Pixbuf = pixbuf;
+
+       }
+
+       private void loadPreferences () 
+       {
+               preferences = Preferences.LoadAllFromSqlite();
+
+               LogB.Information (string.Format(Catalog.GetString("Chronojump database version file: {0}"), 
+                                       preferences.databaseVersion));
+
+               checkbutton_allow_finish_rj_after_time.Active = preferences.allowFinishRjAfterTime;
+
+               //---- video ----
+
+               UtilGtk.ColorsCheckOnlyPrelight(checkbutton_video);
+               UtilGtk.ColorsCheckOnlyPrelight(checkbutton_video_encoder);
+               
+               //don't raise the signal        
+               checkbutton_video.Clicked -= new EventHandler(on_checkbutton_video_clicked);
+               checkbutton_video.Active = preferences.videoOn;
+               checkbutton_video.Clicked += new EventHandler(on_checkbutton_video_clicked);
+               //don't raise the signal        
+               checkbutton_video_encoder.Clicked -= new EventHandler(on_checkbutton_video_encoder_clicked);
+               checkbutton_video_encoder.Active = preferences.videoOn;
+               checkbutton_video_encoder.Clicked += new EventHandler(on_checkbutton_video_encoder_clicked);
+               
+               changeVideoButtons(preferences.videoOn);
+
+               //change language works on windows. On Linux let's change the locale
+               //if(UtilAll.IsWindows())
+               //      languageChange();
+
+               //pass to report
+               report.preferences = preferences;
+               report.Progversion = progVersion;
+
+               LogB.Information ( Catalog.GetString ("Preferences loaded") );
+       }
+
+       /*
+        * languageChange is not related to windows and linux, is related to .net or mono
+        * on .net (windows) we can change language. On mono, we use locale
+        * now since 0.53 svn, we use mono on windows and linux, then this is not used
+        *
+       private void languageChange () {
+               string myLanguage = SqlitePreferences.Select("language");
+               if ( myLanguage != "0") {
+                       try {
+                               Log.WriteLine("myLanguage: {0}", myLanguage);
+                               System.Threading.Thread.CurrentThread.CurrentCulture = new 
System.Globalization.CultureInfo(myLanguage);
+                               System.Threading.Thread.CurrentThread.CurrentUICulture = new 
System.Globalization.CultureInfo(myLanguage);
+                               //probably only works on newly created windows, if change, then say user has 
to restart
+                               Log.WriteLine ("Changed language to {0}", myLanguage );
+                       } catch {
+                               new DialogMessage(Catalog.GetString("There's a problem with this language on 
this computer. Please, choose another language."));
+                       }
+               }
+       }
+*/
+
+       /* ---------------------------------------------------------
+        * ----------------  test modes (small GUI) ----------------
+        *  --------------------------------------------------------
+        */
+
+
+       public void on_radio_mode_reaction_times_small_toggled (object obj, EventArgs args) {
+               if(radio_mode_reaction_times_small.Active) {
+                       notebooks_change(4);
+                       on_extra_window_reaction_times_test_changed(obj, args);
+                       hbox_results_legend.Visible = true;
+               }
+       }
+
+       public void on_radio_mode_pulses_small_toggled (object obj, EventArgs args) {
+               if(radio_mode_pulses_small.Active) {
+                       notebooks_change(5);
+                       on_extra_window_pulses_test_changed(obj, args);
+                       hbox_results_legend.Visible = false;
+               }
+       }
+
+       public void on_radio_mode_multi_chronopic_small_toggled (object obj, EventArgs args) {
+               if(radio_mode_multi_chronopic_small.Active) {
+                       notebooks_change(6);
+                       on_extra_window_multichronopic_test_changed(obj, args);
+                       hbox_results_legend.Visible = false;
+               }
+       }
+       
+       public void on_radio_mode_encoder_capture_small_toggled (object obj, EventArgs args) {
+               if(radio_mode_encoder_capture_small.Active) 
+                       notebook_encoder_sup.CurrentPage = 0;
+       }
+
+       public void on_radio_mode_encoder_analyze_small_toggled (object obj, EventArgs args) {
+               if(radio_mode_encoder_analyze_small.Active) 
+                       notebook_encoder_sup.CurrentPage = 1;
+       }
+
+       
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW (generic) --------------------
+        *  --------------------------------------------------------
+        */
+
+       private void expandOrMinimizeTreeView(TreeViewEvent tvEvent, TreeView tv) {
+               if(tvEvent.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED) 
+                       tv.CollapseAll();
+               else if (tvEvent.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
+                       tv.CollapseAll();
+                       tvEvent.ExpandOptimal();
+               } else   //MAXIMIZED
+                       tv.ExpandAll();
+
+               //Log.WriteLine("IS " + tvEvent.ExpandState);
+       }
+
+       private void on_treeview_button_release_event (object o, ButtonReleaseEventArgs args) {
+               Gdk.EventButton e = args.Event;
+               Gtk.TreeView myTv = (Gtk.TreeView) o;
+               if (e.Button == 3) {
+                       if(myTv == treeview_persons) {
+                               treeviewPersonsContextMenu(currentPerson);
+                       } else if(myTv == treeview_jumps) {
+                               if (myTreeViewJumps.EventSelectedID > 0) {
+                                       Jump myJump = SqliteJump.SelectJumpData( 
myTreeViewJumps.EventSelectedID, false );
+                                       treeviewJumpsContextMenu(myJump);
+                               }
+                       } else if(myTv == treeview_jumps_rj) {
+                               if (myTreeViewJumpsRj.EventSelectedID > 0) {
+                                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
+                                       treeviewJumpsRjContextMenu(myJump);
+                               }
+                       } else if(myTv == treeview_runs) {
+                               if (myTreeViewRuns.EventSelectedID > 0) {
+                                       Run myRun = SqliteRun.SelectRunData( myTreeViewRuns.EventSelectedID, 
false );
+                                       treeviewRunsContextMenu(myRun);
+                               }
+                       } else if(myTv == treeview_runs_interval) {
+                               if (myTreeViewRunsInterval.EventSelectedID > 0) {
+                                       RunInterval myRun = SqliteRunInterval.SelectRunData( 
Constants.RunIntervalTable, myTreeViewRunsInterval.EventSelectedID, false );
+                                       treeviewRunsIntervalContextMenu(myRun);
+                               }
+                       } else if(myTv == treeview_reaction_times) {
+                               if (myTreeViewReactionTimes.EventSelectedID > 0) {
+                                       ReactionTime myRt = SqliteReactionTime.SelectReactionTimeData( 
myTreeViewReactionTimes.EventSelectedID, false );
+                                       treeviewReactionTimesContextMenu(myRt);
+                               }
+                       } else if(myTv == treeview_pulses) {
+                               if (myTreeViewPulses.EventSelectedID > 0) {
+                                       Pulse myPulse = SqlitePulse.SelectPulseData( 
myTreeViewPulses.EventSelectedID, false );
+                                       treeviewPulsesContextMenu(myPulse);
+                               }
+                       } else if(myTv == treeview_multi_chronopic) {
+                               if (myTreeViewMultiChronopic.EventSelectedID > 0) {
+                                       MultiChronopic mc = SqliteMultiChronopic.SelectMultiChronopicData( 
myTreeViewMultiChronopic.EventSelectedID, false );
+                                       treeviewMultiChronopicContextMenu(mc);
+                               }
+                       } else
+                               LogB.Information(myTv.ToString());
+               }
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW PERSONS ----------------------
+        *  --------------------------------------------------------
+        */
+
+       private void createTreeView_persons (Gtk.TreeView tv) {
+               myTreeViewPersons = new TreeViewPersons( tv );
+               tv.Selection.Changed += onTreeviewPersonsSelectionEntry;
+       }
+
+       private void fillTreeView_persons () {
+               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
+                               currentSession.UniqueID, 
+                               false); //means: do not returnPersonAndPSlist
+
+               if(myPersons.Count > 0) {
+                       //fill treeview
+                       myTreeViewPersons.Fill(myPersons);
+               }
+       }
+
+       private void on_treeview_persons_up (object o, EventArgs args) {
+               myTreeViewPersons.SelectPreviousRow(currentPerson.UniqueID);
+       }
+       
+       private void on_treeview_persons_down (object o, EventArgs args) {
+               myTreeViewPersons.SelectNextRow(currentPerson.UniqueID);
+       }
+       
+       //return true if selection is done (there's any person)
+       private bool selectRowTreeView_persons(Gtk.TreeView tv, TreeStore store, int rowNum) 
+       {
+               myTreeViewPersons.SelectRow(rowNum);
+               
+               //the selection of row in treeViewPersons.SelectRow is not a real selection 
+               //and unfortunately doesn't raises the on_treeview_persons_cursor_changed ()
+               //for this reason we reproduce the method here
+               TreeModel model;
+               TreeIter iter;
+               if (tv.Selection.GetSelected (out model, out iter)) {
+                       string selectedID = (string) model.GetValue (iter, 0); //ID, Name
+                       currentPerson = SqlitePerson.Select(Convert.ToInt32(selectedID));
+                       currentPersonSession = SqlitePersonSession.Select(Convert.ToInt32(selectedID), 
currentSession.UniqueID);
+                       label_person_change();
+               
+                       return true;
+               } else {
+                       return false;
+               }
+       }
+
+       void label_person_change() {
+               label_current_person.Text = "<b>" + currentPerson.Name + "</b>"; 
+               label_current_person.UseMarkup = true; 
+               label_encoder_person_name.Text = "<b>" + currentPerson.Name + "</b>"; 
+               label_encoder_person_name.UseMarkup = true; 
+       }
+       
+       private void treeview_persons_storeReset() {
+               myTreeViewPersons.RemoveColumns();
+               myTreeViewPersons = new TreeViewPersons(treeview_persons);
+       }
+       
+       //private void on_treeview_persons_cursor_changed (object o, EventArgs args) {
+       private void onTreeviewPersonsSelectionEntry (object o, EventArgs args) {
+               TreeModel model;
+               TreeIter iter;
+
+               // you get the iter and the model if something is selected
+               if (((TreeSelection)o).GetSelected(out model, out iter)) {
+                       string selectedID = (string) model.GetValue (iter, 0); //ID, Name
+               
+                       currentPerson = SqlitePerson.Select(Convert.ToInt32(selectedID));
+                       currentPersonSession = SqlitePersonSession.Select(Convert.ToInt32(selectedID), 
currentSession.UniqueID);
+                       label_person_change();
+       
+                       personChanged();        
+               }
+       }
+
+       private void personChanged() {
+               //1) change on jumps, runs, pulse capture graph
+               if(radio_menuitem_mode_jumps_simple.Active) {
+                       updateGraphJumpsSimple();
+
+                       if(notebook_capture_analyze.CurrentPage == 2) //Jumps Profile
+                               jumpsProfileDo(true); //calculate data
+               }
+               else if(radio_menuitem_mode_runs_simple.Active) 
+                       updateGraphRunsSimple();
+               else if(radio_mode_reaction_times_small.Active) 
+                       updateGraphReactionTimes();
+               
+               //2) change on encoder
+               encoderPersonChanged();
+       }
+
+       private void treeviewPersonsContextMenu(Person myPerson) {
+               Menu myMenu = new Menu ();
+               Gtk.MenuItem myItem;
+
+               myItem = new MenuItem ( Catalog.GetString("Edit") + " " + myPerson.Name);
+               myItem.Activated += on_edit_current_person_clicked_from_main_gui;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+
+               myItem = new MenuItem ( Catalog.GetString("Show all tests of") + " " + myPerson.Name);
+               myItem.Activated += on_show_all_person_events_activate;
+               myMenu.Attach( myItem, 0, 1, 1, 2 );
+
+               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
+               myMenu.Attach( mySep, 0, 1, 2, 3 );
+
+               myItem = new MenuItem ( string.Format(Catalog.GetString("Delete {0} from this 
session"),myPerson.Name));
+               myItem.Activated += on_delete_current_person_from_session_clicked;
+               myMenu.Attach( myItem, 0, 1, 3, 4 );
+
+               myMenu.Popup();
+               myMenu.ShowAll();
+       }
+               
+
+       private void resetAllTreeViews( bool alsoPersons) {
+               if(alsoPersons) {
+                       //load the persons treeview
+                       treeview_persons_storeReset();
+                       fillTreeView_persons();
+               }
+
+               //Leave SQL opened in all this process
+               Sqlite.Open(); // ------------------------------
+
+               //load the jumps treeview
+               treeview_jumps_storeReset();
+               fillTreeView_jumps(Constants.AllJumpsName, true);
+
+               //load the jumps_rj treeview_rj
+               treeview_jumps_rj_storeReset();
+               fillTreeView_jumps_rj(Constants.AllJumpsName, true);
+
+               //load the runs treeview
+               treeview_runs_storeReset();
+               fillTreeView_runs(Constants.AllRunsName, true);
+
+               //load the runs_interval treeview
+               treeview_runs_interval_storeReset();
+               fillTreeView_runs_interval(Constants.AllRunsName, true);
+
+               //load the pulses treeview
+               treeview_pulses_storeReset();
+               fillTreeView_pulses(Constants.AllPulsesName, true);
+
+               //load the reaction_times treeview
+               treeview_reaction_times_storeReset();
+               fillTreeView_reaction_times("reactionTime", true);
+
+               //load the multiChronopic treeview
+               treeview_multi_chronopic_storeReset(true);
+               fillTreeView_multi_chronopic(true);
+               
+
+               //close SQL opened in all this process
+               Sqlite.Close(); // ------------------------------
+       }
+
+
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW JUMPS ------------------------
+        *  --------------------------------------------------------
+        */
+
+       private void createTreeView_jumps (Gtk.TreeView tv) {
+               //myTreeViewJumps is a TreeViewJumps instance
+               myTreeViewJumps = new TreeViewJumps(tv, preferences, TreeViewEvent.ExpandStates.MINIMIZED);
+
+               //the glade cursor_changed does not work on mono 1.2.5 windows
+               tv.CursorChanged += on_treeview_jumps_cursor_changed; 
+       
+               //show or hide help_power and help_stiffness depending on preferences
+               button_jumps_result_help_power.Visible = preferences.showPower;
+               button_jumps_result_help_stiffness.Visible = preferences.showStiffness;
+       }
+
+       private void fillTreeView_jumps (string filter) {
+               fillTreeView_jumps(filter, false);
+       }
+       private void fillTreeView_jumps (string filter, bool dbconOpened) {
+               string [] myJumps;
+       
+               myJumps = SqliteJump.SelectJumps(dbconOpened, currentSession.UniqueID, -1, "", "",
+                               Sqlite.Orders_by.DEFAULT, -1);
+
+               myTreeViewJumps.Fill(myJumps, filter);
+
+               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewJumps, treeview_jumps);
+       }
+
+       private void on_button_jumps_zoom_clicked (object o, EventArgs args) {
+               myTreeViewJumps.ExpandState = myTreeViewJumps.ZoomChange(myTreeViewJumps.ExpandState);
+               if(myTreeViewJumps.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
+                       treeview_jumps.CollapseAll();
+               else
+                       treeview_jumps.ExpandAll();
+       }
+       
+       private void treeview_jumps_storeReset() {
+               myTreeViewJumps.RemoveColumns();
+               
+               myTreeViewJumps = new TreeViewJumps(treeview_jumps, preferences, myTreeViewJumps.ExpandState);
+       }
+
+       private void on_treeview_jumps_cursor_changed (object o, EventArgs args) {
+               LogB.Information("Cursor changed");
+               // don't select if it's a person, 
+               // is for not confusing with the person treeviews that controls who jumps
+               if (myTreeViewJumps.EventSelectedID == 0) {
+                       myTreeViewJumps.Unselect();
+                       showHideActionEventButtons(false, "Jump"); //hide
+               } else {
+                       showHideActionEventButtons(true, "Jump"); //show
+               }
+       }
+
+       private void treeviewJumpsContextMenu(Jump myJump) {
+               Menu myMenu = new Menu ();
+               Gtk.MenuItem myItem;
+
+               /*
+               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
+                               myJump.Type + " (" + myJump.PersonName + ")");
+               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
+                               Constants.TestTypes.JUMP, myTreeViewJumps.EventSelectedID))) {
+                       myItem.Activated += on_video_play_selected_jump_clicked;
+                       myItem.Sensitive = true;
+               } else 
+                       myItem.Sensitive = false;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+               */
+
+               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
+               myItem.Activated += on_edit_selected_jump_clicked;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+       
+               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
+               myMenu.Attach( mySep, 0, 1, 1, 2 );
+
+               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
+               myItem.Activated += on_delete_selected_jump_clicked;
+               myMenu.Attach( myItem, 0, 1, 2, 3 );
+
+               myMenu.Popup();
+               myMenu.ShowAll();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW JUMPS RJ ---------------------
+        *  --------------------------------------------------------
+        */
+
+       private void createTreeView_jumps_rj (Gtk.TreeView tv) {
+               myTreeViewJumpsRj = new TreeViewJumpsRj (tv, preferences, 
TreeViewEvent.ExpandStates.MINIMIZED);
+
+               //the glade cursor_changed does not work on mono 1.2.5 windows
+               tv.CursorChanged += on_treeview_jumps_rj_cursor_changed; 
+       
+               //show or hide help_power and help_stiffness depending on preferences
+               button_jumps_rj_result_help_power.Visible = preferences.showPower;
+               button_jumps_rj_result_help_stiffness.Visible = preferences.showStiffness;
+       }
+
+       private void fillTreeView_jumps_rj (string filter) {
+               fillTreeView_jumps_rj (filter, false);
+       }
+       private void fillTreeView_jumps_rj (string filter, bool dbconOpened) {
+               string [] myJumps;
+               myJumps = SqliteJumpRj.SelectJumps(dbconOpened, currentSession.UniqueID, -1, "", "");
+               myTreeViewJumpsRj.Fill(myJumps, filter);
+
+               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewJumpsRj, treeview_jumps_rj);
+
+       }
+
+       private void on_button_jumps_rj_zoom_clicked (object o, EventArgs args) {
+               myTreeViewJumpsRj.ExpandState = myTreeViewJumpsRj.ZoomChange(myTreeViewJumpsRj.ExpandState);
+               if(myTreeViewJumpsRj.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
+                       treeview_jumps_rj.CollapseAll();
+               else if(myTreeViewJumpsRj.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
+                       treeview_jumps_rj.CollapseAll();
+                       myTreeViewJumpsRj.ExpandOptimal();
+               } else
+                       treeview_jumps_rj.ExpandAll();
+       }
+
+       private void treeview_jumps_rj_storeReset() {
+               myTreeViewJumpsRj.RemoveColumns();
+               myTreeViewJumpsRj = new TreeViewJumpsRj (treeview_jumps_rj, preferences, 
myTreeViewJumpsRj.ExpandState);
+       }
+
+       private void on_treeview_jumps_rj_cursor_changed (object o, EventArgs args) {
+               // don't select if it's a person, 
+               // is for not confusing with the person treeviews that controls who jumps
+               if (myTreeViewJumpsRj.EventSelectedID == 0) {
+                       myTreeViewJumpsRj.Unselect();
+                       showHideActionEventButtons(false, "JumpRj");
+               } else if (myTreeViewJumpsRj.EventSelectedID == -1) {
+                       myTreeViewJumpsRj.SelectHeaderLine();
+                       showHideActionEventButtons(true, "JumpRj");
+               } else {
+                       showHideActionEventButtons(true, "JumpRj");
+               }
+       }
+
+       private void treeviewJumpsRjContextMenu(JumpRj myJump) {
+               Menu myMenu = new Menu ();
+               Gtk.MenuItem myItem;
+
+               /*
+               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
+                               myJump.Type + " (" + myJump.PersonName + ")");
+               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
+                               Constants.TestTypes.JUMP_RJ, myTreeViewJumpsRj.EventSelectedID))) {
+                       myItem.Activated += on_video_play_selected_jump_rj_clicked;
+                       myItem.Sensitive = true;
+               } else 
+                       myItem.Sensitive = false;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+               */
+               
+               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
+               myItem.Activated += on_edit_selected_jump_rj_clicked;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+
+               myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
+               myItem.Activated += on_repair_selected_jump_rj_clicked;
+               myMenu.Attach( myItem, 0, 1, 1, 2 );
+               
+               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
+               myMenu.Attach( mySep, 0, 1, 2, 3 );
+
+               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myJump.Type + " (" + 
myJump.PersonName + ")");
+               myItem.Activated += on_delete_selected_jump_rj_clicked;
+               myMenu.Attach( myItem, 0, 1, 3, 4 );
+
+               myMenu.Popup();
+               myMenu.ShowAll();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW RUNS -------------------------
+        *  --------------------------------------------------------
+        */
+
+       private void createTreeView_runs (Gtk.TreeView tv) {
+               //myTreeViewRuns is a TreeViewRuns instance
+               myTreeViewRuns = new TreeViewRuns (tv, preferences.digitsNumber, 
preferences.metersSecondsPreferred, TreeViewEvent.ExpandStates.MINIMIZED );
+
+               //the glade cursor_changed does not work on mono 1.2.5 windows
+               tv.CursorChanged += on_treeview_runs_cursor_changed; 
+       }
+
+       private void fillTreeView_runs (string filter) {
+               fillTreeView_runs (filter, false);
+       }
+       private void fillTreeView_runs (string filter, bool dbconOpened) {
+               string [] myRuns = SqliteRun.SelectRuns(dbconOpened, currentSession.UniqueID, -1, "",
+                               Sqlite.Orders_by.DEFAULT, -1);
+
+               myTreeViewRuns.Fill(myRuns, filter);
+
+               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewRuns, treeview_runs);
+       }
+       
+       private void on_button_runs_zoom_clicked (object o, EventArgs args) {
+               myTreeViewRuns.ExpandState = myTreeViewRuns.ZoomChange(myTreeViewRuns.ExpandState);
+               if(myTreeViewRuns.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
+                       treeview_runs.CollapseAll();
+               else
+                       treeview_runs.ExpandAll();
+       }
+       
+       private void treeview_runs_storeReset() {
+               myTreeViewRuns.RemoveColumns();
+               myTreeViewRuns = new TreeViewRuns(treeview_runs, preferences.digitsNumber, 
preferences.metersSecondsPreferred, myTreeViewRuns.ExpandState);
+       }
+
+       private void on_treeview_runs_cursor_changed (object o, EventArgs args) {
+               // don't select if it's a person, 
+               // is for not confusing with the person treeviews that controls who runs
+               if (myTreeViewRuns.EventSelectedID == 0) {
+                       myTreeViewRuns.Unselect();
+                       showHideActionEventButtons(false, "Run");
+               } else {
+                       showHideActionEventButtons(true, "Run");
+               }
+       }
+
+       private void treeviewRunsContextMenu(Run myRun) {
+               Menu myMenu = new Menu ();
+               Gtk.MenuItem myItem;
+
+               /*
+               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
+                               myRun.Type + " (" + myRun.PersonName + ")");
+               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
+                               Constants.TestTypes.RUN, myTreeViewRuns.EventSelectedID))) {
+                       myItem.Activated += on_video_play_selected_run_clicked;
+                       myItem.Sensitive = true;
+               } else 
+                       myItem.Sensitive = false;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+               */
+
+               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
+               myItem.Activated += on_edit_selected_run_clicked;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+
+               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
+               myMenu.Attach( mySep, 0, 1, 1, 2 );
+
+               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
+               myItem.Activated += on_delete_selected_run_clicked;
+               myMenu.Attach( myItem, 0, 1, 2, 3 );
+
+               myMenu.Popup();
+               myMenu.ShowAll();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW RUN INTERVAL -----------------
+        *  --------------------------------------------------------
+        */
+
+       private void createTreeView_runs_interval (Gtk.TreeView tv) {
+               //myTreeViewRunsInterval is a TreeViewRunsInterval instance
+               myTreeViewRunsInterval = new TreeViewRunsInterval (tv, preferences.digitsNumber, 
preferences.metersSecondsPreferred, TreeViewEvent.ExpandStates.MINIMIZED);
+
+               //the glade cursor_changed does not work on mono 1.2.5 windows
+               tv.CursorChanged += on_treeview_runs_interval_cursor_changed; 
+       }
+
+       private void fillTreeView_runs_interval (string filter) {
+               fillTreeView_runs_interval (filter, false);
+       }
+       private void fillTreeView_runs_interval (string filter, bool dbconOpened) {
+               string [] myRuns = SqliteRunInterval.SelectRuns(dbconOpened, currentSession.UniqueID, -1, "");
+               myTreeViewRunsInterval.Fill(myRuns, filter);
+               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewRunsInterval, treeview_runs_interval);
+       }
+       
+       private void on_button_runs_interval_zoom_clicked (object o, EventArgs args) {
+               myTreeViewRunsInterval.ExpandState = 
myTreeViewRunsInterval.ZoomChange(myTreeViewRunsInterval.ExpandState);
+               if(myTreeViewRunsInterval.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
+                       treeview_runs_interval.CollapseAll();
+               else if(myTreeViewRunsInterval.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
+                       treeview_runs_interval.CollapseAll();
+                       myTreeViewRunsInterval.ExpandOptimal();
+               } else
+                       treeview_runs_interval.ExpandAll();
+       }
+
+       private void treeview_runs_interval_storeReset() {
+               myTreeViewRunsInterval.RemoveColumns();
+               myTreeViewRunsInterval = new TreeViewRunsInterval (treeview_runs_interval,  
+                               preferences.digitsNumber, preferences.metersSecondsPreferred, 
myTreeViewRunsInterval.ExpandState);
+       }
+
+       private void on_treeview_runs_interval_cursor_changed (object o, EventArgs args) {
+               // don't select if it's a person, 
+               // is for not confusing with the person treeviews that controls who runs
+               if (myTreeViewRunsInterval.EventSelectedID == 0) {
+                       myTreeViewRunsInterval.Unselect();
+                       showHideActionEventButtons(false, "RunInterval");
+               } else if (myTreeViewRunsInterval.EventSelectedID == -1) {
+                       myTreeViewRunsInterval.SelectHeaderLine();
+                       showHideActionEventButtons(true, "RunInterval");
+               } else {
+                       showHideActionEventButtons(true, "RunInterval");
+               }
+       }
+
+       private void treeviewRunsIntervalContextMenu(RunInterval myRun) {
+               Menu myMenu = new Menu ();
+               Gtk.MenuItem myItem;
+
+               /*
+               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
+                               myRun.Type + " (" + myRun.PersonName + ")");
+               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
+                               Constants.TestTypes.RUN_I, myTreeViewRunsInterval.EventSelectedID))) {
+                       myItem.Activated += on_video_play_selected_run_interval_clicked;
+                       myItem.Sensitive = true;
+               } else 
+                       myItem.Sensitive = false;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+               */
+
+               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
+               myItem.Activated += on_edit_selected_run_interval_clicked;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+
+               myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
+               myItem.Activated += on_repair_selected_run_interval_clicked;
+               myMenu.Attach( myItem, 0, 1, 1, 2 );
+               
+               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
+               myMenu.Attach( mySep, 0, 1, 2, 3 );
+
+               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myRun.Type + " (" + 
myRun.PersonName + ")");
+               myItem.Activated += on_delete_selected_run_interval_clicked;
+               myMenu.Attach( myItem, 0, 1, 3, 4 );
+
+               myMenu.Popup();
+               myMenu.ShowAll();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW REACTION TIMES ---------------
+        *  --------------------------------------------------------
+        */
+
+       private void createTreeView_reaction_times (Gtk.TreeView tv) {
+               //myTreeViewReactionTimes is a TreeViewReactionTimes instance
+               myTreeViewReactionTimes = new TreeViewReactionTimes( tv, preferences.digitsNumber, 
TreeViewEvent.ExpandStates.MINIMIZED);
+
+               //the glade cursor_changed does not work on mono 1.2.5 windows
+               tv.CursorChanged += on_treeview_reaction_times_cursor_changed; 
+       }
+
+       private void fillTreeView_reaction_times (string filter) {
+               fillTreeView_reaction_times (filter, false);
+       }
+       private void fillTreeView_reaction_times (string filter, bool dbconOpened) {
+               string [] myRTs = SqliteReactionTime.SelectReactionTimes(dbconOpened, 
currentSession.UniqueID, -1, "", 
+                               Sqlite.Orders_by.DEFAULT, -1);
+
+               myTreeViewReactionTimes.Fill(myRTs, filter);
+               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewReactionTimes, treeview_reaction_times);
+       }
+       
+       private void on_button_reaction_times_zoom_clicked (object o, EventArgs args) {
+               myTreeViewReactionTimes.ExpandState = myTreeViewReactionTimes.ZoomChange(
+                               myTreeViewReactionTimes.ExpandState);
+               if(myTreeViewReactionTimes.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
+                       treeview_reaction_times.CollapseAll();
+               else
+                       treeview_reaction_times.ExpandAll();
+       }
+       
+       private void treeview_reaction_times_storeReset() {
+               myTreeViewReactionTimes.RemoveColumns();
+               myTreeViewReactionTimes = new TreeViewReactionTimes( treeview_reaction_times, 
preferences.digitsNumber, myTreeViewReactionTimes.ExpandState );
+       }
+
+       private void on_treeview_reaction_times_cursor_changed (object o, EventArgs args) {
+               // don't select if it's a person, 
+               // is for not confusing with the person treeviews that controls who is executing
+               if (myTreeViewReactionTimes.EventSelectedID == 0) {
+                       myTreeViewReactionTimes.Unselect();
+                       showHideActionEventButtons(false, "ReactionTime");
+               } else {
+                       showHideActionEventButtons(true, "ReactionTime");
+               }
+       }
+
+       private void treeviewReactionTimesContextMenu(ReactionTime myRt) {
+               Menu myMenu = new Menu ();
+               Gtk.MenuItem myItem;
+
+               /*
+               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
+                               myRt.Type + " (" + myRt.PersonName + ")");
+               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
+                               Constants.TestTypes.RT, myTreeViewReactionTimes.EventSelectedID))) {
+                       myItem.Activated += on_video_play_selected_reaction_time_clicked;
+                       myItem.Sensitive = true;
+               } else 
+                       myItem.Sensitive = false;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+               */
+
+               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myRt.Type + " (" + 
myRt.PersonName + ")");
+               myItem.Activated += on_edit_selected_reaction_time_clicked;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+
+               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
+               myMenu.Attach( mySep, 0, 1, 1, 2 );
+
+               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myRt.Type + " (" + 
myRt.PersonName + ")");
+               myItem.Activated += on_delete_selected_reaction_time_clicked;
+               myMenu.Attach( myItem, 0, 1, 2, 3 );
+
+               myMenu.Popup();
+               myMenu.ShowAll();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW PULSES -----------------------
+        *  --------------------------------------------------------
+        */
+
+       private void createTreeView_pulses (Gtk.TreeView tv) {
+               //myTreeViewPulses is a TreeViewPulses instance
+               myTreeViewPulses = new TreeViewPulses( tv, preferences.digitsNumber, 
TreeViewEvent.ExpandStates.MINIMIZED );
+
+               //the glade cursor_changed does not work on mono 1.2.5 windows
+               tv.CursorChanged += on_treeview_pulses_cursor_changed; 
+       }
+
+       private void fillTreeView_pulses (string filter) {
+               fillTreeView_pulses (filter, false);
+       }
+       private void fillTreeView_pulses (string filter, bool dbconOpened) {
+               string [] myPulses = SqlitePulse.SelectPulses(dbconOpened, currentSession.UniqueID, -1);
+               myTreeViewPulses.Fill(myPulses, filter);
+               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewPulses, treeview_pulses);
+       }
+       
+       private void on_button_pulses_zoom_clicked (object o, EventArgs args) {
+               myTreeViewPulses.ExpandState = myTreeViewPulses.ZoomChange(myTreeViewPulses.ExpandState);
+               if(myTreeViewPulses.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
+                       treeview_pulses.CollapseAll();
+               else if(myTreeViewPulses.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
+                       treeview_pulses.CollapseAll();
+                       myTreeViewPulses.ExpandOptimal();
+               } else
+                       treeview_pulses.ExpandAll();
+       }
+
+       private void treeview_pulses_storeReset() {
+               myTreeViewPulses.RemoveColumns();
+               myTreeViewPulses = new TreeViewPulses( treeview_pulses, preferences.digitsNumber, 
myTreeViewPulses.ExpandState );
+       }
+
+       private void on_treeview_pulses_cursor_changed (object o, EventArgs args) {
+               // don't select if it's a person, 
+               // is for not confusing with the person treeviews that controls who is executing
+               if (myTreeViewPulses.EventSelectedID == 0) {
+                       myTreeViewPulses.Unselect();
+                       showHideActionEventButtons(false, "Pulse");
+               } else if (myTreeViewPulses.EventSelectedID == -1) {
+                       myTreeViewPulses.SelectHeaderLine();
+                       showHideActionEventButtons(true, "Pulse");
+               } else {
+                       showHideActionEventButtons(true, "Pulse");
+               }
+       }
+
+       private void treeviewPulsesContextMenu(Pulse myPulse) {
+               Menu myMenu = new Menu ();
+               Gtk.MenuItem myItem;
+
+               /*
+               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
+                               myPulse.Type + " (" + myPulse.PersonName + ")");
+               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
+                               Constants.TestTypes.PULSE, myTreeViewPulses.EventSelectedID))) {
+                       myItem.Activated += on_video_play_selected_pulse_clicked;
+                       myItem.Sensitive = true;
+               } else 
+                       myItem.Sensitive = false;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+               */
+
+               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + myPulse.Type + " (" + 
myPulse.PersonName + ")");
+               myItem.Activated += on_edit_selected_pulse_clicked;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+
+               myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + myPulse.Type + " (" + 
myPulse.PersonName + ")");
+               myItem.Activated += on_repair_selected_pulse_clicked;
+               myMenu.Attach( myItem, 0, 1, 1, 2 );
+               
+               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
+               myMenu.Attach( mySep, 0, 1, 2, 3 );
+
+               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + myPulse.Type + " (" + 
myPulse.PersonName + ")");
+               myItem.Activated += on_delete_selected_pulse_clicked;
+               myMenu.Attach( myItem, 0, 1, 3, 4 );
+
+               myMenu.Popup();
+               myMenu.ShowAll();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  TREEVIEW MULTI CHRONOPIC --------------
+        *  --------------------------------------------------------
+        */
+
+       private void createTreeView_multi_chronopic (bool dbconOpened, Gtk.TreeView tv) {
+               //myTreeViewMultiChronopic is a TreeViewMultiChronopic instance
+               if(definedSession)
+                       myTreeViewMultiChronopic = new TreeViewMultiChronopic( tv, preferences.digitsNumber, 
+                                       TreeViewEvent.ExpandStates.MINIMIZED, 
SqliteMultiChronopic.MaxCPs(dbconOpened, currentSession.UniqueID) );
+               else
+                       myTreeViewMultiChronopic = new TreeViewMultiChronopic( tv, preferences.digitsNumber, 
+                                       TreeViewEvent.ExpandStates.MINIMIZED, 2);
+
+               //the glade cursor_changed does not work on mono 1.2.5 windows
+               tv.CursorChanged += on_treeview_multi_chronopic_cursor_changed; 
+       }
+       
+       private void fillTreeView_multi_chronopic () {
+               fillTreeView_multi_chronopic (false);
+       }
+       private void fillTreeView_multi_chronopic (bool dbconOpened) {
+               string [] mcs = SqliteMultiChronopic.SelectTests(dbconOpened, currentSession.UniqueID, -1);
+               myTreeViewMultiChronopic.Fill(mcs, "");
+               expandOrMinimizeTreeView((TreeViewEvent) myTreeViewMultiChronopic, treeview_multi_chronopic);
+       }
+       
+       private void on_button_multi_chronopic_zoom_clicked (object o, EventArgs args) {
+               myTreeViewMultiChronopic.ExpandState = 
myTreeViewMultiChronopic.ZoomChange(myTreeViewMultiChronopic.ExpandState);
+               if(myTreeViewMultiChronopic.ExpandState == TreeViewEvent.ExpandStates.MINIMIZED)
+                       treeview_multi_chronopic.CollapseAll();
+               else if(myTreeViewMultiChronopic.ExpandState == TreeViewEvent.ExpandStates.OPTIMAL) {
+                       treeview_multi_chronopic.CollapseAll();
+                       myTreeViewMultiChronopic.ExpandOptimal();
+               } else
+                       treeview_multi_chronopic.ExpandAll();
+       }
+       
+       private void treeview_multi_chronopic_storeReset(bool dbconOpened) {
+               myTreeViewMultiChronopic.RemoveColumns();
+               if(definedSession)
+                       myTreeViewMultiChronopic = new TreeViewMultiChronopic( treeview_multi_chronopic, 
preferences.digitsNumber, 
+                                       myTreeViewMultiChronopic.ExpandState, 
SqliteMultiChronopic.MaxCPs(dbconOpened, currentSession.UniqueID) );
+               else
+                       myTreeViewMultiChronopic = new TreeViewMultiChronopic( treeview_multi_chronopic, 
preferences.digitsNumber, 
+                                       myTreeViewMultiChronopic.ExpandState, 2);
+       }
+
+       private void on_treeview_multi_chronopic_cursor_changed (object o, EventArgs args) {
+               LogB.Information("Cursor changed");
+               // don't select if it's a person, 
+               // is for not confusing with the person treeviews that controls who does events
+               if (myTreeViewMultiChronopic.EventSelectedID == 0) {
+                       myTreeViewMultiChronopic.Unselect();
+                       showHideActionEventButtons(false, Constants.MultiChronopicName); //hide
+               } else if (myTreeViewMultiChronopic.EventSelectedID == -1) {
+                       myTreeViewMultiChronopic.SelectHeaderLine();
+                       showHideActionEventButtons(true, Constants.MultiChronopicName);
+               } else {
+                       showHideActionEventButtons(true, Constants.MultiChronopicName); //show
+               }
+       }
+
+       private void treeviewMultiChronopicContextMenu(MultiChronopic mc) {
+               Menu myMenu = new Menu ();
+               Gtk.MenuItem myItem;
+
+               /*
+               myItem = new MenuItem ( Catalog.GetString("Play Video") + " " + 
+                               mc.Type + " (" + mc.PersonName + ")");
+               if(File.Exists(Util.GetVideoFileName(currentSession.UniqueID, 
+                               Constants.TestTypes.MULTICHRONOPIC, 
myTreeViewMultiChronopic.EventSelectedID))) {
+                       myItem.Activated += on_video_play_selected_multi_chronopic_clicked;
+                       myItem.Sensitive = true;
+               } else 
+                       myItem.Sensitive = false;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+               */
+
+               myItem = new MenuItem ( Catalog.GetString("Edit selected") + " " + mc.Type + " (" + 
mc.PersonName + ")");
+               myItem.Activated += on_edit_selected_multi_chronopic_clicked;
+               myMenu.Attach( myItem, 0, 1, 0, 1 );
+
+               /*
+               myItem = new MenuItem ( Catalog.GetString("Repair selected") + " " + mc.Type + " (" + 
mc.PersonName + ")");
+               myItem.Activated += on_repair_selected_multi_chronopic_clicked;
+               myMenu.Attach( myItem, 0, 1, 2, 3 );
+               */
+               
+               Gtk.SeparatorMenuItem mySep = new SeparatorMenuItem();
+               myMenu.Attach( mySep, 0, 1, 1, 2 );
+
+               myItem = new MenuItem ( Catalog.GetString("Delete selected") + " " + mc.Type + " (" + 
mc.PersonName + ")");
+               myItem.Activated += on_delete_selected_multi_chronopic_clicked;
+               myMenu.Attach( myItem, 0, 1, 2, 3 );
+
+               myMenu.Popup();
+               myMenu.ShowAll();
+       }
+
+
+
+
+       /* ---------------------------------------------------------
+        * ----------------  CREATE AND UPDATE COMBOS ---------------
+        *  --------------------------------------------------------
+        */
+       
+       string [] selectJumpsString;
+       string [] selectJumpsRjString;
+       string [] selectRunsString;
+       string [] selectRunsIntervalString;
+
+       // ---------------- combo_select ----------------------
+
+       private void createComboSelectJumps(bool create) {
+               if(create)
+                       combo_select_jumps = ComboBox.NewText ();
+
+               string [] jumpTypes = SqliteJumpType.SelectJumpTypes(false, "", "", false); //without 
alljumpsname, without filter, not only name
+               selectJumpsString = new String [jumpTypes.Length];
+               string [] jumpNamesToCombo = new String [jumpTypes.Length];
+               int i =0;
+               foreach(string jumpType in jumpTypes) {
+                       string [] j = jumpType.Split(new char[] {':'});
+                       string nameTranslated = Catalog.GetString(j[1]);
+                       selectJumpsString[i] = 
+                               j[0] + ":" + j[1] + ":" + nameTranslated + ":" +        //uniqueID, name, 
nameTranslated
+                               j[2] + ":" + j[3] + ":" + j[4];                         //startIn, weight, 
description
+                       jumpNamesToCombo[i] = nameTranslated;
+                       i++;
+               }
+
+               UtilGtk.ComboUpdate(combo_select_jumps, jumpNamesToCombo, "");
+               combo_select_jumps.Active = 0;
+               combo_select_jumps.Changed += new EventHandler (on_combo_select_jumps_changed);
+
+               if(create) {
+                       hbox_combo_select_jumps.PackStart(combo_select_jumps, true, true, 0);
+                       hbox_combo_select_jumps.ShowAll();
+                       combo_select_jumps.Sensitive = false;
+               }
+       }
+       
+       private void createComboSelectJumpsRj(bool create) {
+               if(create)
+                       combo_select_jumps_rj = ComboBox.NewText ();
+
+               string [] jumpTypes = SqliteJumpType.SelectJumpRjTypes("", false); //without alljumpsname, 
not only name
+               selectJumpsRjString = new String [jumpTypes.Length];
+               string [] jumpNamesToCombo = new String [jumpTypes.Length];
+               int i =0;
+               foreach(string jumpType in jumpTypes) {
+                       string [] j = jumpType.Split(new char[] {':'});
+                       string nameTranslated = Catalog.GetString(j[1]);
+                       selectJumpsRjString[i] = 
+                               j[0] + ":" + j[1] + ":" + nameTranslated + ":" +        //uniqueID, name, 
nameTranslated
+                               j[2] + ":" + j[3] + ":" + j[4] + ":" +                  //startIn, weight, 
jumpsLimited
+                               j[5] + ":" + j[6];                                      //fixedValue, 
description
+                       jumpNamesToCombo[i] = nameTranslated;
+                       i++;
+               }
+
+               UtilGtk.ComboUpdate(combo_select_jumps_rj, jumpNamesToCombo, "");
+               combo_select_jumps_rj.Active = 0;
+               combo_select_jumps_rj.Changed += new EventHandler (on_combo_select_jumps_rj_changed);
+
+               if(create) {
+                       hbox_combo_select_jumps_rj.PackStart(combo_select_jumps_rj, true, true, 0);
+                       hbox_combo_select_jumps_rj.ShowAll();
+                       combo_select_jumps_rj.Sensitive = false;
+               }
+       }
+       
+       private void createComboSelectRuns(bool create) {
+               if(create)
+                       combo_select_runs = ComboBox.NewText ();
+
+               string [] runTypes = SqliteRunType.SelectRunTypes("", false); //without allrunsname, not only 
name
+               selectRunsString = new String [runTypes.Length];
+               string [] runNamesToCombo = new String [runTypes.Length];
+               int i =0;
+               foreach(string runType in runTypes) {
+                       string [] j = runType.Split(new char[] {':'});
+                       string nameTranslated = Catalog.GetString(j[1]);
+                       selectRunsString[i] = 
+                               j[0] + ":" + j[1] + ":" + nameTranslated + ":" +        //uniqueID, name, 
nameTranslated
+                               j[2] + ":" + j[3];                                      //distance, 
description
+                       runNamesToCombo[i] = nameTranslated;
+                       i++;
+               }
+
+               UtilGtk.ComboUpdate(combo_select_runs, runNamesToCombo, "");
+               combo_select_runs.Active = 0;
+               combo_select_runs.Changed += new EventHandler (on_combo_select_runs_changed);
+
+               if(create) {
+                       hbox_combo_select_runs.PackStart(combo_select_runs, true, true, 0);
+                       hbox_combo_select_runs.ShowAll();
+                       combo_select_runs.Sensitive = false;
+               }
+       }
+
+       private void createComboSelectRunsInterval(bool create) {
+               if(create)
+                       combo_select_runs_interval = ComboBox.NewText ();
+
+               string [] runTypes = SqliteRunIntervalType.SelectRunIntervalTypes("", false); //without 
allrunsname, not only name
+               selectRunsIntervalString = new String [runTypes.Length];
+               string [] runNamesToCombo = new String [runTypes.Length];
+               int i =0;
+               foreach(string runType in runTypes) {
+                       string [] j = runType.Split(new char[] {':'});
+                       string nameTranslated = Catalog.GetString(j[1]);
+                       selectRunsIntervalString[i] = 
+                               j[0] + ":" + j[1] + ":" + nameTranslated + ":" +        //uniqueID, name, 
nameTranslated
+                               j[2] + ":" + j[3] + ":" + j[4] + ":" +                  //distance, 
tracksLimited, fixedValue
+                               j[5] + ":" + j[6] + ":" + j[6];                         //unlimited, 
description, distancesString
+                       runNamesToCombo[i] = nameTranslated;
+                       i++;
+               }
+
+               UtilGtk.ComboUpdate(combo_select_runs_interval, runNamesToCombo, "");
+               combo_select_runs_interval.Active = 0;
+               combo_select_runs_interval.Changed += new EventHandler 
(on_combo_select_runs_interval_changed);
+
+               if(create) {
+                       hbox_combo_select_runs_interval.PackStart(combo_select_runs_interval, true, true, 0);
+                       hbox_combo_select_runs_interval.ShowAll();
+                       combo_select_runs_interval.Sensitive = false;
+               }
+       }
+
+
+       // ---------------- combo_result ----------------------
+
+       private void createComboResultJumps() {
+               combo_result_jumps = ComboBox.NewText ();
+               UtilGtk.ComboUpdate(combo_result_jumps,
+                               SqliteJumpType.SelectJumpTypes(false, Constants.AllJumpsName, "", true), 
//with alljumpsname, without filter, only select name
+                               "");
+               
+               combo_result_jumps.Active = 0;
+               combo_result_jumps.Changed += new EventHandler (on_combo_result_jumps_changed);
+
+               hbox_combo_result_jumps.PackStart(combo_result_jumps, true, true, 0);
+               hbox_combo_result_jumps.ShowAll();
+               combo_result_jumps.Sensitive = false;
+       }
+       
+       private void createComboResultJumpsRj() {
+               combo_result_jumps_rj = ComboBox.NewText();
+               UtilGtk.ComboUpdate(combo_result_jumps_rj, 
SqliteJumpType.SelectJumpRjTypes(Constants.AllJumpsName, true), ""); //only select name
+               
+               combo_result_jumps_rj.Active = 0;
+               combo_result_jumps_rj.Changed += new EventHandler (on_combo_result_jumps_rj_changed);
+
+               hbox_combo_result_jumps_rj.PackStart(combo_result_jumps_rj, true, true, 0);
+               hbox_combo_result_jumps_rj.ShowAll();
+               combo_result_jumps_rj.Sensitive = false;
+       }
+       
+       private void createComboResultRuns() {
+               combo_result_runs = ComboBox.NewText();
+               UtilGtk.ComboUpdate(combo_result_runs, SqliteRunType.SelectRunTypes(Constants.AllRunsName, 
true), ""); //without filter, only select name
+               
+               combo_result_runs.Active = 0;
+               combo_result_runs.Changed += new EventHandler (on_combo_result_runs_changed);
+
+               hbox_combo_result_runs.PackStart(combo_result_runs, true, true, 0);
+               hbox_combo_result_runs.ShowAll();
+               combo_result_runs.Sensitive = false;
+       }
+
+       private void createComboResultRunsInterval() {
+               combo_result_runs_interval = ComboBox.NewText();
+               UtilGtk.ComboUpdate(combo_result_runs_interval, 
SqliteRunIntervalType.SelectRunIntervalTypes(Constants.AllRunsName, true), ""); //without filter, only select 
name
+               
+               combo_result_runs_interval.Active = 0;
+               combo_result_runs_interval.Changed += new EventHandler 
(on_combo_result_runs_interval_changed);
+
+               hbox_combo_result_runs_interval.PackStart(combo_result_runs_interval, true, true, 0);
+               hbox_combo_result_runs_interval.ShowAll();
+               combo_result_runs_interval.Sensitive = false;
+       }
+       
+       //no need of reationTimes
+
+       private void createComboPulses() {
+               combo_pulses = ComboBox.NewText();
+               UtilGtk.ComboUpdate(combo_pulses, SqlitePulseType.SelectPulseTypes(Constants.AllPulsesName, 
true), ""); //without filter, only select name
+               
+               combo_pulses.Active = 0;
+               combo_pulses.Changed += new EventHandler (on_combo_pulses_changed);
+
+               hbox_combo_pulses.PackStart(combo_pulses, true, true, 0);
+               hbox_combo_pulses.ShowAll();
+               combo_pulses.Sensitive = false;
+       }
+
+       /*
+       private void createComboMultiChronopic() 
+       {
+               button_multi_chronopic_start.Sensitive = false;
+               button_run_analysis.Sensitive = false;
+               extra_window_spin_run_analysis_distance.Sensitive = false;
+       }
+       */
+
+
+       // -------------- combo select tests changed --------
+
+       private void on_combo_select_jumps_changed(object o, EventArgs args) {
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+               LogB.Information("Selected: " + myText); 
+
+               //show extra window options
+               on_extra_window_jumps_test_changed(o, args);
+       }
+       
+       private void on_combo_select_jumps_rj_changed(object o, EventArgs args) {
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+               LogB.Information("Selected: " + myText); 
+
+               //show extra window options
+               on_extra_window_jumps_rj_test_changed(o, args);
+       }
+       
+       private void on_combo_select_runs_changed(object o, EventArgs args) {
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+               LogB.Information("Selected: " + myText); 
+
+               //show extra window options
+               on_extra_window_runs_test_changed(o, args);
+       }
+       
+       private void on_combo_select_runs_interval_changed(object o, EventArgs args) {
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+               LogB.Information("Selected: " + myText); 
+
+               //show extra window options
+               on_extra_window_runs_interval_test_changed(o, args);
+       }
+       
+       // -------------- combo result tests changed --------
+       
+       private void on_combo_result_jumps_changed(object o, EventArgs args) {
+               //combo_result_jumps.Changed -= new EventHandler (on_combo_result_jumps_changed);
+
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+
+               treeview_jumps_storeReset();
+               fillTreeView_jumps(myText);
+       }
+       
+       
+       private void on_combo_result_jumps_rj_changed(object o, EventArgs args) {
+               //combo_result_jumps_rj.Changed -= new EventHandler (on_combo_result_jumps_rj_changed);
+
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+
+               treeview_jumps_rj_storeReset();
+               fillTreeView_jumps_rj(myText);
+       }
+
+       private void on_combo_result_runs_changed(object o, EventArgs args) {
+               //combo_result_runs.Changed -= new EventHandler (on_combo_result_runs_changed);
+
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+
+               treeview_runs_storeReset();
+               fillTreeView_runs(myText);
+       }
+
+       private void on_combo_result_runs_interval_changed(object o, EventArgs args) {
+               //combo_result_runs_interval.Changed -= new EventHandler 
(on_combo_result_runs_interval_changed);
+
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+
+               treeview_runs_interval_storeReset();
+               fillTreeView_runs_interval(myText);
+       }
+
+       //no need of reationTimes because is done in:
+       //gui/reactionTime on_extra_window_reaction_times_test_changed()
+       
+       private void on_combo_pulses_changed(object o, EventArgs args) {
+               //combo_pulses.Changed -= new EventHandler (on_combo_pulses_changed);
+
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+               string myText = UtilGtk.ComboGetActive(combo);
+
+               treeview_pulses_storeReset();
+               fillTreeView_pulses(myText);
+       }
+
+
+       /* ---------------------------------------------------------
+        * ----------------  DELETE EVENT, QUIT  -----------------------
+        *  --------------------------------------------------------
+        */
+       
+       private void on_delete_event (object o, DeleteEventArgs args) {
+               args.RetVal = true;
+               
+               //cannot terminate chronojump untile press 'cancel' if  autodetect encoder is working
+               if(cpDetect != null && cpDetect.Detecting == true)
+                       return;
+    
+               on_quit1_activate (new object(), new EventArgs ());
+       }
+
+
+       private void on_quit1_activate (object o, EventArgs args) {
+               /*
+               if(chronopicCancelledTimes > 0 && UtilAll.IsWindows()) {
+                       confirmWinJumpRun = ConfirmWindowJumpRun.Show( 
+                                       Catalog.GetString("Attention, current version of Chronojump gets 
hanged on exit\nif user has cancelled detection of Chronopic."),
+                                       Catalog.GetString("Sorry, you will have to close Chronojump using 
CTRL + ALT + DEL."));
+                       confirmWinJumpRun.Button_accept.Clicked += new EventHandler(on_quit2_activate);
+               } else
+                       on_quit2_activate(new object(), new EventArgs());
+               
+               */
+               on_quit2_activate(new object(), new EventArgs());
+       }
+               
+
+       private void on_quit2_activate (object o, EventArgs args) {
+               LogB.Information("Bye!");
+
+               if(chronopicWin.Connected == true) {
+                       chronopicWin.SerialPortsCloseIfNeeded();
+               }
+       
+               try {   
+                       File.Delete(runningFileName);
+               } catch {
+                       new DialogMessage(Constants.MessageTypes.WARNING, 
+                                       string.Format(Catalog.GetString("Could not delete file:\n{0}"), 
runningFileName));
+               }
+               
+               if(File.Exists(Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar + 
"chronojump.db"))
+                       File.Move(Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar + 
"chronojump.db",
+                               Util.GetDatabaseDir() + System.IO.Path.DirectorySeparatorChar + 
"chronojump.db");
+               
+               LogB.Information("Bye2!");
+               
+               encoderRProcCapture.SendEndProcess();
+               encoderRProcAnalyze.SendEndProcess();
+
+               LogB.Information("Bye3!");
+
+               //exit start ping if has not ended
+               if(pingThread.IsAlive)
+                       pingThread.Abort();
+               
+               Log.End();
+
+               Application.Quit();
+               
+               //Environment.Exit(Environment.ExitCode);
+       }
+       
+       /* ---------------------------------------------------------
+        * ----------------  SESSION NEW, LOAD, EXPORT, DELETE -----
+        *  --------------------------------------------------------
+        */
+
+       private void on_new_activate (object o, EventArgs args) {
+               LogB.Information("new session");
+               sessionAddEditWin = SessionAddEditWindow.Show(app1, new Session());
+               sessionAddEditWin.FakeButtonAccept.Clicked -= new EventHandler(on_new_session_accepted);
+               sessionAddEditWin.FakeButtonAccept.Clicked += new EventHandler(on_new_session_accepted);
+       }
+       
+       private void on_new_session_accepted (object o, EventArgs args) {
+               if(sessionAddEditWin.CurrentSession != null) 
+               {
+                       currentSession = sessionAddEditWin.CurrentSession;
+                       sessionAddEditWin.HideAndNull();
+
+                       //serverUniqueID is undefined until session is updated
+                       currentSession.ServerUniqueID = Constants.ServerUndefinedID;
+
+                       app1.Title = progName + " - " + currentSession.Name;
+
+                       if(createdStatsWin) {
+                               stats_win_initializeSession();
+                       }
+               
+                       resetAllTreeViews(true); //boolean means: "also persons"
+
+                       //show hidden widgets
+                       sensitiveGuiNoSession();
+                       sensitiveGuiYesSession();
+                       definedSession = true;
+
+                       //for sure, jumpsExists is false, because we create a new session
+
+                       button_edit_current_person.Sensitive = false;
+                       button_show_all_person_events.Sensitive = false;
+                       button_delete_current_person.Sensitive = false;
+               
+                       //update report
+                       report.SessionID = currentSession.UniqueID;
+                       report.StatisticsRemove();
+                       try {
+                               reportWin.FillTreeView();
+                       } catch {} //reportWin is still not created, not need to Fill again
+       
+                       //feedback (more in 1st session created)
+                       string feedbackLoadUsers = Catalog.GetString ("Session created, now add or load 
persons.");
+                       new DialogMessage(Constants.MessageTypes.INFO, feedbackLoadUsers);
+               }
+       }
+       
+       private void on_edit_session_activate (object o, EventArgs args) 
+       {
+               LogB.Information("edit session");
+               
+               if(currentSession.Name == Constants.SessionSimulatedName)
+                       new DialogMessage(Constants.MessageTypes.INFO, Constants.SessionProtected);
+               else {
+                       sessionAddEditWin = SessionAddEditWindow.Show(app1, currentSession);
+                       sessionAddEditWin.FakeButtonAccept.Clicked -= new 
EventHandler(on_edit_session_accepted);
+                       sessionAddEditWin.FakeButtonAccept.Clicked += new 
EventHandler(on_edit_session_accepted);
+               }
+       }
+       
+       private void on_edit_session_accepted (object o, EventArgs args) {
+               if(sessionAddEditWin.CurrentSession != null) 
+               {
+                       currentSession = sessionAddEditWin.CurrentSession;
+                       sessionAddEditWin.HideAndNull();
+                       
+                       app1.Title = progName + " - " + currentSession.Name;
+
+                       if(createdStatsWin) {
+                               stats_win_initializeSession();
+                       }
+               }
+       }
+
+       private void on_button_encoder_import_chronojump_session(object o, EventArgs args)
+       {
+               sessionLoadWin = SessionLoadWindow.Show (app1, SessionLoadWindow.WindowType.IMPORT_SESSION);
+               sessionLoadWin.Button_accept.Clicked += new EventHandler(on_load_session_accepted_to_import);
+       }
+
+       //from import session
+       private void on_load_session_accepted_to_import(object o, EventArgs args)
+       {
+               int sessionNumber = sessionLoadWin.CurrentSessionId();
+               string databasePath = sessionLoadWin.DatabasePath();
+               LogB.Information (databasePath);
+
+               ImportSessionFromDatabase (databasePath, sessionNumber);
+       }
+
+       private void ImportSessionFromDatabase(string databasePath, int sessionNumber)
+       {
+               string source_filename = databasePath;
+               string destination_filename = Sqlite.DatabaseFilePath;
+               string session = Convert.ToString (sessionNumber);
+
+               ChronojumpImporter chronojumpImporter = new ChronojumpImporter (source_filename, 
destination_filename, session);
+
+               ChronojumpImporter.Result result = chronojumpImporter.import ();
+
+               if (result.success) {
+                       updateComboStats ();
+                       new DialogMessage (Constants.MessageTypes.INFO, Catalog.GetString ("Session 
imported."));
+               } else {
+                       LogB.Debug ("Chronojump Importer error: ", result.error);
+                       new DialogMessage (Constants.MessageTypes.WARNING, result.error);
+               }
+       }
+
+       private void on_open_activate (object o, EventArgs args) 
+       {
+               LogB.Information("open session");
+               sessionLoadWin = SessionLoadWindow.Show(app1, SessionLoadWindow.WindowType.LOAD_SESSION);
+               sessionLoadWin.Button_accept.Clicked += new EventHandler(on_load_session_accepted_from_open);
+       }
+
+       //from open session
+       private void on_load_session_accepted_from_open (object o, EventArgs args) 
+       {
+               currentSession = sessionLoadWin.CurrentSession;
+               on_load_session_accepted();
+       }
+       //called from open session OR from gui/networks configInit when config.SessionMode == 
Config.SessionModeEnum.UNIQUE
+       private void on_load_session_accepted () 
+       {
+               app1.Title = progName + " - " + currentSession.Name;
+       
+               if(createdStatsWin) {
+                       stats_win_initializeSession();
+               }
+               
+               resetAllTreeViews(true); //boolean means: "also persons"
+
+               bool foundPersons = selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0);
+               
+               //show hidden widgets
+               sensitiveGuiNoSession();
+               sensitiveGuiYesSession();
+               definedSession = true;
+               
+               button_edit_current_person.Sensitive = false;
+               button_show_all_person_events.Sensitive = false;
+               button_delete_current_person.Sensitive = false;
+
+               //if there are persons
+               if(foundPersons) {
+                       //activate the gui for persons in main window
+                       sensitiveGuiYesPerson();
+               }
+
+               //update report
+               report.SessionID = currentSession.UniqueID;
+               report.StatisticsRemove();
+
+               if(reportWin != null)
+                       reportWin.FillTreeView();
+               
+               chronojumpWindowTestsNext();
+       }
+       
+       
+       private void on_delete_session_activate (object o, EventArgs args) 
+       {
+               LogB.Information("--- delete session ---");
+               
+               if(currentSession.Name == Constants.SessionSimulatedName)
+                       new DialogMessage(Constants.MessageTypes.INFO, Constants.SessionProtected);
+               else {
+                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are you sure you 
want to delete the current session"), "", Catalog.GetString("and all the session tests?"));
+                       confirmWin.Button_accept.Clicked += new EventHandler(on_delete_session_accepted);
+               }
+       }
+       
+       private void on_delete_session_accepted (object o, EventArgs args) 
+       {
+               new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Deleted session and all its 
tests."));
+               SqliteSession.DeleteAllStuff(currentSession.UniqueID.ToString());
+               
+               sensitiveGuiNoSession();
+               definedSession = false;
+               app1.Title = progName + "";
+       }
+
+       
+       private void on_export_session_activate(object o, EventArgs args) {
+               ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Encoder data will not be 
exported."), "", "");
+               confirmWin.Button_accept.Clicked += new EventHandler(on_export_session_accepted);
+       }
+
+       private void on_export_session_accepted(object o, EventArgs args) {
+               new ExportSessionCSV(currentSession, app1, preferences);
+       }
+
+       
+       /* ---------------------------------------------------------
+        * ----------------  PERSON RECUPERATE, LOAD, EDIT, DELETE -
+        *  --------------------------------------------------------
+        */
+       
+       private void on_recuperate_person_clicked (object o, EventArgs args) {
+               LogB.Information("recuperate person");
+               personRecuperateWin = PersonRecuperateWindow.Show(app1, currentSession, 
preferences.digitsNumber);
+               personRecuperateWin.FakeButtonDone.Clicked += new EventHandler(on_recuperate_person_accepted);
+       }
+
+       private void on_recuperate_person_accepted (object o, EventArgs args) {
+               LogB.Information("here!!!");
+               currentPerson = personRecuperateWin.CurrentPerson;
+               currentPersonSession = personRecuperateWin.CurrentPersonSession;
+               label_person_change();
+               
+               myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);
+
+               int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
+               if(rowToSelect != -1) {
+                       selectRowTreeView_persons(treeview_persons,
+                                       treeview_persons_store, 
+                                       rowToSelect);
+                       sensitiveGuiYesPerson();
+               }
+       }
+               
+       private void on_recuperate_persons_from_session_clicked (object o, EventArgs args) {
+               LogB.Information("recuperate persons from other session");
+               personsRecuperateFromOtherSessionWin = PersonsRecuperateFromOtherSessionWindow.Show(app1, 
currentSession);
+               personsRecuperateFromOtherSessionWin.FakeButtonDone.Clicked += new 
EventHandler(on_recuperate_persons_from_session_accepted);
+       }
+       
+       private void on_recuperate_persons_from_session_accepted (object o, EventArgs args) {
+               currentPerson = personsRecuperateFromOtherSessionWin.CurrentPerson;
+               currentPersonSession = personsRecuperateFromOtherSessionWin.CurrentPersonSession;
+               label_person_change();
+
+               treeview_persons_storeReset();
+               fillTreeView_persons();
+               int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
+               if(rowToSelect != -1) {
+                       selectRowTreeView_persons(treeview_persons,
+                                       treeview_persons_store, 
+                                       rowToSelect);
+                       sensitiveGuiYesPerson();
+               }
+       }
+       
+       bool person_add_single_called_from_person_select_window;
+       private void on_person_add_single_from_main_gui (object o, EventArgs args) {
+               person_add_single_called_from_person_select_window = false;
+               person_add_single();
+       }
+
+       private void person_add_single () {
+               personAddModifyWin = PersonAddModifyWindow.Show(app1, 
+                               currentSession, new Person(-1), 
+                               preferences.digitsNumber, checkbutton_video, useVideo
+                               );
+               //-1 means we are adding a new person
+               //if we were modifying it will be it's uniqueID
+               
+               personAddModifyWin.FakeButtonAccept.Clicked += new 
EventHandler(on_person_add_single_accepted);
+       }
+       
+       private void on_person_add_single_accepted (object o, EventArgs args) {
+               if (personAddModifyWin.CurrentPerson != null)
+               {
+                       currentPerson = personAddModifyWin.CurrentPerson;
+                       currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
+                       label_person_change();
+                       myTreeViewPersons.Add(currentPerson.UniqueID.ToString(), currentPerson.Name);
+
+                       //when adding new person, photos cannot be recorded as currentPerson.UniqueID
+                       //because it was undefined. Copy them now
+                       if(File.Exists(Util.GetPhotoTempFileName(false)) && 
File.Exists(Util.GetPhotoTempFileName(true))) {
+                               try {
+                                       File.Move(Util.GetPhotoTempFileName(false), 
+                                                       Util.GetPhotoFileName(false, currentPerson.UniqueID));
+                               } catch {
+                                       File.Copy(Util.GetPhotoTempFileName(false), 
+                                                       Util.GetPhotoFileName(false, currentPerson.UniqueID), 
true);
+                               }
+                               try {
+                                       File.Move(Util.GetPhotoTempFileName(true), 
+                                                       Util.GetPhotoFileName(true, currentPerson.UniqueID));
+                               } catch {
+                                       File.Copy(Util.GetPhotoTempFileName(true), 
+                                                       Util.GetPhotoFileName(true, currentPerson.UniqueID), 
true);
+                               }
+                       }
+                       
+                       int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
+                       if(rowToSelect != -1) {
+                               selectRowTreeView_persons(treeview_persons,
+                                               treeview_persons_store, 
+                                               rowToSelect);
+                               sensitiveGuiYesPerson();
+                               //appbar2.Push( 1, Catalog.GetString("Successfully added") + " " + 
currentPerson.Name );
+                       }
+                       
+                       if(person_add_single_called_from_person_select_window) {
+                               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
+                                               currentSession.UniqueID, 
+                                               false); //means: do not returnPersonAndPSlist
+                               personSelectWin.Update(myPersons);
+                       }
+               }
+       }
+
+       //show spinbutton window asking for how many people to create   
+       private void on_person_add_multiple_clicked (object o, EventArgs args) {
+               personAddMultipleWin = PersonAddMultipleWindow.Show(app1, currentSession);
+               personAddMultipleWin.Button_accept.Clicked += new 
EventHandler(on_person_add_multiple_accepted);
+       }
+       
+       private void on_person_add_multiple_accepted (object o, EventArgs args) {
+               if (personAddMultipleWin.CurrentPerson != null)
+               {
+                       currentPerson = personAddMultipleWin.CurrentPerson;
+                       currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
+                       label_person_change();
+                       treeview_persons_storeReset();
+                       fillTreeView_persons();
+                       int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
+                       if(rowToSelect != -1) {
+                               selectRowTreeView_persons(treeview_persons,
+                                               treeview_persons_store, 
+                                               rowToSelect);
+                               sensitiveGuiYesPerson();
+                       
+                               string myString = string.Format(
+                                               Catalog.GetPluralString(
+                                                       "Successfully added one person.", 
+                                                       "Successfully added {0} persons.", 
+                                                       personAddMultipleWin.PersonsCreatedCount),
+                                               personAddMultipleWin.PersonsCreatedCount);
+                               //appbar2.Push( 1, Catalog.GetString(myString) );
+                       }
+               }
+       }
+       
+       bool person_edit_single_called_from_person_select_window;
+       private void on_edit_current_person_clicked_from_main_gui (object o, EventArgs args) {
+               person_edit_single_called_from_person_select_window = false;
+               person_edit_single();
+       }
+
+       private void person_edit_single() {
+               LogB.Information("modify person");
+
+               personAddModifyWin = PersonAddModifyWindow.Show(app1, currentSession, currentPerson, 
+                               preferences.digitsNumber, checkbutton_video, useVideo
+                               ); 
+               personAddModifyWin.FakeButtonAccept.Clicked += new 
EventHandler(on_edit_current_person_accepted);
+       }
+       
+       private void on_edit_current_person_accepted (object o, EventArgs args) {
+               if (personAddModifyWin.CurrentPerson != null)
+               {
+                       currentPerson = personAddModifyWin.CurrentPerson;
+                       currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
+                       label_person_change();
+                       treeview_persons_storeReset();
+                       fillTreeView_persons();
+                       
+                       int rowToSelect = myTreeViewPersons.FindRow(currentPerson.UniqueID);
+                       if(rowToSelect != -1) {
+                               selectRowTreeView_persons(treeview_persons,
+                                               treeview_persons_store, 
+                                               rowToSelect);
+                               sensitiveGuiYesPerson();
+                       }
+
+                       on_combo_result_jumps_changed(combo_result_jumps, args);
+                       on_combo_result_jumps_rj_changed(combo_result_jumps_rj, args);
+                       on_combo_result_runs_changed(combo_result_runs, args);
+                       on_combo_result_runs_interval_changed(combo_result_runs_interval, args);
+                       on_combo_pulses_changed(combo_pulses, args);
+
+                       if(createdStatsWin) {
+                               stats_win_fillTreeView_stats(false, true);
+                       }
+
+//                     personAddModifyWin.Destroy();
+                       
+                       if(person_edit_single_called_from_person_select_window) {
+                               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
+                                               currentSession.UniqueID, 
+                                               false); //means: do not returnPersonAndPSlist
+                               personSelectWin.Update(myPersons);
+                       }
+               }
+       }
+
+       
+       private void on_show_all_person_events_activate (object o, EventArgs args) {
+               PersonShowAllEventsWindow.Show(app1, currentSession.UniqueID, currentPerson);
+       }
+       
+       
+       private void on_delete_current_person_from_session_clicked (object o, EventArgs args) {
+               LogB.Information("delete current person from this session");
+               ConfirmWindow confirmWin = ConfirmWindow.Show(
+                               Catalog.GetString("Are you sure you want to delete the current person and all 
his/her tests (jumps, runs, pulses, ...) from this session?\n(His/her personal data and tests in other 
sessions will remain intact.)"), "", 
+                               Catalog.GetString("Current Person: ") + currentPerson.Name);
+
+               confirmWin.Button_accept.Clicked += new 
EventHandler(on_delete_current_person_from_session_accepted);
+       }
+       
+       private void on_delete_current_person_from_session_accepted (object o, EventArgs args) 
+       {
+               new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Deleted person and all 
his/her tests on this session."));
+               SqlitePersonSession.DeletePersonFromSessionAndTests(
+                               currentSession.UniqueID.ToString(), currentPerson.UniqueID.ToString());
+               
+               resetAllTreeViews(true); //boolean means: "also persons"
+               bool foundPersons = selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0);
+                       
+               if(createdStatsWin) {
+                       stats_win_fillTreeView_stats(false, true);
+               }
+               
+               //if there are no persons
+               if(!foundPersons) {
+                       sensitiveGuiNoPerson ();
+                       if(createdStatsWin) {
+                               stats_win_hide();
+                       }
+               }
+       }
+
+       private void on_button_encoder_person_change_clicked (object o, EventArgs args) 
+       {
+               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
+                               currentSession.UniqueID, 
+                               false); //means: do not returnPersonAndPSlist
+
+               personSelectWin = PersonSelectWindow.Show(app1, myPersons);
+               personSelectWin.FakeButtonAddPerson.Clicked += new 
EventHandler(on_button_encoder_person_add_person);
+               personSelectWin.FakeButtonEditPerson.Clicked += new 
EventHandler(on_button_encoder_person_edit_person);
+               personSelectWin.FakeButtonDeletePerson.Clicked += new 
EventHandler(on_button_encoder_person_delete_person);
+               personSelectWin.FakeButtonDone.Clicked += new 
EventHandler(on_button_encoder_person_change_done);
+       }
+       private void on_button_encoder_person_add_person(object o, EventArgs args)
+       {
+               person_add_single_called_from_person_select_window = true;
+               person_add_single();
+       }
+       private void on_button_encoder_person_edit_person(object o, EventArgs args)
+       {
+               currentPerson = personSelectWin.SelectedPerson; 
+               
+               person_edit_single_called_from_person_select_window = true;
+               person_edit_single();
+       }
+       private void on_button_encoder_person_delete_person(object o, EventArgs args)
+       {
+               currentPerson = personSelectWin.SelectedPerson;
+               
+               //without confirm, because it's already confirmed on PersonSelect
+               on_delete_current_person_from_session_accepted (o, args);
+                               
+               ArrayList myPersons = SqlitePersonSession.SelectCurrentSessionPersons(
+                               currentSession.UniqueID, 
+                               false); //means: do not returnPersonAndPSlist
+               personSelectWin.Update(myPersons);
+               personSelectWin.Button_delete_confirm_focus(false, false);
+       }
+       private void on_button_encoder_person_change_done(object o, EventArgs args) 
+       {
+               currentPerson = personSelectWin.SelectedPerson; 
+               currentPersonSession = SqlitePersonSession.Select(currentPerson.UniqueID, 
currentSession.UniqueID);
+               label_person_change();
+
+               personChanged();
+       }
+
+
+
+       /* ---------------------------------------------------------
+        * ----------------  SOME CALLBACKS ------------------------
+        *  --------------------------------------------------------
+        */
+
+       //edit
+       private void on_cut1_activate (object o, EventArgs args) {
+       }
+       
+       private void on_copy1_activate (object o, EventArgs args) {
+       }
+       
+       private void on_paste1_activate (object o, EventArgs args) {
+       }
+
+
+       private void on_preferences_activate (object o, EventArgs args) 
+       {
+               preferencesWin = PreferencesWindow.Show(preferences, getMenuItemMode());
+               
+               preferencesWin.FakeButtonImported.Clicked += new 
EventHandler(on_preferences_import_configuration);
+               preferencesWin.FakeButtonDebugModeStart.Clicked += new 
EventHandler(on_preferences_debug_mode_start);
+               preferencesWin.Button_accept.Clicked += new EventHandler(on_preferences_accepted);
+       }
+               
+       private void on_preferences_import_configuration (object o, EventArgs args) {
+               preferencesWin.FakeButtonImported.Clicked -= new 
EventHandler(on_preferences_import_configuration);
+               
+               configInit();
+               LogB.Information("Initialized configuration");
+       }
+
+       private void on_preferences_accepted (object o, EventArgs args) 
+       {
+               preferences = preferencesWin.GetPreferences;
+
+               if(checkbutton_video.Active) {
+                       videoCapturePrepare(false); //if error, show message
+               }
+
+               //change language works on windows. On Linux let's change the locale
+               //if(UtilAll.IsWindows()) 
+               //      languageChange();
+               
+
+               if(repetitiveConditionsWin != null)
+                       repetitiveConditionsWin.VolumeOn = preferences.volumeOn;
+
+               try {
+                       if(createdStatsWin) {
+                               //statsWin.PrefsDigitsNumber = preferences.digitsNumber;
+                               //statsWin.WeightStatsPercent = preferences.weightStatsPercent;
+                               //statsWin.HeightPreferred = preferences.heightPreferred;
+
+                               stats_win_fillTreeView_stats(false, true);
+                       }
+
+                       //pass to report
+                       report.preferences = preferences;
+                       
+                       
+                       createTreeView_jumps (treeview_jumps);
+                       createTreeView_jumps_rj (treeview_jumps_rj);
+                       createTreeView_runs (treeview_runs);
+                       createTreeView_runs_interval (treeview_runs_interval);
+                       createTreeView_pulses(treeview_pulses);
+                       createTreeView_reaction_times(treeview_reaction_times);
+                       createTreeView_multi_chronopic(false, treeview_multi_chronopic);
+                       
+                       on_combo_result_jumps_changed(combo_result_jumps, args);
+                       on_combo_result_jumps_rj_changed(combo_result_jumps_rj, args);
+                       on_combo_result_runs_changed(combo_result_runs, args);
+                       on_combo_result_runs_interval_changed(combo_result_runs_interval, args);
+                       on_combo_pulses_changed(combo_pulses, args);
+
+                       //currently no combo_reaction_times
+                       treeview_reaction_times_storeReset();
+                       fillTreeView_reaction_times("reactionTime");
+
+                       //currently no combo_multi_chronopic
+                       treeview_multi_chronopic_storeReset(false);
+                       fillTreeView_multi_chronopic();
+               }
+               catch 
+               {
+               }
+       }
+
+
+       /*
+        * menu test selectors
+        */
+
+       private void on_menuitem_mode_main_menu_activate (object o, EventArgs args) 
+       {
+               reset_buttons_selector_start();
+               notebook_start.CurrentPage = 0;
+               
+               //don't show menu bar on start page
+               main_menu.Visible = false;
+       }       
+       
+       private void select_menuitem_mode_toggled(Constants.Menuitem_modes m) 
+       {
+               menuitem_mode_selected_jumps_simple.Visible = false;
+               menuitem_mode_selected_jumps_reactive.Visible = false;
+               menuitem_mode_selected_runs_simple.Visible = false;
+               menuitem_mode_selected_runs_intervallic.Visible = false;
+               menuitem_mode_selected_power_gravitatory.Visible = false;
+               menuitem_mode_selected_power_inertial.Visible = false;
+               menuitem_mode_selected_other.Visible = false;
+                       
+               LogB.Information("MODE", m.ToString());
+               
+               //default for everythong except encoder 
+               menuitem_encoder_session_overview.Visible = false;
+               menuitem_export_encoder_signal.Visible = false;
+               menuitem_export_csv.Visible = true;
+               menuitem_import_chronojump_session.Visible = true;
+
+               hbox_other.Visible = false;
+
+               if(m == Constants.Menuitem_modes.JUMPSSIMPLE || m == Constants.Menuitem_modes.JUMPSREACTIVE)
+               {
+                       notebook_sup.CurrentPage = 0;
+                       notebook_capture_analyze.ShowTabs = true;
+                       if(m == Constants.Menuitem_modes.JUMPSSIMPLE) 
+                       {
+                               menuitem_mode_selected_jumps_simple.Visible = true;
+                               notebooks_change(0);
+                               on_extra_window_jumps_test_changed(new object(), new EventArgs());
+                               hbox_results_legend.Visible = true;
+                               notebook_capture_analyze.GetNthPage(2).Show(); //show jumpsProfile on jumps 
simple
+                       } else 
+                       {
+                               menuitem_mode_selected_jumps_reactive.Visible = true;
+                               notebooks_change(1);
+                               on_extra_window_jumps_rj_test_changed(new object(), new EventArgs());
+                               hbox_results_legend.Visible = false;
+                               notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on jumps 
reactive
+                       }
+               }
+               else if(m == Constants.Menuitem_modes.RUNSSIMPLE || m == 
Constants.Menuitem_modes.RUNSINTERVALLIC)
+               {
+                       notebook_sup.CurrentPage = 0;
+                       notebook_capture_analyze.ShowTabs = true;
+
+                       menuitem_import_chronojump_session.Visible = false;     // not implemented yet
+
+                       if(m == Constants.Menuitem_modes.RUNSSIMPLE) 
+                       {
+                               menuitem_mode_selected_runs_simple.Visible = true;
+                               notebooks_change(2);
+                               on_extra_window_runs_test_changed(new object(), new EventArgs());
+                               hbox_results_legend.Visible = true;
+                       }
+                       else
+                       {
+                               menuitem_mode_selected_runs_intervallic.Visible = true;
+                               notebooks_change(3);
+                               on_extra_window_runs_interval_test_changed(new object(), new EventArgs());
+                               hbox_results_legend.Visible = false;
+                       }
+                       notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on runs
+               }
+               else if(m == Constants.Menuitem_modes.POWERGRAVITATORY || m == 
Constants.Menuitem_modes.POWERINERTIAL) 
+               {
+                       menuitem_encoder_session_overview.Visible = true;
+                       menuitem_export_encoder_signal.Visible = true;
+                       menuitem_export_csv.Visible = false;
+
+                       menuitem_import_chronojump_session.Visible = false;     // not implemented yet
+                       
+                       //on OSX R is not installed by default. Check if it's installed. Needed for encoder
+                       if( UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX &&
+                                       ! Util.FileExists(Constants.ROSX) )
+                       {
+                               new DialogMessage(Constants.MessageTypes.WARNING,
+                                               Catalog.GetString("Sorry, R software is not installed.") +
+                                               "\n" + Catalog.GetString("Please, install it from here:") +
+                                               "\n\nhttp://cran.cnr.berkeley.edu/bin/macosx/R-latest.pkg";);
+                               return;
+                       }
+
+                       notebook_sup.CurrentPage = 1;
+
+
+                       /*
+                        * If there's a signal on gravitatory and we move to inertial, 
+                        * interface has to change to YESPERSON (meaning no_signal).
+                        * But, if there's no person shoud continue on NOPERSON
+                        */
+                       if(selectRowTreeView_persons(treeview_persons, treeview_persons_store, 0))
+                               encoderButtonsSensitive(encoderSensEnum.YESPERSON);
+                       
+                       blankEncoderInterface();
+
+                       bool changed = false;
+                       if(m == Constants.Menuitem_modes.POWERGRAVITATORY) {
+                               menuitem_mode_selected_power_gravitatory.Visible = true;
+
+                               //change encoderConfigurationCurrent if needed
+                               if(encoderConfigurationCurrent.has_inertia) {
+                                       encoderConfigurationCurrent = new EncoderConfiguration(); //LINEAR, 
not INERTIAL
+                                       changed = true;
+                               }
+                               
+                               currentEncoderGI = Constants.EncoderGI.GRAVITATORY;
+                               hbox_capture_1RM.Visible = true;
+                               notebook_encoder_capture_extra_mass.CurrentPage = 0;
+                               if(radio_encoder_analyze_individual_current_set.Active || 
radio_encoder_analyze_individual_current_session.Active) {
+                                       radiobutton_encoder_analyze_1RM.Visible = true;
+                                       radiobutton_encoder_analyze_neuromuscular_profile.Visible = true;
+                               }
+                               hbox_encoder_capture_1_or_cont.Visible = true;
+                       } else {
+                               menuitem_mode_selected_power_inertial.Visible = true;
+
+                               //change encoderConfigurationCurrent if needed
+                               if(! encoderConfigurationCurrent.has_inertia) {
+                                       encoderConfigurationCurrent = new EncoderConfiguration(
+                                                       
Constants.EncoderConfigurationNames.ROTARYAXISINERTIAL);        
+                                       encoderConfigurationCurrent.SetInertialDefaultOptions();
+                                       changed = true;
+                               }
+                               
+                               currentEncoderGI = Constants.EncoderGI.INERTIAL;
+                               hbox_capture_1RM.Visible = false;
+                               notebook_encoder_capture_extra_mass.CurrentPage = 1;
+                               radiobutton_encoder_analyze_1RM.Visible = false;
+                               radiobutton_encoder_analyze_neuromuscular_profile.Visible = false;
+                               
+                               radio_encoder_capture_1set.Active = true;
+                               hbox_encoder_capture_1_or_cont.Visible = false;
+                       }
+                       encoderGuiChangesAfterEncoderConfigurationWin(true);
+                       if(changed) {
+                               prepareAnalyzeRepetitions ();
+                       }
+               } 
+               else {  //m == Constants.Menuitem_modes.OTHER (contacts / other)
+                       notebook_sup.CurrentPage = 0;
+                       hbox_other.Visible = true;
+                       menuitem_mode_selected_other.Visible = true;
+                       radio_mode_reaction_times_small.Active = true;
+
+                       notebook_capture_analyze.CurrentPage = 0;
+                       notebook_capture_analyze.ShowTabs = false; //only capture tab is shown (only valid 
for "OTHER" tests)
+                       //notebook_capture_analyze.GetNthPage(2).Hide(); //hide jumpsProfile on other tests
+               }
+
+               //show the program
+               notebook_start.CurrentPage = 1;
+
+               //it's not visible at startup
+               main_menu.Visible = true;
+
+
+               //if wizard has been used mark Chronopic as connected or disconnected depending if port exists
+               if(Constants.Menuitem_mode_IsContacts(m) && wizardPortContacts != "")
+                       chronopicWin.Connected =
+                               Util.FoundInStringArray(ChronopicPorts.GetPorts(), wizardPortContacts);
+               else if(! Constants.Menuitem_mode_IsContacts(m) && wizardPortEncoder != "")
+                       chronopicWin.Connected =
+                               Util.FoundInStringArray(ChronopicPorts.GetPorts(), wizardPortEncoder);
+
+
+               //change multitest firmware or autoDetectChronopic
+               if(Constants.Menuitem_mode_IsContacts(m))
+               {
+                       if(chronopicWin.Connected)
+                               change_multitest_firmware(m);
+                       else
+                               autoDetectChronopic(m); //on contacts will perform change_multitest_firmware 
at the end
+               }
+               else if(wizardPortEncoder == "")
+                       autoDetectChronopic(m);
+
+               chronojumpWindowTestsNext();
+       }
+       
+       ChronopicDetect cpDetect;
+       private void autoDetectChronopic(Constants.Menuitem_modes m)
+       {
+               main_menu.Sensitive = false;
+
+               if(m == Constants.Menuitem_modes.POWERGRAVITATORY || m == 
Constants.Menuitem_modes.POWERINERTIAL) 
+               {
+                       hbox_chronopic_encoder_detecting.Visible = true;
+                       viewport_chronopic_encoder.Visible = false;
+
+                       cpDetect = new ChronopicDetect(
+                                       chronopicWin.SP,
+                                       progressbar_chronopic_encoder_detecting, 
+                                       button_chronopic_encoder_detecting_cancel,
+                                       button_chronopic_encoder_detecting_info,
+                                       configAutodetectPort
+                                       );
+                       
+                       cpDetect.Detect("ENCODER");
+
+                       cpDetect.FakeButtonDone.Clicked += new 
EventHandler(on_autoDetectChronopic_encoder_done);
+               } 
+               else {
+                       //disabled on Windows until is fixed //TODO
+                       if(UtilAll.IsWindows()) {
+                               main_menu.Sensitive = true;
+                               return;
+                       }
+
+                       hbox_chronopic_detecting.Visible = true;
+                       viewport_chronopics.Visible = false;
+
+                       cpDetect = new ChronopicDetect(
+                                       chronopicWin.SP,
+                                       progressbar_chronopic_detecting, 
+                                       button_chronopic_detecting_cancel,
+                                       button_chronopic_detecting_info,
+                                       configAutodetectPort
+                                       );
+                       
+                       cpDetect.Detect("NORMAL");
+
+                       cpDetect.FakeButtonDone.Clicked += new 
EventHandler(on_autoDetectChronopic_normal_done);
+               }
+       }
+       private void on_autoDetectChronopic_encoder_done(object o, EventArgs args) 
+       {
+               cpDetect.FakeButtonDone.Clicked -= new EventHandler(on_autoDetectChronopic_encoder_done);
+                       
+               hbox_chronopic_encoder_detecting.Visible = false;
+               viewport_chronopic_encoder.Visible = true;
+               
+               string str = cpDetect.Detected;
+
+               if(str != null && str != "") {
+                       LogB.Information("Detected at port: " + str);
+                       createChronopicWindow(true, str);
+               }
+               else {
+                       LogB.Information("Not detected.");
+                       createChronopicWindow(true, Util.GetDefaultPort());
+               }
+       
+               on_autoDetectChronopic_all_done();
+       }
+       private void on_autoDetectChronopic_normal_done(object o, EventArgs args) 
+       {
+               cpDetect.FakeButtonDone.Clicked -= new EventHandler(on_autoDetectChronopic_normal_done);
+                       
+               hbox_chronopic_detecting.Visible = false;
+               viewport_chronopics.Visible = true;
+       
+               string str = cpDetect.Detected;
+
+               if(str != null && str != "") {
+                       LogB.Information("Detected at port: " + str);
+
+                       //set connected stuff for chronopicWin
+                       chronopicWin.Connected = true;
+               
+                       //set cpd for chronopicWin
+                       ChronopicPortData cpd = new ChronopicPortData(1, str, true);
+                       ArrayList cpdArray = new ArrayList();
+                       cpdArray.Add(cpd);
+                       
+                       LogB.Debug("chronopicWin is null? " + (chronopicWin == null).ToString());
+                       LogB.Debug("chronopicWin.CP is null? " + (chronopicWin.CP == null).ToString());
+                       
+                       createChronopicWindow(cpDetect.getCP(), cpdArray, true, str);
+                       
+                       LogB.Debug("chronopicWin.CP is null? " + (chronopicWin.CP == null).ToString());
+               
+                       change_multitest_firmware(getMenuItemMode());
+               }
+               else {
+                       LogB.Information("Not detected.");
+                       createChronopicWindow(true, Util.GetDefaultPort());
+               }
+       
+               on_autoDetectChronopic_all_done();
+       }
+       private void on_autoDetectChronopic_all_done() 
+       {
+               main_menu.Sensitive = true;
+       }
+               
+       private bool previousMultitestFirmwareDefined = false;
+       private Constants.Menuitem_modes previousMultitestFirmware;
+
+       //change debounce time automatically on change menuitem mode (if multitest firmware)
+       private void change_multitest_firmware(Constants.Menuitem_modes m) 
+       {
+               LogB.Information("change_multitest_firmware");
+
+               //---- 1 if don't need to change, return
+               if(previousMultitestFirmwareDefined && 
+                               ! Constants.Menuitem_mode_multitest_should_change(previousMultitestFirmware, 
m)) 
+               {
+                       LogB.Information("don't need to change multitest firmware");
+                       return;
+               }
+
+               label_chronopics_multitest.Text = "";
+               
+               //---- 2 if is not connected, return
+               
+               if(! chronopicWin.Connected)
+                       return;
+
+               //---- 3 if port does not exists, show cp window and return
+
+               //http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
+               //https://bugzilla.xamarin.com/show_bug.cgi?id=15514
+               if(! UtilAll.IsWindows ()) {
+                       if(! File.Exists(chronopicWin.GetContactsFirstPort())) {
+                               LogB.Information("Chronopic has been disconnected");
+                               createChronopicWindow(true, "");
+                               chronopicWin.Connected = false;
+                               return;
+                       }
+               }
+
+               LogB.Information("change_multitest_firmware 1");
+               
+               LogB.Debug("chronopicWin is null? " + (chronopicWin == null).ToString());
+
+               int cps = chronopicWin.NumConnected();
+               LogB.Debug("cps: " + cps.ToString());
+               
+               LogB.Debug("chronopicWin.Connected? " + chronopicWin.Connected.ToString());
+               
+               Chronopic.Plataforma ps;
+               bool ok = (chronopicWin.CP).Read_platform(out ps);
+               if(!ok) {
+                       LogB.Information("Chronopic has been disconnected");
+                       createChronopicWindow(true, "");
+                       chronopicWin.Connected = false;
+                       return;
+               }
+
+       
+               LogB.Information("change_multitest_firmware 2");
+               ChronopicAuto ca;
+       
+               /*      
+               try {
+                       ca = new ChronopicAutoCheck();
+                       //problems with windows using this:
+                       string chronopicVersion = ca.Read(chronopicWin.SP);
+                       LogB.Debug("version: " + chronopicVersion);
+               } catch {
+                       LogB.Information("Could not read from Chronopic with method 1");
+                       return;
+               }
+               */
+
+               //---- 4 try to communicate with multitest firmware (return if cannot connect)
+               
+               LogB.Information("Trying method 2");
+               bool isChronopicAuto = false;
+               try {
+                       string result = chronopicWin.CheckAuto(out isChronopicAuto);
+                       LogB.Debug("version: " + result);
+               } catch {
+                       LogB.Information("Could not read from Chronopic with method 2");
+                       return;
+               }
+               
+               //---- 5 change 10 <-> 50 ms
+
+               LogB.Information("change_multitest_firmware 3");
+               if(isChronopicAuto) {
+                       int debounceChange = 50;
+                       if(m == Constants.Menuitem_modes.RUNSSIMPLE || m == 
Constants.Menuitem_modes.RUNSINTERVALLIC)
+                               debounceChange = 10;
+
+                       int msChanged = chronopicWin.ChangeMultitestFirmware(debounceChange);
+                       if(msChanged != -1) {
+                               if(msChanged == 50)
+                                       label_chronopics_multitest.Text = "[" + Catalog.GetString("Jumps") + 
"]";
+                               else if(msChanged == 10)
+                                       label_chronopics_multitest.Text = "[" + Catalog.GetString("Runs") + 
"]";
+                               else
+                                       label_chronopics_multitest.Text = "";
+                       } else
+                               label_chronopics_multitest.Text = "";
+               }
+       
+               previousMultitestFirmwareDefined = true;
+               previousMultitestFirmware = m;
+       }
+
+       private Constants.Menuitem_modes getMenuItemMode() 
+       {
+               if(radio_menuitem_mode_jumps_simple.Active)
+                       return Constants.Menuitem_modes.JUMPSSIMPLE;
+               else if(radio_menuitem_mode_jumps_reactive.Active)
+                       return Constants.Menuitem_modes.JUMPSREACTIVE;
+               else if(radio_menuitem_mode_runs_simple.Active)
+                       return Constants.Menuitem_modes.RUNSSIMPLE;
+               else if(radio_menuitem_mode_runs_intervallic.Active)
+                       return Constants.Menuitem_modes.RUNSINTERVALLIC;
+               else if(radio_menuitem_mode_power_gravitatory.Active)
+                       return Constants.Menuitem_modes.POWERGRAVITATORY;
+               else if(radio_menuitem_mode_power_inertial.Active)
+                       return Constants.Menuitem_modes.POWERINERTIAL;
+               else // if(radio_menuitem_mode_other.Active)
+                       return Constants.Menuitem_modes.OTHER;
+       }
+
+       private void reset_buttons_selector_start_from_gui(object o, EventArgs args) {
+               reset_buttons_selector_start();
+       }
+       private void reset_buttons_selector_start()
+       {
+               notebook_selector_start_jumps.CurrentPage = 0;
+               notebook_selector_start_runs.CurrentPage = 0;
+               notebook_selector_start_encoder.CurrentPage = 0;
+       }
+
+       private void on_radio_menuitem_mode_activate(object o, EventArgs args) 
+       {
+               //togglebutton sends signal two times (deactivate/activate), just get the good signal
+               //http://stackoverflow.com/questions/10755541/mono-gtk-radiobutton-clicked-event-firing-twice
+               if( ! (o as Gtk.RadioMenuItem).Active )
+                       return;
+               
+               select_menuitem_mode_toggled(getMenuItemMode());
+       }
+
+       private void on_button_selector_start_jumps_clicked(object o, EventArgs args) 
+       {
+               notebook_selector_start_jumps.CurrentPage = 1;
+               notebook_selector_start_runs.CurrentPage = 0;
+               notebook_selector_start_encoder.CurrentPage = 0;
+       }
+       private void on_button_selector_start_jumps_simple_clicked(object o, EventArgs args) 
+       {
+               if(radio_menuitem_mode_jumps_simple.Active) {
+                       //needed if people select again the same option
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.JUMPSSIMPLE);
+               }
+               else
+                       radio_menuitem_mode_jumps_simple.Active = true;
+       }
+       private void on_button_selector_start_jumps_reactive_clicked(object o, EventArgs args) 
+       {
+               if(radio_menuitem_mode_jumps_reactive.Active)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.JUMPSREACTIVE);
+               else
+                       radio_menuitem_mode_jumps_reactive.Active = true;
+       }
+       
+       private void on_button_selector_start_runs_clicked(object o, EventArgs args) 
+       {
+               notebook_selector_start_jumps.CurrentPage = 0;
+               notebook_selector_start_runs.CurrentPage = 1;
+               notebook_selector_start_encoder.CurrentPage = 0;
+       }
+       private void on_button_selector_start_runs_simple_clicked(object o, EventArgs args)
+       {
+               if(radio_menuitem_mode_runs_simple.Active)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSSIMPLE);
+               else
+                       radio_menuitem_mode_runs_simple.Active = true;
+       }
+       private void on_button_selector_start_runs_intervallic_clicked(object o, EventArgs args) 
+       {
+               if(radio_menuitem_mode_runs_intervallic.Active)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.RUNSINTERVALLIC);
+               else
+                       radio_menuitem_mode_runs_intervallic.Active = true;
+       }
+       
+       private void on_button_selector_start_encoder_clicked(object o, EventArgs args) 
+       {
+               notebook_selector_start_jumps.CurrentPage = 0;
+               notebook_selector_start_runs.CurrentPage = 0;
+               notebook_selector_start_encoder.CurrentPage = 1;
+       }
+       private void on_button_selector_start_encoder_gravitatory_clicked(object o, EventArgs args) 
+       {
+               if(radio_menuitem_mode_power_gravitatory.Active)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY);
+               else
+                       radio_menuitem_mode_power_gravitatory.Active = true;
+       }
+       private void on_button_selector_start_encoder_inertial_clicked(object o, EventArgs args) 
+       {
+               if(radio_menuitem_mode_power_inertial.Active)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERINERTIAL);
+               else
+                       radio_menuitem_mode_power_inertial.Active = true;
+       }
+       
+       private void on_button_selector_start_other_clicked(object o, EventArgs args) 
+       {
+               if(radio_menuitem_mode_other.Active)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.OTHER);
+               else
+                       radio_menuitem_mode_other.Active = true;
+       }
+       
+       /*
+        * end of menu test selectors
+        */
+
+       
+
+       /*
+        * videoOn
+        */
+       
+
+       //at what tab of notebook_sup there's the video_capture
+       private int video_capture_notebook_sup = 0;
+
+       //changed by user clicking on notebook tabs
+       private void on_notebook_sup_switch_page (object o, SwitchPageArgs args) {
+               if( 
+                               (notebook_sup.CurrentPage == 0 && video_capture_notebook_sup == 1) ||
+                               (notebook_sup.CurrentPage == 1 && video_capture_notebook_sup == 0)) 
+               {
+                       //first stop showing video
+                       bool wasActive = false;
+                       if(checkbutton_video.Active) {
+                               wasActive = true;
+                               checkbutton_video.Active = false;
+                       }
+
+                       if(notebook_sup.CurrentPage == 0) {
+                               //remove video capture from encoder tab
+                               viewport_video_capture_encoder.Remove(capturer);
+                               //add in contacts tab
+                               hbox_video_capture.PackStart(capturer, true, true, 0);
+                       } else {
+                               //remove video capture from contacts tab
+                               hbox_video_capture.Remove(capturer);
+                               //add in encoder tab
+
+                               //switch to capture tab                 
+                               radiobutton_video_encoder_capture.Active = true;
+
+                               //sometimes it seems is not removed and then cannot be added again
+                               //just add if not exists
+                               //maybe this error was because before we were not doing the:
+                               //radiobutton_video_encoder_capture.Active = true;
+                               if(viewport_video_capture_encoder.Child == null)
+                                       viewport_video_capture_encoder.Add(capturer);
+                       }
+               
+                       if(wasActive) 
+                               checkbutton_video.Active = true;
+               
+                       video_capture_notebook_sup = notebook_sup.CurrentPage;
+               }
+       }
+
+       CapturerBin capturer;
+       private void videoCaptureInitialize() 
+       {
+               capturer = new CapturerBin();
+               
+               hbox_video_capture.PackStart(capturer, true, true, 0);
+               
+               videoCapturePrepare(false); //if error, show message
+       }
+
+       int videoDeviceNum = 0; 
+       private void videoCapturePrepare(bool showErrorMessage) {
+               LogB.Information("videoCapturePPPPPPPPPPPPPPPPPrepare");
+               List<LongoMatch.Video.Utils.Device> devices = 
LongoMatch.Video.Utils.Device.ListVideoDevices();
+               if(devices.Count == 0) {
+                       if(showErrorMessage)
+                               new DialogMessage(Constants.MessageTypes.WARNING, Constants.CameraNotFound);
+                       return;
+               }
+
+
+               CapturePropertiesStruct s = new CapturePropertiesStruct();
+
+               s.OutputFile = Util.GetVideoTempFileName();
+
+               s.VideoBitrate =  1000;
+               s.AudioBitrate =  128;
+               s.CaptureSourceType = CaptureSourceType.System;
+               s.Width = 360;
+               s.Height = 288;
+               
+               foreach(LongoMatch.Video.Utils.Device dev in devices){
+                       LogB.Information(dev.ID.ToString());
+                       LogB.Information(dev.IDProperty.ToString());
+                       LogB.Information(dev.DeviceType.ToString());
+               }
+                       
+               s.DeviceID = devices[videoDeviceNum].ID;
+               
+
+               capturer.CaptureProperties = s;
+
+               //checkbutton_video and checkbutton_video_encoder are synchronized
+               if(checkbutton_video.Active)
+                       capturer.Type = CapturerType.Live;
+               else
+                       capturer.Type = CapturerType.Fake;
+               capturer.Visible=true;
+
+               try {
+                       capturer.Stop();
+               } catch {}
+               capturer.Run();
+       }
+       
+       
+       private void changeVideoButtons(bool myVideo) {
+               image_video_yes.Visible = myVideo;
+               image_video_no.Visible = ! myVideo;
+       }
+       
+       private void on_checkbutton_video_clicked(object o, EventArgs args) {
+               if(checkbutton_video.Active) {
+                       preferences.videoOn = true;
+                       SqlitePreferences.Update("videoOn", "True", false);
+               } else {
+                       preferences.videoOn = false;
+                       SqlitePreferences.Update("videoOn", "False", false);
+               }
+               //change encoder checkbox but don't raise the signal    
+               checkbutton_video_encoder.Clicked -= new EventHandler(on_checkbutton_video_encoder_clicked);
+               checkbutton_video_encoder.Active = preferences.videoOn;
+               checkbutton_video_encoder.Clicked += new EventHandler(on_checkbutton_video_encoder_clicked);
+               
+               changeVideoButtons(preferences.videoOn);
+               
+               videoCapturePrepare(true); //if error, show message
+       }
+
+       private void on_checkbutton_video_encoder_clicked(object o, EventArgs args) {
+               if(checkbutton_video_encoder.Active) {
+                       preferences.videoOn = true;
+                       SqlitePreferences.Update("videoOn", "True", false);
+               } else {
+                       preferences.videoOn = false;
+                       SqlitePreferences.Update("videoOn", "False", false);
+               }
+               //change contacts checkbox but don't raise the signal   
+               checkbutton_video.Clicked -= new EventHandler(on_checkbutton_video_clicked);
+               checkbutton_video.Active = preferences.videoOn;
+               checkbutton_video.Clicked += new EventHandler(on_checkbutton_video_clicked);
+               
+               //changeVideoButtons(preferences.videoOn);
+       
+               //will start on record  
+               videoCapturePrepare(true); //if error, show message
+       }
+
+
+       /*
+        * cancel and finish
+        */
+
+
+       private void on_cancel_clicked (object o, EventArgs args) 
+       {
+               event_execute_ButtonCancel.Clicked -= new EventHandler(on_cancel_clicked);
+
+               LogB.Information("cancel clicked one");
+
+               //this will cancel jumps or runs
+               currentEventExecute.Cancel = true;
+
+               if(chronopicWin.Connected)
+                       checkCancelTotally(o, args);
+
+               //let update stats
+               //nothing changed, but stats update button cannot be insensitive,
+               //because probably some jump type has changed it's jumper
+               //the unsensitive of button stats is for showing the user, that he has to update manually
+               //because it's not automatically updated
+               //because it crashes in some thread problem
+               //that will be fixed in other release
+               //if(createdStatsWin)
+               //      showUpdateStatsAndHideData(true);
+       }
+       
+       private void on_cancel_multi_clicked (object o, EventArgs args) 
+       {
+               LogB.Information("cancel multi clicked one");
+
+               //this will cancel jumps or runs
+               currentEventExecute.Cancel = true;
+
+               if(chronopicWin.Connected)
+                       checkCancelMultiTotally(o, args);
+       }
+
+
+       //if user doesn't touch the platform after pressing "cancel", sometimes it gets waiting a Read_event
+       //now the event cancels ok, and next will be ok, also   
+       private void checkCancelTotally (object o, EventArgs args) 
+       {
+               if(currentEventExecute.TotallyCancelled) 
+                       LogB.Information("totallyCancelled");
+               else {
+                       LogB.Information("NOT-totallyCancelled ");
+                       errorWin = ErrorWindow.Show(Catalog.GetString("Please, touch the contact platform for 
full cancelling.") + "\n" +
+                                       Catalog.GetString("Then press Accept") + "\n");
+                       errorWin.Button_accept.Clicked -= new EventHandler(checkCancelTotally);
+                       errorWin.Button_accept.Clicked += new EventHandler(checkCancelTotally);
+                       
+                       //abort test when there are problems with USB disconnected      
+                       errorWin.Show_button_abort();
+                       errorWin.Button_abort.Clicked += new EventHandler(abortTest);
+               }
+       }
+       
+       private void checkCancelMultiTotally (object o, EventArgs args) 
+       {
+               bool needCancel1 = false;
+               bool needCancel2 = false;
+               bool needCancel3 = false;
+               bool needCancel4 = false;
+                       
+               needCancel1 = !currentEventExecute.TotallyCancelledMulti1;
+               if(currentEventExecute.Chronopics > 1) {
+                       needCancel2 = !currentEventExecute.TotallyCancelledMulti2;
+                       if(currentEventExecute.Chronopics > 2) {
+                               needCancel3 = !currentEventExecute.TotallyCancelledMulti3;
+                               if(currentEventExecute.Chronopics > 3)
+                                       needCancel4 = !currentEventExecute.TotallyCancelledMulti4;
+                       }
+               }
+
+               if(needCancel1 || needCancel2 || needCancel3 || needCancel4) {
+//                     LogB.Information("NOT-totallyCancelled ");
+                       string cancelStr = "";
+                       string sep = "";
+                       if(needCancel1) {
+                               cancelStr += sep + "1";
+                               sep = ", ";
+                       }
+                       if(needCancel2) {
+                               cancelStr += sep + "2";
+                               sep = ", ";
+                       }
+                       if(needCancel3) {
+                               cancelStr += sep + "3";
+                               sep = ", ";
+                       }
+                       if(needCancel4) {
+                               cancelStr += sep + "4";
+                               sep = ", ";
+                       }
+
+                       errorWin = ErrorWindow.Show(string.Format(Catalog.GetString("Please, touch the 
contact platform on Chronopic/s [{0}] for full cancelling.\nThen press button\n"), cancelStr));
+                       errorWin.Button_accept.Clicked += new EventHandler(checkCancelMultiTotally);
+               }
+       }
+               
+               
+       private void on_finish_clicked (object o, EventArgs args) 
+       {
+               currentEventExecute.Finish = true;
+       
+               if(chronopicWin.Connected)
+                       checkFinishTotally(o, args);
+               
+               //let update stats
+               if(createdStatsWin)
+                       showUpdateStatsAndHideData(true);
+       }
+               
+       //mark to only get inside on_multi_chronopic_finished one time
+       //static bool multiFinishingByClickFinish;
+       private void on_finish_multi_clicked (object o, EventArgs args) 
+       {
+               /*
+               if(multiFinishingByClickFinish)
+                       return;
+               else
+                       multiFinishingByClickFinish =  true;
+                       */
+
+               currentEventExecute.Finish = true;
+               
+               //runA is not called for this, because it ends different
+               //and there's a message on gui/eventExecute.cs for runA 
+               LogB.Debug("RR1");
+               if(currentMultiChronopicType.Name != Constants.RunAnalysisName && chronopicWin.Connected) {
+                       checkFinishMultiTotally(o, args);
+               }
+               LogB.Debug("RR2");
+               
+               //let update stats
+               //if(createdStatsWin)
+               //      showUpdateStatsAndHideData(true);
+       }
+               
+       //if user doesn't touch the platform after pressing "finish", sometimes it gets waiting a Read_event
+       //now the event finishes ok, and next will be ok
+       //
+       //not for multiChronopic:
+       
+       private void checkFinishTotally (object o, EventArgs args) 
+       {
+               if(currentEventExecute.TotallyFinished) 
+                       LogB.Information("totallyFinished");
+               else {
+                       LogB.Information("NOT-totallyFinished ");
+                       errorWin = ErrorWindow.Show(Catalog.GetString("Please, touch the contact platform for 
full finishing.") + "\n" +
+                                       Catalog.GetString("Then press Accept") + "\n");
+                       errorWin.Button_accept.Clicked -= new EventHandler(checkFinishTotally);
+                       errorWin.Button_accept.Clicked += new EventHandler(checkFinishTotally);
+               
+                       //abort test when there are problems with USB disconnected      
+                       errorWin.Show_button_abort();
+                       errorWin.Button_abort.Clicked += new EventHandler(abortTest);
+               }
+       }
+       
+       private void abortTest (object o, EventArgs args) {
+               errorWin.Button_abort.Clicked -= new EventHandler(abortTest);
+               
+               LogB.Warning("Destroying error window");
+               errorWin.HideAndNull();
+               
+               LogB.Warning("Going to abort thread");
+               currentEventExecute.ThreadAbort();
+               LogB.Warning("Aborted");
+               
+               sensitiveGuiEventDone();
+               LogB.Warning("Sensitivity restored");
+       }
+
+       //runA is not called for this, because it ends different
+       //and there's a message on gui/eventExecute.cs for runA 
+       private void checkFinishMultiTotally (object o, EventArgs args) 
+       {
+               bool needFinish1 = false;
+               bool needFinish2 = false;
+               bool needFinish3 = false;
+               bool needFinish4 = false;
+                       
+               LogB.Information("cfmt 0");
+               needFinish1 = !currentEventExecute.TotallyFinishedMulti1;
+               if(currentEventExecute.Chronopics > 1) {
+                       LogB.Information("cfmt 1");
+                       needFinish2 = !currentEventExecute.TotallyFinishedMulti2;
+                       if(currentEventExecute.Chronopics > 2) {
+                               LogB.Information("cfmt 2");
+                               needFinish3 = !currentEventExecute.TotallyFinishedMulti3;
+                               if(currentEventExecute.Chronopics > 3) {
+                                       LogB.Information("cfmt 3");
+                                       needFinish4 = !currentEventExecute.TotallyFinishedMulti4;
+                               }
+                       }
+               }
+               LogB.Information("cfmt 4");
+
+               if(needFinish1 || needFinish2 || needFinish3 || needFinish4) {
+//                     LogB.Information("NOT-totallyFinishled ");
+                       string cancelStr = "";
+                       string sep = "";
+                       if(needFinish1) {
+                               cancelStr += sep + "1";
+                               sep = ", ";
+                       }
+                       if(needFinish2) {
+                               cancelStr += sep + "2";
+                               sep = ", ";
+                       }
+                       if(needFinish3) {
+                               cancelStr += sep + "3";
+                               sep = ", ";
+                       }
+                       if(needFinish4) {
+                               cancelStr += sep + "4";
+                               sep = ", ";
+                       }
+               
+                       LogB.Information("cfmt 5");
+                       //try here because maybe solves problems in runAnalysis when seem to update the 
eventExecuteWindow at the same time as tries to show this errorWindow
+                               errorWin = ErrorWindow.Show(string.Format(
+                                                       Catalog.GetString("Please, touch the contact platform 
on Chronopic/s [{0}] for full finishing.") + 
+                                                       "\n" + Catalog.GetString("Then press this 
button:\n"), cancelStr));
+                               LogB.Information("cfmt 6");
+                               errorWin.Button_accept.Clicked += new EventHandler(checkFinishMultiTotally);
+                               LogB.Information("cfmt 7");
+                       //}
+               } else {
+                       LogB.Information("totallyFinished");
+                       /*
+                       //call write here, because if done in execute/MultiChronopic, will be called n times 
if n chronopics are working
+                       currentEventExecute.MultiChronopicWrite(false);
+                       currentMultiChronopic = (MultiChronopic) currentEventExecute.EventDone;
+               
+
+                       //if this multichronopic has more chronopics than other in session, then reload 
treeview, else simply add
+                       if(currentMultiChronopic.CPs() != 
SqliteMultiChronopic.MaxCPs(currentSession.UniqueID)) {
+                               treeview_multi_chronopic_storeReset(false);
+                               fillTreeView_multi_chronopic();
+                       } else
+                               myTreeViewMultiChronopic.Add(currentPerson.Name, currentMultiChronopic);
+                       
+                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
+                       showHideActionEventButtons(true, Constants.MultiChronopicName); //show
+               
+                       //unhide buttons for delete last test
+                       sensitiveGuiYesEvent();
+                       */
+               }
+       }
+
+
+       void on_button_execute_test_clicked (object o, EventArgs args) 
+       {
+               //http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
+               //https://bugzilla.xamarin.com/show_bug.cgi?id=15514
+               if(! UtilAll.IsWindows() && chronopicWin.Connected) {
+                       if(! File.Exists(chronopicWin.GetContactsFirstPort())) {
+                               LogB.Information("Chronopic has been disconnected");
+                               createChronopicWindow(true, "");
+                               chronopicWin.Connected = false;
+                               return;
+                       }
+               }
+
+               on_button_execute_test_accepted(o, args);
+       }
+       
+       void on_button_execute_test_accepted (object o, EventArgs args) 
+       {
+               //simulated tests are only allowed on SIMULATED session
+               if(currentSession.Name != Constants.SessionSimulatedName && ! chronopicWin.Connected) {
+                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.SimulatedTestsNotAllowed);
+                       return;
+               }
+               
+               if(radio_menuitem_mode_jumps_simple.Active) 
+               {
+                       LogB.Debug("radio_menuitem_mode_jumps_simple");
+                       on_normal_jump_activate(o, args);
+               }
+               else if(radio_menuitem_mode_jumps_reactive.Active) 
+               {
+                       LogB.Debug("radio_menuitem_mode_jumps_reactive");
+                       on_rj_activate(o, args);
+               }
+               else if(radio_menuitem_mode_runs_simple.Active) {
+                       LogB.Debug("radio_menuitem_mode_runs_simple");
+                       extra_window_runs_distance = (double) extra_window_runs_spinbutton_distance.Value;
+                       
+                       on_normal_run_activate(o, args);
+               }
+               else if(radio_menuitem_mode_runs_intervallic.Active) {
+                       LogB.Debug("radio_mode_runs_i_small");
+                       //RSA runs cannot be simulated because it's complicated to manage the countdown 
event...
+                       if(currentRunIntervalType.IsRSA && !chronopicWin.Connected) {
+                               new DialogMessage(Constants.MessageTypes.WARNING, 
+                                               Catalog.GetString("Sorry, RSA tests cannot be simulated."));
+                               return;
+                       }
+
+                       extra_window_runs_interval_distance = (double) 
extra_window_runs_interval_spinbutton_distance.Value;
+                       extra_window_runs_interval_limit = extra_window_runs_interval_spinbutton_limit.Value;
+                       
+                       on_run_interval_activate(o, args);
+               }
+               else if(radio_mode_reaction_times_small.Active) {
+                       LogB.Debug("radio_mode_rt");
+       
+                       if(extra_window_radio_reaction_time_discriminative.Active)
+                               reaction_time_discriminative_lights_prepare();
+
+                       on_reaction_time_activate (o, args);
+               }
+               else if(radio_mode_pulses_small.Active) {
+                       LogB.Debug("radio_mode_pulses");
+                       on_pulse_activate (o, args);
+               }
+               else if(radio_mode_multi_chronopic_small.Active) {
+                       LogB.Debug("radio_mode_mc");
+                       on_multi_chronopic_start_clicked(o, args);
+               }
+
+               //if a test has been deleted
+               //notebook_results_data changes to page 3: "deleted test"
+               //when a new test is done
+               //this notebook has to poing again to data of it's test
+               change_notebook_results_data();
+       }
+
+       private void change_notebook_results_data()
+       {
+               //there are some notebook_execut pages that have not notebook_results_data pages
+               //like jump simple (0), run simple (2), reaction time (4)
+               if(notebook_execute.CurrentPage == 1) //reactive jump
+                       notebook_results_data.CurrentPage = 0;
+               else if(notebook_execute.CurrentPage == 3) //interval run
+                       notebook_results_data.CurrentPage = 1;
+               else if(notebook_execute.CurrentPage == 5) //pulse
+                       notebook_results_data.CurrentPage = 2;
+       }
+
+       private void changeTestImage(string eventTypeString, string eventName, string fileNameString) {
+               Pixbuf pixbuf; //main image
+               Pixbuf pixbufZoom; //icon of zoom image (if shown can have two different images)
+
+               switch (fileNameString) {
+                       case "LOGO":
+                               pixbuf = new Pixbuf (null, Util.GetImagePath(false) + Constants.FileNameLogo);
+                               button_image_test_zoom.Hide();
+                       break;
+                       case "":
+                               pixbuf = new Pixbuf (null, Util.GetImagePath(true) + "no_image.png");
+                               button_image_test_zoom.Hide();
+                       break;
+                       default:
+                               pixbuf = new Pixbuf (null, Util.GetImagePath(true) + fileNameString);
+
+                               //button image test zoom will have a different image depending on if there's 
text
+                               //future: change tooltip also
+                               if(eventTypeString != "" && eventName != "" && eventTypeHasLongDescription 
(eventTypeString, eventName))
+                                       pixbufZoom = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameZoomInWithTextIcon);
+                               else 
+                                       pixbufZoom = new Pixbuf (null, Util.GetImagePath(false) + 
Constants.FileNameZoomInIcon);
+
+                               image_test_zoom.Pixbuf = pixbufZoom;
+                               button_image_test_zoom.Show();
+                       break;
+               }
+               image_test.Pixbuf = pixbuf;
+       }
+
+       private bool eventTypeHasLongDescription (string eventTypeString, string eventName) {
+               if(eventTypeString != "" && eventName != "")
+               {
+                       EventType myType = new EventType ();
+
+                       if(eventTypeString == EventType.Types.JUMP.ToString()) 
+                               myType = new JumpType(eventName);
+                       else if (eventTypeString == EventType.Types.RUN.ToString()) 
+                               myType = new RunType(eventName);
+                       else if (eventTypeString == EventType.Types.REACTIONTIME.ToString()) 
+                               myType = new ReactionTimeType(eventName);
+                       else if (eventTypeString == EventType.Types.PULSE.ToString()) 
+                               myType = new PulseType(eventName);
+                       else if (eventTypeString == EventType.Types.MULTICHRONOPIC.ToString()) 
+                               myType = new MultiChronopicType(eventName);
+                       else LogB.Error("Error on eventTypeHasLongDescription");
+
+                       if(myType.HasLongDescription)
+                               return true;
+               }
+               return false;
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  JUMPS EXECUTION (no RJ) ----------------
+        *  --------------------------------------------------------
+        */
+
+       
+       //suitable for all jumps not repetitive
+       private void on_normal_jump_activate (object o, EventArgs args) 
+       {
+               if(execute_auto_doing)
+                       sensitiveGuiAutoExecuteOrWait (true);
+               
+               //currentJumpType is already defined in selecting name from combo or from jumpsMoreWin
+               //string jumpEnglishName = Util.FindOnArray(':',2,1, 
UtilGtk.ComboGetActive(combo_select_jumps), selectJumpsString);
+               //currentJumpType = new JumpType(jumpEnglishName);
+
+               double jumpWeight = 0;
+               if(currentJumpType.HasWeight) {
+                       if(extra_window_jumps_option == "%") 
+                               jumpWeight = (double) extra_window_jumps_spinbutton_weight.Value;
+                       else 
+                               jumpWeight = Util.WeightFromKgToPercent(
+                                               (double) extra_window_jumps_spinbutton_weight.Value, 
+                                               currentPersonSession.Weight);
+               }
+               double myFall = 0;
+               if(currentJumpType.HasFall) {
+                       if(extra_window_jumps_check_dj_fall_calculate.Active)
+                               myFall = -1;
+                       else
+                               myFall = (double) extra_window_jumps_spinbutton_fall.Value;
+               }
+
+               string description = "";
+               if(currentJumpType.Name == "slCMJleft" || currentJumpType.Name == "slCMJright") {
+                       description = slCMJString(); 
+
+                       extra_window_jumps_spin_single_leg_distance.Value = 0;
+                       extra_window_jumps_spin_single_leg_angle.Value = 90;
+               }
+                       
+               //used by cancel and finish
+               //currentEventType = new JumpType();
+               currentEventType = currentJumpType;
+                       
+               //hide jumping buttons
+               if(! execute_auto_doing)
+                       sensitiveGuiEventDoing();
+
+               //show the event doing window
+               double progressbarLimit = 3; //3 phases for show the Dj
+               if(myFall == -1)
+                       progressbarLimit = 4; //4 if there's a pre-jump
+               else if( currentJumpType.StartIn || 
+                               currentJumpType.Name == Constants.TakeOffName || 
+                               currentJumpType.Name == Constants.TakeOffWeightName)
+                       progressbarLimit = 2; //2 for normal jump (or take off)
+                       
+               //don't let update until test finishes
+               if(createdStatsWin)
+                       showUpdateStatsAndHideData(false);
+
+               event_execute_initializeVariables(
+                       ! chronopicWin.Connected,       //is simulated
+                       currentPerson.UniqueID, 
+                       currentPerson.Name, 
+                       Catalog.GetString("Phases"),      //name of the different moments
+                       Constants.JumpTable, //tableName
+                       currentJumpType.Name 
+                       );
+               ExecutingGraphData egd = event_execute_prepareForTest ();
+
+               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
+               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
+
+               //when user clicks on update the eventExecute window 
+               //(for showing with his new confgured values: max, min and guides
+               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
+               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
+
+               currentEventExecute = new JumpExecute(currentPerson.UniqueID, currentPerson.Name, 
+                               currentSession.UniqueID, currentJumpType.Name, myFall, jumpWeight,
+                               chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber, 
preferences.volumeOn,
+                               progressbarLimit, egd, description);
+
+
+               UtilGtk.ChronopicColors(viewport_chronopics, label_chronopics, label_connected_chronopics, 
chronopicWin.Connected);
+
+
+               if (!chronopicWin.Connected) 
+                       currentEventExecute.SimulateInitValues(rand);
+               
+               if( currentJumpType.StartIn ) 
+                       currentEventExecute.Manage();
+               else 
+                       currentEventExecute.ManageFall();
+               
+               thisJumpIsSimple = true; //used by: on_event_execute_update_graph_in_progress_clicked
+               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
+                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
+               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
+
+               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_jump_finished);
+               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
+       }       
+       
+
+       private void on_jump_finished (object o, EventArgs args)
+       {
+               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_jump_finished);
+       
+               //test can be deleted if not cancelled
+               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
+
+               if ( ! currentEventExecute.Cancel ) {
+                       currentJump = (Jump) currentEventExecute.EventDone;
+               
+                       if(currentJumpType.Name == "slCMJleft" || currentJumpType.Name == "slCMJright") {
+                               if(extra_window_jumps_radiobutton_single_leg_mode_vertical.Active)
+                                       currentJump.Description += " 0 90";
+                               else {
+                                       currentJump.Description += " 0 90";
+                                       
+                                       //unsensitive slCMJ options 
+                                       hbox_extra_window_jumps_single_leg_radios.Sensitive = false;
+                                       //but show the input cm
+                                       notebook_options_after_execute.CurrentPage = 1;
+                               }
+                               SqliteJump.UpdateDescription(Constants.JumpTable, 
+                                               currentJump.UniqueID, currentJump.Description);
+                       }
+
+                       //move video file if exists
+                       if(preferences.videoOn)
+                               if (! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP, 
currentJump.UniqueID))
+                                       new DialogMessage(Constants.MessageTypes.WARNING, 
+                                                       Catalog.GetString("Sorry, video cannot be stored."));
+
+                       myTreeViewJumps.PersonWeight = currentPersonSession.Weight;
+                       myTreeViewJumps.Add(currentPerson.Name, currentJump);
+                       
+                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
+                       showHideActionEventButtons(true, "Jump"); //show
+               
+                       if(createdStatsWin) {
+                               showUpdateStatsAndHideData(true);
+                       }
+               
+                       lastJumpIsSimple = true;
+               
+                       //unhide buttons for delete last jump
+                       if(! execute_auto_doing)
+                               sensitiveGuiYesEvent();
+               } 
+               else if( currentEventExecute.ChronopicDisconnected )
+                       chronopicDisconnectedWhileExecuting();
+               
+               //unhide buttons that allow jumping
+               if(execute_auto_doing) {
+                       execute_auto_order_pos ++;
+                       execute_auto_select();
+                       sensitiveGuiAutoExecuteOrWait (false);
+               }
+       }
+
+       private void chronopicDisconnectedWhileExecuting() {
+               LogB.Error("DISCONNECTED gui/cj");
+               createChronopicWindow(true, "");
+               chronopicWin.Connected = false;
+       }
+               
+       private void on_test_finished_can_touch_gtk (object o, EventArgs args)
+       {
+               currentEventExecute.FakeButtonThreadDyed.Clicked -= new 
EventHandler(on_test_finished_can_touch_gtk);
+               LogB.Information(" cantouch1 ");
+               if(! execute_auto_doing)
+                       sensitiveGuiEventDone();
+               LogB.Information(" cantouch3 ");
+
+               if ( ! currentEventExecute.Cancel )
+                       event_execute_progressbar_time.Fraction = 1; 
+       }
+
+
+
+       /* ---------------------------------------------------------
+        * ----------------  JUMPS RJ EXECUTION  ------------------
+        *  --------------------------------------------------------
+        */
+       
+       private void on_rj_activate (object o, EventArgs args) 
+       {
+               //currentJumpRjType is already defined in selecting name from combo or from jumpsMoreWin
+               //string jumpEnglishName = Util.FindOnArray(':',2,1, 
UtilGtk.ComboGetActive(combo_select_jumps_rj), selectJumpsRjString);
+               //currentJumpRjType = new JumpType(jumpEnglishName);
+
+               double progressbarLimit = 0;
+               
+               //if it's a unlimited interval run, put -1 as limit value
+               if(currentJumpRjType.Unlimited) {
+                       progressbarLimit = -1;
+               } else {
+                       if(currentJumpRjType.FixedValue > 0) {
+                               progressbarLimit = currentJumpRjType.FixedValue;
+                       } else {
+                               progressbarLimit = (double) extra_window_jumps_rj_spinbutton_limit.Value;
+                       }
+               }
+
+               double jumpWeight = 0;
+               if(currentJumpRjType.HasWeight) {
+                       if(extra_window_jumps_rj_option == "%") {
+                               jumpWeight = (double) extra_window_jumps_rj_spinbutton_weight.Value;
+                       } else {
+                               jumpWeight = Util.WeightFromKgToPercent(
+                                               (double) extra_window_jumps_rj_spinbutton_weight.Value,
+                                               currentPersonSession.Weight);
+                       }
+               }
+               double myFall = 0;
+               if( currentJumpRjType.HasFall || currentJumpRjType.Name == Constants.RunAnalysisName)
+                       myFall = (double) extra_window_jumps_rj_spinbutton_fall.Value;
+                       
+               //used by cancel and finish
+               //currentEventType = new JumpRjType();
+               currentEventType = currentJumpRjType;
+                       
+               //hide jumping buttons
+               sensitiveGuiEventDoing();
+       
+               //don't let update until test finishes
+               if(createdStatsWin)
+                       showUpdateStatsAndHideData(false);
+
+               //show the event doing window
+               event_execute_initializeVariables(
+                       ! chronopicWin.Connected,       //is simulated
+                       currentPerson.UniqueID, 
+                       currentPerson.Name, 
+                       Catalog.GetString("Jumps"),       //name of the different moments
+                       Constants.JumpRjTable, //tableName
+                       currentJumpRjType.Name
+                       );
+               ExecutingGraphData egd = event_execute_prepareForTest ();
+               
+               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
+               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
+               
+               //when user clicks on update the eventExecute window 
+               //(for showing with his new configured values: max, min and guides
+               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
+               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
+       
+               currentEventExecute = new JumpRjExecute(currentPerson.UniqueID, currentPerson.Name, 
+                               currentSession.UniqueID, currentJumpRjType.Name, myFall, jumpWeight, 
+                               progressbarLimit, currentJumpRjType.JumpsLimited, 
+                               chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber,
+                               checkbutton_allow_finish_rj_after_time.Active, preferences.volumeOn, 
+                               repetitiveConditionsWin, progressbarLimit, egd
+                               );
+               
+               
+               //suitable for limited by jump and time
+               //simulated always simulate limited by jumps
+               if(!chronopicWin.Connected) 
+                       currentEventExecute.SimulateInitValues(rand);
+               
+               currentEventExecute.Manage();
+               
+               thisJumpIsSimple = false; //used by: on_event_execute_update_graph_in_progress_clicked
+               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
+                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
+               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
+               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_jump_rj_finished);
+               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
+       }
+               
+       private void on_jump_rj_finished (object o, EventArgs args) 
+       {
+               LogB.Information("ON JUMP RJ FINISHED");
+               
+               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_jump_rj_finished);
+               
+               //test can be deleted if not cancelled
+               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
+
+               if ( ! currentEventExecute.Cancel ) {
+                       currentJumpRj = (JumpRj) currentEventExecute.EventDone;
+                       
+                       //move video file if exists
+                       if(preferences.videoOn)
+                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.JUMP_RJ, 
currentJumpRj.UniqueID))
+                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
+
+                       //if user clicked in finish earlier
+                       if(currentEventExecute.Finish) {
+                               currentJumpRj.Jumps = Util.GetNumberOfJumps(currentJumpRj.TvString, false);
+                               if(currentJumpRj.JumpsLimited) {
+                                       currentJumpRj.Limited = currentJumpRj.Jumps.ToString() + "J";
+                               } else {
+                                       currentJumpRj.Limited = Util.GetTotalTime(
+                                                       currentJumpRj.TcString, currentJumpRj.TvString) + "T";
+                               }
+                       }
+
+                       myTreeViewJumpsRj.PersonWeight = currentPersonSession.Weight;
+                       myTreeViewJumpsRj.Add(currentPerson.Name, currentJumpRj);
+                       
+                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
+                       showHideActionEventButtons(true, "JumpRj"); //show
+
+                       if(createdStatsWin) {
+                               showUpdateStatsAndHideData(true);
+                       }
+
+                       lastJumpIsSimple = false;
+
+                       //unhide buttons for delete last jump
+                       sensitiveGuiYesEvent();
+
+                       //put correct time value in eventWindow (put the time from chronopic and not onTimer 
soft chronometer)
+                       event_execute_LabelTimeValue = Util.GetTotalTime(currentJumpRj.TcString, 
currentJumpRj.TvString);
+                       //possible deletion of last jump can make the jumps on event window be false
+                       event_execute_LabelEventValue = currentJumpRj.Jumps;
+               } 
+               else if( currentEventExecute.ChronopicDisconnected )
+                       chronopicDisconnectedWhileExecuting();
+               
+               //delete the temp tables if exists
+               Sqlite.DeleteTempEvents("tempJumpRj");
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  RUNS EXECUTION (no interval) ----------
+        *  --------------------------------------------------------
+        */
+
+       //suitable for all runs not repetitive
+       private void on_normal_run_activate (object o, EventArgs args) 
+       {
+               //if distance can be always different in this run,
+               //show values selected in runExtraWin
+               double myDistance = 0;          
+               if(currentRunType.Distance == 0) {
+                       myDistance = extra_window_runs_distance;
+               } else {
+                       myDistance = currentRunType.Distance;
+               }
+               
+               //used by cancel and finish
+               //currentEventType = new RunType();
+               currentEventType = currentRunType;
+                       
+               //hide jumping (running) buttons
+               sensitiveGuiEventDoing();
+       
+               //show the event doing window
+               
+               double progressbarLimit = 3; //same for startingIn than out (before)
+               
+               //don't let update until test finishes
+               if(createdStatsWin)
+                       showUpdateStatsAndHideData(false);
+
+               event_execute_initializeVariables(
+                       ! chronopicWin.Connected,       //is simulated
+                       currentPerson.UniqueID, 
+                       currentPerson.Name, 
+                       Catalog.GetString("Phases"),      //name of the different moments
+                       Constants.RunTable, //tableName
+                       currentRunType.Name 
+                       );
+               ExecutingGraphData egd = event_execute_prepareForTest ();
+               
+               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
+               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
+
+
+               //when user clicks on update the eventExecute window 
+               //(for showing with his new confgured values: max, min and guides
+               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
+               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
+
+
+               currentEventExecute = new RunExecute(
+                               currentPerson.UniqueID, currentSession.UniqueID, 
+                               currentRunType.Name, myDistance, 
+                               chronopicWin.CP, event_execute_label_message, app1,
+                               preferences.digitsNumber, preferences.metersSecondsPreferred, 
preferences.volumeOn, 
+                               progressbarLimit, egd,
+                               preferences.runDoubleContactsMode,
+                               preferences.runDoubleContactsMS,
+                               preferences.runSpeedStartArrival
+                               );
+               
+               if (!chronopicWin.Connected) 
+                       currentEventExecute.SimulateInitValues(rand);
+                       
+               currentEventExecute.Manage();
+
+               thisRunIsSimple = true; //used by: on_event_execute_update_graph_in_progress_clicked
+               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
+                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
+               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
+               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_run_finished);
+               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
+       }
+       
+       private void on_run_finished (object o, EventArgs args)
+       {
+               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_run_finished);
+               
+               //test can be deleted if not cancelled
+               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
+
+               if ( ! currentEventExecute.Cancel ) {
+                       currentRun = (Run) currentEventExecute.EventDone;
+                       
+                       //move video file if exists
+                       if(preferences.videoOn)
+                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN, 
currentRun.UniqueID))
+                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
+                       
+                       currentRun.MetersSecondsPreferred = preferences.metersSecondsPreferred;
+
+                       myTreeViewRuns.Add(currentPerson.Name, currentRun);
+                       
+                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
+                       showHideActionEventButtons(true, "Run"); //show
+               
+                       if(createdStatsWin) {
+                               showUpdateStatsAndHideData(true);
+                       }
+               
+                       lastRunIsSimple = true;
+
+                       //unhide buttons for delete last jump
+                       sensitiveGuiYesEvent();
+
+                       //put correct time value in eventWindow (put the time from chronopic and not onTimer 
soft chronometer)
+                       event_execute_LabelTimeValue = currentRun.Time;
+               }
+               else if( currentEventExecute.ChronopicDisconnected )
+                       chronopicDisconnectedWhileExecuting();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  RUNS EXECUTION (interval) ----------
+        *  --------------------------------------------------------
+        */
+
+       
+       private void on_run_interval_activate (object o, EventArgs args)
+       {
+               LogB.Information("run interval accepted");
+               
+               //if distance can be always different in this run,
+               //show values selected in runExtraWin
+               double distanceInterval = 0;            
+               if(currentRunIntervalType.Distance == 0) {
+                       distanceInterval = extra_window_runs_interval_distance;
+               } else {
+                       distanceInterval = currentRunIntervalType.Distance;
+               }
+               
+               double progressbarLimit = 0;
+               //if it's a unlimited interval run, put -1 as limit value
+               if(currentRunIntervalType.Unlimited) {
+                       progressbarLimit = -1;
+               } else {
+                       if(currentRunIntervalType.FixedValue > 0) {
+                               progressbarLimit = currentRunIntervalType.FixedValue;
+                       } else {
+                               progressbarLimit = extra_window_runs_interval_limit;
+                       }
+               }
+
+
+               //used by cancel and finish
+               //currentEventType = new RunType();
+               currentEventType = currentRunIntervalType;
+                       
+               //hide running buttons
+               sensitiveGuiEventDoing();
+               
+               //don't let update until test finishes
+               if(createdStatsWin)
+                       showUpdateStatsAndHideData(false);
+
+               //show the event doing window
+               event_execute_initializeVariables(
+                       ! chronopicWin.Connected,       //is simulated
+                       currentPerson.UniqueID, 
+                       currentPerson.Name, 
+                       Catalog.GetString("Tracks"),      //name of the different moments
+                       Constants.RunIntervalTable, //tableName
+                       currentRunIntervalType.Name
+                       );
+               ExecutingGraphData egd = event_execute_prepareForTest ();
+
+               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
+               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
+
+               //when user clicks on update the eventExecute window 
+               //(for showing with his new confgured values: max, min and guides
+               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
+               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
+       
+               currentEventExecute = new RunIntervalExecute(
+                               currentPerson.UniqueID, currentSession.UniqueID, currentRunIntervalType.Name, 
+                               distanceInterval, progressbarLimit, currentRunIntervalType.TracksLimited, 
+                               chronopicWin.CP, event_execute_label_message, app1,
+                               preferences.digitsNumber, preferences.metersSecondsPreferred, 
preferences.volumeOn, repetitiveConditionsWin, 
+                               progressbarLimit, egd,
+                               preferences.runIDoubleContactsMode,
+                               preferences.runIDoubleContactsMS,
+                               preferences.runSpeedStartArrival
+                               );
+               
+               
+               //suitable for limited by tracks and time
+               if(!chronopicWin.Connected)
+                       currentEventExecute.SimulateInitValues(rand);
+                       
+               currentEventExecute.Manage();
+               
+               thisRunIsSimple = false; //used by: on_event_execute_update_graph_in_progress_clicked
+               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
+                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
+               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
+               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_run_interval_finished);
+               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
+       }
+
+
+       private void on_run_interval_finished (object o, EventArgs args) 
+       {
+               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_run_interval_finished);
+               
+               //test can be deleted if not cancelled
+               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
+
+               if ( ! currentEventExecute.Cancel ) {
+                       currentRunInterval = (RunInterval) currentEventExecute.EventDone;
+
+                       //move video file if exists
+                       if(preferences.videoOn)
+                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.RUN_I, 
currentRunInterval.UniqueID))
+                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
+
+                       currentRunInterval.MetersSecondsPreferred = preferences.metersSecondsPreferred;
+
+                       //if user clicked in finish earlier
+                       if(currentEventExecute.Finish) {
+                               currentRunInterval.Tracks = 
Util.GetNumberOfJumps(currentRunInterval.IntervalTimesString, false);
+                               if(currentRunInterval.TracksLimited) {
+                                       currentRunInterval.Limited = currentRunInterval.Tracks.ToString() + 
"R";
+                               } else {
+                                       currentRunInterval.Limited = Util.GetTotalTime(
+                                                       currentRunInterval.IntervalTimesString) + "T";
+                               }
+                       }
+                       myTreeViewRunsInterval.Add(currentPerson.Name, currentRunInterval);
+                       
+                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
+                       showHideActionEventButtons(true, "RunInterval"); //show
+
+                       if(createdStatsWin) {
+                               showUpdateStatsAndHideData(true);
+                       }
+
+                       lastRunIsSimple = false;
+
+                       //unhide buttons for delete last jump
+                       sensitiveGuiYesEvent();
+
+                       //put correct time value in eventWindow (put the time from chronopic and not onTimer 
soft chronometer)
+                       event_execute_LabelTimeValue = currentRunInterval.TimeTotal;
+                       //possible deletion of last run can make the runs on event window be false
+                       event_execute_LabelEventValue = currentRunInterval.Tracks;
+               }
+               else if( currentEventExecute.ChronopicDisconnected )
+                       chronopicDisconnectedWhileExecuting();
+               
+               //delete the temp tables if exists
+               Sqlite.DeleteTempEvents("tempRunInterval");
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  REACTION TIMES EXECUTION --------------
+        *  --------------------------------------------------------
+        */
+
+       
+       //suitable for reaction times
+       private void on_reaction_time_activate (object o, EventArgs args) 
+       {
+               //used by cancel and finish
+               currentEventType = new ReactionTimeType();
+                       
+               //hide jumping buttons
+               sensitiveGuiEventDoing();
+
+               //show the event doing window
+               double progressbarLimit = 2;
+                       
+               //don't let update until test finishes
+               if(createdStatsWin)
+                       showUpdateStatsAndHideData(false);
+
+               event_execute_initializeVariables(
+                       ! chronopicWin.Connected,       //is simulated
+                       currentPerson.UniqueID, 
+                       currentPerson.Name, 
+                       Catalog.GetString("Phases"),      //name of the different moments
+                       Constants.ReactionTimeTable, //tableName
+                       "" 
+                       );
+               ExecutingGraphData egd = event_execute_prepareForTest ();
+
+               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
+               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
+
+               //when user clicks on update the eventExecute window 
+               //(for showing with his new confgured values: max, min and guides
+               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
+               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
+
+               string sep = "";
+               string description = "";
+               if(extra_window_radio_reaction_time_discriminative.Active) {
+                       if(check_reaction_time_disc_red.Active == true) {
+                               description += sep + Catalog.GetString("red");
+                               sep = " + ";
+                       }
+                       if(check_reaction_time_disc_yellow.Active == true) {
+                               description += sep + Catalog.GetString("yellow");
+                               sep = " + ";
+                       }
+                       if(check_reaction_time_disc_green.Active == true) {
+                               description += sep + Catalog.GetString("green");
+                               sep = " + ";
+                       }
+                       if(check_reaction_time_disc_buzzer.Active == true) {
+                               description += sep + Catalog.GetString("buzzer");
+                               sep = " + ";
+                       }
+               }
+               else if(extra_window_radio_reaction_time_animation_lights.Active)
+                       description = spinbutton_flicker_lights_speed.Value.ToString() + " - " + 
label_animation_lights_interval.Text;
+
+               currentEventExecute = new ReactionTimeExecute(currentPerson.UniqueID, currentPerson.Name, 
+                               currentSession.UniqueID, currentReactionTimeType.Name, 
+                               chronopicWin.CP, event_execute_label_message, app1, preferences.digitsNumber, 
preferences.volumeOn,
+                               progressbarLimit, egd, description
+                               );
+
+               if (!chronopicWin.Connected) 
+                       currentEventExecute.SimulateInitValues(rand);
+       
+               //not on simulated because results would be always 0
+               if( chronopicWin.Connected &&
+                               (extra_window_radio_reaction_time_discriminative.Active || 
+                                extra_window_radio_reaction_time_animation_lights.Active) )
+                       //TODO: do also for flickr
+                       currentEventExecute.StartIn = false;
+               
+               currentEventExecute.FakeButtonReactionTimeStart.Clicked += new 
EventHandler(on_event_execute_reaction_time_start);
+
+               currentEventExecute.Manage(); //check that platform is ok
+               
+               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
+                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
+               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
+               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_reaction_time_finished);
+               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
+       }       
+
+       private void on_event_execute_reaction_time_start (object o, EventArgs args) 
+       {
+               currentEventExecute.FakeButtonReactionTimeStart.Clicked -= new 
EventHandler(on_event_execute_reaction_time_start);
+
+               //Fire leds or buzzer on discriminative (if not simulated)
+               if(chronopicWin.Connected) {            
+                       if(extra_window_radio_reaction_time_discriminative.Active) {
+                               Thread.Sleep(Convert.ToInt32(discriminativeStartTime * 1000)); //in ms
+
+                               ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
+                               cs.CharToSend = discriminativeCharToSend;
+                               cs.Write(chronopicWin.SP, 0);
+                       }
+                       else if(extra_window_radio_reaction_time_animation_lights.Active) {
+                               int speed = Convert.ToInt32(spinbutton_animation_lights_speed.Value);
+                               ChronopicAuto cs = new ChronopicStartReactionTimeAnimation();
+                               cs.CharToSend = "l";
+                               cs.Write(chronopicWin.SP,speed);
+                       }
+
+                       LogB.Information("opening port at gui/chronojump.cs");  
+                       chronopicWin.SP.Open();
+
+                       /*
+                        * some machines needed to flush
+                        * - my Linux laptop two bytes
+                        * - a linux guest on windows host (virtual box) don't need
+                        * Note this will not allow reaction time be lower than 100 ms (DefaultTimeout on 
chronopic.cs)
+                        */
+                       LogB.Information("Going to flush by time out"); //needed on some machines
+                       chronopicWin.CP.FlushByTimeOut();
+                       LogB.Information("flushed!");   
+               }
+
+               currentEventExecute.Manage2();
+       }
+
+
+       private void on_reaction_time_finished (object o, EventArgs args)
+       {
+               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_reaction_time_finished);
+               
+               //test can be deleted if not cancelled
+               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
+
+               if ( ! currentEventExecute.Cancel ) {
+
+                       currentReactionTime = (ReactionTime) currentEventExecute.EventDone;
+                       
+                       //move video file if exists
+                       if(preferences.videoOn)
+                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.RT, 
currentReactionTime.UniqueID))
+                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
+                       
+                       myTreeViewReactionTimes.Add(currentPerson.Name, currentReactionTime);
+                       
+                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
+                       showHideActionEventButtons(true, "ReactionTime"); //show
+               
+                       if(createdStatsWin) {
+                               showUpdateStatsAndHideData(true);
+                       }
+               
+                       //unhide buttons for delete last reaction time
+                       sensitiveGuiYesEvent();
+               }
+               else if( currentEventExecute.ChronopicDisconnected )
+                       chronopicDisconnectedWhileExecuting();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  PULSES EXECUTION ----------------------
+        *  --------------------------------------------------------
+        */
+
+       private void on_pulse_activate (object o, EventArgs args)
+       {
+               LogB.Information("pulse accepted");
+       
+               double pulseStep = 0;
+               int totalPulses = 0;
+
+               if(currentPulseType.Name == "Free") {
+                       pulseStep = currentPulseType.FixedPulse; // -1
+                       totalPulses = currentPulseType.TotalPulsesNum; //-1
+               } else { //custom (info comes from Extra Window
+                       pulseStep = extra_window_pulses_spinbutton_pulse_step.Value;
+                       if(extra_window_pulses_checkbutton_unlimited.Active)
+                               totalPulses = currentPulseType.TotalPulsesNum; //-1
+                       else
+                               totalPulses = Convert.ToInt32(
+                                               extra_window_pulses_spinbutton_total_pulses.Value); //-1: 
unlimited; or 'n': limited by 'n' pulses
+               }
+
+               //used by cancel and finish
+               //currentEventType = new PulseType();
+               currentEventType = currentPulseType;
+                       
+               //hide pulse buttons
+               sensitiveGuiEventDoing();
+               
+               //don't let update until test finishes
+               if(createdStatsWin)
+                       showUpdateStatsAndHideData(false);
+
+               //show the event doing window
+               event_execute_initializeVariables(
+                       ! chronopicWin.Connected,       //is simulated
+                       currentPerson.UniqueID, 
+                       currentPerson.Name, 
+                       Catalog.GetString("Pulses"),      //name of the different moments
+                       Constants.PulseTable, //tableName
+                       currentPulseType.Name 
+                       );
+               ExecutingGraphData egd = event_execute_prepareForTest ();
+
+               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_clicked);
+               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_clicked);
+               
+               //when user clicks on update the eventExecute window 
+               //(for showing with his new confgured values: max, min and guides
+               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
+               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
+
+               currentEventExecute = new PulseExecute(currentPerson.UniqueID, currentPerson.Name, 
+                               currentSession.UniqueID, currentPulseType.Name, pulseStep, totalPulses, 
+                               chronopicWin.CP, event_execute_label_message, 
+                               app1, preferences.digitsNumber, preferences.volumeOn, egd
+                               );
+               
+               if(!chronopicWin.Connected)     
+                       currentEventExecute.SimulateInitValues(rand);
+               
+               currentEventExecute.Manage();
+               
+               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
+                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
+               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
+               currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_pulse_finished);
+               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
+       }
+
+       private void on_pulse_finished (object o, EventArgs args) 
+       {
+               LogB.Information("pulse finished");
+               
+               currentEventExecute.FakeButtonFinished.Clicked -= new EventHandler(on_pulse_finished);
+               
+               //test can be deleted if not cancelled
+               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
+
+               if ( ! currentEventExecute.Cancel ) {
+                       /*
+                        * CURRENTLY NOT NEEDED... check
+                       //if user clicked in finish earlier
+                       if(currentPulse.Finish) {
+                               currentRunInterval.Tracks = 
Util.GetNumberOfJumps(currentRunInterval.IntervalTimesString, false);
+                               if(currentRunInterval.TracksLimited) {
+                                       currentRunInterval.Limited = currentRunInterval.Tracks.ToString() + 
"R";
+                               } else {
+                                       currentRunInterval.Limited = Util.GetTotalTime(
+                                                       currentRunInterval.IntervalTimesString) + "T";
+                               }
+                       }
+                       */
+                       
+                       currentPulse = (Pulse) currentEventExecute.EventDone;
+                       
+                       //move video file if exists
+                       if(preferences.videoOn)
+                               if(! Util.CopyTempVideo(currentSession.UniqueID, Constants.TestTypes.PULSE, 
currentPulse.UniqueID))
+                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
+
+                       myTreeViewPulses.Add(currentPerson.Name, currentPulse);
+                       
+                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
+                       showHideActionEventButtons(true, "Pulse"); //show
+                       
+                       if(createdStatsWin) {
+                               showUpdateStatsAndHideData(true);
+                       }
+                       
+                       //unhide buttons for delete last jump
+                       sensitiveGuiYesEvent();
+
+                       //put correct time value in eventWindow (put the time from chronopic and not onTimer 
soft chronometer)
+                       event_execute_LabelTimeValue = Util.GetTotalTime(currentPulse.TimesString);
+               }
+               else if( currentEventExecute.ChronopicDisconnected )
+                       chronopicDisconnectedWhileExecuting();
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  MULTI CHRONOPIC EXECUTION -------------
+        *  --------------------------------------------------------
+        */
+
+       //recreate is used when a Chronopic was disconnected
+       //
+       //encoderPort is usually "" and will be Util.GetDefaultPort
+       //but, since 1.5.1 when selecting encoder option from main menu,
+       //then encoderPort will be found and send here
+       
+       //normal call
+       private void createChronopicWindow(bool recreate, string encoderPort) 
+       {
+               ArrayList cpd = new ArrayList();
+               for(int i=1; i<=4;i++) {
+                       ChronopicPortData cpdata = new ChronopicPortData(i,"",false);
+                       cpd.Add(cpdata);
+               }
+               createChronopicWindow(null, cpd, recreate, encoderPort);
+       }
+       //called directly on autodetect (detected cp and cpd is send)
+       private void createChronopicWindow(Chronopic cp, ArrayList cpd, bool recreate, string encoderPort) 
+       {
+               if(encoderPort == "")
+                       encoderPort = Util.GetDefaultPort();
+
+               chronopicWin = ChronopicWindow.Create(cp, cpd, encoderPort, recreate, preferences.volumeOn);
+               //chronopicWin.FakeButtonCancelled.Clicked += new EventHandler(on_chronopic_window_cancelled);
+               
+               if(notebook_sup.CurrentPage == 0) {
+                       int cps = chronopicWin.NumConnected();
+                       LogB.Debug("cps: " + cps.ToString());
+                       chronopicContactsLabels(cps, recreate);
+               }
+               else //(notebook_sup.CurrentPage == 1)
+                       chronopicEncoderLabels(recreate);
+               
+               if(recreate)    
+                       label_chronopics_multitest.Text = "";
+       }
+
+       private void on_chronopic_contacts_clicked (object o, EventArgs args) {
+               ChronopicWindow.ChronojumpMode cmode = ChronopicWindow.ChronojumpMode.JUMPORRUN;
+               if(radio_menuitem_mode_other.Active)
+                       cmode = ChronopicWindow.ChronojumpMode.OTHER;
+
+               chronopicWin = ChronopicWindow.View(cmode, preferences.volumeOn);
+               //chronopicWin.FakeWindowReload.Clicked += new EventHandler(chronopicWindowReload);
+               chronopicWin.FakeWindowDone.Clicked += new 
EventHandler(on_chronopic_window_contacts_connected_or_done);
+       }
+
+       private void on_chronopic_encoder_clicked (object o, EventArgs args) {
+               chronopicWin = ChronopicWindow.View(ChronopicWindow.ChronojumpMode.ENCODER, 
preferences.volumeOn);
+               //chronopicWin.FakeWindowReload.Clicked += new EventHandler(chronopicWindowReload);
+               chronopicWin.FakeWindowDone.Clicked += new 
EventHandler(on_chronopic_window_encoder_connected_or_done);
+       }
+
+       
+       /*      
+       private void on_chronopic_window_cancelled (object o, EventArgs ags) {
+               chronopicWin.FakeButtonCancelled.Clicked -= new EventHandler(on_chronopic_window_cancelled);
+               chronopicCancelledTimes ++;
+       }
+       */
+
+       /*      
+       private void chronopicWindowReload(object o, EventArgs args) {
+               //chronopicWin.FakeWindowReload.Clicked -= new EventHandler(chronopicWindowReload);
+
+               //store ports info and update labels if necessary
+               on_chronopic_window_connected_or_done (o, args);
+
+               //create chronopic window again (maybe new ports)
+               //createChronopicWindow(true);
+
+               //show it
+               chronopicWin = ChronopicWindow.View(preferences.volumeOn);
+       }
+       */
+
+       private void on_chronopic_window_contacts_connected_or_done (object o, EventArgs args) {
+               chronopicWin.FakeWindowDone.Clicked -= new 
EventHandler(on_chronopic_window_contacts_connected_or_done);
+               int cps = chronopicWin.NumConnected();
+
+               if(radio_mode_multi_chronopic_small.Active)     
+                       on_extra_window_multichronopic_test_changed(new object(), new EventArgs());
+               
+               if(cps > 0)
+                       change_multitest_firmware(getMenuItemMode());
+               else 
+                       label_chronopics_multitest.Text = "";
+               
+               chronopicContactsLabels(cps, true);
+       }
+       
+       private void on_chronopic_window_encoder_connected_or_done (object o, EventArgs args) {
+               chronopicWin.FakeWindowDone.Clicked -= new 
EventHandler(on_chronopic_window_encoder_connected_or_done);
+
+               chronopicEncoderLabels(true);
+       }
+
+
+       private void chronopicContactsLabels(int cps, bool colorize) {
+               //string text = "<b>" + cps.ToString() + "</b>";
+               string text = cps.ToString();
+               
+               label_connected_chronopics.Text = text;
+               //label_connected_chronopics.UseMarkup = true; 
+               
+               LogB.Debug("cpwin connected: " + chronopicWin.Connected.ToString());    
+               if(colorize)
+                       UtilGtk.ChronopicColors(viewport_chronopics, 
+                                       label_chronopics, label_connected_chronopics, 
+                                       chronopicWin.Connected);
+       }
+
+       private void chronopicEncoderLabels(bool colorize) {
+               LogB.Information("at chronopicEncoderLabels");
+               string encoderPort = chronopicWin.GetEncoderPort();
+               LogB.Debug("gui/chronojump.cs encoderPort:", encoderPort);
+
+               if(encoderPort != null && encoderPort != "" && encoderPort != Util.GetDefaultPort())
+               {
+                       label_chronopic_encoder.Text = Catalog.GetString("Encoder connected");
+                       image_chronopic_encoder_no.Visible = false;
+                       image_chronopic_encoder_yes.Visible = true;
+               }
+               else {
+                       label_chronopic_encoder.Text = Catalog.GetString("Encoder disconnected");
+                       image_chronopic_encoder_no.Visible = true;
+                       image_chronopic_encoder_yes.Visible = false;
+               }
+               
+               if(colorize)
+                       UtilGtk.ChronopicColors(viewport_chronopic_encoder, 
+                                       label_chronopic_encoder, new Gtk.Label(),
+                                       encoderPort != "");
+
+               LogB.Information("at chronopicEncoderLabels end");
+       }
+
+
+       private void on_multi_chronopic_start_clicked (object o, EventArgs args) {
+               LogB.Information("multi chronopic accepted");
+               
+               bool syncAvailable = false;
+               if(currentMultiChronopicType.SyncAvailable && extra_window_check_multichronopic_sync.Active)
+                       syncAvailable = true;
+
+
+               //used by cancel and finish
+               currentEventType = new MultiChronopicType();
+                       
+               //hide pulse buttons
+               sensitiveGuiEventDoing();
+               
+               //don't let update until test finishes
+               if(createdStatsWin)
+                       showUpdateStatsAndHideData(false);
+
+               //show the event doing window
+               event_execute_initializeVariables(
+                       ! chronopicWin.Connected,       //is simulated
+                       currentPerson.UniqueID, 
+                       currentPerson.Name, 
+                       Catalog.GetString("Changes"),     //name of the different moments
+                       Constants.MultiChronopicTable, //tableName
+                       currentMultiChronopicType.Name
+                       ); 
+               ExecutingGraphData egd = event_execute_prepareForTest ();
+
+               event_execute_ButtonCancel.Clicked += new EventHandler(on_cancel_multi_clicked);
+               event_execute_ButtonFinish.Clicked += new EventHandler(on_finish_multi_clicked);
+               
+               //when user clicks on update the eventExecute window 
+               //(for showing with his new confgured values: max, min and guides
+               event_execute_ButtonUpdate.Clicked -= new EventHandler(on_update_clicked); //if we don't do 
this, on_update_clicked it's called 'n' times when 'n' events are done
+               event_execute_ButtonUpdate.Clicked += new EventHandler(on_update_clicked);
+
+
+               /*
+               bool syncAvailable = false;
+               if(currentMultiChronopicType.SyncAvailable && extra_window_check_multichronopic_sync.Active)
+                       syncAvailable = true;
+                       */
+
+               int numConnected = chronopicWin.NumConnected();
+
+               if(numConnected == 1)
+                       currentEventExecute = new MultiChronopicExecute(
+                                       currentPerson.UniqueID, currentPerson.Name, 
+                                       currentSession.UniqueID, currentMultiChronopicType.Name, 
+                                       chronopicWin.CP, 
+                                       syncAvailable, extra_window_check_multichronopic_delete_first.Active, 
+                                       extra_window_spin_run_analysis_distance.Value.ToString(),
+                                       app1, egd
+                                       );
+               else if(numConnected == 2)
+                       currentEventExecute = new MultiChronopicExecute(
+                                       currentPerson.UniqueID, currentPerson.Name, 
+                                       currentSession.UniqueID, currentMultiChronopicType.Name,  
+                                       chronopicWin.CP, chronopicWin.CP2, 
+                                       syncAvailable, extra_window_check_multichronopic_delete_first.Active, 
+                                       extra_window_spin_run_analysis_distance.Value.ToString(),
+                                       app1, egd
+                                       );
+               else if(numConnected == 3)
+                       currentEventExecute = new MultiChronopicExecute(
+                                       currentPerson.UniqueID, currentPerson.Name, 
+                                       currentSession.UniqueID, currentMultiChronopicType.Name,
+                                       chronopicWin.CP, chronopicWin.CP2, chronopicWin.CP3, 
+                                       syncAvailable, extra_window_check_multichronopic_delete_first.Active, 
+                                       extra_window_spin_run_analysis_distance.Value.ToString(),
+                                       app1, egd
+                                       );
+               else if(numConnected == 4)
+                       currentEventExecute = new MultiChronopicExecute(
+                                       currentPerson.UniqueID, currentPerson.Name, 
+                                       currentSession.UniqueID, currentMultiChronopicType.Name,
+                                       chronopicWin.CP, chronopicWin.CP2, chronopicWin.CP3, chronopicWin.CP4,
+                                       syncAvailable, extra_window_check_multichronopic_delete_first.Active, 
+                                       extra_window_spin_run_analysis_distance.Value.ToString(),
+                                       app1, egd
+                                       );
+
+               //if(!chronopicWin.Connected)   
+               //      currentEventExecute.SimulateInitValues(rand);
+
+
+               //mark to only get inside on_multi_chronopic_finished one time
+               multiFinishing = false;
+               currentEventExecute.Manage();
+
+               currentEventExecute.FakeButtonUpdateGraph.Clicked += 
+                       new EventHandler(on_event_execute_update_graph_in_progress_clicked);
+               currentEventExecute.FakeButtonEventEnded.Clicked += new 
EventHandler(on_event_execute_EventEnded);
+//             currentEventExecute.FakeButtonRunATouchPlatform.Clicked += new 
EventHandler(on_event_execute_RunATouchPlatform);
+               currentEventExecute.FakeButtonFinished.Clicked += new 
EventHandler(on_multi_chronopic_finished);
+               currentEventExecute.FakeButtonThreadDyed.Clicked += new 
EventHandler(on_test_finished_can_touch_gtk);
+       }
+
+       bool multiFinishing;
+       private void on_multi_chronopic_finished (object o, EventArgs args) {
+               if(multiFinishing)
+                       return;
+               else
+                       multiFinishing = true;
+
+               currentEventExecute.FakeButtonFinished.Clicked -= new 
EventHandler(on_multi_chronopic_finished);
+
+               //test can be deleted if not cancelled
+               button_delete_this_test.Sensitive = ! currentEventExecute.Cancel;
+
+               if(currentMultiChronopicType.Name == Constants.RunAnalysisName && ! 
currentEventExecute.MultiChronopicRunAUsedCP2()) 
+                       //new DialogMessage(Constants.MessageTypes.WARNING, 
+                       //              Catalog.GetString("This Run Analysis is not valid because there are 
no strides."));
+                       currentEventExecute.RunANoStrides();
+               else if ( ! currentEventExecute.Cancel ) {
+LogB.Debug("T");
+                       /*
+                          on runAnalysis test, when cp1 ends, run ends,
+                          but cp2 is still waiting event
+                          with this will ask cp2 to press button
+                          solves problem with threads at ending
+                          */
+
+                       //on_finish_multi_clicked(o, args);
+                       //this produces also a crash:
+                       //new DialogMessage(Constants.MessageTypes.INFO, "Please, touch a platform now.");
+LogB.Debug("U");
+                       //call write here, because if done in execute/MultiChronopic, will be called n times 
if n chronopics are working
+                       currentEventExecute.MultiChronopicWrite(false);
+LogB.Debug("V");
+                       currentMultiChronopic = (MultiChronopic) currentEventExecute.EventDone;
+LogB.Debug("W");
+                       //move video file if exists
+                       if(preferences.videoOn)
+                               if(! Util.CopyTempVideo(currentSession.UniqueID, 
+                                                       Constants.TestTypes.MULTICHRONOPIC, 
currentMultiChronopic.UniqueID))
+                                       new DialogMessage(Constants.MessageTypes.WARNING, 
Catalog.GetString("Sorry, video cannot be stored."));
+
+                       //this produces also a crash:
+                       //new DialogMessage(Constants.MessageTypes.INFO, "Please, touch a platform now.");
+
+LogB.Debug("W2");
+                       
+                       //if this multichronopic has more chronopics than other in session, then reload 
treeview, else simply add
+                       if(currentMultiChronopic.CPs() != SqliteMultiChronopic.MaxCPs(false, 
currentSession.UniqueID)) {
+                               treeview_multi_chronopic_storeReset(false);
+                               fillTreeView_multi_chronopic();
+                       } else
+                               myTreeViewMultiChronopic.Add(currentPerson.Name, currentMultiChronopic);
+LogB.Debug("X");
+                       
+                       //since 0.7.4.1 when test is done, treeview select it. action event button have to be 
shown 
+                       showHideActionEventButtons(true, Constants.MultiChronopicName); //show
+               
+                       //unhide buttons for delete last test
+                       sensitiveGuiYesEvent();
+               }
+               else if( currentEventExecute.ChronopicDisconnected )
+                       chronopicDisconnectedWhileExecuting();
+       }
+               
+
+       /*
+        * update button is clicked on eventWindow, chronojump.cs delegate points here
+        */
+       
+       private void on_update_clicked (object o, EventArgs args) {
+               LogB.Information("--On_update_clicked--");
+               try {
+                       switch (currentEventType.Type) {
+                               case EventType.Types.JUMP:
+                                       if(lastJumpIsSimple && radio_menuitem_mode_jumps_simple.Active) 
+                                               
PrepareJumpSimpleGraph(currentEventExecute.PrepareEventGraphJumpSimpleObject, false);
+                                       else if (radio_menuitem_mode_jumps_reactive.Active)
+                                               PrepareJumpReactiveGraph(
+                                                               Util.GetLast(currentJumpRj.TvString), 
Util.GetLast(currentJumpRj.TcString),
+                                                               currentJumpRj.TvString, 
currentJumpRj.TcString, preferences.volumeOn, repetitiveConditionsWin);
+                                       break;
+                               case EventType.Types.RUN:
+                                       if(lastRunIsSimple && radio_menuitem_mode_runs_simple.Active) 
+                                               
PrepareRunSimpleGraph(currentEventExecute.PrepareEventGraphRunSimpleObject, false);
+                                       else if(radio_menuitem_mode_runs_intervallic.Active) {
+                                               RunType runType = 
SqliteRunIntervalType.SelectAndReturnRunIntervalType(currentRunInterval.Type, false);
+                                               double distanceTotal = 
Util.GetRunITotalDistance(currentRunInterval.DistanceInterval, 
+                                                               runType.DistancesString, 
currentRunInterval.Tracks);
+
+                                               double distanceInterval = currentRunInterval.DistanceInterval;
+                                               if(distanceInterval == -1) //variable distances
+                                                       distanceInterval = 
Util.GetRunIVariableDistancesStringRow(
+                                                                       runType.DistancesString, (int) 
currentRunInterval.Tracks -1);
+                                               
+                                               PrepareRunIntervalGraph(distanceInterval, 
+                                                               
Util.GetLast(currentRunInterval.IntervalTimesString), 
+                                                               currentRunInterval.IntervalTimesString, 
+                                                               distanceTotal,
+                                                               runType.DistancesString,
+                                                               currentRunInterval.StartIn,
+                                                               preferences.volumeOn, 
repetitiveConditionsWin);
+                                       }
+                                       break;
+                               case EventType.Types.PULSE:
+                                       if(radio_mode_pulses_small.Active)
+                                               PreparePulseGraph(Util.GetLast(currentPulse.TimesString), 
currentPulse.TimesString);
+                                       break;
+                               case EventType.Types.REACTIONTIME:
+                                       if(radio_mode_reaction_times_small.Active)
+                                               
PrepareReactionTimeGraph(currentEventExecute.PrepareEventGraphReactionTimeObject, false);
+                                       break;
+                               case EventType.Types.MULTICHRONOPIC:
+                                       if(radio_mode_multi_chronopic_small.Active)
+                                               PrepareMultiChronopicGraph(
+                                                               //currentMultiChronopic.timestamp, 
+                                                               
Util.IntToBool(currentMultiChronopic.Cp1StartedIn), 
+                                                               
Util.IntToBool(currentMultiChronopic.Cp2StartedIn), 
+                                                               
Util.IntToBool(currentMultiChronopic.Cp3StartedIn), 
+                                                               
Util.IntToBool(currentMultiChronopic.Cp4StartedIn), 
+                                                               currentMultiChronopic.Cp1InStr, 
+                                                               currentMultiChronopic.Cp1OutStr,
+                                                               currentMultiChronopic.Cp2InStr, 
+                                                               currentMultiChronopic.Cp2OutStr,
+                                                               currentMultiChronopic.Cp3InStr, 
+                                                               currentMultiChronopic.Cp3OutStr,
+                                                               currentMultiChronopic.Cp4InStr, 
+                                                               currentMultiChronopic.Cp4OutStr);
+                                       break;
+                       }
+               }
+               catch {
+                       errorWin = ErrorWindow.Show(Catalog.GetString("Cannot update. Probably this test was 
deleted."));
+               }
+       
+       }
+
+
+
+       /* ---------------------------------------------------------
+        * ----------------  EVENTS EDIT ---------------------------
+        *  --------------------------------------------------------
+        */
+
+       int eventOldPerson;
+
+       private void on_edit_selected_jump_clicked (object o, EventArgs args) {
+               //notebooks_change(0); see "notebooks_change sqlite problem"
+               LogB.Information("Edit selected jump (normal)");
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
+               if (myTreeViewJumps.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected jump
+                       Jump myJump = SqliteJump.SelectJumpData( myTreeViewJumps.EventSelectedID, false );
+                       eventOldPerson = myJump.PersonID;
+               
+                       //4.- edit this jump
+                       editJumpWin = EditJumpWindow.Show(app1, myJump, preferences.weightStatsPercent, 
preferences.digitsNumber);
+                       editJumpWin.Button_accept.Clicked += new EventHandler(on_edit_selected_jump_accepted);
+               }
+       }
+       
+       private void on_edit_selected_jump_rj_clicked (object o, EventArgs args) {
+               //notebooks_change(1); see "notebooks_change sqlite problem"
+               LogB.Information("Edit selected jump (RJ)");
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
+               if (myTreeViewJumpsRj.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected jump
+                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
+                       eventOldPerson = myJump.PersonID;
+               
+                       //4.- edit this jump
+                       editJumpRjWin = EditJumpRjWindow.Show(app1, myJump, preferences.weightStatsPercent, 
preferences.digitsNumber);
+                       editJumpRjWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_jump_rj_accepted);
+               }
+       }
+       
+       private void on_edit_selected_jump_accepted (object o, EventArgs args) {
+               LogB.Information("edit selected jump accepted");
+       
+               Jump myJump = SqliteJump.SelectJumpData( myTreeViewJumps.EventSelectedID, false );
+
+               //if person changed, fill treeview again, if not, only update it's line
+               if(eventOldPerson == myJump.PersonID) {
+                       if(! preferences.weightStatsPercent) {
+                               double personWeight = SqlitePersonSession.SelectAttribute(
+                                               false, myJump.PersonID, currentSession.UniqueID, 
Constants.Weight);
+                               myJump.Weight = Util.WeightFromPercentToKg(myJump.Weight, personWeight);
+                       }
+                       myTreeViewJumps.Update(myJump);
+               }
+               else {
+                       treeview_jumps_storeReset();
+                       fillTreeView_jumps(UtilGtk.ComboGetActive(combo_result_jumps));
+               }
+               
+               updateGraphJumpsSimple();
+
+               if(createdStatsWin) 
+                       stats_win_fillTreeView_stats(false, false);
+       }
+       
+       private void on_edit_selected_jump_rj_accepted (object o, EventArgs args) {
+               LogB.Information("edit selected jump RJ accepted");
+       
+               JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", myTreeViewJumpsRj.EventSelectedID, 
false );
+               
+               //if person changed, fill treeview again, if not, only update it's line
+               if(eventOldPerson == myJump.PersonID) {
+                       if(! preferences.weightStatsPercent) {
+                               double personWeight = SqlitePersonSession.SelectAttribute(
+                                               false, myJump.PersonID, currentSession.UniqueID, 
Constants.Weight);
+                               myJump.Weight = Util.WeightFromPercentToKg(myJump.Weight, personWeight);
+                       }
+                       myTreeViewJumpsRj.Update(myJump);
+               }
+               else {
+                       treeview_jumps_rj_storeReset();
+                       fillTreeView_jumps_rj(UtilGtk.ComboGetActive(combo_result_jumps_rj));
+               }
+
+               if(createdStatsWin) 
+                       stats_win_fillTreeView_stats(false, false);
+       }
+       
+       private void on_edit_selected_run_clicked (object o, EventArgs args) {
+               //notebooks_change(2); see "notebooks_change sqlite problem"
+               LogB.Information("Edit selected run (normal)");
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
+               if (myTreeViewRuns.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected run
+                       Run myRun = SqliteRun.SelectRunData( myTreeViewRuns.EventSelectedID, false );
+                       myRun.MetersSecondsPreferred = preferences.metersSecondsPreferred;
+                       eventOldPerson = myRun.PersonID;
+               
+                       //4.- edit this run
+                       editRunWin = EditRunWindow.Show(app1, myRun, preferences.digitsNumber, 
preferences.metersSecondsPreferred);
+                       editRunWin.Button_accept.Clicked += new EventHandler(on_edit_selected_run_accepted);
+               }
+       }
+       
+       private void on_edit_selected_run_interval_clicked (object o, EventArgs args) {
+               //notebooks_change(3); see "notebooks_change sqlite problem"
+               LogB.Information("Edit selected run interval");
+               //1.- check that there's a line selected
+               //2.- check that this line is a run and not a person (check also if it's not a individual 
subrun, the pass the parent run)
+               if (myTreeViewRunsInterval.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected run
+                       RunInterval myRun = SqliteRunInterval.SelectRunData( Constants.RunIntervalTable, 
myTreeViewRunsInterval.EventSelectedID, false );
+                       eventOldPerson = myRun.PersonID;
+               
+                       //4.- edit this run
+                       editRunIntervalWin = EditRunIntervalWindow.Show(app1, myRun, 
preferences.digitsNumber, preferences.metersSecondsPreferred);
+                       editRunIntervalWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_run_interval_accepted);
+               }
+       }
+       
+       private void on_edit_selected_run_accepted (object o, EventArgs args) {
+               LogB.Information("edit selected run accepted");
+               
+               Run myRun = SqliteRun.SelectRunData( myTreeViewRuns.EventSelectedID, false );
+               
+               //if person changed, fill treeview again, if not, only update it's line
+               if(eventOldPerson == myRun.PersonID)
+                       myTreeViewRuns.Update(myRun);
+               else {
+                       treeview_runs_storeReset();
+                       fillTreeView_runs(UtilGtk.ComboGetActive(combo_result_runs));
+               }
+               
+               updateGraphRunsSimple();
+
+               if(createdStatsWin) 
+                       stats_win_fillTreeView_stats(false, false);
+       }
+       
+       private void on_edit_selected_run_interval_accepted (object o, EventArgs args) {
+               LogB.Information("edit selected run interval accepted");
+               
+               RunInterval myRun = SqliteRunInterval.SelectRunData( Constants.RunIntervalTable, 
myTreeViewRunsInterval.EventSelectedID, false );
+
+               //if person changed, fill treeview again, if not, only update it's line
+               if(eventOldPerson == myRun.PersonID)
+                       myTreeViewRunsInterval.Update(myRun);
+               else {
+                       treeview_runs_interval_storeReset();
+                       fillTreeView_runs_interval(UtilGtk.ComboGetActive(combo_result_runs_interval));
+               }
+               
+               if(createdStatsWin)
+                       stats_win_fillTreeView_stats(false, false);
+       }
+
+       private void on_edit_selected_reaction_time_clicked (object o, EventArgs args) {
+               //notebooks_change(4); see "notebooks_change sqlite problem"
+               LogB.Information("Edit selected reaction time");
+               //1.- check that there's a line selected
+               //2.- check that this line is a event and not a person
+               if (myTreeViewReactionTimes.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected event
+                       ReactionTime myRT = SqliteReactionTime.SelectReactionTimeData( 
myTreeViewReactionTimes.EventSelectedID, false );
+                       eventOldPerson = myRT.PersonID;
+               
+                       //4.- edit this event
+                       editReactionTimeWin = EditReactionTimeWindow.Show(app1, myRT, 
preferences.digitsNumber);
+                       editReactionTimeWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_reaction_time_accepted);
+               }
+       }
+       
+       private void on_edit_selected_reaction_time_accepted (object o, EventArgs args) {
+               LogB.Information("edit selected reaction time accepted");
+               
+               ReactionTime myRT = SqliteReactionTime.SelectReactionTimeData( 
myTreeViewReactionTimes.EventSelectedID, false);
+
+               //if person changed, fill treeview again, if not, only update it's line
+               if(eventOldPerson == myRT.PersonID)
+                       myTreeViewReactionTimes.Update(myRT);
+               else {
+                       treeview_reaction_times_storeReset();
+                       fillTreeView_reaction_times(currentReactionTimeType.Name);
+               }
+               
+               updateGraphReactionTimes();
+       }
+       
+       private void on_edit_selected_pulse_clicked (object o, EventArgs args) {
+               //notebooks_change(5); see "notebooks_change sqlite problem"
+               LogB.Information("Edit selected pulse");
+               //1.- check that there's a line selected
+               //2.- check that this line is a event and not a person
+               if (myTreeViewPulses.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected event
+                       Pulse myPulse = SqlitePulse.SelectPulseData( myTreeViewPulses.EventSelectedID, false 
);
+                       eventOldPerson = myPulse.PersonID;
+               
+                       //4.- edit this event
+                       editPulseWin = EditPulseWindow.Show(app1, myPulse, preferences.digitsNumber);
+                       editPulseWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_pulse_accepted);
+               }
+       }
+       
+       private void on_edit_selected_pulse_accepted (object o, EventArgs args) {
+               LogB.Information("edit selected pulse accepted");
+               
+               Pulse myPulse = SqlitePulse.SelectPulseData( myTreeViewPulses.EventSelectedID, false );
+
+               //if person changed, fill treeview again, if not, only update it's line
+               if(eventOldPerson == myPulse.PersonID)
+                       myTreeViewPulses.Update(myPulse);
+               else {
+                       treeview_pulses_storeReset();
+                       fillTreeView_pulses(UtilGtk.ComboGetActive(combo_pulses));
+               }
+       }
+       
+       private void on_edit_selected_multi_chronopic_clicked (object o, EventArgs args) {
+               //notebooks_change(6); see "notebooks_change sqlite problem"
+               LogB.Information("Edit selected multi chronopic");
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
+               if (myTreeViewMultiChronopic.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected test
+                       MultiChronopic mc = SqliteMultiChronopic.SelectMultiChronopicData( 
myTreeViewMultiChronopic.EventSelectedID, false );
+                       eventOldPerson = mc.PersonID;
+               
+                       //4.- edit this jump
+                       editMultiChronopicWin = EditMultiChronopicWindow.Show(app1, mc, 
preferences.digitsNumber);
+                       editMultiChronopicWin.Button_accept.Clicked += new 
EventHandler(on_edit_selected_multi_chronopic_accepted);
+               }
+       }
+
+       private void on_edit_selected_multi_chronopic_accepted (object o, EventArgs args) {
+               LogB.Information("edit selected multi chronopic accepted");
+       
+               MultiChronopic mc = SqliteMultiChronopic.SelectMultiChronopicData( 
myTreeViewMultiChronopic.EventSelectedID, false );
+               
+               //if person changed, fill treeview again, if not, only update it's line
+               if(eventOldPerson == mc.PersonID) 
+                       myTreeViewMultiChronopic.Update(mc);
+               else {
+                       treeview_multi_chronopic_storeReset(false);
+                       fillTreeView_multi_chronopic();
+               }
+       }
+       
+       /* ---------------------------------------------------------
+        * ----------------  EVENTS PLAY VIDEO ---------------------
+        *  --------------------------------------------------------
+        */
+
+       //Not used on encoder   
+       private bool playVideo(string fileName, bool play) 
+       {
+               if(File.Exists(fileName)) {
+                       LogB.Information("Play video starting...");
+                       PlayerBin player = new PlayerBin();
+                       player.Open(fileName);
+
+                       //without these lines works also but has less functionalities (speed, go to ms)
+                       Gtk.Window d = new Gtk.Window(Catalog.GetString("Playing video"));
+                       d.Add(player);
+                       d.Modal = true;
+                       d.SetDefaultSize(500,400);
+                       d.ShowAll();
+                       d.DeleteEvent += delegate(object sender, DeleteEventArgs e) {player.Close(); 
player.Dispose();};
+
+                       if(play) {
+                               LogB.Information("Play video playing...");
+                               player.Play();
+                       }
+                       return true;    
+               }
+               return false;   
+       }
+
+
+       private void on_video_play_this_test_clicked (object o, EventArgs args) {
+               Constants.TestTypes type = Constants.TestTypes.JUMP;
+               int id = 0;
+               switch (currentEventType.Type) {
+                       case EventType.Types.JUMP:
+                               if(lastJumpIsSimple) {
+                                       type = Constants.TestTypes.JUMP;
+                                       id = currentJump.UniqueID;
+                               }
+                               else {
+                                       type = Constants.TestTypes.JUMP_RJ;
+                                       id = currentJumpRj.UniqueID;
+                               } break;
+                       case EventType.Types.RUN:
+                               if(lastRunIsSimple) {
+                                       type = Constants.TestTypes.RUN;
+                                       id = currentRun.UniqueID;
+                               } else {
+                                       type = Constants.TestTypes.RUN_I;
+                                       id = currentRunInterval.UniqueID;
+                               }
+                               break;
+                       case EventType.Types.PULSE:
+                               type = Constants.TestTypes.PULSE;
+                               id = currentPulse.UniqueID;
+                               break;
+                       case EventType.Types.REACTIONTIME:
+                               type = Constants.TestTypes.RT;
+                               id = currentReactionTime.UniqueID;
+                               break;
+                       case EventType.Types.MULTICHRONOPIC:
+                               type = Constants.TestTypes.MULTICHRONOPIC;
+                               id = currentMultiChronopic.UniqueID;
+                               break;
+               }
+
+               playVideo(Util.GetVideoFileName(currentSession.UniqueID, type, id), true);
+       }
+
+       private void on_video_play_selected_jump_clicked (object o, EventArgs args) {
+               if (myTreeViewJumps.EventSelectedID > 0) 
+                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
+                                               Constants.TestTypes.JUMP,
+                                               myTreeViewJumps.EventSelectedID), true);
+       }
+
+       private void on_video_play_selected_jump_rj_clicked (object o, EventArgs args) {
+               if (myTreeViewJumpsRj.EventSelectedID > 0) 
+                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
+                                               Constants.TestTypes.JUMP_RJ,
+                                               myTreeViewJumpsRj.EventSelectedID), true);
+       }
+
+       private void on_video_play_selected_run_clicked (object o, EventArgs args) {
+               if (myTreeViewRuns.EventSelectedID > 0) 
+                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
+                                               Constants.TestTypes.RUN,
+                                               myTreeViewRuns.EventSelectedID), true);
+       }
+
+       private void on_video_play_selected_run_interval_clicked (object o, EventArgs args) {
+               if (myTreeViewRunsInterval.EventSelectedID > 0) 
+                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
+                                               Constants.TestTypes.RUN_I,
+                                               myTreeViewRunsInterval.EventSelectedID), true);
+       }
+
+       private void on_video_play_selected_reaction_time_clicked (object o, EventArgs args) {
+               if (myTreeViewReactionTimes.EventSelectedID > 0) 
+                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
+                                               Constants.TestTypes.RT,
+                                               myTreeViewReactionTimes.EventSelectedID), true);
+       }
+
+       private void on_video_play_selected_pulse_clicked (object o, EventArgs args) {
+               if (myTreeViewPulses.EventSelectedID > 0) 
+                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
+                                               Constants.TestTypes.PULSE,
+                                               myTreeViewPulses.EventSelectedID), true);
+       }
+
+       private void on_video_play_selected_multi_chronopic_clicked (object o, EventArgs args) {
+               if (myTreeViewMultiChronopic.EventSelectedID > 0) 
+                       playVideo(Util.GetVideoFileName(currentSession.UniqueID, 
+                                               Constants.TestTypes.MULTICHRONOPIC,
+                                               myTreeViewMultiChronopic.EventSelectedID), true);
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  EVENTS DELETE -------------------------
+        *  --------------------------------------------------------
+        */
+       
+       private void on_delete_this_test_clicked (object o, EventArgs args) {
+               switch (currentEventType.Type) {
+                       case EventType.Types.JUMP:
+                               if(lastJumpIsSimple) {
+                                       //maybe, after executing the test, user has selected other test on 
treeview
+                                       //delete this is called on execute
+                                       //we should ensure we are deleting last jump and not the selected jump
+                                       //force selection of last jump
+                                       if(currentJump.UniqueID != myTreeViewJumps.EventSelectedID)
+                                               myTreeViewJumps.SelectEvent(currentJump.UniqueID);
+                                       on_delete_selected_jump_clicked(o, args);
+                               } else {
+                                       if(currentJumpRj.UniqueID != myTreeViewJumpsRj.EventSelectedID)
+                                               myTreeViewJumpsRj.SelectEvent(currentJumpRj.UniqueID);
+                                       on_delete_selected_jump_rj_clicked(o, args);
+                               }
+                               break;
+                       case EventType.Types.RUN:
+                               if(lastRunIsSimple) {
+                                       if(currentRun.UniqueID != myTreeViewRuns.EventSelectedID)
+                                               myTreeViewRuns.SelectEvent(currentRun.UniqueID);
+                                       on_delete_selected_run_clicked(o, args);
+                               } else {
+                                       if(currentRunInterval.UniqueID != 
myTreeViewRunsInterval.EventSelectedID)
+                                               
myTreeViewRunsInterval.SelectEvent(currentRunInterval.UniqueID);
+                                       on_delete_selected_run_interval_clicked(o, args);
+                               }
+                               break;
+                       case EventType.Types.PULSE:
+                               if(currentPulse.UniqueID != myTreeViewPulses.EventSelectedID)
+                                       myTreeViewPulses.SelectEvent(currentPulse.UniqueID);
+                               on_delete_selected_pulse_clicked(o, args);
+                               break;
+                       case EventType.Types.REACTIONTIME:
+                               if(currentReactionTime.UniqueID != myTreeViewReactionTimes.EventSelectedID)
+                                       myTreeViewReactionTimes.SelectEvent(currentReactionTime.UniqueID);
+                               on_delete_selected_reaction_time_clicked(o, args);
+                               break;
+                       case EventType.Types.MULTICHRONOPIC:
+                               if(currentMultiChronopic.UniqueID != myTreeViewMultiChronopic.EventSelectedID)
+                                       myTreeViewMultiChronopic.SelectEvent(currentMultiChronopic.UniqueID);
+                               on_delete_selected_multi_chronopic_clicked(o, args);
+                               break;
+               }
+       }
+
+       private void deleted_last_test_update_widgets() {
+               vbox_this_test_buttons.Sensitive = false;
+               UtilGtk.ClearDrawingArea(event_execute_drawingarea, event_execute_pixmap);
+               notebook_results_data.CurrentPage = 3; //shows "deleted test"
+       }
+       
+       private void on_delete_selected_jump_clicked (object o, EventArgs args) {
+               //notebooks_change(0); see "notebooks_change sqlite problem"
+               LogB.Information("delete this jump (normal)");
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person
+               LogB.Information(myTreeViewJumps.EventSelectedID.ToString());
+               if (myTreeViewJumps.EventSelectedID > 0) {
+                       //3.- display confirmwindow of deletion 
+                       if (preferences.askDeletion) {
+                               confirmWinJumpRun = ConfirmWindowJumpRun.Show(Catalog.GetString("Do you want 
to delete this jump?"), "");
+                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_jump_accepted);
+                       } else {
+                               on_delete_selected_jump_accepted(o, args);
+                       }
+               }
+       }
+       
+       private void on_delete_selected_jump_rj_clicked (object o, EventArgs args) {
+               //notebooks_change(1); see "notebooks_change sqlite problem"
+               LogB.Information("delete this reactive jump");
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
+               if (myTreeViewJumpsRj.EventSelectedID > 0) {
+                       //3.- display confirmwindow of deletion 
+                       if (preferences.askDeletion) {
+                               confirmWinJumpRun = ConfirmWindowJumpRun.Show( Catalog.GetString("Do you want 
to delete this jump?"), 
+                                                Catalog.GetString("Attention: Deleting a Reactive subjump 
will delete the whole jump"));
+                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_jump_rj_accepted);
+                       } else {
+                               on_delete_selected_jump_rj_accepted(o, args);
+                       }
+               }
+       }
+       
+       private void on_delete_selected_jump_accepted (object o, EventArgs args) {
+               LogB.Information("accept delete this jump");
+               int id = myTreeViewJumps.EventSelectedID;
+               
+               Sqlite.Delete(false, Constants.JumpTable, id);
+               
+               myTreeViewJumps.DelEvent(id);
+               showHideActionEventButtons(false, "Jump");
+               
+               if(createdStatsWin) {
+                       stats_win_fillTreeView_stats(false, false);
+               }
+               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.JUMP, id );
+               //we can be here being called from jump treeview (not from execute tab)
+               //then what we are deleting is selected jump, not last jump 
+               //only if selected is last, then
+               //change executing window: drawingarea, button_delete, "deleted test" message
+               try {
+                       if(currentJump.UniqueID == id)
+                               deleted_last_test_update_widgets();
+               } catch {
+                       //there's no currentJump (no one jumped), then it crashed,
+                       //but don't need to update widgets
+               }
+               
+               updateGraphJumpsSimple();
+
+               //if auto mode, show last person/test again
+               if(execute_auto_doing) {
+                       execute_auto_order_pos --;
+                       execute_auto_select();
+               }
+       }
+
+       private void on_delete_selected_jump_rj_accepted (object o, EventArgs args) {
+               LogB.Information("accept delete this jump");
+               int id = myTreeViewJumpsRj.EventSelectedID;
+               
+               Sqlite.Delete(false, Constants.JumpRjTable, id);
+               
+               myTreeViewJumpsRj.DelEvent(id);
+               showHideActionEventButtons(false, "JumpRj");
+
+               if(createdStatsWin) {
+                       stats_win_fillTreeView_stats(false, false);
+               }
+               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.JUMP_RJ, id );
+               try {
+                       if(currentJumpRj.UniqueID == id)
+                               deleted_last_test_update_widgets();
+               } catch {
+                       //there's no currentJumpRj (no one jumped), then it crashed,
+                       //but don't need to update widgets
+               }
+       }
+       
+       private void on_delete_selected_run_clicked (object o, EventArgs args) {
+               //notebooks_change(2); see "notebooks_change sqlite problem"
+               LogB.Information("delete this run (normal)");
+               
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person
+               if (myTreeViewRuns.EventSelectedID > 0) {
+                       //3.- display confirmwindow of deletion 
+                       if (preferences.askDeletion) {
+                               confirmWinJumpRun = ConfirmWindowJumpRun.Show(Catalog.GetString("Do you want 
to delete this run?"), "");
+                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_run_accepted);
+                       } else {
+                               on_delete_selected_run_accepted(o, args);
+                       }
+               }
+       }
+               
+       
+       private void on_delete_selected_run_interval_clicked (object o, EventArgs args) {
+               //notebooks_change(3); see "notebooks_change sqlite problem"
+               LogB.Information("delete this run interval");
+               //1.- check that there's a line selected
+               //2.- check that this line is a run and not a person (check also if it's a subrun, pass the 
parent run)
+               if (myTreeViewRunsInterval.EventSelectedID > 0) {
+                       //3.- display confirmwindow of deletion 
+                       if (preferences.askDeletion) {
+                               confirmWinJumpRun = ConfirmWindowJumpRun.Show( Catalog.GetString("Do you want 
to delete this run?"), 
+                                                Catalog.GetString("Attention: Deleting a Intervallic subrun 
will delete the whole run"));
+                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_run_interval_accepted);
+                       } else {
+                               on_delete_selected_run_interval_accepted(o, args);
+                       }
+               }
+       }
+
+       private void on_delete_selected_run_accepted (object o, EventArgs args) {
+               LogB.Information("accept delete this run");
+               int id = myTreeViewRuns.EventSelectedID;
+               
+               Sqlite.Delete(false, Constants.RunTable, id);
+               
+               myTreeViewRuns.DelEvent(id);
+               showHideActionEventButtons(false, "Run");
+               
+               if(createdStatsWin) {
+                       stats_win_fillTreeView_stats(false, false);
+               }
+               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.RUN, id );
+               try {
+                       if(currentRun.UniqueID == id)
+                               deleted_last_test_update_widgets();
+               } catch {
+                       //there's no currentRun (no one done it now), then it crashed,
+                       //but don't need to update widgets
+               }
+               
+               updateGraphRunsSimple();
+       }
+
+       private void on_delete_selected_run_interval_accepted (object o, EventArgs args) {
+               LogB.Information("accept delete this run");
+               int id = myTreeViewRunsInterval.EventSelectedID;
+               
+               Sqlite.Delete(false, Constants.RunIntervalTable, id);
+               
+               myTreeViewRunsInterval.DelEvent(id);
+               showHideActionEventButtons(false, "RunInterval");
+
+               if(createdStatsWin) {
+                       stats_win_fillTreeView_stats(false, false);
+               }
+               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.RUN_I, id );
+               try {
+                       if(currentRunInterval.UniqueID == id)
+                               deleted_last_test_update_widgets();
+               } catch {
+                       //there's no currentRunInterval (no one done it now), then it crashed,
+                       //but don't need to update widgets
+               }
+       }
+       
+       private void on_delete_selected_reaction_time_clicked (object o, EventArgs args) {
+               //notebooks_change(4); see "notebooks_change sqlite problem"
+               LogB.Information("delete this reaction time");
+               
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person
+               LogB.Information(myTreeViewReactionTimes.EventSelectedID.ToString());
+               if (myTreeViewReactionTimes.EventSelectedID > 0) {
+                       //3.- display confirmwindow of deletion 
+                       if (preferences.askDeletion) {
+                               confirmWinJumpRun = ConfirmWindowJumpRun.Show("Do you want to delete this 
test?", "");
+                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_reaction_time_accepted);
+                       } else {
+                               on_delete_selected_reaction_time_accepted(o, args);
+                       }
+               }
+       }
+               
+       private void on_delete_selected_reaction_time_accepted (object o, EventArgs args) {
+               LogB.Information("accept delete this reaction time");
+               int id = myTreeViewReactionTimes.EventSelectedID;
+               
+               Sqlite.Delete(false, Constants.ReactionTimeTable, id);
+               
+               myTreeViewReactionTimes.DelEvent(id);
+               showHideActionEventButtons(false, "ReactionTime");
+
+               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.RT, id );
+               try {
+                       if(currentReactionTime.UniqueID == id)
+                               deleted_last_test_update_widgets();
+               } catch {
+                       //there's no currentReactionTime (no one done it now), then it crashed,
+                       //but don't need to update widgets
+               }
+
+               updateGraphReactionTimes();
+       }
+
+       private void on_delete_selected_pulse_clicked (object o, EventArgs args) {
+               //notebooks_change(5); see "notebooks_change sqlite problem"
+               LogB.Information("delete this pulse");
+               
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person
+               LogB.Information(myTreeViewPulses.EventSelectedID.ToString());
+               if (myTreeViewPulses.EventSelectedID > 0) {
+                       //3.- display confirmwindow of deletion 
+                       if (preferences.askDeletion) {
+                               confirmWinJumpRun = ConfirmWindowJumpRun.Show("Do you want to delete this 
test?", "");
+                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_pulse_accepted);
+                       } else {
+                               on_delete_selected_pulse_accepted(o, args);
+                       }
+               }
+       }
+               
+       private void on_delete_selected_pulse_accepted (object o, EventArgs args) {
+               LogB.Information("accept delete this pulse");
+               int id = myTreeViewPulses.EventSelectedID;
+               
+               Sqlite.Delete(false, Constants.PulseTable, id);
+               
+               myTreeViewPulses.DelEvent(id);
+               showHideActionEventButtons(false, "Pulse");
+
+               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.PULSE, id );
+               try {
+                       if(currentPulse.UniqueID == id)
+                               deleted_last_test_update_widgets();
+               } catch {
+                       //there's no currentPulse (no one done it now), then it crashed,
+                       //but don't need to update widgets
+               }
+       }
+
+       private void on_delete_selected_multi_chronopic_clicked (object o, EventArgs args) {
+               //notebooks_change(6); see "notebooks_change sqlite problem"
+               LogB.Information("delete this multi chronopic");
+               //1.- check that there's a line selected
+               //2.- check that this line is a test and not a person (check also if it's not a individual 
mc, then pass the parent mc)
+               if (myTreeViewMultiChronopic.EventSelectedID > 0) {
+                       //3.- display confirmwindow of deletion 
+                       if (preferences.askDeletion) {
+                               confirmWinJumpRun = ConfirmWindowJumpRun.Show( Catalog.GetString("Do you want 
to delete this test?"), "");
+                               confirmWinJumpRun.Button_accept.Clicked += new 
EventHandler(on_delete_selected_multi_chronopic_accepted);
+                       } else {
+                               on_delete_selected_multi_chronopic_accepted(o, args);
+                       }
+               }
+       }
+       
+       private void on_delete_selected_multi_chronopic_accepted (object o, EventArgs args) {
+               LogB.Information("accept delete this multi chronopic");
+               int id = myTreeViewMultiChronopic.EventSelectedID;
+               
+               Sqlite.Delete(false, Constants.MultiChronopicTable, id);
+               
+               myTreeViewMultiChronopic.DelEvent(id);
+               showHideActionEventButtons(false, Constants.MultiChronopicName);
+               
+               Util.DeleteVideo(currentSession.UniqueID, Constants.TestTypes.MULTICHRONOPIC, id );
+               try {
+                       if(currentMultiChronopic.UniqueID == id)
+                               deleted_last_test_update_widgets();
+               } catch {
+                       //there's no currentMultiChronopic (no one done it now), then it crashed,
+                       //but don't need to update widgets
+               }
+       }
+       
+
+
+
+       /* ---------------------------------------------------------
+        * ----------------  EVENTS TYPE ADD -----------------------
+        *  --------------------------------------------------------
+        */
+
+       
+       private void on_jump_simple_type_add_clicked (object o, EventArgs args) {
+               LogB.Information("Add simple new jump type");
+                       
+               jumpTypeAddWin = JumpTypeAddWindow.Show(app1, true); //is simple
+               jumpTypeAddWin.FakeButtonAccept.Clicked += new EventHandler(on_jump_type_add_accepted);
+       }
+       
+       private void on_jump_reactive_type_add_clicked (object o, EventArgs args) {
+               LogB.Information("Add reactive new jump type");
+                       
+               jumpTypeAddWin = JumpTypeAddWindow.Show(app1, false); //is reactive
+               jumpTypeAddWin.FakeButtonAccept.Clicked += new EventHandler(on_jump_type_add_accepted);
+       }
+       
+       private void on_jump_type_add_accepted (object o, EventArgs args) {
+               LogB.Information("ACCEPTED Add new jump type");
+               if(jumpTypeAddWin.InsertedSimple) {
+                       createComboSelectJumps(false); //this will update also the selectJumpsString
+
+                       UtilGtk.ComboUpdate(combo_result_jumps, 
+                                       SqliteJumpType.SelectJumpTypes(false, Constants.AllJumpsName, "", 
true), ""); //without filter, only select name
+                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added simple 
jump."));
+               } else {
+                       createComboSelectJumpsRj(false); //this will update also the selectJumpsRjString
+                       
+                       UtilGtk.ComboUpdate(combo_result_jumps_rj, 
+                                       SqliteJumpType.SelectJumpRjTypes(Constants.AllJumpsName, true), ""); 
//without filter, only select name
+                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added reactive 
jump."));
+               }
+               updateComboStats();
+               combo_select_jumps.Active = 0;
+               combo_select_jumps_rj.Active = 0;
+               combo_result_jumps.Active = 0;
+               combo_result_jumps_rj.Active = 0;
+       }
+
+       private void on_run_simple_type_add_activate (object o, EventArgs args) {
+               LogB.Information("Add simple new run type");
+                       
+               runTypeAddWin = RunTypeAddWindow.Show(app1, true); //is simple
+               runTypeAddWin.FakeButtonAccept.Clicked += new EventHandler(on_run_type_add_accepted);
+       }
+       
+       private void on_run_intervallic_type_add_activate (object o, EventArgs args) {
+               LogB.Information("Add intervallic new run type");
+                       
+               runTypeAddWin = RunTypeAddWindow.Show(app1, false); //is intervallic
+               runTypeAddWin.FakeButtonAccept.Clicked += new EventHandler(on_run_type_add_accepted);
+       }
+       
+       private void on_run_type_add_accepted (object o, EventArgs args) {
+               LogB.Information("ACCEPTED Add new run type");
+               if(runTypeAddWin.InsertedSimple) {
+                       createComboSelectRuns(false); //this will update also the selectRunsString
+
+                       UtilGtk.ComboUpdate(combo_result_runs, 
+                                       SqliteRunType.SelectRunTypes(Constants.AllRunsName, true), ""); 
//without filter, only select name
+                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added simple 
run."));
+               } else {
+                       createComboSelectRunsInterval(false); //this will update also the 
selectRunsIntervalString
+                       
+                       UtilGtk.ComboUpdate(combo_result_runs_interval, 
+                                       SqliteRunIntervalType.SelectRunIntervalTypes(Constants.AllRunsName, 
true), ""); //without filter, only select name
+                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Added intervallic 
run."));
+               }
+               updateComboStats();
+               combo_select_runs.Active = 0;
+               combo_select_runs_interval.Active = 0;
+               combo_result_runs.Active = 0;
+               combo_result_runs_interval.Active = 0;
+       }
+
+       //reactiontime has no types
+
+       private void on_pulse_type_add_activate (object o, EventArgs args) {
+               LogB.Information("Add new pulse type");
+       }
+       
+       private void on_pulse_type_add_accepted (object o, EventArgs args) {
+               LogB.Information("ACCEPTED Add new pulse type");
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  EVENTS TYPE DELETE --------------------
+        *  --------------------------------------------------------
+        */
+
+       private void on_jump_type_delete_simple (object o, EventArgs args) {
+               jumpsMoreWin = JumpsMoreWindow.Show(app1, false); //delete jump type
+               jumpsMoreWin.Button_deleted_test.Clicked += new EventHandler(on_deleted_jump_type);
+       }
+       
+       private void on_jump_type_delete_reactive (object o, EventArgs args) {
+               jumpsRjMoreWin = JumpsRjMoreWindow.Show(app1, false); //delete jump type
+               jumpsRjMoreWin.Button_deleted_test.Clicked += new EventHandler(on_deleted_jump_rj_type);
+       }
+       
+       private void on_run_type_delete_simple (object o, EventArgs args) {
+               runsMoreWin = RunsMoreWindow.Show(app1, false); //delete run type
+               runsMoreWin.Button_deleted_test.Clicked += new EventHandler(on_deleted_run_type);
+       }
+       
+       private void on_run_type_delete_intervallic (object o, EventArgs args) {
+               runsIntervalMoreWin = RunsIntervalMoreWindow.Show(app1, false); //delete run type
+               runsIntervalMoreWin.Button_deleted_test.Clicked += new EventHandler(on_deleted_run_i_type);
+       }
+       
+       //----
+       
+       private void on_deleted_jump_type (object o, EventArgs args) {
+               //first delete if from combos
+               string translatedName = Util.FindOnArray(':', 2, 1, jumpsMoreWin.SelectedEventName, 
selectJumpsString);
+               UtilGtk.ComboDelThisValue(combo_select_jumps, translatedName);
+               UtilGtk.ComboDelThisValue(combo_result_jumps, translatedName);
+               
+               //2nd delete if from global string. -1 selects all row
+               string row = Util.FindOnArray(':',1, -1, jumpsMoreWin.SelectedEventName, selectJumpsString);
+               selectJumpsString = Util.DeleteString(selectJumpsString, row);
+
+               combo_select_jumps.Active = 0;
+               combo_result_jumps.Active = 0;
+
+               extra_window_jumps_initialize(new JumpType("Free"));
+       }
+
+       private void on_deleted_jump_rj_type (object o, EventArgs args) {
+               //first delete if from combos
+               string translatedName = Util.FindOnArray(':', 2, 1, jumpsRjMoreWin.SelectedEventName, 
selectJumpsRjString);
+               UtilGtk.ComboDelThisValue(combo_select_jumps_rj, translatedName);
+               UtilGtk.ComboDelThisValue(combo_result_jumps_rj, translatedName);
+               
+               //2nd delete if from global string. -1 selects all row
+               string row = Util.FindOnArray(':',1, -1, jumpsRjMoreWin.SelectedEventName, 
selectJumpsRjString);
+               selectJumpsRjString = Util.DeleteString(selectJumpsRjString, row);
+
+               combo_select_jumps_rj.Active = 0;
+               combo_result_jumps_rj.Active = 0;
+
+               extra_window_jumps_rj_initialize(new JumpType("RJ(j)"));
+       }
+
+       private void on_deleted_run_type (object o, EventArgs args) {
+               extra_window_runs_initialize(new RunType("Custom"));
+       }
+       private void on_deleted_run_i_type (object o, EventArgs args) {
+               extra_window_runs_interval_initialize(new RunType("byLaps"));
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  EVENTS REPAIR -------------------------
+        *  --------------------------------------------------------
+        */
+       
+       private void on_repair_selected_jump_rj_clicked (object o, EventArgs args) {
+               //notebooks_change(1); see "notebooks_change sqlite problem"
+               LogB.Information("Repair selected subjump");
+               //1.- check that there's a line selected
+               //2.- check that this line is a jump and not a person (check also if it's not a individual 
RJ, the pass the parent RJ)
+               if (myTreeViewJumpsRj.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected jump
+                       JumpRj myJump = SqliteJumpRj.SelectJumpData( "jumpRj", 
myTreeViewJumpsRj.EventSelectedID, false );
+               
+                       //4.- edit this jump
+                       repairJumpRjWin = RepairJumpRjWindow.Show(app1, myJump, preferences.digitsNumber);
+                       repairJumpRjWin.Button_accept.Clicked += new 
EventHandler(on_repair_selected_jump_rj_accepted);
+               }
+       }
+       
+       private void on_repair_selected_jump_rj_accepted (object o, EventArgs args) {
+               LogB.Information("Repair selected reactive jump accepted");
+               
+               treeview_jumps_rj_storeReset();
+               fillTreeView_jumps_rj(UtilGtk.ComboGetActive(combo_result_jumps_rj));
+               
+               if(createdStatsWin) {
+                       stats_win_fillTreeView_stats(false, false);
+               }
+       }
+       
+       private void on_repair_selected_run_interval_clicked (object o, EventArgs args) {
+               //notebooks_change(3); see "notebooks_change sqlite problem"
+               LogB.Information("Repair selected subrun");
+               //1.- check that there's a line selected
+               //2.- check that this line is a run and not a person 
+               //(check also if it's not a individual run interval, then pass the parent run interval)
+               if (myTreeViewRunsInterval.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected run
+                       RunInterval myRun = SqliteRunInterval.SelectRunData( Constants.RunIntervalTable, 
myTreeViewRunsInterval.EventSelectedID, false );
+               
+                       //4.- edit this run
+                       repairRunIntervalWin = RepairRunIntervalWindow.Show(app1, myRun, 
preferences.digitsNumber);
+                       repairRunIntervalWin.Button_accept.Clicked += new 
EventHandler(on_repair_selected_run_interval_accepted);
+               }
+       }
+       
+       private void on_repair_selected_run_interval_accepted (object o, EventArgs args) {
+               LogB.Information("repair selected run interval accepted");
+               
+               treeview_runs_interval_storeReset();
+               fillTreeView_runs_interval(UtilGtk.ComboGetActive(combo_result_runs_interval));
+               
+               if(createdStatsWin) {
+                       stats_win_fillTreeView_stats(false, false);
+               }
+       }
+
+       private void on_repair_selected_pulse_clicked (object o, EventArgs args) {
+               //notebooks_change(5); see "notebooks_change sqlite problem"
+               LogB.Information("Repair selected pulse");
+               //1.- check that there's a line selected
+               //2.- check that this line is a pulse and not a person 
+               //(check also if it's not a individual pulse, then pass the parent pulse)
+               if (myTreeViewPulses.EventSelectedID > 0) {
+                       //3.- obtain the data of the selected pulse
+                       Pulse myPulse = SqlitePulse.SelectPulseData( myTreeViewPulses.EventSelectedID, false 
);
+               
+                       //4.- edit this pulse
+                       repairPulseWin = RepairPulseWindow.Show(app1, myPulse, preferences.digitsNumber);
+                       repairPulseWin.Button_accept.Clicked += new 
EventHandler(on_repair_selected_pulse_accepted);
+               }
+       }
+       
+       private void on_repair_selected_pulse_accepted (object o, EventArgs args) {
+               LogB.Information("repair selected pulse accepted");
+               
+               treeview_pulses_storeReset();
+               fillTreeView_pulses(UtilGtk.ComboGetActive(combo_pulses));
+       }
+
+       private void on_repair_selected_multi_chronopic_clicked (object o, EventArgs args) {
+               //notebooks_change(6); see "notebooks_change sqlite problem"
+               LogB.Information("Repair selected multichronopic");
+       }
+
+       /* ---------------------------------------------------------
+        * ----------------  Info on power and stiffness -----------
+        *  --------------------------------------------------------
+        */
+
+
+       private void on_button_jumps_jumpsRj_result_help_power_clicked (object o, EventArgs args) {
+               new DialogMessage(Constants.MessageTypes.INFO, Constants.HelpPower);
+       }
+       private void on_button_jumps_jumpsRj_result_help_stiffness_clicked (object o, EventArgs args) {
+               new DialogMessage(Constants.MessageTypes.INFO, Constants.HelpStiffness, 
"hbox_stiffness_formula");
+       }
+
+       
+       /* ---------------------------------------------------------
+        * ----------------  AUTO MODE -----------------------------
+        *  --------------------------------------------------------
+        */
+
+       private void on_button_auto_start_clicked (object o, EventArgs args) {
+
+//TODO: put five buttons in a viewport than can be colorified
+
+               executeAutoWin = ExecuteAutoWindow.Show(app1, currentSession.UniqueID);
+               executeAutoWin.FakeButtonAccept.Clicked += new EventHandler(on_button_auto_start_accepted);
+       }
+
+       ArrayList execute_auto_order;
+       int execute_auto_order_pos;
+       bool execute_auto_doing = false;
+       private void on_button_auto_start_accepted (object o, EventArgs args) {
+               executeAutoWin.FakeButtonAccept.Clicked -= new EventHandler(on_button_auto_start_accepted);
+
+               sensitiveGuiAutoStartEnd (true);
+       
+               execute_auto_order = executeAutoWin.GetOrderedData();
+               execute_auto_order_pos = 0;
+               execute_auto_doing = true;
+
+               executeAutoWin.Close();
+
+               execute_auto_select();
+       }
+
+       private void execute_auto_select() 
+       {
+               if(execute_auto_order_pos >= execute_auto_order.Count) {
+                       on_button_auto_end_clicked (new object (), new EventArgs());
+                       return;
+               }
+
+               ExecuteAuto ea = (ExecuteAuto) execute_auto_order[execute_auto_order_pos];
+               int rowToSelect = myTreeViewPersons.FindRow(ea.personUniqueID);
+               if(rowToSelect != -1) {
+                       //this will update also currentPerson
+                       selectRowTreeView_persons(treeview_persons, treeview_persons_store, rowToSelect);
+                       label_jump_auto_current_person.Text = currentPerson.Name;
+
+                       //select the test
+                       int rowTest = Convert.ToInt32(Util.FindOnArray(':', 0, -2, 
ea.testUniqueID.ToString(), selectJumpsString));
+                       combo_select_jumps.Active = rowTest;
+                       label_jump_auto_current_test.Text = "(" + ea.testTrName + ")";
+                       
+                       //put GUI on auto_waiting
+                       sensitiveGuiAutoExecuteOrWait (false);
+               }
+       }
+
+       private void on_button_auto_end_clicked (object o, EventArgs args) 
+       {
+               sensitiveGuiAutoStartEnd (false);
+               execute_auto_doing = false;
+       }
+       
+       private void on_button_auto_order_clicked (object o, EventArgs args) {
+               executeAutoWin = ExecuteAutoWindow.ShowJustOrder(app1, execute_auto_order, 
execute_auto_order_pos);
+       }
+
+       private void on_button_auto_skip_person_clicked (object o, EventArgs args) {
+               execute_auto_order = ExecuteAuto.SkipPerson(execute_auto_order, execute_auto_order_pos, 
currentPerson);
+               
+               //update currentPerson and labels from current position
+               execute_auto_select();
+       }
+
+       private void on_button_auto_remove_person_clicked (object o, EventArgs args) {
+               execute_auto_order = ExecuteAuto.RemovePerson(execute_auto_order, execute_auto_order_pos, 
currentPerson);
+               
+               //update currentPerson and labels from current position
+               execute_auto_select();
+       }
+
+
+       /* ---------------------------------------------------------
+        * ----------------  SOME MORE CALLBACKS---------------------
+        *  --------------------------------------------------------
+        */
+
+       //changed by chronojump when it's needed
+       private void notebooks_change(int desiredPage) {
+               LogB.Information("notebooks_change");
+               //LogB.Debug(new StackFrame(1).GetMethod().Name);
+
+               //LogB.Information("currentPage" + notebook_execute.CurrentPage.ToString());
+               //LogB.Information("desiredPage" + desiredPage.ToString());
+
+               while(notebook_execute.CurrentPage < desiredPage) 
+                       notebook_execute.NextPage();
+               while(notebook_execute.CurrentPage > desiredPage) 
+                       notebook_execute.PrevPage();
+               
+               //delete capture graph 
+               UtilGtk.ClearDrawingArea(event_execute_drawingarea, event_execute_pixmap);
+               //change table under graph
+               change_notebook_results_data();
+
+               while(notebook_results.CurrentPage < desiredPage) 
+                       notebook_results.NextPage();
+               while(notebook_results.CurrentPage > desiredPage) 
+                       notebook_results.PrevPage();
+
+               while(notebook_options_top.CurrentPage < desiredPage) 
+                       notebook_options_top.NextPage();
+               while(notebook_options_top.CurrentPage > desiredPage) 
+                       notebook_options_top.PrevPage();
+               
+       
+               //change test image according to notebook_execute       
+               if(notebook_execute.CurrentPage == 0)
+                       changeTestImage(EventType.Types.JUMP.ToString(), 
+                                       currentJumpType.Name, currentJumpType.ImageFileName);
+               else if(notebook_execute.CurrentPage == 1)
+                       changeTestImage(EventType.Types.JUMP.ToString(), 
+                                       currentJumpRjType.Name, currentJumpRjType.ImageFileName);
+               else if(notebook_execute.CurrentPage == 2)
+                       changeTestImage(EventType.Types.RUN.ToString(), 
+                                       currentRunType.Name, currentRunType.ImageFileName);
+               else if(notebook_execute.CurrentPage == 3)
+                       changeTestImage(EventType.Types.RUN.ToString(), 
+                                       currentRunIntervalType.Name, currentRunIntervalType.ImageFileName);
+               else if(notebook_execute.CurrentPage == 4)
+                       changeTestImage(EventType.Types.REACTIONTIME.ToString(), 
+                                       currentReactionTimeType.Name, currentReactionTimeType.ImageFileName);
+               else if(notebook_execute.CurrentPage == 5)
+                       changeTestImage(EventType.Types.PULSE.ToString(), 
+                                       currentPulseType.Name, currentPulseType.ImageFileName);
+               else if(notebook_execute.CurrentPage == 6) {
+                       changeTestImage(EventType.Types.MULTICHRONOPIC.ToString(), 
+                                       currentMultiChronopicType.Name, 
currentMultiChronopicType.ImageFileName);
+               }
+       
+               //button_execute_test have to be non sensitive in multichronopic without two cps
+               //else has to be sensitive
+
+               //if there are persons
+               if (notebook_execute.CurrentPage == 6) {
+                       if (chronopicWin.NumConnected() >= 2)
+                               extra_window_multichronopic_can_do(true);
+                       else 
+                               extra_window_multichronopic_can_do(false);
+               } else {
+                       button_execute_test.Sensitive = myTreeViewPersons.IsThereAnyRecord();
+               }
+
+               //Attention: "notebooks_change sqlite problem"
+               //This will call stats_win_change_test_type
+               //that will call on_combo_stats_type_changed
+               //that will call updateComboStats
+               //and that will call Sqlite.
+               //This is dangerous because it can crash when notebooks_change is called after deleting a test
+               //just disable notebooks change in that situation
+               stats_win_change_test_type(notebook_execute.CurrentPage);
+       }
+       
+       //changed by user clicking on notebook tabs
+       private void on_notebook_change_by_user (object o, SwitchPageArgs args) {
+               //show chronojump logo on down-left area
+               //changeTestImage("", "", "LOGO");
+       }
+
+       //help
+       private void on_menuitem_manual_activate (object o, EventArgs args) {
+               /*
+               new DialogMessage(Constants.MessageTypes.HELP, 
+                               Catalog.GetString("There's a copy of Chronojump Manual at:") + "\n" + 
+                               "<i>" + Path.GetFullPath(Util.GetManualDir()) + "</i>\n\n" + 
+                               Catalog.GetString("Newer versions will be on this site:") +"\n" + 
+                               "<i>http://www.chronojump.org/multimedia.html</i>");
+                               */
+               LogB.Information("Opening manual at: " + System.IO.Path.GetFullPath(Util.GetManualDir())); 
+               try {
+                       System.Diagnostics.Process.Start(System.IO.Path.GetFullPath(Util.GetManualDir())); 
+               } catch {
+                       new DialogMessage(Constants.MessageTypes.WARNING, "Sorry, manual folder does not 
exist.");
+               }
+       }
+
+       private void on_menuitem_formulas_activate (object o, EventArgs args) {
+               new DialogMessage(Constants.MessageTypes.INFO, "Here there will be bibliographic information 
about formulas and some notes.\n\nProbably this will be a window and not a dialog\n\nNote text is 
selectable");
+       }
+
+       private void on_menuitem_accelerators_activate (object o, EventArgs args) {
+               new DialogMessage(
+                               Catalog.GetString("Accelerators help"),
+                               Constants.MessageTypes.INFO, 
+                               Catalog.GetString("Use these keys in order to work faster.") + "\n\n" +
+                               "- " + Catalog.GetString("On execute test tab:") + "\n\n" +
+                               "<tt><b>CTRL+p</b></tt> " + Catalog.GetString("Edit selected person") + "\n" +
+                               "<tt><b>CTRL+" + Catalog.GetString("CURSOR_UP") + "</b></tt> " + 
Catalog.GetString("Select previous person") + "\n" +
+                               "<tt><b>CTRL+" + Catalog.GetString("CURSOR_DOWN") + "</b></tt> " + 
Catalog.GetString("Select next person") + "\n" +
+                               "<tt><b>(space)</b></tt> " + Catalog.GetString("Execute test") + "\n" +
+                               "<tt><b>v</b></tt> " + Catalog.GetString("Play video of this test") + " " + 
Catalog.GetString("(if available)")+ "\n" +
+                               "<tt><b>d</b></tt> " + Catalog.GetString("Delete this test") + "\n" +
+                               "\n" + "- " + Catalog.GetString("On results tab:") + "\n\n" +
+                               "<tt><b>z</b></tt> " + Catalog.GetString("Zoom change") + "\n" +
+                               "<tt><b>v</b></tt> " + Catalog.GetString("Play video of selected test") + " " 
+ Catalog.GetString("(if available)")+ "\n" +
+                               "<tt><b>e</b></tt> " + Catalog.GetString("Edit selected test") + "\n" +
+                               "<tt><b>d</b></tt> " + Catalog.GetString("Delete selected test") + "\n" +
+                               "<tt><b>r</b></tt> " + Catalog.GetString("Repair selected test") + " " + 
Catalog.GetString("(if available)")
+                               );
+       }
+       
+       private void on_menuitem_check_last_version_activate (object o, EventArgs args) 
+       {
+               Json js = new Json();
+               bool success = js.GetLastVersion(progVersion);
+
+               if(success) {
+                       LogB.Information(js.ResultMessage);
+                       new DialogMessage(
+                                       "Chronojump",
+                                       Constants.MessageTypes.INFO, 
+                                       js.ResultMessage
+                                       );
+               }
+               else {
+                       LogB.Error(js.ResultMessage);
+                       new DialogMessage(
+                                       "Chronojump",
+                                       Constants.MessageTypes.WARNING, 
+                                       js.ResultMessage);
+               }
+       }
+
+       private void on_menuitem_ping_activate (object o, EventArgs args) 
+       {
+               pingDo(true);
+       }
+       private void pingAtStart()
+       {
+               pingDo(false);
+       }
+       private void pingDo(bool showInWindow)
+       {
+               Json js = new Json();
+               bool success = js.Ping(UtilAll.GetOS(), UtilAll.ReadVersion(), preferences.machineID);
+
+               if(success) {
+                       LogB.Information(js.ResultMessage);
+                       if(showInWindow)
+                               new DialogMessage(
+                                               "Chronojump",
+                                               Constants.MessageTypes.INFO, 
+                                               js.ResultMessage);
+               }
+               else {
+                       LogB.Error(js.ResultMessage);
+                       if(showInWindow)
+                               new DialogMessage(
+                                               "Chronojump",
+                                               Constants.MessageTypes.WARNING, 
+                                               js.ResultMessage);
+               }
+
+               /*
+               new DialogMessage(
+                               "Chronojump",
+                               Constants.MessageTypes.INFO, 
+                               "Temporarily Disabled");
+               */
+       }
+       
+       
+       private void on_preferences_debug_mode_start (object o, EventArgs args) {
+               //first delete debug file
+               Util.FileDelete(System.IO.Path.GetTempPath() + "chronojump-debug.txt");
+
+               encoderRProcCapture.Debug = true;
+               encoderRProcAnalyze.Debug = true;
+       
+               hbox_gui_tests.Visible = true;
+               button_carles.Visible = true;
+
+               preferencesWin.DebugActivated();
+       }
+
+       private void on_button_gui_tests_clicked (object o, EventArgs args) {
+               chronojumpWindowTestsStart(Convert.ToInt32(spin_gui_tests.Value -1));
+       }
+       
+       private void on_button_carles_clicked (object o, EventArgs args) {
+               //carles stuff
+       }
+
+
+       private void on_about1_activate (object o, EventArgs args) {
+               string translator_credits = Catalog.GetString ("translator-credits");
+               //only print if exist (don't print 'translator-credits' word
+               if(translator_credits == "translator-credits") 
+                       translator_credits = "";
+
+               new About(progVersion, translator_credits);
+       }
+               
+       private void on_button_rj_bells_clicked(object o, EventArgs args) {
+               repetitiveConditionsWin.View(Constants.BellModes.JUMPS, preferences.volumeOn);
+       }
+
+       private void on_button_time_bells_clicked(object o, EventArgs args) {
+               repetitiveConditionsWin.View(Constants.BellModes.RUNS, preferences.volumeOn);
+       }
+       
+       private void on_repetitive_conditions_closed(object o, EventArgs args) {
+               //treeview_encoder should be updated (to colorize some cells)
+               //only if there was data
+               //this avoids misbehaviour when bell is pressed and there's no data in treeview
+               EncoderCurve curve = treeviewEncoderCaptureCurvesGetCurve(1, false);
+               if(curve.N != null) {
+                       List<string> contents = 
Util.ReadFileAsStringList(UtilEncoder.GetEncoderCurvesTempFileName());
+                       encoderUpdateTreeViewCapture(contents); //this updates encoderCaptureCurves
+                       
+                       findAndMarkSavedCurves(false, false); //SQL closed; don't update curve SQL records 
(like future1: meanPower)
+                       
+                       //also update the bars plot (to show colors depending on bells changes)
+                       if(captureCurvesBarsData.Count > 0) {
+                               string mainVariable = 
Constants.GetEncoderVariablesCapture(preferences.encoderCaptureMainVariable);
+                               double mainVariableHigher = 
repetitiveConditionsWin.GetMainVariableHigher(mainVariable);
+                               double mainVariableLower = 
repetitiveConditionsWin.GetMainVariableLower(mainVariable);
+                               plotCurvesGraphDoPlot(mainVariable, mainVariableHigher, mainVariableLower, 
captureCurvesBarsData,
+                                               repetitiveConditionsWin.EncoderInertialDiscardFirstThree,
+                                               false); //not capturing
+                       } else
+                               UtilGtk.ErasePaint(encoder_capture_curves_bars_drawingarea, 
encoder_capture_curves_bars_pixmap);
+               }
+       }
+       
+
+       JumpsProfile jumpsProfile;
+
+       private void jumpsProfileDo (bool calculateData)
+       {
+               if(currentPerson == null || currentSession == null)
+                       return;
+               
+               if(jumpsProfile == null) {
+                       jumpsProfile = new JumpsProfile();
+                       calculateData = true;
+               }
+
+               if(calculateData)
+                       jumpsProfile.Calculate(currentPerson.UniqueID, currentSession.UniqueID);
+
+               JumpsProfileGraph.Do(jumpsProfile.GetIndexes(), drawingarea_jumps_profile);
+       }
+       private void on_drawingarea_jumps_profile_expose_event (object o, ExposeEventArgs args) 
+       {
+               jumpsProfileDo(false); //do not calculate data
+               //data is calculated on switch page (at notebook_capture_analyze) or on change person
+       }
+       
+       private void on_notebook_capture_analyze_switch_page (object o, SwitchPageArgs args) {
+               if(notebook_capture_analyze.CurrentPage == 2)
+                       jumpsProfileDo(true);
+       }
+
+       private void on_button_jumps_profile_help_clicked (object o, EventArgs args) {
+               scrolledwindow_jumps_profile_training.Visible = false;
+               scrolledwindow_jumps_profile_help.Visible = ! scrolledwindow_jumps_profile_help.Visible;
+       }
+
+       private void on_button_jumps_profile_training_clicked (object o, EventArgs args) {
+               scrolledwindow_jumps_profile_help.Visible = false;
+               scrolledwindow_jumps_profile_training.Visible = ! 
scrolledwindow_jumps_profile_training.Visible;
+       }
+
+
+       /* ---------------------------------------------------------
+        * ----------------  SENSITIVE GUI METHODS-------------------
+        *  --------------------------------------------------------
+        */
+
+       private void menuSessionSensitive(bool option)
+       {
+               menuitem_edit_session.Sensitive = option;
+               menuitem_delete_session.Sensitive = option;
+               menuitem_export_csv.Sensitive = option;
+               //menuitem_export_xml.Sensitive = option; not implemented yet
+               menuitem_encoder_session_overview.Sensitive = option;
+
+       }
+       
+       private void menuPersonSelectedSensitive(bool option)
+       {
+               button_persons_up.Sensitive = option;
+               button_persons_down.Sensitive = option;
+               button_edit_current_person.Sensitive = option;
+               button_show_all_person_events.Sensitive = option;
+               button_delete_current_person.Sensitive = option;
+       }
+
+       private void sensitiveGuiNoSession () 
+       {
+               notebook_session_person.CurrentPage = 0;
+
+               treeview_persons.Sensitive = false;
+               
+               //menuitems
+               menuSessionSensitive(false);
+               menuPersonSelectedSensitive(false);
+               
+               button_image_test_zoom.Sensitive = false;
+               frame_persons.Sensitive = false;
+               button_recuperate_person.Sensitive = false;
+               button_recuperate_persons_from_session.Sensitive = false;
+               button_person_add_single.Sensitive = false;
+               button_person_add_multiple.Sensitive = false;
+               button_edit_current_person.Sensitive = false;
+               button_delete_current_person.Sensitive = false;
+       
+               button_encoder_person_change.Sensitive = false;
+               
+               //notebooks
+               notebook_execute.Sensitive = false;
+               //hbox_chronopics.Sensitive = false;
+               notebook_results.Sensitive = false;
+               notebook_options_top.Sensitive = false;
+               notebook_encoder_sup.Sensitive = false;
+               vbox_stats.Sensitive = false;
+               frame_share_data.Sensitive = false;
+               
+               vbox_this_test_buttons.Sensitive = false;
+               vbox_execute_test.Sensitive = false;
+               button_execute_test.Sensitive = false;
+
+               encoderButtonsSensitive(encoderSensEnum.NOSESSION);
+               
+               eventExecuteHideAllTables();
+       }
+       
+       private void sensitiveGuiYesSession () 
+       {
+               notebook_session_person.CurrentPage = 1;
+
+               button_image_test_zoom.Sensitive = true;
+               frame_persons.Sensitive = true;
+               button_recuperate_person.Sensitive = true;
+               button_recuperate_persons_from_session.Sensitive = true;
+               button_person_add_single.Sensitive = true;
+               button_person_add_multiple.Sensitive = true;
+               
+               button_encoder_person_change.Sensitive = true;
+               
+               menuSessionSensitive(true);
+               vbox_stats.Sensitive = true;
+               frame_share_data.Sensitive = true;
+               
+               //changeTestImage("", "", "LOGO");
+       }
+
+       //only called by delete person functions (if we run out of persons)
+       private void sensitiveGuiNoPerson () {
+               hbox_jumps.Sensitive = false;
+               hbox_jumps_rj.Sensitive = false;
+               button_execute_test.Sensitive = false;
+               
+               encoderButtonsSensitive(encoderSensEnum.NOPERSON);
+               personChanged();
+               
+               notebook_execute.Sensitive = false;
+               //hbox_chronopics.Sensitive = false;
+               notebook_results.Sensitive = false;
+               notebook_options_top.Sensitive = false;
+               notebook_encoder_sup.Sensitive = false;
+               treeview_persons.Sensitive = false;
+               
+               menuPersonSelectedSensitive(false);
+               vbox_execute_test.Sensitive = false;
+
+               label_encoder_person_name.Text = "";
+       }
+       
+       private void sensitiveGuiYesPerson () {
+               hbox_jumps.Sensitive = true;
+               hbox_jumps_rj.Sensitive = true;
+               button_execute_test.Sensitive = true;
+
+               encoderButtonsSensitive(encoderSensEnum.YESPERSON);
+               personChanged();
+               
+               notebook_execute.Sensitive = true;
+               //hbox_chronopics.Sensitive = true;
+               notebook_results.Sensitive = true;
+               notebook_options_top.Sensitive = true;
+               notebook_encoder_sup.Sensitive = true;
+               treeview_persons.Sensitive = true;
+               
+               menuPersonSelectedSensitive(true);
+       
+               //unsensitive edit, delete, repair events because no event is initially selected
+               showHideActionEventButtons(false, "ALL");
+
+               combo_select_jumps.Sensitive = true;
+               combo_result_jumps.Sensitive = true;
+               combo_select_jumps_rj.Sensitive = true;
+               combo_result_jumps_rj.Sensitive = true;
+               combo_select_runs.Sensitive = true;
+               combo_result_runs.Sensitive = true;
+               combo_select_runs_interval.Sensitive = true;
+               combo_result_runs_interval.Sensitive = true;
+               combo_pulses.Sensitive = true;
+               
+               vbox_execute_test.Sensitive = true;
+       }
+       
+       private void sensitiveGuiYesEvent () {
+       }
+       
+       private void sensitiveGuiEventDoing () {
+               session_menuitem.Sensitive = false;
+               menuitem_mode.Sensitive = false;
+               
+               //jumpsProfile has Sqlite calls. Don't do them while jumping
+               //but don't unsensitive the notebook because user need to "finish" or cancel"
+               //notebook_capture_analyze.Sensitive = true; 
+               notebook_capture_analyze.GetNthPage(1).Hide();
+               if(radio_menuitem_mode_jumps_simple.Active)
+                       notebook_capture_analyze.GetNthPage(2).Hide();
+               
+               
+               help_menuitem.Sensitive = false;
+               frame_persons.Sensitive = false;
+               
+               button_execute_test.Sensitive = false;
+               
+               button_encoder_person_change.Sensitive = false;
+
+               encoderButtonsSensitive(encoderSensEnum.PROCESSINGR);
+               
+               //hbox
+               hbox_jumps_test.Sensitive = false;
+               hbox_jump_types_options.Sensitive = false;
+               
+               hbox_jumps_rj.Sensitive = false;
+               hbox_runs.Sensitive = false;
+               hbox_runs_interval.Sensitive = false;
+               hbox_pulses.Sensitive = false;
+               vbox_this_test_buttons.Sensitive = false;
+               
+               button_upload_session.Sensitive = false;
+               button_activate_chronopics.Sensitive = false;
+               notebook_options_top.Sensitive = false;
+               event_execute_button_update.Sensitive = false;
+               
+               //hbox_multi_chronopic_buttons.Sensitive = false;
+       }
+   
+       private void sensitiveGuiEventDone () {
+               LogB.Information(" sensitiveGuiEventDone start ");
+
+               session_menuitem.Sensitive = true;
+               menuitem_mode.Sensitive = true;
+
+               //jumpsProfile has Sqlite calls. Don't do them while jumping
+               //but don't unsensitive the notebook because user need to "finish" or cancel"
+               //notebook_capture_analyze.Sensitive = true; 
+               notebook_capture_analyze.GetNthPage(1).Show();
+               if(radio_menuitem_mode_jumps_simple.Active)
+                       notebook_capture_analyze.GetNthPage(2).Show();
+               
+               help_menuitem.Sensitive = true;
+               frame_persons.Sensitive = true;
+
+               button_execute_test.Sensitive = true;
+               
+               button_encoder_person_change.Sensitive = true;
+       
+               if(encoderCaptureCurves != null && encoderCaptureCurves.Count > 0)
+                       encoderButtonsSensitive(encoderSensEnum.DONEYESSIGNAL);
+               else
+                       encoderButtonsSensitive(encoderSensEnum.DONENOSIGNAL);
+
+               //hbox
+               hbox_jumps_test.Sensitive = true;
+               hbox_jump_types_options.Sensitive = true;
+               
+               hbox_jumps_rj.Sensitive = true;
+               hbox_runs.Sensitive = true;
+               hbox_runs_interval.Sensitive = true;
+               hbox_pulses.Sensitive = true;
+               //hbox_multi_chronopic_buttons.Sensitive = true;
+               vbox_this_test_buttons.Sensitive = true;
+               
+               button_upload_session.Sensitive = true;
+               button_activate_chronopics.Sensitive = true;
+               notebook_options_top.Sensitive = true;
+               event_execute_button_update.Sensitive = true;
+
+               //allow repeat last jump or run (check also if it wasn't cancelled)
+               if(currentEventExecute != null && ! currentEventExecute.Cancel) {
+                       switch (currentEventType.Type) {
+                               case EventType.Types.REACTIONTIME:
+                                       LogB.Information("sensitiveGuiEventDone reaction time");
+                                       break;
+                               case EventType.Types.PULSE:
+                                       LogB.Information("sensitiveGuiEventDone pulse");
+                                       break;
+                               case EventType.Types.MULTICHRONOPIC:
+                                       LogB.Information("sensitiveGuiEventDone multichronopic");
+                                       break;
+                               default:
+                                       LogB.Information("sensitiveGuiEventDone default");
+                                       break;
+                       }
+               }
+               LogB.Information(" sensitiveGuiEventDone end ");
+       }
+       
+       /*
+        * sensitive GUI on executeAuto methods 
+        */
+
+       private void on_autodetect_help_clicked (object o, EventArgs args) {
+               new DialogMessage(
+                               Catalog.GetString("Help on auto-detect"),
+                               Constants.MessageTypes.INFO, 
+                               Catalog.GetString("Modes:") + "\n\n" +
+                               "- <b>" + Catalog.GetString("Active") + "</b>:  " +
+                                       Catalog.GetString("Auto-detection on hardware is active.") + " " + 
Catalog.GetString("Default mode") + ".\n\n" +
+                               "- <b>" + Catalog.GetString("Active, discarding first port") + "</b>:  " + 
+                                       Catalog.GetString("Use this option on computers where first port 
fails.") + "\n\n" +
+                               "- <b>" + Catalog.GetString("Inactive") + "</b>:  " + 
+                                       Catalog.GetString("Auto-detection on hardware is inactive.") + " " + 
Catalog.GetString("Use it if you have problems at start or at capture.")
+                               );
+       }
+       
+       private void on_button_chronopic_wizard_clicked (object o, EventArgs args) 
+       {
+               chronopicWizardWin = ChronopicWizardWindow.Show();
+       
+               chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked -= 
+                       new EventHandler(chronopic_wizard_finished);
+               chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked += new 
+                       EventHandler(chronopic_wizard_finished);
+       }
+       private void chronopic_wizard_finished (object o, EventArgs args) 
+       {
+               chronopicWizardWin.FakeButtonChronopicWizardFinished.Clicked -= 
+                       new EventHandler(chronopic_wizard_finished);
+               
+               wizardPortContacts = chronopicWizardWin.PortContacts;
+               wizardPortEncoder = chronopicWizardWin.PortEncoder;
+               
+               LogB.Information("wizardPortContacts: " + wizardPortContacts);
+               LogB.Information("wizardPortEncoder: " + wizardPortEncoder);
+       
+               /*
+                * createChronopicWindow (pass cp,...)
+                * recreate is true because it has been created on first ChronojumpWindow call
+                */
+               //contacts and encoder
+               if(wizardPortContacts != "")
+               {
+                       Chronopic cpW; //cp Wizard
+                       chronopicWin.CreateSPifNeeded(wizardPortContacts);
+                       cpW = new Chronopic(chronopicWin.SP);
+                       ChronopicPortData cpdata = new ChronopicPortData(1, wizardPortContacts, true);
+                       ArrayList cpd = new ArrayList();
+                       cpd.Add(cpdata);
+
+                       if(wizardPortEncoder == "") //no encoder
+                               createChronopicWindow(cpW, cpd, true, "");
+                       else
+                               createChronopicWindow(cpW, cpd, true, wizardPortEncoder);
+               }
+               else { //only encoder
+                       createChronopicWindow(true, wizardPortEncoder);
+               }
+               
+               //need to do this because createChronopicWindow does it but relying on menuitem_mode, and now 
we are on start page      
+               if(wizardPortEncoder != "")
+                       chronopicEncoderLabels(true);
+
+               //all the needed info is take. Can destroy wizard window 
+               chronopicWizardWin.HideAndNull();
+       }
+
+       //start/end auto mode
+       private void sensitiveGuiAutoStartEnd (bool start) {
+               //if automode, sensitiveGuiEventDoing, sensitiveGuiEventDone don't work
+               session_menuitem.Sensitive      = ! start;
+               menuitem_mode.Sensitive         = ! start;
+               help_menuitem.Sensitive         = ! start;
+               frame_persons.Sensitive         = ! start;
+
+               hbox_jumps_test.Visible         = ! start;
+               button_auto_start.Visible       = ! start;      
+               hbox_jump_types_options.Visible = ! start;
+               hbox_jump_auto_controls.Visible  = start;
+               
+               notebook_capture_analyze.GetNthPage(1).Visible = ! start;
+               if(radio_menuitem_mode_jumps_simple.Active)
+                       notebook_capture_analyze.GetNthPage(2).Visible = ! start;
+
+               //when start, put button delete_this_test as not sensitive
+               //(just for the test previous to the auto process)
+               if(start)
+                       button_delete_this_test.Sensitive = false;
+       }
+       
+       //true: executing a test; false: waiting a test to be executed
+       private void sensitiveGuiAutoExecuteOrWait (bool execute) {
+               //if automode, sensitiveGuiEventDoing, sensitiveGuiEventDone don't work
+               button_activate_chronopics.Sensitive    = ! execute;
+               button_execute_test.Sensitive           = ! execute;
+               notebook_options_top.Sensitive          = ! execute;
+               vbox_this_test_buttons.Sensitive        = ! execute;
+       }
+
+
+       private void showHideActionEventButtons(bool show, string type) {
+               bool success = false;
+               bool recordedVideo = false;
+               if(type == "ALL" || type == "Jump") {
+                       button_edit_selected_jump.Sensitive = show;
+                       button_delete_selected_jump.Sensitive = show;
+
+                       button_video_play_selected_jump.Sensitive = false;
+                       if (myTreeViewJumps.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
+                                                       currentSession.UniqueID, 
+                                                       Constants.TestTypes.JUMP,
+                                                       myTreeViewJumps.EventSelectedID))) {
+                               button_video_play_selected_jump.Sensitive = true;
+                               recordedVideo = true;
+                       }
+
+
+                       success = true;
+               } 
+               if (type == "ALL" || type == "JumpRj") {
+                       button_edit_selected_jump_rj.Sensitive = show;
+                       button_delete_selected_jump_rj.Sensitive = show;
+                       button_repair_selected_jump_rj.Sensitive = show;
+
+                       button_video_play_selected_jump_rj.Sensitive = false;
+                       if (myTreeViewJumpsRj.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
+                                                       currentSession.UniqueID, 
+                                                       Constants.TestTypes.JUMP_RJ,
+                                                       myTreeViewJumpsRj.EventSelectedID))) {
+                               button_video_play_selected_jump_rj.Sensitive = true;
+                               recordedVideo = true;
+                       }
+
+                       success = true;
+               } 
+               if (type == "ALL" || type == "Run") {
+                       button_edit_selected_run.Sensitive = show;
+                       button_delete_selected_run.Sensitive = show;
+
+                       button_video_play_selected_run.Sensitive = false;
+                       if (myTreeViewRuns.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
+                                                       currentSession.UniqueID, 
+                                                       Constants.TestTypes.RUN,
+                                                       myTreeViewRuns.EventSelectedID))) {
+                               button_video_play_selected_run.Sensitive = true;
+                               recordedVideo = true;
+                       }
+
+                       success = true;
+               } 
+               if (type == "ALL" || type == "RunInterval") {
+                       button_edit_selected_run_interval.Sensitive = show;
+                       button_delete_selected_run_interval.Sensitive = show;
+                       button_repair_selected_run_interval.Sensitive = show;
+                       
+                       button_video_play_selected_run_interval.Sensitive = false;
+                       if (myTreeViewRunsInterval.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
+                                                       currentSession.UniqueID, 
+                                                       Constants.TestTypes.RUN_I,
+                                                       myTreeViewRunsInterval.EventSelectedID))) {
+                               button_video_play_selected_run_interval.Sensitive = true;
+                               recordedVideo = true;
+                       }
+
+                       success = true;
+               } 
+               if (type == "ALL" || type == "ReactionTime") {
+                       button_edit_selected_reaction_time.Sensitive = show;
+                       button_delete_selected_reaction_time.Sensitive = show;
+                       
+                       button_video_play_selected_reaction_time.Sensitive = false;
+                       if (myTreeViewReactionTimes.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
+                                                       currentSession.UniqueID, 
+                                                       Constants.TestTypes.RT,
+                                                       myTreeViewReactionTimes.EventSelectedID))) {
+                               button_video_play_selected_reaction_time.Sensitive = true;
+                               recordedVideo = true;
+                       }
+
+                       success = true;
+               } 
+               if (type == "ALL" || type == "Pulse") {
+                       // menuitem_edit_selected_pulse.Sensitive = show;
+                       // menuitem_delete_selected_pulse.Sensitive = show;
+                       button_edit_selected_pulse.Sensitive = show;
+                       button_delete_selected_pulse.Sensitive = show;
+                       button_repair_selected_pulse.Sensitive = show;
+                       
+                       button_video_play_selected_pulse.Sensitive = false;
+                       if (myTreeViewPulses.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
+                                                       currentSession.UniqueID, 
+                                                       Constants.TestTypes.PULSE,
+                                                       myTreeViewPulses.EventSelectedID))) {
+                               button_video_play_selected_pulse.Sensitive = true;
+                               recordedVideo = true;
+                       }
+
+                       success = true;
+               } 
+               if (type == "ALL" || type == Constants.MultiChronopicName) {
+                       button_edit_selected_multi_chronopic.Sensitive = show;
+                       button_delete_selected_multi_chronopic.Sensitive = show;
+                       
+                       button_video_play_selected_multi_chronopic.Sensitive = false;
+                       if (myTreeViewMultiChronopic.EventSelectedID > 0 && File.Exists(Util.GetVideoFileName(
+                                                       currentSession.UniqueID, 
+                                                       Constants.TestTypes.MULTICHRONOPIC,
+                                                       myTreeViewMultiChronopic.EventSelectedID))) {
+                               button_video_play_selected_multi_chronopic.Sensitive = true;
+                               recordedVideo = true;
+                       }
+
+                       success = true;
+               } 
+               if (!success)
+                       LogB.Error(string.Format("Error in showHideActionEventButtons, type: {0}", type));
+
+               button_video_play_this_test.Sensitive = recordedVideo;
+       }
+       
+       
+       /*
+        * voluntary crash for testing purposes 
+        */
+
+       private void on_debug_crash_activate (object o, EventArgs args) {
+               bool voluntaryCrashAllowed = true;
+               if(voluntaryCrashAllowed) {
+                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Done for testing 
purposes. Chronojump will exit badly"), "", "Are you sure you want to crash application?");
+                       confirmWin.Button_accept.Clicked += new EventHandler(crashing);
+               } else {
+                       new DialogMessage(Constants.MessageTypes.INFO, "Currently disabled.");
+               }
+       }
+
+       private void crashing (object o, EventArgs args) {
+               string [] myString = new String [3];
+               LogB.Error(myString[5]);
+       }
+
+       private void on_menuitem_server_activate (object o, EventArgs args) {
+               LogB.Information("SERVER");
+       }
+
+
+}
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index 71f2203..ee425a2 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -1,1110 +1,1110 @@
-/*
- * This file is part of ChronoJump
- *
- * Chronojump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * Chronojump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
- */
-
-
-using System;
-using Gtk;
-using Gdk;
-using Glade;
-using System.IO.Ports;
-using Mono.Unix;
-using System.Threading;
-using System.IO; //"File" things
-using System.Collections; //ArrayList
-
-public class ChronopicPortData
-{
-       public int Num;
-       public string Port; //port filename
-       public bool Connected;
-       
-       public ChronopicPortData(int num, string port, bool connected) {
-               this.Num = num;
-               this.Port = port;
-               this.Connected = connected;
-       }
-}
-
-public class ChronopicWindow 
-{
-       [Widget] Gtk.Window chronopic_window;
-       static ChronopicWindow ChronopicWindowBox;
-       //ChronopicConnection chronopicConnectionWin;
-
-       [Widget] Gtk.Notebook notebook_main;
-       //[Widget] Gtk.Image image_contact_modular;
-       //[Widget] Gtk.Image image_infrared;
-       
-       [Widget] Gtk.Label label_connect_contacts;
-       [Widget] Gtk.Label label_connect_encoder;
-
-       [Widget] Gtk.Frame frame_supplementary;
-
-       [Widget] Gtk.Image image_cp1_yes;
-       [Widget] Gtk.Image image_cp1_no;
-       [Widget] Gtk.Image image_cp2_yes;
-       [Widget] Gtk.Image image_cp2_no;
-       [Widget] Gtk.Image image_cp3_yes;
-       [Widget] Gtk.Image image_cp3_no;
-       [Widget] Gtk.Image image_cp4_yes;
-       [Widget] Gtk.Image image_cp4_no;
-                               
-       //[Widget] Gtk.Entry entry_multi_chronopic_cp2;
-       
-       string [] comboWindowsOptions;
-       [Widget] Gtk.ComboBox combo_windows1;
-       [Widget] Gtk.ComboBox combo_windows2;
-       [Widget] Gtk.ComboBox combo_windows3;
-       [Widget] Gtk.ComboBox combo_windows4;
-       [Widget] Gtk.ComboBox combo_linux1;
-       [Widget] Gtk.ComboBox combo_linux2;
-       [Widget] Gtk.ComboBox combo_linux3;
-       [Widget] Gtk.ComboBox combo_linux4;
-       [Widget] Gtk.ComboBox combo_windows_encoder;
-       [Widget] Gtk.ComboBox combo_linux_encoder;
-       
-       [Widget] Gtk.Button button_connect_cp1;
-       [Widget] Gtk.Button button_connect_cp2;
-       [Widget] Gtk.Button button_connect_cp3;
-       [Widget] Gtk.Button button_connect_cp4;
-       
-       [Widget] Gtk.CheckButton check_multichronopic_show;
-       [Widget] Gtk.Table table_multi_chronopic;
-       //[Widget] Gtk.Button button_reload;
-       
-       //frame_connections
-       [Widget] Gtk.Frame frame_connection;
-       [Widget] Gtk.Label label_title;
-       [Widget] Gtk.ProgressBar progressbar;
-       [Widget] Gtk.Button button_cancel;
-       
-       [Widget] Gtk.Image chronopic_image;
-       [Widget] Gtk.TextView textview_ports_found_explanation;
-
-       //Automatic firmware stuff
-       [Widget] Gtk.CheckButton check_multitest_show;
-       [Widget] Gtk.Table table_chronopic_auto;
-       [Widget] Gtk.SpinButton spin_auto_change_debounce;
-       [Widget] Gtk.Label label_auto_check;
-       [Widget] Gtk.Label label_auto_check_debounce;
-       [Widget] Gtk.Label label_auto_change_debounce;
-
-       //chronopic connection thread
-       Thread thread;
-       bool needUpdateChronopicWin;
-       bool updateChronopicWinValuesState;
-       string updateChronopicWinValuesMessage;
-       //Gtk.Button fakeButtonCancelled;
-
-       [Widget] Gtk.Button fakeConnectionButton; //raised when chronopic connection ended
-       [Widget] Gtk.Button fakeWindowDone; //raised when chronopic connection ended
-       //[Widget] Gtk.Button fakeWindowReload; //raised when asked to reload
-
-       bool isWindows; 
-
-       //ArrayList of ChronopicPortData
-       static ArrayList cpd;
-       static string encoderPort;
-       
-       //platform state variables
-       enum States {
-               ON,
-               OFF
-       }
-       bool connected;
-       bool volumeOn;
-       int currentCp; //1 to 4
-               
-       //in order to cancel before close window
-       static bool connecting;
-
-       //cp1   
-       Chronopic cp;
-       SerialPort sp;
-       Chronopic.Plataforma platformState;     //on (in platform), off (jumping), or unknow
-       
-       //cp2   
-       Chronopic cp2;
-       Chronopic.Plataforma platformState2;
-
-       //cp3   
-       Chronopic cp3;
-       Chronopic.Plataforma platformState3;
-
-       //cp4   
-       Chronopic cp4;
-       Chronopic.Plataforma platformState4;
-
-       States loggedState;             //log of last state
-       
-       public enum ChronojumpMode { JUMPORRUN, ENCODER, OTHER };
-               
-       private ChronopicInit chronopicInit;
-       
-       public ChronopicWindow(Chronopic cpDetected, ArrayList myCpd)
-       {
-               LogB.Debug("constructor");
-
-               Glade.XML gxml;
-               gxml = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", "chronopic_window", 
"chronojump");
-               gxml.Autoconnect(this);
-
-               cpd = myCpd;
-                       
-               if(cpDetected != null) {
-                       cp = cpDetected;
-                       sp = new SerialPort( ((ChronopicPortData) cpd[0]).Port );
-               }
-
-               UtilGtk.IconWindow(chronopic_window);
-
-               if(UtilAll.IsWindows())
-                       isWindows = true;
-               else
-                       isWindows = false;
-
-               setDefaultValues();             
-                       
-               chronopicInit = new ChronopicInit();
-               
-               //Pixbuf pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "chronopic_128.png");
-               //chronopic_image.Pixbuf = pixbuf;
-               /*
-               Pixbuf pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(true) + 
Constants.FileNameContactPlatformModular);
-               image_contact_modular.Pixbuf = pixbuf;
-               pixbuf = new Pixbuf (null, Util.GetImagePath(true) + Constants.FileNameInfrared);
-               image_infrared.Pixbuf = pixbuf;
-               */
-
-               /*
-               if(chronopicPort1 != Constants.ChronopicDefaultPortWindows && 
-                               (chronopicPort1 != Constants.ChronopicDefaultPortLinux && 
File.Exists(chronopicPort1))
-                 ) {
-                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Do you want to 
connect to Chronopic now?"), "", "");
-                       confirmWin.Button_accept.Clicked += new EventHandler(chronopicAtStart);
-               }
-               */
-       }
-       
-       /*
-        * recreate is false the first time (on initialization of ChronoJumpWindow at gui/chronojump.cs)
-        * after that is true. Usually is used to manage a disconnected chronopic or other ports problems
-        *
-        * port names come from gui/chronojump.cs to this method (myCpd)
-        */
-       //this is the normal call
-       static public ChronopicWindow Create (ArrayList myCpd, string myEncoderPort, bool recreate, bool 
volumeOn)
-       {
-               return Create(null, myCpd, myEncoderPort, recreate, volumeOn);
-       }
-       //this is called on AutoDetect
-       static public ChronopicWindow Create (Chronopic cpDetected, ArrayList myCpd, string myEncoderPort, 
bool recreate, bool volumeOn)
-       {
-               LogB.Debug("enter create");
-               if (ChronopicWindowBox != null && recreate) {
-                       ChronopicWindowBox.chronopic_window.Hide();
-               }
-               if (ChronopicWindowBox == null || recreate) {
-                       ChronopicWindowBox = new ChronopicWindow (cpDetected, myCpd);
-               }
-               
-               LogB.Information("create cp is null? " + (ChronopicWindowBox.cp == null).ToString());
-               
-               //don't show until View is called
-               //ChronopicWindowBox.chronopic_window.Show ();
-               
-               ChronopicWindowBox.volumeOn = volumeOn;
-
-               ChronopicWindowBox.setEncoderPort(myEncoderPort);       
-
-               ChronopicWindowBox.fakeWindowDone = new Gtk.Button();
-               //ChronopicWindowBox.fakeWindowReload = new Gtk.Button();
-               
-               return ChronopicWindowBox;
-       }
-
-       static public ChronopicWindow View (ChronojumpMode cmode, bool volumeOn)
-       {
-               if (ChronopicWindowBox == null) {
-                       ChronopicWindowBox = new ChronopicWindow (null, cpd);
-               } 
-               
-               LogB.Information("view cp is null? " + (ChronopicWindowBox.cp == null).ToString());
-               
-               
-               ChronopicWindowBox.volumeOn = volumeOn;
-               
-               if(cmode == ChronojumpMode.JUMPORRUN || cmode == ChronojumpMode.OTHER) {
-                       ChronopicWindowBox.notebook_main.CurrentPage = 0;
-                       ChronopicWindowBox.checkChronopicDisconnected(); //encoder does not need this because 
there's no connection
-               
-                       ChronopicWindowBox.frame_supplementary.Visible = 
-                               (cmode == ChronojumpMode.OTHER); //can have multichronopic
-               }
-               else    //cmode == ChronojumpMode.ENCODER)
-                       ChronopicWindowBox.notebook_main.CurrentPage = 1;
-               
-               ChronopicWindowBox.createCombos();
-               ChronopicWindowBox.setEncoderPort(encoderPort); 
-
-               //ports info comes from gui/chronojump.cs to Create mehod
-               if(! ChronopicWindowBox.connected)
-                       ChronopicWindowBox.connectingInfoShow();
-
-               ChronopicWindowBox.chronopic_window.Show();
-               ChronopicWindowBox.chronopic_window.Present();
-       
-               return ChronopicWindowBox;
-       }
-
-       private void setEncoderPort(string myEncoderPort) {
-               if(Util.FoundInStringArray(ChronopicPorts.GetPorts(), myEncoderPort))
-                       encoderPort = myEncoderPort;
-               else
-                       encoderPort = Util.GetDefaultPort();
-       }
-
-       private void setDefaultValues() 
-       {
-               label_connect_contacts.Text = "<b>" + label_connect_contacts.Text + "</b>";
-               label_connect_encoder.Text = "<b>" + label_connect_encoder.Text + "</b>";
-               label_connect_contacts.UseMarkup = true;
-               label_connect_encoder.UseMarkup = true;
-               
-               
-               check_multichronopic_show.Active = false;
-               table_multi_chronopic.Visible = false;
-               
-               check_multitest_show.Active = false;
-               check_multitest_show.Sensitive = false;
-
-               if(isWindows) {
-                       combo_linux1.Hide();
-                       combo_linux2.Hide();
-                       combo_linux3.Hide();
-                       combo_linux4.Hide();
-                       combo_linux_encoder.Hide();
-                               
-                       combo_windows2.Sensitive = false;
-                       combo_windows3.Sensitive = false;
-                       combo_windows4.Sensitive = false;
-               } else {
-                       combo_windows1.Hide();
-                       combo_windows2.Hide();
-                       combo_windows3.Hide();
-                       combo_windows4.Hide();
-                       combo_windows_encoder.Hide();
-                               
-                       combo_linux2.Sensitive = false;
-                       combo_linux3.Sensitive = false;
-                       combo_linux4.Sensitive = false;
-               }
-                       
-               button_connect_cp1.Sensitive = false;
-               button_connect_cp2.Sensitive = false;
-               button_connect_cp3.Sensitive = false;
-               button_connect_cp4.Sensitive = false;
-
-               connected = false;
-               foreach(ChronopicPortData a in cpd) 
-                       if(a.Connected)
-                               connected = true;
-
-               image_cp1_yes.Hide();
-               image_cp2_yes.Hide();
-               image_cp3_yes.Hide();
-               image_cp4_yes.Hide();
-
-               //encoderPort = "";
-               //fakeButtonCancelled = new Gtk.Button();
-       }
-       
-       //check if user has disconnected chronopic or port has changed
-       private void checkChronopicDisconnected() 
-       {
-               bool errorFound = false;
-       
-               foreach(ChronopicPortData a in cpd) {
-                       Chronopic myCP;
-                       Chronopic.Plataforma myPS;
-                       if(a.Num == 1) {
-                               myCP = cp;
-                               myPS = platformState;
-                       } else if(a.Num == 2) {
-                               myCP = cp2;
-                               myPS = platformState2;
-                       } else if(a.Num == 3) {
-                               myCP = cp3;
-                               myPS = platformState3;
-                       } else {
-                               myCP = cp4;
-                               myPS = platformState4;
-                       }
-                       
-                       bool ok = false;        
-                       if(a.Connected) {
-                               string myPort = a.Port;
-
-                               //http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
-                               //https://bugzilla.xamarin.com/show_bug.cgi?id=15514
-                               if(! isWindows) {
-                                       if(! File.Exists(myPort)) {
-                                               LogB.Error("port does not exists:", myPort);
-                                               errorFound = true;
-                                       }
-                               }
-                       
-                               if(! errorFound) {
-                                       //try {
-                                       ok = myCP.Read_platform(out myPS);
-                                       //} catch { 
-                                       //      LogB.DebugLine("catch at 1"); 
-                                       //}
-                                       if(!ok) {
-                                               LogB.Error("false at 1");
-                                               errorFound = true;
-                                       }
-                               }
-                       }
-               }
-                       
-               if(errorFound) {
-                       ArrayList myCPD = new ArrayList();
-                       for(int i=1; i<=4; i++) {
-                               ChronopicPortData b = new ChronopicPortData(i,"",false);
-                               myCPD.Add(b);
-                       }
-                       Create (myCPD, encoderPort, true, volumeOn);
-
-                       connected = false;
-
-                       new DialogMessage(Constants.MessageTypes.WARNING, 
-                                       Catalog.GetString("One or more Chronopics have been disconnected.") + 
"\n" + 
-                                       Catalog.GetString("Please connect again, and configure on Chronopic 
window."));
-               }
-       }
-       
-       private void createCombos() {
-               if(isWindows)
-                       ChronopicWindowBox.createComboWindows();
-               else
-                       ChronopicWindowBox.createComboLinux();
-       
-               if(connected) {
-                       int num = 1;
-                       foreach(ChronopicPortData a in cpd) {
-                               if(a.Connected)
-                                       connectionSucceded(num, false); //don't playSound
-                               num ++;
-                       }
-               }
-       }
-
-       //private void createComboWindows(string myPort, Gtk.ComboBox myCombo) {
-       private void createComboWindows() {
-               //combo port stuff
-               comboWindowsOptions = new string[32];
-               //for (int i=1; i <= 32; i ++)
-                       //comboWindowsOptions[i-1] = "COM" + i;
-               comboWindowsOptions = SerialPort.GetPortNames();
-
-               string [] def = Util.StringToStringArray(Constants.ChronopicDefaultPortWindows);
-               string [] allWithDef = Util.AddArrayString(def, comboWindowsOptions);
-       
-               UtilGtk.ComboUpdate(combo_windows1, allWithDef, Constants.ChronopicDefaultPortWindows);
-               UtilGtk.ComboUpdate(combo_windows2, allWithDef, Constants.ChronopicDefaultPortWindows);
-               UtilGtk.ComboUpdate(combo_windows3, allWithDef, Constants.ChronopicDefaultPortWindows);
-               UtilGtk.ComboUpdate(combo_windows4, allWithDef, Constants.ChronopicDefaultPortWindows);
-               
-               foreach(ChronopicPortData a in cpd) {
-                       if(a.Num == 1) {
-                               combo_windows1.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
-                               combo_windows1.Changed += new EventHandler (on_combo_changed);
-                               if(a.Connected) {
-                                       UtilGtk.ComboDelThisValue(combo_windows2, a.Port);
-                                       UtilGtk.ComboDelThisValue(combo_windows3, a.Port);
-                                       UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
-                               }
-                       } else if(a.Num == 2) {
-                               combo_windows2.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
-                               combo_windows2.Changed += new EventHandler (on_combo_changed);
-                               if(a.Connected) {
-                                       UtilGtk.ComboDelThisValue(combo_windows3, a.Port);
-                                       UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
-                               }
-                       } else if(a.Num == 3) {
-                               combo_windows3.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
-                               combo_windows3.Changed += new EventHandler (on_combo_changed);
-                               if(a.Connected)
-                                       UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
-                       } else { //4
-                               combo_windows4.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
-                               combo_windows4.Changed += new EventHandler (on_combo_changed);
-                       }
-               }
-               
-               //encoder
-               //this reduces the callbacks of combo change
-               combo_windows_encoder.Sensitive = false;
-
-               UtilGtk.ComboUpdate(combo_windows_encoder, allWithDef, encoderPort);
-
-               combo_windows_encoder.Changed += new EventHandler (on_combo_changed);
-                       
-               combo_windows_encoder.Active = UtilGtk.ComboMakeActive(allWithDef, encoderPort);
-
-               combo_windows_encoder.Sensitive = true;
-       }
-
-       private void createComboLinux() {
-               //string [] serial = Directory.GetFiles("/dev/", "ttyS*");
-               string [] usbSerial = Directory.GetFiles("/dev/", "ttyUSB*");
-               string [] usbSerialMac = Directory.GetFiles("/dev/", "tty.usbserial*");
-               string [] all = Util.AddArrayString(usbSerial, usbSerialMac);
-               
-               string [] def = Util.StringToStringArray(Constants.ChronopicDefaultPortLinux);
-               
-               string [] allWithDef = Util.AddArrayString(def, all);
-
-               UtilGtk.ComboUpdate(combo_linux1, allWithDef, Constants.ChronopicDefaultPortLinux);
-               UtilGtk.ComboUpdate(combo_linux2, allWithDef, Constants.ChronopicDefaultPortLinux);
-               UtilGtk.ComboUpdate(combo_linux3, allWithDef, Constants.ChronopicDefaultPortLinux);
-               UtilGtk.ComboUpdate(combo_linux4, allWithDef, Constants.ChronopicDefaultPortLinux);
-               
-               foreach(ChronopicPortData a in cpd) {
-                       if(a.Num == 1) {
-                               combo_linux1.Active = UtilGtk.ComboMakeActive(combo_linux1, a.Port);
-                               combo_linux1.Changed += new EventHandler (on_combo_changed);
-                               if(a.Connected) {
-                                       UtilGtk.ComboDelThisValue(combo_linux2, a.Port);
-                                       UtilGtk.ComboDelThisValue(combo_linux3, a.Port);
-                                       UtilGtk.ComboDelThisValue(combo_linux4, a.Port);
-                               }
-                       } else if(a.Num == 2) {
-                               combo_linux2.Active = UtilGtk.ComboMakeActive(combo_linux2, a.Port);
-                               combo_linux2.Changed += new EventHandler (on_combo_changed);
-                               if(a.Connected) {
-                                       UtilGtk.ComboDelThisValue(combo_linux3, a.Port);
-                                       UtilGtk.ComboDelThisValue(combo_linux4, a.Port);
-                               }
-                       } else if(a.Num == 3) {
-                               combo_linux3.Active = UtilGtk.ComboMakeActive(combo_linux3, a.Port);
-                               combo_linux3.Changed += new EventHandler (on_combo_changed);
-                               if(a.Connected)
-                                       UtilGtk.ComboDelThisValue(combo_linux4, a.Port);
-                       } else { //4
-                               combo_linux4.Active = UtilGtk.ComboMakeActive(combo_linux4, a.Port);
-                               combo_linux4.Changed += new EventHandler (on_combo_changed);
-                       }
-               }
-               
-               //encoder
-               //this reduces the callbacks of combo change
-               combo_linux_encoder.Sensitive = false;
-
-               UtilGtk.ComboUpdate(combo_linux_encoder, allWithDef, encoderPort);
-
-               combo_linux_encoder.Changed += new EventHandler (on_combo_changed);
-
-               combo_linux_encoder.Active = UtilGtk.ComboMakeActive(allWithDef, encoderPort);
-
-               combo_linux_encoder.Sensitive = true;
-       }
-       
-       private void on_combo_changed(object o, EventArgs args) {
-               ComboBox combo = o as ComboBox;
-               if (o == null)
-                       return;
-
-               //combo is not sensitive when it has been connected
-               //this helps to have button_connect with correct sensitiveness after close window
-               //also help to not have lots of callbacks coming here about encoder combos
-               if(! combo.Sensitive)
-                       return;
-
-               bool portOk = true;
-               if(UtilGtk.ComboGetActive(combo) == Constants.ChronopicDefaultPortWindows ||
-                               UtilGtk.ComboGetActive(combo) == Constants.ChronopicDefaultPortLinux) 
-                       portOk = false;
-
-               if (o == combo_linux1 || o == combo_windows1) 
-                       button_connect_cp1.Sensitive = portOk;
-               else if (o == combo_linux2 || o == combo_windows2) 
-                       button_connect_cp2.Sensitive = portOk;
-               else if (o == combo_linux3 || o == combo_windows3) 
-                       button_connect_cp3.Sensitive = portOk;
-               else if (o == combo_linux4 || o == combo_windows4) 
-                       button_connect_cp4.Sensitive = portOk;
-               else if (o == combo_windows_encoder) {
-                       combo_windows_encoder.Changed -= new EventHandler (on_combo_changed);
-                       encoderPort = UtilGtk.ComboGetActive(combo);
-               } else if (o == combo_linux_encoder) {
-                       combo_linux_encoder.Changed -= new EventHandler (on_combo_changed);
-                       encoderPort = UtilGtk.ComboGetActive(combo);
-               }
-       }
-       
-       private void connectingInfoShow() {
-               textview_ports_found_explanation.Buffer = UtilGtk.TextViewPrint(
-                               Catalog.GetString("If you just plugged Chronopic cable and expected port is 
not listed, close and open again this window.") + "\n" + 
-                               Catalog.GetString("If you have problems connecting with Chronopic, press help 
button.")  
-                               //saferPorts
-                               );
-       }
-       private void connectingInfoHide() {
-               textview_ports_found_explanation.Buffer = UtilGtk.TextViewPrint("");
-       }
-
-       private void chronopicAtStart(object o, EventArgs args) {
-               //make active menuitem chronopic, and this
-               //will raise other things
-//             menuitem_chronopic.Active = true;
-               LogB.Information("CP AT START from gui/chronopic.cs");
-       }
-
-
-       protected bool PulseGTK ()
-       {
-               if(needUpdateChronopicWin || ! thread.IsAlive) {
-                       LogB.ThreadEnding();
-                       fakeConnectionButton.Click();
-                       pulseEnd();
-
-                       LogB.ThreadEnded();
-                       return false;
-               }
-               //need to do this, if not it crashes because chronopicConnectionWin gets died by thread ending
-               //chronopicConnectionWin = ChronopicConnection.Show();
-               //chronopicConnectionWin.Pulse();
-               progressbar.Pulse();
-               
-               Thread.Sleep (50);
-               LogB.Debug(thread.ThreadState.ToString());
-               return true;
-       }
-
-       private void pulseEnd() {
-               button_cancel.Sensitive = false;
-               connecting = false;
-               fakeWindowDone.Click();
-       }
-                       
-       private void updateChronopicWin(bool state, string message) {
-               LogB.Information("updateChronopicWin-1");
-
-               //need to do this, if not it crashes because chronopicConnectionWin gets died by thread ending
-               //chronopicConnectionWin = ChronopicConnection.Show();
-
-               LogB.Information("updateChronopicWin-2");
-               if(state) {
-                       //chronopicConnectionWin.Connected(message);
-                       sensitivityConnected(message);
-                       progressbar.Fraction = 1.0;
-               }
-               else
-                       //chronopicConnectionWin.Disconnected(message);
-                       sensitivityDisconnected(message);
-               
-               needUpdateChronopicWin = false;
-       }
-       
-       private void sensitivityConnected(string message) {
-               LogB.Information("CONNECTED!!");
-               label_title.Text = message;
-               label_title.UseMarkup = true;
-               button_cancel.Sensitive = false;
-               check_multitest_show.Sensitive = true;
-       }
-
-       private void sensitivityDisconnected(string message) {
-               LogB.Information("DISCONNECTED!!");
-               label_title.Text = message;
-               button_cancel.Sensitive = false;
-               check_multitest_show.Sensitive = false;
-       }
-               
-       private void on_button_help_ports_clicked (object o, EventArgs args) {
-               new HelpPorts();
-       }
-
-       private void on_check_multichronopic_show_clicked(object o, EventArgs args) {
-               table_multi_chronopic.Visible = check_multichronopic_show.Active;
-       }
-
-       private void on_button_connect_cp_clicked (object o, EventArgs args) {
-               if (o == null)
-                       return;
-
-               if(isWindows){
-                       if (o == button_connect_cp1) 
-                               ((ChronopicPortData) cpd[0]).Port = UtilGtk.ComboGetActive(combo_windows1);
-                       else if (o == button_connect_cp2) 
-                               ((ChronopicPortData) cpd[1]).Port = UtilGtk.ComboGetActive(combo_windows2);
-                       else if (o == button_connect_cp3) 
-                               ((ChronopicPortData) cpd[2]).Port = UtilGtk.ComboGetActive(combo_windows3);
-                       else if (o == button_connect_cp4) 
-                               ((ChronopicPortData) cpd[3]).Port = UtilGtk.ComboGetActive(combo_windows4);
-               }
-               else {
-                       if (o == button_connect_cp1) 
-                               ((ChronopicPortData) cpd[0]).Port = UtilGtk.ComboGetActive(combo_linux1);
-                       else if (o == button_connect_cp2) 
-                               ((ChronopicPortData) cpd[1]).Port = UtilGtk.ComboGetActive(combo_linux2);
-                       else if (o == button_connect_cp3) 
-                               ((ChronopicPortData) cpd[2]).Port = UtilGtk.ComboGetActive(combo_linux3);
-                       else if (o == button_connect_cp4) 
-                               ((ChronopicPortData) cpd[3]).Port = UtilGtk.ComboGetActive(combo_linux4);
-               }
-               
-               if (o == button_connect_cp1) 
-                       currentCp = 1;
-               else if (o == button_connect_cp2) 
-                       currentCp = 2;
-               else if (o == button_connect_cp3) 
-                       currentCp = 3;
-               else // if (o == button_connect_cp4) 
-                       currentCp = 4;
-
-               prepareChronopicConnection();
-       }
-       
-       private void on_button_help_clicked (object o, EventArgs args) {
-               LogB.Information("HELP");
-               new HelpPorts();
-       }
-       
-       public void SerialPortsCloseIfNeeded() {
-               if(sp != null && sp.IsOpen) {
-                       LogB.Information("Closing sp");
-                       sp.Close();
-               }
-       }
-
-
-       // Chronopic Automatic Firmware ---------------
-       
-       private void on_check_multitest_show_clicked (object o, EventArgs args) 
-       {
-               table_chronopic_auto.Visible = check_multitest_show.Active;
-       }
-
-       private void on_button_auto_check_auto_clicked (object o, EventArgs args)
-       {
-               ChronopicAuto ca = new ChronopicAutoCheck();
-               label_auto_check.Text = ca.Read(sp);
-       }       
-
-       private void on_button_auto_check_debounce_clicked (object o, EventArgs args)
-       {
-               ChronopicAuto ca = new ChronopicAutoCheckDebounce();
-               label_auto_check_debounce.Text = ca.Read(sp);
-       }       
-
-       private void on_button_auto_change_debounce_clicked (object o, EventArgs args)
-       {
-               ChronopicAuto ca = new ChronopicAutoChangeDebounce();
-               ca.Write(sp, (int) spin_auto_change_debounce.Value);
-               
-               ca = new ChronopicAutoCheckDebounce();
-               label_auto_change_debounce.Text = ca.Read(sp);
-       }       
-       
-       private void on_button_auto_check_help_clicked (object o, EventArgs args) 
-       {
-               new DialogMessage(Constants.MessageTypes.INFO, 
-                               "50 ms recommended for jumps." + "\n" + 
-                               "10 ms recommended for runs.");
-       }
-
-       private void on_button_auto_change_help_clicked (object o, EventArgs args) 
-       {
-               new DialogMessage(Constants.MessageTypes.INFO, 
-                               "Minimum value will be 50 ms again when user unplugs USB cable.");
-       }
-       
-       
-       //called from gui/chronojump.cs
-       //done here because sending the SP is problematic on windows
-       public string CheckAuto (out bool isChronopicAuto)
-       {
-               ChronopicAuto ca = new ChronopicAutoCheck();
-
-               string str = ca.Read(sp);
-               
-               isChronopicAuto = ca.IsChronopicAuto;
-
-               return str;
-       }       
-       public int ChangeMultitestFirmware (int debounceChange) 
-       {
-               LogB.Information("change_multitest_firmware 3 a");
-               try {
-                       //write change
-                       ChronopicAuto ca = new ChronopicAutoChangeDebounce();
-                       ca.Write(sp, debounceChange);
-
-                       //read if ok
-                       string ms = "";
-                       bool success = false;
-                       int tryNum = 7; //try to connect seven times
-                       do {
-                               ca = new ChronopicAutoCheckDebounce();
-                               ms = ca.Read(sp);
-
-                               if(ms.Length == 0)
-                                       LogB.Error("multitest firmware. ms is null");
-                               else if(ms[0] == '-') //is negative
-                                       LogB.Error("multitest firmware. ms = " + ms);
-                               else
-                                       success = true;
-                               tryNum --;
-                       } while (! success && tryNum > 0);
-
-                       LogB.Debug("multitest firmware. ms = " + ms);
-
-                       if(ms == "50 ms")
-                               return 50;
-                       else if(ms == "10 ms")
-                               return 10;
-               } catch {
-                       LogB.Error("Could not change debounce");
-               }
-                       
-               return -1;
-       }
-
-
-       // end of Chronopic Automatic Firmware ---------------
-
-
-       void prepareChronopicConnection() {
-               check_multitest_show.Sensitive = false;
-               frame_connection.Visible = true;
-               
-               label_title.Text = Catalog.GetString("Please touch the platform or click Chronopic 
<i>TEST</i> button");
-               label_title.UseMarkup = true;
-                       
-               button_cancel.Sensitive = true;
-               
-               fakeConnectionButton = new Gtk.Button();
-               fakeConnectionButton.Clicked += new EventHandler(on_chronopic_connection_ended);
-
-               connecting = true;
-               needUpdateChronopicWin = false;
-               thread = new Thread(new ThreadStart(waitChronopicStart));
-               GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
-
-               LogB.ThreadStart();
-               thread.Start(); 
-       }
-
-       static Chronopic cpDoing;       
-       protected void waitChronopicStart () 
-       {
-               if(currentCp == 1) {
-               //      simulated = false;
-               //      SqlitePreferences.Update("simulated", simulated.ToString(), false);
-                       if(connected)
-                               return;
-               }
-       
-               SerialPort sp2;
-               SerialPort sp3;
-               SerialPort sp4;
-
-               string message = "";
-               string myPort = "";
-               bool success = false;
-                       
-               if(currentCp == 1) {
-                       myPort = ((ChronopicPortData) cpd[0]).Port;
-                       cpDoing = cp;
-                       connected = chronopicInit.Do(currentCp, out cpDoing, out sp, platformState, myPort, 
out message, out success);
-                       cp = cpDoing;
-                       if(success)
-                               connectionSucceded(1, true);
-               }
-               else if(currentCp == 2) {
-                       myPort = ((ChronopicPortData) cpd[1]).Port;
-                       cpDoing = cp2;
-                       connected = chronopicInit.Do(currentCp, out cpDoing, out sp2, platformState2, myPort, 
out message, out success);
-                       cp2 = cpDoing;
-                       if(success)
-                               connectionSucceded(2, true);
-               }
-               else if(currentCp == 3) {
-                       myPort = ((ChronopicPortData) cpd[2]).Port;
-                       cpDoing = cp3;
-                       connected = chronopicInit.Do(currentCp, out cpDoing, out sp3, platformState3, myPort, 
out message, out success);
-                       cp3 = cpDoing;
-                       if(success)
-                               connectionSucceded(3, true);
-               }
-               else if(currentCp == 4) {
-                       myPort = ((ChronopicPortData) cpd[3]).Port;
-                       cpDoing = cp4;
-                       connected = chronopicInit.Do(currentCp, out cpDoing, out sp4, platformState4, myPort, 
out message, out success);
-                       cp4 = cpDoing;
-                       if(success)
-                               connectionSucceded(4, true);
-               }
-               
-
-               LogB.Information(string.Format("wait_chronopic_start {0}", message));
-                       
-               if(success) {
-                       Util.PlaySound(Constants.SoundTypes.GOOD, volumeOn);
-                       updateChronopicWinValuesState= true; //connected
-                       updateChronopicWinValuesMessage= message;
-               } else {
-                       Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
-                       updateChronopicWinValuesState= false; //disconnected
-                       updateChronopicWinValuesMessage= message;
-               }
-
-               foreach(ChronopicPortData a in cpd)
-                       LogB.Information(a.Num + ", " + a.Port + ", " + a.Connected);
-
-               needUpdateChronopicWin = true;
-       }
-
-       private void connectionSucceded(int port, bool playSound)
-       {
-               string myPort = ((ChronopicPortData) cpd[port -1]).Port;
-               ((ChronopicPortData) cpd[port -1]).Connected=true;
-
-               if(port == 1) {
-                       button_connect_cp1.Sensitive = false;
-                       image_cp1_no.Hide();
-                       image_cp1_yes.Show();
-
-                       if(isWindows) {
-                               combo_windows1.Sensitive = false;
-                               combo_windows2.Sensitive = true;
-                               UtilGtk.ComboDelThisValue(combo_windows2, myPort);
-                               combo_windows2.Active = 0; //first option
-                               UtilGtk.ComboDelThisValue(combo_windows3, myPort);
-                               combo_windows3.Active = 0;
-                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
-                               combo_windows4.Active = 0;
-                       } else {
-                               combo_linux1.Sensitive = false;
-                               combo_linux2.Sensitive = true;
-                               UtilGtk.ComboDelThisValue(combo_linux2, myPort);
-                               combo_linux2.Active = 0; //first option
-                               UtilGtk.ComboDelThisValue(combo_linux3, myPort);
-                               combo_linux3.Active = 0;
-                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
-                               combo_linux4.Active = 0;
-                       }
-               }
-               else if(port == 2) {
-                       button_connect_cp2.Sensitive = false;
-                       image_cp2_no.Hide();
-                       image_cp2_yes.Show();
-
-                       if(isWindows) {
-                               combo_windows2.Sensitive = false;
-                               combo_windows3.Sensitive = true;
-                               UtilGtk.ComboDelThisValue(combo_windows3, myPort);
-                               combo_windows3.Active = 0;
-                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
-                               combo_windows4.Active = 0;
-                       } else {
-                               combo_linux2.Sensitive = false;
-                               combo_linux3.Sensitive = true;
-                               UtilGtk.ComboDelThisValue(combo_linux3, myPort);
-                               combo_linux3.Active = 0;
-                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
-                               combo_linux4.Active = 0;
-                       }
-               }
-               else if(port == 3) {
-                       button_connect_cp3.Sensitive = false;
-                       image_cp3_no.Hide();
-                       image_cp3_yes.Show();
-
-                       if(isWindows) {
-                               combo_windows3.Sensitive = false;
-                               combo_windows4.Sensitive = true;
-                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
-                               combo_windows4.Active = 0;
-                       } else {
-                               combo_linux3.Sensitive = false;
-                               combo_linux4.Sensitive = true;
-                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
-                               combo_linux4.Active = 0;
-                       }
-               }
-               else if(port == 4) {
-                       button_connect_cp4.Sensitive = false;
-                       image_cp4_no.Hide();
-                       image_cp4_yes.Show();
-
-                       if(isWindows) 
-                               combo_windows4.Sensitive = false;
-                       else 
-                               combo_linux4.Sensitive = false;
-               }
-                       
-
-               connectingInfoHide();
-               frame_connection.Visible = true;
-               updateChronopicWin(true, Catalog.GetString("connected"));
-               if(playSound)           
-                       Util.PlaySound(Constants.SoundTypes.GOOD, volumeOn);
-               updateChronopicWinValuesState= true; //connected
-       }
-
-       private void on_chronopic_connection_ended(object o, EventArgs args) {
-               updateChronopicWin(updateChronopicWinValuesState, updateChronopicWinValuesMessage);
-       }
-
-
-       private void on_button_cancel_clicked (object o, EventArgs args) {
-               LogB.Information("cancelled-----");
-               //fakeButtonCancelled.Click(); //just to show message of crashing on windows exiting
-               
-               button_cancel.Sensitive = false;
-               
-               cpDoing.AbortFlush = true;
-               chronopicInit.CancelledByUser = true;
-
-               //kill the chronopicInit.Do function that is waiting event 
-               //thread.Abort();
-               //http://stackoverflow.com/questions/2853072/thread-does-not-abort-on-application-closing
-               //LogB.Debug(thread.ThreadState.ToString());
-               //thread.IsBackground = true;
-               
-               //try to solve windows problems when a chronopic connection was cancelled
-               //LogB.Debug(thread.ThreadState.ToString());
-               //thread.Join(1000);
-               //LogB.Debug(thread.ThreadState.ToString());
-
-               
-               updateChronopicWinValuesState= false; //disconnected
-               updateChronopicWinValuesMessage= Catalog.GetString("Cancelled by user");
-               needUpdateChronopicWin = true;
-       }
-       
-       void on_button_close_clicked (object o, EventArgs args)
-       {
-               if(connecting)
-                       button_cancel.Click();
-
-               LogB.Information("CLOSE");
-               fakeWindowDone.Click();
-               ChronopicWindowBox.chronopic_window.Hide();
-       }
-
-       void on_delete_event (object o, DeleteEventArgs args)
-       {
-               //nice: this makes windows no destroyed, then it works like button_close
-               fakeWindowDone.Click();
-               
-               if(connecting)
-                       button_cancel.Click();
-
-               args.RetVal = true;
-               ChronopicWindowBox.chronopic_window.Hide();
-       }
-
-       public bool IsConnected(int numCP) {
-               //int count = 1;
-               //foreach(ChronopicPortData a in cpd) 
-               //      LogB.InformationLine(a.Num + ", " + a.Port + ", " + a.Connected);
-               return ((ChronopicPortData) cpd[numCP]).Connected;
-       }
-
-       public int NumConnected() {
-               int count = 0;
-               foreach(ChronopicPortData a in cpd) 
-                       if(a.Connected)
-                               count ++;
-               return count;
-       }
-
-       public string GetContactsFirstPort() {
-               return ((ChronopicPortData) cpd[0]).Port;
-       }
-
-       public string GetEncoderPort() {
-               /*
-               if(isWindows)
-                       return UtilGtk.ComboGetActive(combo_windows_encoder);
-               else
-                       return UtilGtk.ComboGetActive(combo_linux_encoder);
-                       */
-               /*
-                * better like this because this can be created from Create
-                * and readed from the software
-                * without needing to define the combos (from View)
-                */
-               return encoderPort;
-       }
-       
-       public void CreateSPifNeeded(string port) 
-       {
-               if(sp == null)
-                       sp = new SerialPort(port);
-       }
-
-
-       public Chronopic CP {
-               get { return cp; }
-       }
-
-       public Chronopic CP2 {
-               get { return cp2; }
-       }
-
-       public Chronopic CP3 {
-               get { return cp3; }
-       }
-
-       public Chronopic CP4 {
-               get { return cp4; }
-       }
-       
-       public SerialPort SP {
-               get { return sp; }
-       }
-       
-       public Chronopic.Plataforma PlatformState {     //on (in platform), off (jumping), or unknow
-               get { return platformState; }
-       }
-
-
-       //connected to a Chronopic      
-       public bool Connected {
-               get { return connected; }
-               set { connected = value; }
-       }
-       
-       public Button FakeWindowDone {
-               get { return fakeWindowDone; }
-       }
-
-       //public Gtk.Button FakeButtonCancelled {
-       //      get { return fakeButtonCancelled; }
-       //}
-
-}
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+
+using System;
+using Gtk;
+using Gdk;
+using Glade;
+using System.IO.Ports;
+using Mono.Unix;
+using System.Threading;
+using System.IO; //"File" things
+using System.Collections; //ArrayList
+
+public class ChronopicPortData
+{
+       public int Num;
+       public string Port; //port filename
+       public bool Connected;
+       
+       public ChronopicPortData(int num, string port, bool connected) {
+               this.Num = num;
+               this.Port = port;
+               this.Connected = connected;
+       }
+}
+
+public class ChronopicWindow 
+{
+       [Widget] Gtk.Window chronopic_window;
+       static ChronopicWindow ChronopicWindowBox;
+       //ChronopicConnection chronopicConnectionWin;
+
+       [Widget] Gtk.Notebook notebook_main;
+       //[Widget] Gtk.Image image_contact_modular;
+       //[Widget] Gtk.Image image_infrared;
+       
+       [Widget] Gtk.Label label_connect_contacts;
+       [Widget] Gtk.Label label_connect_encoder;
+
+       [Widget] Gtk.Frame frame_supplementary;
+
+       [Widget] Gtk.Image image_cp1_yes;
+       [Widget] Gtk.Image image_cp1_no;
+       [Widget] Gtk.Image image_cp2_yes;
+       [Widget] Gtk.Image image_cp2_no;
+       [Widget] Gtk.Image image_cp3_yes;
+       [Widget] Gtk.Image image_cp3_no;
+       [Widget] Gtk.Image image_cp4_yes;
+       [Widget] Gtk.Image image_cp4_no;
+                               
+       //[Widget] Gtk.Entry entry_multi_chronopic_cp2;
+       
+       string [] comboWindowsOptions;
+       [Widget] Gtk.ComboBox combo_windows1;
+       [Widget] Gtk.ComboBox combo_windows2;
+       [Widget] Gtk.ComboBox combo_windows3;
+       [Widget] Gtk.ComboBox combo_windows4;
+       [Widget] Gtk.ComboBox combo_linux1;
+       [Widget] Gtk.ComboBox combo_linux2;
+       [Widget] Gtk.ComboBox combo_linux3;
+       [Widget] Gtk.ComboBox combo_linux4;
+       [Widget] Gtk.ComboBox combo_windows_encoder;
+       [Widget] Gtk.ComboBox combo_linux_encoder;
+       
+       [Widget] Gtk.Button button_connect_cp1;
+       [Widget] Gtk.Button button_connect_cp2;
+       [Widget] Gtk.Button button_connect_cp3;
+       [Widget] Gtk.Button button_connect_cp4;
+       
+       [Widget] Gtk.CheckButton check_multichronopic_show;
+       [Widget] Gtk.Table table_multi_chronopic;
+       //[Widget] Gtk.Button button_reload;
+       
+       //frame_connections
+       [Widget] Gtk.Frame frame_connection;
+       [Widget] Gtk.Label label_title;
+       [Widget] Gtk.ProgressBar progressbar;
+       [Widget] Gtk.Button button_cancel;
+       
+       [Widget] Gtk.Image chronopic_image;
+       [Widget] Gtk.TextView textview_ports_found_explanation;
+
+       //Automatic firmware stuff
+       [Widget] Gtk.CheckButton check_multitest_show;
+       [Widget] Gtk.Table table_chronopic_auto;
+       [Widget] Gtk.SpinButton spin_auto_change_debounce;
+       [Widget] Gtk.Label label_auto_check;
+       [Widget] Gtk.Label label_auto_check_debounce;
+       [Widget] Gtk.Label label_auto_change_debounce;
+
+       //chronopic connection thread
+       Thread thread;
+       bool needUpdateChronopicWin;
+       bool updateChronopicWinValuesState;
+       string updateChronopicWinValuesMessage;
+       //Gtk.Button fakeButtonCancelled;
+
+       [Widget] Gtk.Button fakeConnectionButton; //raised when chronopic connection ended
+       [Widget] Gtk.Button fakeWindowDone; //raised when chronopic connection ended
+       //[Widget] Gtk.Button fakeWindowReload; //raised when asked to reload
+
+       bool isWindows; 
+
+       //ArrayList of ChronopicPortData
+       static ArrayList cpd;
+       static string encoderPort;
+       
+       //platform state variables
+       enum States {
+               ON,
+               OFF
+       }
+       bool connected;
+       bool volumeOn;
+       int currentCp; //1 to 4
+               
+       //in order to cancel before close window
+       static bool connecting;
+
+       //cp1   
+       Chronopic cp;
+       SerialPort sp;
+       Chronopic.Plataforma platformState;     //on (in platform), off (jumping), or unknow
+       
+       //cp2   
+       Chronopic cp2;
+       Chronopic.Plataforma platformState2;
+
+       //cp3   
+       Chronopic cp3;
+       Chronopic.Plataforma platformState3;
+
+       //cp4   
+       Chronopic cp4;
+       Chronopic.Plataforma platformState4;
+
+       States loggedState;             //log of last state
+       
+       public enum ChronojumpMode { JUMPORRUN, ENCODER, OTHER };
+               
+       private ChronopicInit chronopicInit;
+       
+       public ChronopicWindow(Chronopic cpDetected, ArrayList myCpd)
+       {
+               LogB.Debug("constructor");
+
+               Glade.XML gxml;
+               gxml = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", "chronopic_window", 
"chronojump");
+               gxml.Autoconnect(this);
+
+               cpd = myCpd;
+                       
+               if(cpDetected != null) {
+                       cp = cpDetected;
+                       sp = new SerialPort( ((ChronopicPortData) cpd[0]).Port );
+               }
+
+               UtilGtk.IconWindow(chronopic_window);
+
+               if(UtilAll.IsWindows())
+                       isWindows = true;
+               else
+                       isWindows = false;
+
+               setDefaultValues();             
+                       
+               chronopicInit = new ChronopicInit();
+               
+               //Pixbuf pixbuf = new Pixbuf (null, Util.GetImagePath(false) + "chronopic_128.png");
+               //chronopic_image.Pixbuf = pixbuf;
+               /*
+               Pixbuf pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(true) + 
Constants.FileNameContactPlatformModular);
+               image_contact_modular.Pixbuf = pixbuf;
+               pixbuf = new Pixbuf (null, Util.GetImagePath(true) + Constants.FileNameInfrared);
+               image_infrared.Pixbuf = pixbuf;
+               */
+
+               /*
+               if(chronopicPort1 != Constants.ChronopicDefaultPortWindows && 
+                               (chronopicPort1 != Constants.ChronopicDefaultPortLinux && 
File.Exists(chronopicPort1))
+                 ) {
+                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Do you want to 
connect to Chronopic now?"), "", "");
+                       confirmWin.Button_accept.Clicked += new EventHandler(chronopicAtStart);
+               }
+               */
+       }
+       
+       /*
+        * recreate is false the first time (on initialization of ChronoJumpWindow at gui/chronojump.cs)
+        * after that is true. Usually is used to manage a disconnected chronopic or other ports problems
+        *
+        * port names come from gui/chronojump.cs to this method (myCpd)
+        */
+       //this is the normal call
+       static public ChronopicWindow Create (ArrayList myCpd, string myEncoderPort, bool recreate, bool 
volumeOn)
+       {
+               return Create(null, myCpd, myEncoderPort, recreate, volumeOn);
+       }
+       //this is called on AutoDetect
+       static public ChronopicWindow Create (Chronopic cpDetected, ArrayList myCpd, string myEncoderPort, 
bool recreate, bool volumeOn)
+       {
+               LogB.Debug("enter create");
+               if (ChronopicWindowBox != null && recreate) {
+                       ChronopicWindowBox.chronopic_window.Hide();
+               }
+               if (ChronopicWindowBox == null || recreate) {
+                       ChronopicWindowBox = new ChronopicWindow (cpDetected, myCpd);
+               }
+               
+               LogB.Information("create cp is null? " + (ChronopicWindowBox.cp == null).ToString());
+               
+               //don't show until View is called
+               //ChronopicWindowBox.chronopic_window.Show ();
+               
+               ChronopicWindowBox.volumeOn = volumeOn;
+
+               ChronopicWindowBox.setEncoderPort(myEncoderPort);       
+
+               ChronopicWindowBox.fakeWindowDone = new Gtk.Button();
+               //ChronopicWindowBox.fakeWindowReload = new Gtk.Button();
+               
+               return ChronopicWindowBox;
+       }
+
+       static public ChronopicWindow View (ChronojumpMode cmode, bool volumeOn)
+       {
+               if (ChronopicWindowBox == null) {
+                       ChronopicWindowBox = new ChronopicWindow (null, cpd);
+               } 
+               
+               LogB.Information("view cp is null? " + (ChronopicWindowBox.cp == null).ToString());
+               
+               
+               ChronopicWindowBox.volumeOn = volumeOn;
+               
+               if(cmode == ChronojumpMode.JUMPORRUN || cmode == ChronojumpMode.OTHER) {
+                       ChronopicWindowBox.notebook_main.CurrentPage = 0;
+                       ChronopicWindowBox.checkChronopicDisconnected(); //encoder does not need this because 
there's no connection
+               
+                       ChronopicWindowBox.frame_supplementary.Visible = 
+                               (cmode == ChronojumpMode.OTHER); //can have multichronopic
+               }
+               else    //cmode == ChronojumpMode.ENCODER)
+                       ChronopicWindowBox.notebook_main.CurrentPage = 1;
+               
+               ChronopicWindowBox.createCombos();
+               ChronopicWindowBox.setEncoderPort(encoderPort); 
+
+               //ports info comes from gui/chronojump.cs to Create mehod
+               if(! ChronopicWindowBox.connected)
+                       ChronopicWindowBox.connectingInfoShow();
+
+               ChronopicWindowBox.chronopic_window.Show();
+               ChronopicWindowBox.chronopic_window.Present();
+       
+               return ChronopicWindowBox;
+       }
+
+       private void setEncoderPort(string myEncoderPort) {
+               if(Util.FoundInStringArray(ChronopicPorts.GetPorts(), myEncoderPort))
+                       encoderPort = myEncoderPort;
+               else
+                       encoderPort = Util.GetDefaultPort();
+       }
+
+       private void setDefaultValues() 
+       {
+               label_connect_contacts.Text = "<b>" + label_connect_contacts.Text + "</b>";
+               label_connect_encoder.Text = "<b>" + label_connect_encoder.Text + "</b>";
+               label_connect_contacts.UseMarkup = true;
+               label_connect_encoder.UseMarkup = true;
+               
+               
+               check_multichronopic_show.Active = false;
+               table_multi_chronopic.Visible = false;
+               
+               check_multitest_show.Active = false;
+               check_multitest_show.Sensitive = false;
+
+               if(isWindows) {
+                       combo_linux1.Hide();
+                       combo_linux2.Hide();
+                       combo_linux3.Hide();
+                       combo_linux4.Hide();
+                       combo_linux_encoder.Hide();
+                               
+                       combo_windows2.Sensitive = false;
+                       combo_windows3.Sensitive = false;
+                       combo_windows4.Sensitive = false;
+               } else {
+                       combo_windows1.Hide();
+                       combo_windows2.Hide();
+                       combo_windows3.Hide();
+                       combo_windows4.Hide();
+                       combo_windows_encoder.Hide();
+                               
+                       combo_linux2.Sensitive = false;
+                       combo_linux3.Sensitive = false;
+                       combo_linux4.Sensitive = false;
+               }
+                       
+               button_connect_cp1.Sensitive = false;
+               button_connect_cp2.Sensitive = false;
+               button_connect_cp3.Sensitive = false;
+               button_connect_cp4.Sensitive = false;
+
+               connected = false;
+               foreach(ChronopicPortData a in cpd) 
+                       if(a.Connected)
+                               connected = true;
+
+               image_cp1_yes.Hide();
+               image_cp2_yes.Hide();
+               image_cp3_yes.Hide();
+               image_cp4_yes.Hide();
+
+               //encoderPort = "";
+               //fakeButtonCancelled = new Gtk.Button();
+       }
+       
+       //check if user has disconnected chronopic or port has changed
+       private void checkChronopicDisconnected() 
+       {
+               bool errorFound = false;
+       
+               foreach(ChronopicPortData a in cpd) {
+                       Chronopic myCP;
+                       Chronopic.Plataforma myPS;
+                       if(a.Num == 1) {
+                               myCP = cp;
+                               myPS = platformState;
+                       } else if(a.Num == 2) {
+                               myCP = cp2;
+                               myPS = platformState2;
+                       } else if(a.Num == 3) {
+                               myCP = cp3;
+                               myPS = platformState3;
+                       } else {
+                               myCP = cp4;
+                               myPS = platformState4;
+                       }
+                       
+                       bool ok = false;        
+                       if(a.Connected) {
+                               string myPort = a.Port;
+
+                               //http://www.raspberrypi.org/forums/viewtopic.php?f=66&t=88415
+                               //https://bugzilla.xamarin.com/show_bug.cgi?id=15514
+                               if(! isWindows) {
+                                       if(! File.Exists(myPort)) {
+                                               LogB.Error("port does not exists:", myPort);
+                                               errorFound = true;
+                                       }
+                               }
+                       
+                               if(! errorFound) {
+                                       //try {
+                                       ok = myCP.Read_platform(out myPS);
+                                       //} catch { 
+                                       //      LogB.DebugLine("catch at 1"); 
+                                       //}
+                                       if(!ok) {
+                                               LogB.Error("false at 1");
+                                               errorFound = true;
+                                       }
+                               }
+                       }
+               }
+                       
+               if(errorFound) {
+                       ArrayList myCPD = new ArrayList();
+                       for(int i=1; i<=4; i++) {
+                               ChronopicPortData b = new ChronopicPortData(i,"",false);
+                               myCPD.Add(b);
+                       }
+                       Create (myCPD, encoderPort, true, volumeOn);
+
+                       connected = false;
+
+                       new DialogMessage(Constants.MessageTypes.WARNING, 
+                                       Catalog.GetString("One or more Chronopics have been disconnected.") + 
"\n" + 
+                                       Catalog.GetString("Please connect again, and configure on Chronopic 
window."));
+               }
+       }
+       
+       private void createCombos() {
+               if(isWindows)
+                       ChronopicWindowBox.createComboWindows();
+               else
+                       ChronopicWindowBox.createComboLinux();
+       
+               if(connected) {
+                       int num = 1;
+                       foreach(ChronopicPortData a in cpd) {
+                               if(a.Connected)
+                                       connectionSucceded(num, false); //don't playSound
+                               num ++;
+                       }
+               }
+       }
+
+       //private void createComboWindows(string myPort, Gtk.ComboBox myCombo) {
+       private void createComboWindows() {
+               //combo port stuff
+               comboWindowsOptions = new string[32];
+               //for (int i=1; i <= 32; i ++)
+                       //comboWindowsOptions[i-1] = "COM" + i;
+               comboWindowsOptions = SerialPort.GetPortNames();
+
+               string [] def = Util.StringToStringArray(Constants.ChronopicDefaultPortWindows);
+               string [] allWithDef = Util.AddArrayString(def, comboWindowsOptions);
+       
+               UtilGtk.ComboUpdate(combo_windows1, allWithDef, Constants.ChronopicDefaultPortWindows);
+               UtilGtk.ComboUpdate(combo_windows2, allWithDef, Constants.ChronopicDefaultPortWindows);
+               UtilGtk.ComboUpdate(combo_windows3, allWithDef, Constants.ChronopicDefaultPortWindows);
+               UtilGtk.ComboUpdate(combo_windows4, allWithDef, Constants.ChronopicDefaultPortWindows);
+               
+               foreach(ChronopicPortData a in cpd) {
+                       if(a.Num == 1) {
+                               combo_windows1.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
+                               combo_windows1.Changed += new EventHandler (on_combo_changed);
+                               if(a.Connected) {
+                                       UtilGtk.ComboDelThisValue(combo_windows2, a.Port);
+                                       UtilGtk.ComboDelThisValue(combo_windows3, a.Port);
+                                       UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
+                               }
+                       } else if(a.Num == 2) {
+                               combo_windows2.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
+                               combo_windows2.Changed += new EventHandler (on_combo_changed);
+                               if(a.Connected) {
+                                       UtilGtk.ComboDelThisValue(combo_windows3, a.Port);
+                                       UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
+                               }
+                       } else if(a.Num == 3) {
+                               combo_windows3.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
+                               combo_windows3.Changed += new EventHandler (on_combo_changed);
+                               if(a.Connected)
+                                       UtilGtk.ComboDelThisValue(combo_windows4, a.Port);
+                       } else { //4
+                               combo_windows4.Active = UtilGtk.ComboMakeActive(comboWindowsOptions, a.Port);
+                               combo_windows4.Changed += new EventHandler (on_combo_changed);
+                       }
+               }
+               
+               //encoder
+               //this reduces the callbacks of combo change
+               combo_windows_encoder.Sensitive = false;
+
+               UtilGtk.ComboUpdate(combo_windows_encoder, allWithDef, encoderPort);
+
+               combo_windows_encoder.Changed += new EventHandler (on_combo_changed);
+                       
+               combo_windows_encoder.Active = UtilGtk.ComboMakeActive(allWithDef, encoderPort);
+
+               combo_windows_encoder.Sensitive = true;
+       }
+
+       private void createComboLinux() {
+               //string [] serial = Directory.GetFiles("/dev/", "ttyS*");
+               string [] usbSerial = Directory.GetFiles("/dev/", "ttyUSB*");
+               string [] usbSerialMac = Directory.GetFiles("/dev/", "tty.usbserial*");
+               string [] all = Util.AddArrayString(usbSerial, usbSerialMac);
+               
+               string [] def = Util.StringToStringArray(Constants.ChronopicDefaultPortLinux);
+               
+               string [] allWithDef = Util.AddArrayString(def, all);
+
+               UtilGtk.ComboUpdate(combo_linux1, allWithDef, Constants.ChronopicDefaultPortLinux);
+               UtilGtk.ComboUpdate(combo_linux2, allWithDef, Constants.ChronopicDefaultPortLinux);
+               UtilGtk.ComboUpdate(combo_linux3, allWithDef, Constants.ChronopicDefaultPortLinux);
+               UtilGtk.ComboUpdate(combo_linux4, allWithDef, Constants.ChronopicDefaultPortLinux);
+               
+               foreach(ChronopicPortData a in cpd) {
+                       if(a.Num == 1) {
+                               combo_linux1.Active = UtilGtk.ComboMakeActive(combo_linux1, a.Port);
+                               combo_linux1.Changed += new EventHandler (on_combo_changed);
+                               if(a.Connected) {
+                                       UtilGtk.ComboDelThisValue(combo_linux2, a.Port);
+                                       UtilGtk.ComboDelThisValue(combo_linux3, a.Port);
+                                       UtilGtk.ComboDelThisValue(combo_linux4, a.Port);
+                               }
+                       } else if(a.Num == 2) {
+                               combo_linux2.Active = UtilGtk.ComboMakeActive(combo_linux2, a.Port);
+                               combo_linux2.Changed += new EventHandler (on_combo_changed);
+                               if(a.Connected) {
+                                       UtilGtk.ComboDelThisValue(combo_linux3, a.Port);
+                                       UtilGtk.ComboDelThisValue(combo_linux4, a.Port);
+                               }
+                       } else if(a.Num == 3) {
+                               combo_linux3.Active = UtilGtk.ComboMakeActive(combo_linux3, a.Port);
+                               combo_linux3.Changed += new EventHandler (on_combo_changed);
+                               if(a.Connected)
+                                       UtilGtk.ComboDelThisValue(combo_linux4, a.Port);
+                       } else { //4
+                               combo_linux4.Active = UtilGtk.ComboMakeActive(combo_linux4, a.Port);
+                               combo_linux4.Changed += new EventHandler (on_combo_changed);
+                       }
+               }
+               
+               //encoder
+               //this reduces the callbacks of combo change
+               combo_linux_encoder.Sensitive = false;
+
+               UtilGtk.ComboUpdate(combo_linux_encoder, allWithDef, encoderPort);
+
+               combo_linux_encoder.Changed += new EventHandler (on_combo_changed);
+
+               combo_linux_encoder.Active = UtilGtk.ComboMakeActive(allWithDef, encoderPort);
+
+               combo_linux_encoder.Sensitive = true;
+       }
+       
+       private void on_combo_changed(object o, EventArgs args) {
+               ComboBox combo = o as ComboBox;
+               if (o == null)
+                       return;
+
+               //combo is not sensitive when it has been connected
+               //this helps to have button_connect with correct sensitiveness after close window
+               //also help to not have lots of callbacks coming here about encoder combos
+               if(! combo.Sensitive)
+                       return;
+
+               bool portOk = true;
+               if(UtilGtk.ComboGetActive(combo) == Constants.ChronopicDefaultPortWindows ||
+                               UtilGtk.ComboGetActive(combo) == Constants.ChronopicDefaultPortLinux) 
+                       portOk = false;
+
+               if (o == combo_linux1 || o == combo_windows1) 
+                       button_connect_cp1.Sensitive = portOk;
+               else if (o == combo_linux2 || o == combo_windows2) 
+                       button_connect_cp2.Sensitive = portOk;
+               else if (o == combo_linux3 || o == combo_windows3) 
+                       button_connect_cp3.Sensitive = portOk;
+               else if (o == combo_linux4 || o == combo_windows4) 
+                       button_connect_cp4.Sensitive = portOk;
+               else if (o == combo_windows_encoder) {
+                       combo_windows_encoder.Changed -= new EventHandler (on_combo_changed);
+                       encoderPort = UtilGtk.ComboGetActive(combo);
+               } else if (o == combo_linux_encoder) {
+                       combo_linux_encoder.Changed -= new EventHandler (on_combo_changed);
+                       encoderPort = UtilGtk.ComboGetActive(combo);
+               }
+       }
+       
+       private void connectingInfoShow() {
+               textview_ports_found_explanation.Buffer = UtilGtk.TextViewPrint(
+                               Catalog.GetString("If you just plugged Chronopic cable and expected port is 
not listed, close and open again this window.") + "\n" + 
+                               Catalog.GetString("If you have problems connecting with Chronopic, press help 
button.")  
+                               //saferPorts
+                               );
+       }
+       private void connectingInfoHide() {
+               textview_ports_found_explanation.Buffer = UtilGtk.TextViewPrint("");
+       }
+
+       private void chronopicAtStart(object o, EventArgs args) {
+               //make active menuitem chronopic, and this
+               //will raise other things
+//             menuitem_chronopic.Active = true;
+               LogB.Information("CP AT START from gui/chronopic.cs");
+       }
+
+
+       protected bool PulseGTK ()
+       {
+               if(needUpdateChronopicWin || ! thread.IsAlive) {
+                       LogB.ThreadEnding();
+                       fakeConnectionButton.Click();
+                       pulseEnd();
+
+                       LogB.ThreadEnded();
+                       return false;
+               }
+               //need to do this, if not it crashes because chronopicConnectionWin gets died by thread ending
+               //chronopicConnectionWin = ChronopicConnection.Show();
+               //chronopicConnectionWin.Pulse();
+               progressbar.Pulse();
+               
+               Thread.Sleep (50);
+               LogB.Debug(thread.ThreadState.ToString());
+               return true;
+       }
+
+       private void pulseEnd() {
+               button_cancel.Sensitive = false;
+               connecting = false;
+               fakeWindowDone.Click();
+       }
+                       
+       private void updateChronopicWin(bool state, string message) {
+               LogB.Information("updateChronopicWin-1");
+
+               //need to do this, if not it crashes because chronopicConnectionWin gets died by thread ending
+               //chronopicConnectionWin = ChronopicConnection.Show();
+
+               LogB.Information("updateChronopicWin-2");
+               if(state) {
+                       //chronopicConnectionWin.Connected(message);
+                       sensitivityConnected(message);
+                       progressbar.Fraction = 1.0;
+               }
+               else
+                       //chronopicConnectionWin.Disconnected(message);
+                       sensitivityDisconnected(message);
+               
+               needUpdateChronopicWin = false;
+       }
+       
+       private void sensitivityConnected(string message) {
+               LogB.Information("CONNECTED!!");
+               label_title.Text = message;
+               label_title.UseMarkup = true;
+               button_cancel.Sensitive = false;
+               check_multitest_show.Sensitive = true;
+       }
+
+       private void sensitivityDisconnected(string message) {
+               LogB.Information("DISCONNECTED!!");
+               label_title.Text = message;
+               button_cancel.Sensitive = false;
+               check_multitest_show.Sensitive = false;
+       }
+               
+       private void on_button_help_ports_clicked (object o, EventArgs args) {
+               new HelpPorts();
+       }
+
+       private void on_check_multichronopic_show_clicked(object o, EventArgs args) {
+               table_multi_chronopic.Visible = check_multichronopic_show.Active;
+       }
+
+       private void on_button_connect_cp_clicked (object o, EventArgs args) {
+               if (o == null)
+                       return;
+
+               if(isWindows){
+                       if (o == button_connect_cp1) 
+                               ((ChronopicPortData) cpd[0]).Port = UtilGtk.ComboGetActive(combo_windows1);
+                       else if (o == button_connect_cp2) 
+                               ((ChronopicPortData) cpd[1]).Port = UtilGtk.ComboGetActive(combo_windows2);
+                       else if (o == button_connect_cp3) 
+                               ((ChronopicPortData) cpd[2]).Port = UtilGtk.ComboGetActive(combo_windows3);
+                       else if (o == button_connect_cp4) 
+                               ((ChronopicPortData) cpd[3]).Port = UtilGtk.ComboGetActive(combo_windows4);
+               }
+               else {
+                       if (o == button_connect_cp1) 
+                               ((ChronopicPortData) cpd[0]).Port = UtilGtk.ComboGetActive(combo_linux1);
+                       else if (o == button_connect_cp2) 
+                               ((ChronopicPortData) cpd[1]).Port = UtilGtk.ComboGetActive(combo_linux2);
+                       else if (o == button_connect_cp3) 
+                               ((ChronopicPortData) cpd[2]).Port = UtilGtk.ComboGetActive(combo_linux3);
+                       else if (o == button_connect_cp4) 
+                               ((ChronopicPortData) cpd[3]).Port = UtilGtk.ComboGetActive(combo_linux4);
+               }
+               
+               if (o == button_connect_cp1) 
+                       currentCp = 1;
+               else if (o == button_connect_cp2) 
+                       currentCp = 2;
+               else if (o == button_connect_cp3) 
+                       currentCp = 3;
+               else // if (o == button_connect_cp4) 
+                       currentCp = 4;
+
+               prepareChronopicConnection();
+       }
+       
+       private void on_button_help_clicked (object o, EventArgs args) {
+               LogB.Information("HELP");
+               new HelpPorts();
+       }
+       
+       public void SerialPortsCloseIfNeeded() {
+               if(sp != null && sp.IsOpen) {
+                       LogB.Information("Closing sp");
+                       sp.Close();
+               }
+       }
+
+
+       // Chronopic Automatic Firmware ---------------
+       
+       private void on_check_multitest_show_clicked (object o, EventArgs args) 
+       {
+               table_chronopic_auto.Visible = check_multitest_show.Active;
+       }
+
+       private void on_button_auto_check_auto_clicked (object o, EventArgs args)
+       {
+               ChronopicAuto ca = new ChronopicAutoCheck();
+               label_auto_check.Text = ca.Read(sp);
+       }       
+
+       private void on_button_auto_check_debounce_clicked (object o, EventArgs args)
+       {
+               ChronopicAuto ca = new ChronopicAutoCheckDebounce();
+               label_auto_check_debounce.Text = ca.Read(sp);
+       }       
+
+       private void on_button_auto_change_debounce_clicked (object o, EventArgs args)
+       {
+               ChronopicAuto ca = new ChronopicAutoChangeDebounce();
+               ca.Write(sp, (int) spin_auto_change_debounce.Value);
+               
+               ca = new ChronopicAutoCheckDebounce();
+               label_auto_change_debounce.Text = ca.Read(sp);
+       }       
+       
+       private void on_button_auto_check_help_clicked (object o, EventArgs args) 
+       {
+               new DialogMessage(Constants.MessageTypes.INFO, 
+                               "50 ms recommended for jumps." + "\n" + 
+                               "10 ms recommended for runs.");
+       }
+
+       private void on_button_auto_change_help_clicked (object o, EventArgs args) 
+       {
+               new DialogMessage(Constants.MessageTypes.INFO, 
+                               "Minimum value will be 50 ms again when user unplugs USB cable.");
+       }
+       
+       
+       //called from gui/chronojump.cs
+       //done here because sending the SP is problematic on windows
+       public string CheckAuto (out bool isChronopicAuto)
+       {
+               ChronopicAuto ca = new ChronopicAutoCheck();
+
+               string str = ca.Read(sp);
+               
+               isChronopicAuto = ca.IsChronopicAuto;
+
+               return str;
+       }       
+       public int ChangeMultitestFirmware (int debounceChange) 
+       {
+               LogB.Information("change_multitest_firmware 3 a");
+               try {
+                       //write change
+                       ChronopicAuto ca = new ChronopicAutoChangeDebounce();
+                       ca.Write(sp, debounceChange);
+
+                       //read if ok
+                       string ms = "";
+                       bool success = false;
+                       int tryNum = 7; //try to connect seven times
+                       do {
+                               ca = new ChronopicAutoCheckDebounce();
+                               ms = ca.Read(sp);
+
+                               if(ms.Length == 0)
+                                       LogB.Error("multitest firmware. ms is null");
+                               else if(ms[0] == '-') //is negative
+                                       LogB.Error("multitest firmware. ms = " + ms);
+                               else
+                                       success = true;
+                               tryNum --;
+                       } while (! success && tryNum > 0);
+
+                       LogB.Debug("multitest firmware. ms = " + ms);
+
+                       if(ms == "50 ms")
+                               return 50;
+                       else if(ms == "10 ms")
+                               return 10;
+               } catch {
+                       LogB.Error("Could not change debounce");
+               }
+                       
+               return -1;
+       }
+
+
+       // end of Chronopic Automatic Firmware ---------------
+
+
+       void prepareChronopicConnection() {
+               check_multitest_show.Sensitive = false;
+               frame_connection.Visible = true;
+               
+               label_title.Text = Catalog.GetString("Please touch the platform or click Chronopic 
<i>TEST</i> button");
+               label_title.UseMarkup = true;
+                       
+               button_cancel.Sensitive = true;
+               
+               fakeConnectionButton = new Gtk.Button();
+               fakeConnectionButton.Clicked += new EventHandler(on_chronopic_connection_ended);
+
+               connecting = true;
+               needUpdateChronopicWin = false;
+               thread = new Thread(new ThreadStart(waitChronopicStart));
+               GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+
+               LogB.ThreadStart();
+               thread.Start(); 
+       }
+
+       static Chronopic cpDoing;       
+       protected void waitChronopicStart () 
+       {
+               if(currentCp == 1) {
+               //      simulated = false;
+               //      SqlitePreferences.Update("simulated", simulated.ToString(), false);
+                       if(connected)
+                               return;
+               }
+       
+               SerialPort sp2;
+               SerialPort sp3;
+               SerialPort sp4;
+
+               string message = "";
+               string myPort = "";
+               bool success = false;
+                       
+               if(currentCp == 1) {
+                       myPort = ((ChronopicPortData) cpd[0]).Port;
+                       cpDoing = cp;
+                       connected = chronopicInit.Do(currentCp, out cpDoing, out sp, platformState, myPort, 
out message, out success);
+                       cp = cpDoing;
+                       if(success)
+                               connectionSucceded(1, true);
+               }
+               else if(currentCp == 2) {
+                       myPort = ((ChronopicPortData) cpd[1]).Port;
+                       cpDoing = cp2;
+                       connected = chronopicInit.Do(currentCp, out cpDoing, out sp2, platformState2, myPort, 
out message, out success);
+                       cp2 = cpDoing;
+                       if(success)
+                               connectionSucceded(2, true);
+               }
+               else if(currentCp == 3) {
+                       myPort = ((ChronopicPortData) cpd[2]).Port;
+                       cpDoing = cp3;
+                       connected = chronopicInit.Do(currentCp, out cpDoing, out sp3, platformState3, myPort, 
out message, out success);
+                       cp3 = cpDoing;
+                       if(success)
+                               connectionSucceded(3, true);
+               }
+               else if(currentCp == 4) {
+                       myPort = ((ChronopicPortData) cpd[3]).Port;
+                       cpDoing = cp4;
+                       connected = chronopicInit.Do(currentCp, out cpDoing, out sp4, platformState4, myPort, 
out message, out success);
+                       cp4 = cpDoing;
+                       if(success)
+                               connectionSucceded(4, true);
+               }
+               
+
+               LogB.Information(string.Format("wait_chronopic_start {0}", message));
+                       
+               if(success) {
+                       Util.PlaySound(Constants.SoundTypes.GOOD, volumeOn);
+                       updateChronopicWinValuesState= true; //connected
+                       updateChronopicWinValuesMessage= message;
+               } else {
+                       Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
+                       updateChronopicWinValuesState= false; //disconnected
+                       updateChronopicWinValuesMessage= message;
+               }
+
+               foreach(ChronopicPortData a in cpd)
+                       LogB.Information(a.Num + ", " + a.Port + ", " + a.Connected);
+
+               needUpdateChronopicWin = true;
+       }
+
+       private void connectionSucceded(int port, bool playSound)
+       {
+               string myPort = ((ChronopicPortData) cpd[port -1]).Port;
+               ((ChronopicPortData) cpd[port -1]).Connected=true;
+
+               if(port == 1) {
+                       button_connect_cp1.Sensitive = false;
+                       image_cp1_no.Hide();
+                       image_cp1_yes.Show();
+
+                       if(isWindows) {
+                               combo_windows1.Sensitive = false;
+                               combo_windows2.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_windows2, myPort);
+                               combo_windows2.Active = 0; //first option
+                               UtilGtk.ComboDelThisValue(combo_windows3, myPort);
+                               combo_windows3.Active = 0;
+                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
+                               combo_windows4.Active = 0;
+                       } else {
+                               combo_linux1.Sensitive = false;
+                               combo_linux2.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_linux2, myPort);
+                               combo_linux2.Active = 0; //first option
+                               UtilGtk.ComboDelThisValue(combo_linux3, myPort);
+                               combo_linux3.Active = 0;
+                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
+                               combo_linux4.Active = 0;
+                       }
+               }
+               else if(port == 2) {
+                       button_connect_cp2.Sensitive = false;
+                       image_cp2_no.Hide();
+                       image_cp2_yes.Show();
+
+                       if(isWindows) {
+                               combo_windows2.Sensitive = false;
+                               combo_windows3.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_windows3, myPort);
+                               combo_windows3.Active = 0;
+                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
+                               combo_windows4.Active = 0;
+                       } else {
+                               combo_linux2.Sensitive = false;
+                               combo_linux3.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_linux3, myPort);
+                               combo_linux3.Active = 0;
+                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
+                               combo_linux4.Active = 0;
+                       }
+               }
+               else if(port == 3) {
+                       button_connect_cp3.Sensitive = false;
+                       image_cp3_no.Hide();
+                       image_cp3_yes.Show();
+
+                       if(isWindows) {
+                               combo_windows3.Sensitive = false;
+                               combo_windows4.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_windows4, myPort);
+                               combo_windows4.Active = 0;
+                       } else {
+                               combo_linux3.Sensitive = false;
+                               combo_linux4.Sensitive = true;
+                               UtilGtk.ComboDelThisValue(combo_linux4, myPort);
+                               combo_linux4.Active = 0;
+                       }
+               }
+               else if(port == 4) {
+                       button_connect_cp4.Sensitive = false;
+                       image_cp4_no.Hide();
+                       image_cp4_yes.Show();
+
+                       if(isWindows) 
+                               combo_windows4.Sensitive = false;
+                       else 
+                               combo_linux4.Sensitive = false;
+               }
+                       
+
+               connectingInfoHide();
+               frame_connection.Visible = true;
+               updateChronopicWin(true, Catalog.GetString("connected"));
+               if(playSound)           
+                       Util.PlaySound(Constants.SoundTypes.GOOD, volumeOn);
+               updateChronopicWinValuesState= true; //connected
+       }
+
+       private void on_chronopic_connection_ended(object o, EventArgs args) {
+               updateChronopicWin(updateChronopicWinValuesState, updateChronopicWinValuesMessage);
+       }
+
+
+       private void on_button_cancel_clicked (object o, EventArgs args) {
+               LogB.Information("cancelled-----");
+               //fakeButtonCancelled.Click(); //just to show message of crashing on windows exiting
+               
+               button_cancel.Sensitive = false;
+               
+               cpDoing.AbortFlush = true;
+               chronopicInit.CancelledByUser = true;
+
+               //kill the chronopicInit.Do function that is waiting event 
+               //thread.Abort();
+               //http://stackoverflow.com/questions/2853072/thread-does-not-abort-on-application-closing
+               //LogB.Debug(thread.ThreadState.ToString());
+               //thread.IsBackground = true;
+               
+               //try to solve windows problems when a chronopic connection was cancelled
+               //LogB.Debug(thread.ThreadState.ToString());
+               //thread.Join(1000);
+               //LogB.Debug(thread.ThreadState.ToString());
+
+               
+               updateChronopicWinValuesState= false; //disconnected
+               updateChronopicWinValuesMessage= Catalog.GetString("Cancelled by user");
+               needUpdateChronopicWin = true;
+       }
+       
+       void on_button_close_clicked (object o, EventArgs args)
+       {
+               if(connecting)
+                       button_cancel.Click();
+
+               LogB.Information("CLOSE");
+               fakeWindowDone.Click();
+               ChronopicWindowBox.chronopic_window.Hide();
+       }
+
+       void on_delete_event (object o, DeleteEventArgs args)
+       {
+               //nice: this makes windows no destroyed, then it works like button_close
+               fakeWindowDone.Click();
+               
+               if(connecting)
+                       button_cancel.Click();
+
+               args.RetVal = true;
+               ChronopicWindowBox.chronopic_window.Hide();
+       }
+
+       public bool IsConnected(int numCP) {
+               //int count = 1;
+               //foreach(ChronopicPortData a in cpd) 
+               //      LogB.InformationLine(a.Num + ", " + a.Port + ", " + a.Connected);
+               return ((ChronopicPortData) cpd[numCP]).Connected;
+       }
+
+       public int NumConnected() {
+               int count = 0;
+               foreach(ChronopicPortData a in cpd) 
+                       if(a.Connected)
+                               count ++;
+               return count;
+       }
+
+       public string GetContactsFirstPort() {
+               return ((ChronopicPortData) cpd[0]).Port;
+       }
+
+       public string GetEncoderPort() {
+               /*
+               if(isWindows)
+                       return UtilGtk.ComboGetActive(combo_windows_encoder);
+               else
+                       return UtilGtk.ComboGetActive(combo_linux_encoder);
+                       */
+               /*
+                * better like this because this can be created from Create
+                * and readed from the software
+                * without needing to define the combos (from View)
+                */
+               return encoderPort;
+       }
+       
+       public void CreateSPifNeeded(string port) 
+       {
+               if(sp == null)
+                       sp = new SerialPort(port);
+       }
+
+
+       public Chronopic CP {
+               get { return cp; }
+       }
+
+       public Chronopic CP2 {
+               get { return cp2; }
+       }
+
+       public Chronopic CP3 {
+               get { return cp3; }
+       }
+
+       public Chronopic CP4 {
+               get { return cp4; }
+       }
+       
+       public SerialPort SP {
+               get { return sp; }
+       }
+       
+       public Chronopic.Plataforma PlatformState {     //on (in platform), off (jumping), or unknow
+               get { return platformState; }
+       }
+
+
+       //connected to a Chronopic      
+       public bool Connected {
+               get { return connected; }
+               set { connected = value; }
+       }
+       
+       public Button FakeWindowDone {
+               get { return fakeWindowDone; }
+       }
+
+       //public Gtk.Button FakeButtonCancelled {
+       //      get { return fakeButtonCancelled; }
+       //}
+
+}
diff --git a/src/gui/movingStartWindow.cs b/src/gui/movingStartWindow.cs
index e9eb229..a016cc9 100644
--- a/src/gui/movingStartWindow.cs
+++ b/src/gui/movingStartWindow.cs
@@ -1,173 +1,173 @@
-/*
- * This file is part of ChronoJump
- *
- * Chronojump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * Chronojump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
- */
-
-
-using System;
-using Gtk;
-
-/*
- * Unused because moving doesn't look nice on big buttons, store here for the future
- *
-public partial class ChronoJumpWindow 
-{
-       [Widget] Gtk.HBox hbox_start_test;
-       [Widget] Gtk.Alignment alignment_start_test_l;
-       [Widget] Gtk.Alignment alignment_start_test_m;
-       [Widget] Gtk.Alignment alignment_start_test_r;
-       [Widget] Gtk.Button button_start_test_l;
-       [Widget] Gtk.Button button_start_test_m;
-       [Widget] Gtk.Button button_start_test_r;
-
-       MovingStartButton msb_l;        
-       MovingStartButton msb_m;        
-       MovingStartButton msb_r;        
-       int msb_l_pos;
-       int msb_m_pos;
-       int msb_r_pos;
-       bool timerStartTest_l;
-       bool timerStartTest_m;
-       bool timerStartTest_r;
-
-       private void moveStartTestInitial() 
-       {
-               int emptySpace = hbox_start_test.Allocation.Width - 
-                       (button_start_test_l.Allocation.Width + button_start_test_m.Allocation.Width + 
button_start_test_r.Allocation.Width);
-               int leftSpace = Convert.ToInt32(emptySpace / 4); //4: left, between 1-2, between 2-3, right
-               msb_l_pos = leftSpace;
-               msb_m_pos = leftSpace;
-               msb_r_pos = leftSpace;
-               alignment_start_test_l.SetPadding(0,0,Convert.ToUInt32(msb_l_pos),0);
-               alignment_start_test_m.SetPadding(0,0,Convert.ToUInt32(msb_m_pos),0);
-               alignment_start_test_r.SetPadding(0,0,Convert.ToUInt32(msb_r_pos),0);
-       }
-       
-       private void on_alignment_start_l_clicked(object o, EventArgs args)
-       {
-               msb_m = new MovingStartButton(msb_m_pos, 
-                               //600, 
-                               hbox_start_test.Allocation.Width - button_start_test_m.Allocation.Width - 
button_start_test_r.Allocation.Width,
-                               MovingStartButton.Dirs.R);
-               timerStartTest_l = true;
-               GLib.Timeout.Add(1, new GLib.TimeoutHandler(OnTimerStartTest_l));
-       }
-       //moving m to right will move also r, make him move to left until they collide
-       bool OnTimerStartTest_l()
-       {
-               if (! timerStartTest_l)
-                       return false;
-
-               if(msb_m != null)
-                       msb_m.Next();
-                       
-               if(msb_m.Moving) {
-                       msb_m_pos = msb_m.Pos;
-
-                       if( msb_r_pos - msb_m.Speed >= 1)
-                               msb_r_pos -= msb_m.Speed;
-                       else
-                               msb_r_pos = 1;
-
-                       alignment_start_test_m.SetPadding(0,0,Convert.ToUInt32(msb_m_pos),0);
-                       alignment_start_test_r.SetPadding(0,0,Convert.ToUInt32(msb_r_pos),0);
-
-                       LogB.Information("mpos: " + msb_m.Pos + "; mspeed: " + msb_m.Speed + "; rpos: " + 
msb_r_pos);
-                       return true;
-               } else
-                       return false;
-       }
-       
-       private void on_alignment_start_m_clicked(object o, EventArgs args)
-       {
-               msb_l = new MovingStartButton(msb_l_pos, 1, MovingStartButton.Dirs.L);
-               timerStartTest_m = true;
-               GLib.Timeout.Add(1, new GLib.TimeoutHandler(OnTimerStartTest_m));
-       }
-       //this will move l left, m right to maintain position, r right to the end
-       bool OnTimerStartTest_m()
-       {
-               if (! timerStartTest_m)
-                       return false;
-
-               if(msb_l != null)
-                       msb_l.Next();
-                       
-               if(msb_l.Moving) {
-                       msb_l_pos = msb_l.Pos;
-
-                       msb_m_pos += msb_l.Speed;
-                       msb_r_pos += msb_l.Speed;
-
-                       alignment_start_test_l.SetPadding(0,0,Convert.ToUInt32(msb_l_pos),0);
-                       alignment_start_test_m.SetPadding(0,0,Convert.ToUInt32(msb_m_pos),0);
-                       alignment_start_test_r.SetPadding(0,0,Convert.ToUInt32(msb_r_pos),0);
-
-                       return true;
-               } else
-                       return false;
-       }
-       
-       private void on_alignment_start_r_clicked(object o, EventArgs args)
-       {
-               msb_m = new MovingStartButton(msb_m_pos, -200, MovingStartButton.Dirs.L);
-               timerStartTest_r = true;
-               GLib.Timeout.Add(1, new GLib.TimeoutHandler(OnTimerStartTest_r));
-       }
-       //moving m to left but when colliding with l, move it also
-       bool OnTimerStartTest_r()
-       {
-               if (! timerStartTest_r)
-                       return false;
-
-               if(msb_m != null)
-                       msb_m.Next();
-                       
-               if(msb_m.Moving) {
-                       int msb_l_pos_old = msb_l_pos;
-                       int msb_m_pos_old = msb_m_pos;
-
-                       msb_m_pos = msb_m.Pos;
-
-                       if(msb_m_pos <= 1) {
-                               msb_m_pos = 1;
-                               msb_l_pos -= msb_m.Speed;
-                       }
-
-                       if(msb_l_pos <= 0) {
-                               timerStartTest_r = false;
-                               return false;
-                       }
-                       
-                       msb_r_pos += (msb_l_pos_old - msb_l_pos) + (msb_m_pos_old - msb_m_pos);
-                       
-                       alignment_start_test_l.SetPadding(0,0,Convert.ToUInt32(msb_l_pos),0);
-                       alignment_start_test_m.SetPadding(0,0,Convert.ToUInt32(msb_m_pos),0);
-                       alignment_start_test_r.SetPadding(0,0,Convert.ToUInt32(msb_r_pos),0);
-
-                       return true;
-               } else
-                       return false;
-       }
-       
-       private void on_alignment_start_reset_clicked(object o, EventArgs args)
-       {
-               moveStartTestInitial();
-       }
-}
-*/
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+
+using System;
+using Gtk;
+
+/*
+ * Unused because moving doesn't look nice on big buttons, store here for the future
+ *
+public partial class ChronoJumpWindow 
+{
+       [Widget] Gtk.HBox hbox_start_test;
+       [Widget] Gtk.Alignment alignment_start_test_l;
+       [Widget] Gtk.Alignment alignment_start_test_m;
+       [Widget] Gtk.Alignment alignment_start_test_r;
+       [Widget] Gtk.Button button_start_test_l;
+       [Widget] Gtk.Button button_start_test_m;
+       [Widget] Gtk.Button button_start_test_r;
+
+       MovingStartButton msb_l;        
+       MovingStartButton msb_m;        
+       MovingStartButton msb_r;        
+       int msb_l_pos;
+       int msb_m_pos;
+       int msb_r_pos;
+       bool timerStartTest_l;
+       bool timerStartTest_m;
+       bool timerStartTest_r;
+
+       private void moveStartTestInitial() 
+       {
+               int emptySpace = hbox_start_test.Allocation.Width - 
+                       (button_start_test_l.Allocation.Width + button_start_test_m.Allocation.Width + 
button_start_test_r.Allocation.Width);
+               int leftSpace = Convert.ToInt32(emptySpace / 4); //4: left, between 1-2, between 2-3, right
+               msb_l_pos = leftSpace;
+               msb_m_pos = leftSpace;
+               msb_r_pos = leftSpace;
+               alignment_start_test_l.SetPadding(0,0,Convert.ToUInt32(msb_l_pos),0);
+               alignment_start_test_m.SetPadding(0,0,Convert.ToUInt32(msb_m_pos),0);
+               alignment_start_test_r.SetPadding(0,0,Convert.ToUInt32(msb_r_pos),0);
+       }
+       
+       private void on_alignment_start_l_clicked(object o, EventArgs args)
+       {
+               msb_m = new MovingStartButton(msb_m_pos, 
+                               //600, 
+                               hbox_start_test.Allocation.Width - button_start_test_m.Allocation.Width - 
button_start_test_r.Allocation.Width,
+                               MovingStartButton.Dirs.R);
+               timerStartTest_l = true;
+               GLib.Timeout.Add(1, new GLib.TimeoutHandler(OnTimerStartTest_l));
+       }
+       //moving m to right will move also r, make him move to left until they collide
+       bool OnTimerStartTest_l()
+       {
+               if (! timerStartTest_l)
+                       return false;
+
+               if(msb_m != null)
+                       msb_m.Next();
+                       
+               if(msb_m.Moving) {
+                       msb_m_pos = msb_m.Pos;
+
+                       if( msb_r_pos - msb_m.Speed >= 1)
+                               msb_r_pos -= msb_m.Speed;
+                       else
+                               msb_r_pos = 1;
+
+                       alignment_start_test_m.SetPadding(0,0,Convert.ToUInt32(msb_m_pos),0);
+                       alignment_start_test_r.SetPadding(0,0,Convert.ToUInt32(msb_r_pos),0);
+
+                       LogB.Information("mpos: " + msb_m.Pos + "; mspeed: " + msb_m.Speed + "; rpos: " + 
msb_r_pos);
+                       return true;
+               } else
+                       return false;
+       }
+       
+       private void on_alignment_start_m_clicked(object o, EventArgs args)
+       {
+               msb_l = new MovingStartButton(msb_l_pos, 1, MovingStartButton.Dirs.L);
+               timerStartTest_m = true;
+               GLib.Timeout.Add(1, new GLib.TimeoutHandler(OnTimerStartTest_m));
+       }
+       //this will move l left, m right to maintain position, r right to the end
+       bool OnTimerStartTest_m()
+       {
+               if (! timerStartTest_m)
+                       return false;
+
+               if(msb_l != null)
+                       msb_l.Next();
+                       
+               if(msb_l.Moving) {
+                       msb_l_pos = msb_l.Pos;
+
+                       msb_m_pos += msb_l.Speed;
+                       msb_r_pos += msb_l.Speed;
+
+                       alignment_start_test_l.SetPadding(0,0,Convert.ToUInt32(msb_l_pos),0);
+                       alignment_start_test_m.SetPadding(0,0,Convert.ToUInt32(msb_m_pos),0);
+                       alignment_start_test_r.SetPadding(0,0,Convert.ToUInt32(msb_r_pos),0);
+
+                       return true;
+               } else
+                       return false;
+       }
+       
+       private void on_alignment_start_r_clicked(object o, EventArgs args)
+       {
+               msb_m = new MovingStartButton(msb_m_pos, -200, MovingStartButton.Dirs.L);
+               timerStartTest_r = true;
+               GLib.Timeout.Add(1, new GLib.TimeoutHandler(OnTimerStartTest_r));
+       }
+       //moving m to left but when colliding with l, move it also
+       bool OnTimerStartTest_r()
+       {
+               if (! timerStartTest_r)
+                       return false;
+
+               if(msb_m != null)
+                       msb_m.Next();
+                       
+               if(msb_m.Moving) {
+                       int msb_l_pos_old = msb_l_pos;
+                       int msb_m_pos_old = msb_m_pos;
+
+                       msb_m_pos = msb_m.Pos;
+
+                       if(msb_m_pos <= 1) {
+                               msb_m_pos = 1;
+                               msb_l_pos -= msb_m.Speed;
+                       }
+
+                       if(msb_l_pos <= 0) {
+                               timerStartTest_r = false;
+                               return false;
+                       }
+                       
+                       msb_r_pos += (msb_l_pos_old - msb_l_pos) + (msb_m_pos_old - msb_m_pos);
+                       
+                       alignment_start_test_l.SetPadding(0,0,Convert.ToUInt32(msb_l_pos),0);
+                       alignment_start_test_m.SetPadding(0,0,Convert.ToUInt32(msb_m_pos),0);
+                       alignment_start_test_r.SetPadding(0,0,Convert.ToUInt32(msb_r_pos),0);
+
+                       return true;
+               } else
+                       return false;
+       }
+       
+       private void on_alignment_start_reset_clicked(object o, EventArgs args)
+       {
+               moveStartTestInitial();
+       }
+}
+*/
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index 277a292..bb75269 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -1,258 +1,258 @@
-/*
- * This file is part of ChronoJump
- *
- * Chronojump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * Chronojump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
- */
-
-
-using System;
-using Gtk;
-using Gdk;
-using Glade;
-using System.IO.Ports;
-using System.IO; //"File" things
-using System.Collections; //ArrayList
-using System.Collections.Generic; //List
-       
-public partial class ChronoJumpWindow 
-{
-       //custom buttons
-       [Widget] Gtk.HBox hbox_encoder_analyze_signal_or_curves;
-                       
-       //Auto-detect
-       [Widget] Gtk.RadioButton radio_autodetect_active;
-       [Widget] Gtk.RadioButton radio_autodetect_inactive;
-       [Widget] Gtk.RadioButton radio_autodetect_discard_first;
-       
-       //RFID
-       [Widget] Gtk.Box hbox_rfid;
-       [Widget] Gtk.Label label_rfid;
-       
-       //better raspberry controls
-       [Widget] Gtk.Entry entry_raspberry_extra_weight;
-       [Widget] Gtk.Box hbox_encoder_capture_extra_mass_no_raspberry;
-       [Widget] Gtk.Box hbox_encoder_capture_extra_mass_raspberry;
-       [Widget] Gtk.HBox hbox_encoder_im_weights_n;
-       
-       //config.EncoderNameAndCapture
-       [Widget] Gtk.Box hbox_encoder_person;
-       [Widget] Gtk.Label label_encoder_person_name;
-       [Widget] Gtk.Button button_encoder_person_change;
-
-       //config.EncoderCaptureShowOnlyBars
-       [Widget] Gtk.Notebook notebook_encoder_capture_main;
-       [Widget] Gtk.VBox vbox_treeview_encoder_at_second_page;
-       
-       //shown when menu is hidden
-       [Widget] Gtk.Button button_preferences_not_menu;
-
-
-       private bool useVideo = true;
-       private Config.AutodetectPortEnum configAutodetectPort = Config.AutodetectPortEnum.ACTIVE;
-
-       private enum linuxTypeEnum { NOTLINUX, LINUX, RASPBERRY, NETWORKS }
-       private linuxTypeEnum linuxType;
-       private bool encoderConfigurationDefinedFromFile = false;
-       private bool encoderUpdateTreeViewWhileCapturing = true;
-               
-       private bool autodetectSignalEnabled = true;
-
-
-       private void configInit() 
-       {
-               //trying new Config class
-               Config config = new Config();
-               config.Read();
-               LogB.Information("Config:\n" + config.ToString());
-                       
-               /*
-                * TODO: do an else to any option
-                * is good to do the else here because user can import a configuration at any time 
-                * and things need to be restored to default position in glade
-                *
-                * But note this has to be executed only if it has changed!!
-                */
-
-               if(config.Maximized)
-                       app1.Maximize();
-               if(config.CustomButtons) {
-                       
-                       //---- capture tab ----
-                       
-                       hbox_encoder_capture_extra_mass_no_raspberry.Visible = false;
-                       hbox_encoder_capture_extra_mass_raspberry.Visible = true;
-               
-                       button_encoder_select.HeightRequest = 40;
-                       //this will make all encoder capture controls taller    
-                       button_encoder_capture.SetSizeRequest(125,60);
-
-                       spin_encoder_im_weights_n.Visible = false;
-                       hbox_encoder_im_weights_n.Visible = true;
-                       
-                       //---- analyze tab ----
-
-                       hbox_encoder_analyze_signal_or_curves.HeightRequest = 40;
-                       button_encoder_analyze.SetSizeRequest(120,40);
-               }
-               if(! config.UseVideo) {
-                       useVideo = false;
-                       alignment_video_encoder.Visible = false;
-               }
-               
-               //Auto-detect stuff
-               configAutodetectPort = config.AutodetectPort;
-
-               autodetectSignalEnabled = false; //do not raise signals that could rewrite the config file 
(loop)
-               
-               if(configAutodetectPort == Config.AutodetectPortEnum.ACTIVE)
-                       radio_autodetect_active.Active = true;
-               else if(configAutodetectPort == Config.AutodetectPortEnum.INACTIVE)
-                       radio_autodetect_inactive.Active = true;
-               else // (configAutodetectPort == Config.AutodetectPortEnum.DISCARDFIRST)
-                       radio_autodetect_discard_first.Active = true;
-
-               autodetectSignalEnabled = true; //activate signals again
-               
-
-               //show only power
-               if(config.OnlyEncoderGravitatory)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY);
-               else if(config.OnlyEncoderInertial)
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERINERTIAL);
-               
-               if(config.EncoderCaptureShowOnlyBars) {
-                       vpaned_encoder_capture_video_and_set_graph.Visible = false;
-                       
-                       vpaned_encoder_main.Remove(alignment_treeview_encoder_capture_curves);
-                       
vbox_treeview_encoder_at_second_page.PackStart(alignment_treeview_encoder_capture_curves);
-                       notebook_encoder_capture_main.ShowTabs = true;
-               } else {
-                       /*
-                        * is good to do the else here because user can import a configuration at any time 
-                        * and things need to be restored to default position in glade
-                        *
-                        * But note this has to be executed only if it has changed!!
-                        */
-                       /*
-                       notebook_encoder_capture_main.ShowTabs = false;
-                       
vbox_treeview_encoder_at_second_page.Remove(alignment_treeview_encoder_capture_curves);
-                       vpaned_encoder_main.PackStart(alignment_treeview_encoder_capture_curves);
-                       */
-               }
-               
-               encoderUpdateTreeViewWhileCapturing = config.EncoderUpdateTreeViewWhileCapturing;
-               
-               if(config.PersonWinHide) {
-                       //vbox_persons.Visible = false;
-                       notebook_session_person.Visible = false;
-                       hbox_encoder_person.Visible = true;
-               }
-               
-               if(config.EncoderAnalyzeHide) {
-                       hbox_encoder_sup_capture_analyze_two_buttons.Visible = false;
-               }
-               
-               if(config.Econf != null) {
-                       encoderConfigurationDefinedFromFile = true;
-                       encoderConfigurationCurrent = config.Econf;
-                       encoderConfigurationGUIUpdate();
-                       //TODO: allow to see full data, but don't allow to change it (Open window content as 
unsensitive)
-               }
-               
-               if(config.SessionMode == Config.SessionModeEnum.UNIQUE) 
-               {
-                       main_menu.Visible = false;
-                       button_preferences_not_menu.Visible = true;
-
-                       if(! Sqlite.Exists(false, Constants.SessionTable, "session")) {
-                               //this creates the session and inserts at DB
-                               currentSession = new Session(
-                                               "session", "", DateTime.Today,  //name, place, dateTime
-                                               Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, 
Constants.LevelUndefinedID,
-                                               "", Constants.ServerUndefinedID); //comments, serverID
-                       } else
-                               currentSession = SqliteSession.SelectByName("session");
-                       
-                       on_load_session_accepted();
-               }
-
-               //TODO
-               //RunScriptOnExit
-
-               /*
-               if(linuxType == linuxTypeEnum.NETWORKS) {
-                       //mostrar directament el power
-                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWER);
-                       
-                       //no mostrar menu
-                       main_menu.Visible = false;
-                       
-                       //no mostrar persones
-                       //vbox_persons.Visible = false;
-                       //TODO: rfid can be here, also machine, maybe weight, other features
-                       //time, gym, ...
-
-                       //show rfid
-                       hbox_rfid.Visible = true;
-
-                       //to test display, just make sensitive the top controls, but beware there's no 
session yet and no person
-                       notebook_sup.Sensitive = true;
-                       hbox_encoder_sup_capture_analyze.Sensitive = true;
-                       notebook_encoder_sup.Sensitive = false;
-               }
-               */
-       }
-
-       public void on_radio_autodetect_active_toggled (object obj, EventArgs args) 
-       {
-               if(autodetectSignalEnabled && radio_autodetect_active.Active) 
-               {
-                       configAutodetectPort = Config.AutodetectPortEnum.ACTIVE;
-                       Config.UpdateField("AutodetectPort", configAutodetectPort.ToString());
-               }
-       }
-       public void on_radio_autodetect_inactive_toggled (object obj, EventArgs args) 
-       {
-               if(autodetectSignalEnabled && radio_autodetect_inactive.Active) 
-               {
-                       configAutodetectPort = Config.AutodetectPortEnum.INACTIVE;
-                       Config.UpdateField("AutodetectPort", configAutodetectPort.ToString());
-               }
-       }
-       public void on_radio_autodetect_discard_first_toggled (object obj, EventArgs args) 
-       {
-               if(autodetectSignalEnabled && radio_autodetect_discard_first.Active) 
-               {
-                       configAutodetectPort = Config.AutodetectPortEnum.DISCARDFIRST;
-                       Config.UpdateField("AutodetectPort", configAutodetectPort.ToString());
-               }
-       }
-
-       //rfid
-       private void rfid_test() {
-               Networks networks = new Networks();
-               networks.Test();
-       }
-       void on_button_rfid_read_clicked (object o, EventArgs args) {
-               string file = "/tmp/chronojump_rfid.txt";
-
-               if(Util.FileExists(file))
-                       label_rfid.Text = Util.ReadFile(file, true);
-       }
-
-}
-
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+
+using System;
+using Gtk;
+using Gdk;
+using Glade;
+using System.IO.Ports;
+using System.IO; //"File" things
+using System.Collections; //ArrayList
+using System.Collections.Generic; //List
+       
+public partial class ChronoJumpWindow 
+{
+       //custom buttons
+       [Widget] Gtk.HBox hbox_encoder_analyze_signal_or_curves;
+                       
+       //Auto-detect
+       [Widget] Gtk.RadioButton radio_autodetect_active;
+       [Widget] Gtk.RadioButton radio_autodetect_inactive;
+       [Widget] Gtk.RadioButton radio_autodetect_discard_first;
+       
+       //RFID
+       [Widget] Gtk.Box hbox_rfid;
+       [Widget] Gtk.Label label_rfid;
+       
+       //better raspberry controls
+       [Widget] Gtk.Entry entry_raspberry_extra_weight;
+       [Widget] Gtk.Box hbox_encoder_capture_extra_mass_no_raspberry;
+       [Widget] Gtk.Box hbox_encoder_capture_extra_mass_raspberry;
+       [Widget] Gtk.HBox hbox_encoder_im_weights_n;
+       
+       //config.EncoderNameAndCapture
+       [Widget] Gtk.Box hbox_encoder_person;
+       [Widget] Gtk.Label label_encoder_person_name;
+       [Widget] Gtk.Button button_encoder_person_change;
+
+       //config.EncoderCaptureShowOnlyBars
+       [Widget] Gtk.Notebook notebook_encoder_capture_main;
+       [Widget] Gtk.VBox vbox_treeview_encoder_at_second_page;
+       
+       //shown when menu is hidden
+       [Widget] Gtk.Button button_preferences_not_menu;
+
+
+       private bool useVideo = true;
+       private Config.AutodetectPortEnum configAutodetectPort = Config.AutodetectPortEnum.ACTIVE;
+
+       private enum linuxTypeEnum { NOTLINUX, LINUX, RASPBERRY, NETWORKS }
+       private linuxTypeEnum linuxType;
+       private bool encoderConfigurationDefinedFromFile = false;
+       private bool encoderUpdateTreeViewWhileCapturing = true;
+               
+       private bool autodetectSignalEnabled = true;
+
+
+       private void configInit() 
+       {
+               //trying new Config class
+               Config config = new Config();
+               config.Read();
+               LogB.Information("Config:\n" + config.ToString());
+                       
+               /*
+                * TODO: do an else to any option
+                * is good to do the else here because user can import a configuration at any time 
+                * and things need to be restored to default position in glade
+                *
+                * But note this has to be executed only if it has changed!!
+                */
+
+               if(config.Maximized)
+                       app1.Maximize();
+               if(config.CustomButtons) {
+                       
+                       //---- capture tab ----
+                       
+                       hbox_encoder_capture_extra_mass_no_raspberry.Visible = false;
+                       hbox_encoder_capture_extra_mass_raspberry.Visible = true;
+               
+                       button_encoder_select.HeightRequest = 40;
+                       //this will make all encoder capture controls taller    
+                       button_encoder_capture.SetSizeRequest(125,60);
+
+                       spin_encoder_im_weights_n.Visible = false;
+                       hbox_encoder_im_weights_n.Visible = true;
+                       
+                       //---- analyze tab ----
+
+                       hbox_encoder_analyze_signal_or_curves.HeightRequest = 40;
+                       button_encoder_analyze.SetSizeRequest(120,40);
+               }
+               if(! config.UseVideo) {
+                       useVideo = false;
+                       alignment_video_encoder.Visible = false;
+               }
+               
+               //Auto-detect stuff
+               configAutodetectPort = config.AutodetectPort;
+
+               autodetectSignalEnabled = false; //do not raise signals that could rewrite the config file 
(loop)
+               
+               if(configAutodetectPort == Config.AutodetectPortEnum.ACTIVE)
+                       radio_autodetect_active.Active = true;
+               else if(configAutodetectPort == Config.AutodetectPortEnum.INACTIVE)
+                       radio_autodetect_inactive.Active = true;
+               else // (configAutodetectPort == Config.AutodetectPortEnum.DISCARDFIRST)
+                       radio_autodetect_discard_first.Active = true;
+
+               autodetectSignalEnabled = true; //activate signals again
+               
+
+               //show only power
+               if(config.OnlyEncoderGravitatory)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERGRAVITATORY);
+               else if(config.OnlyEncoderInertial)
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWERINERTIAL);
+               
+               if(config.EncoderCaptureShowOnlyBars) {
+                       vpaned_encoder_capture_video_and_set_graph.Visible = false;
+                       
+                       vpaned_encoder_main.Remove(alignment_treeview_encoder_capture_curves);
+                       
vbox_treeview_encoder_at_second_page.PackStart(alignment_treeview_encoder_capture_curves);
+                       notebook_encoder_capture_main.ShowTabs = true;
+               } else {
+                       /*
+                        * is good to do the else here because user can import a configuration at any time 
+                        * and things need to be restored to default position in glade
+                        *
+                        * But note this has to be executed only if it has changed!!
+                        */
+                       /*
+                       notebook_encoder_capture_main.ShowTabs = false;
+                       
vbox_treeview_encoder_at_second_page.Remove(alignment_treeview_encoder_capture_curves);
+                       vpaned_encoder_main.PackStart(alignment_treeview_encoder_capture_curves);
+                       */
+               }
+               
+               encoderUpdateTreeViewWhileCapturing = config.EncoderUpdateTreeViewWhileCapturing;
+               
+               if(config.PersonWinHide) {
+                       //vbox_persons.Visible = false;
+                       notebook_session_person.Visible = false;
+                       hbox_encoder_person.Visible = true;
+               }
+               
+               if(config.EncoderAnalyzeHide) {
+                       hbox_encoder_sup_capture_analyze_two_buttons.Visible = false;
+               }
+               
+               if(config.Econf != null) {
+                       encoderConfigurationDefinedFromFile = true;
+                       encoderConfigurationCurrent = config.Econf;
+                       encoderConfigurationGUIUpdate();
+                       //TODO: allow to see full data, but don't allow to change it (Open window content as 
unsensitive)
+               }
+               
+               if(config.SessionMode == Config.SessionModeEnum.UNIQUE) 
+               {
+                       main_menu.Visible = false;
+                       button_preferences_not_menu.Visible = true;
+
+                       if(! Sqlite.Exists(false, Constants.SessionTable, "session")) {
+                               //this creates the session and inserts at DB
+                               currentSession = new Session(
+                                               "session", "", DateTime.Today,  //name, place, dateTime
+                                               Constants.SportUndefinedID, Constants.SpeciallityUndefinedID, 
Constants.LevelUndefinedID,
+                                               "", Constants.ServerUndefinedID); //comments, serverID
+                       } else
+                               currentSession = SqliteSession.SelectByName("session");
+                       
+                       on_load_session_accepted();
+               }
+
+               //TODO
+               //RunScriptOnExit
+
+               /*
+               if(linuxType == linuxTypeEnum.NETWORKS) {
+                       //mostrar directament el power
+                       select_menuitem_mode_toggled(Constants.Menuitem_modes.POWER);
+                       
+                       //no mostrar menu
+                       main_menu.Visible = false;
+                       
+                       //no mostrar persones
+                       //vbox_persons.Visible = false;
+                       //TODO: rfid can be here, also machine, maybe weight, other features
+                       //time, gym, ...
+
+                       //show rfid
+                       hbox_rfid.Visible = true;
+
+                       //to test display, just make sensitive the top controls, but beware there's no 
session yet and no person
+                       notebook_sup.Sensitive = true;
+                       hbox_encoder_sup_capture_analyze.Sensitive = true;
+                       notebook_encoder_sup.Sensitive = false;
+               }
+               */
+       }
+
+       public void on_radio_autodetect_active_toggled (object obj, EventArgs args) 
+       {
+               if(autodetectSignalEnabled && radio_autodetect_active.Active) 
+               {
+                       configAutodetectPort = Config.AutodetectPortEnum.ACTIVE;
+                       Config.UpdateField("AutodetectPort", configAutodetectPort.ToString());
+               }
+       }
+       public void on_radio_autodetect_inactive_toggled (object obj, EventArgs args) 
+       {
+               if(autodetectSignalEnabled && radio_autodetect_inactive.Active) 
+               {
+                       configAutodetectPort = Config.AutodetectPortEnum.INACTIVE;
+                       Config.UpdateField("AutodetectPort", configAutodetectPort.ToString());
+               }
+       }
+       public void on_radio_autodetect_discard_first_toggled (object obj, EventArgs args) 
+       {
+               if(autodetectSignalEnabled && radio_autodetect_discard_first.Active) 
+               {
+                       configAutodetectPort = Config.AutodetectPortEnum.DISCARDFIRST;
+                       Config.UpdateField("AutodetectPort", configAutodetectPort.ToString());
+               }
+       }
+
+       //rfid
+       private void rfid_test() {
+               Networks networks = new Networks();
+               networks.Test();
+       }
+       void on_button_rfid_read_clicked (object o, EventArgs args) {
+               string file = "/tmp/chronojump_rfid.txt";
+
+               if(Util.FileExists(file))
+                       label_rfid.Text = Util.ReadFile(file, true);
+       }
+
+}
+
diff --git a/src/gui/old/chronojumpServerOld.cs b/src/gui/old/chronojumpServerOld.cs
index 925d057..3264ca7 100644
--- a/src/gui/old/chronojumpServerOld.cs
+++ b/src/gui/old/chronojumpServerOld.cs
@@ -1,314 +1,314 @@
-/*
- * This file is part of ChronoJump
- *
- * Chronojump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * Chronojump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
- */
-
-
-using System;
-using Gtk;
-using Gdk;
-using Glade;
-using System.IO.Ports;
-using Mono.Unix;
-using System.IO; //"File" things
-using System.Collections; //ArrayList
-using System.Collections.Generic; //List
-using System.Threading;
-
-public partial class ChronoJumpWindow 
-{
-               
-       /* ---------------------------------------------------------
-        * ----------------  SERVER CALLS --------------------------
-        *  --------------------------------------------------------
-        */
-
-       /* 
-        * SERVER CALLBACKS
-        */
-
-       bool serverEvaluatorDoing;
-       // upload session and it's persons (callback)
-       private void on_server_upload_session_pre (object o, EventArgs args) {
-               /*
-               //evaluator stuff
-               //Server.ServerUploadEvaluator();
-               string evalMessage = "";
-               int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
-               if(evalSID == Constants.ServerUndefinedID) 
-                       evalMessage = Catalog.GetString("Please, first fill evaluator data.");
-               else 
-                       evalMessage = Catalog.GetString("Please, first check evaluator data is ok.");
-               
-//             appbar2.Push ( 1, evalMessage );
-               
-               server_evaluator_data_and_after_upload_session();
-               */
-       }
-
-       private bool connectedAndCanI (string serverAction) {
-               string versionAvailable = Server.Ping(false, "", ""); //false: don't do insertion
-               if(versionAvailable != Constants.ServerOffline) { //false: don't do insertion
-                       if(Server.CanI(serverAction, progVersion))
-                               return true;
-                       else
-                               new DialogMessage(Constants.MessageTypes.WARNING, 
-                                               Catalog.GetString("Your version of Chronojump is too old for 
this.") + "\n\n" + 
-                                               Catalog.GetString("Please, update to new version: ") + 
versionAvailable + "\n");
-               } else 
-                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.ServerOffline);
-
-               return false;
-       }
-
-       private void on_menuitem_server_stats (object o, EventArgs args) {
-               /*
-               if(connectedAndCanI(Constants.ServerActionStats)) {
-                       ChronojumpServer myServer = new ChronojumpServer();
-                       LogB.SQL(myServer.ConnectDatabase());
-
-                       string [] statsServer = myServer.Stats();
-
-                       LogB.SQL(myServer.DisConnectDatabase());
-
-                       string [] statsMine = SqliteServer.StatsMine();
-
-                       new DialogServerStats(statsServer, statsMine);
-               }
-               */
-       }
-       
-       private void on_menuitem_server_query (object o, EventArgs args) {
-               /*
-               if(connectedAndCanI(Constants.ServerActionQuery)) {
-                       ChronojumpServer myServer = new ChronojumpServer();
-                       QueryServerWindow.Show(
-                                       preferences.digitsNumber,
-                                       myServer.SelectEvaluators(true)
-                                       );
-               }
-               */
-       }
-       
-       private void on_server_ping (object o, EventArgs args) {
-               /*
-               string str = Server.Ping(false, progName, progVersion); //don't do insertion (will show 
versionAvailable)
-               //show online or offline (not the next version of client available)
-               if(str != Constants.ServerOffline)
-                       str = Catalog.GetString(Constants.ServerOnline);
-               new DialogMessage(Constants.MessageTypes.INFO, str);
-               */
-       }
-
-       /*      
-       bool uploadSessionAfter;
-
-       //called when after that has to continue with upload session
-       private void server_evaluator_data_and_after_upload_session() {
-//             appbar2.Push ( 1, "" );
-               uploadSessionAfter = true;
-               server_evaluator_data (); 
-       }
-
-       //called when only has to be created/updated the evaluator (not update session)
-       //private void on_menuitem_server_evaluator_data_only (object o, EventArgs args) {
-       //      uploadSessionAfter = false;
-       //      server_evaluator_data (); 
-       //}
-       
-       
-       private void server_evaluator_data () {
-               ServerEvaluator myEval = SqliteServer.SelectEvaluator(1); 
-               evalWin = EvaluatorWindow.Show(myEval);
-               evalWin.FakeButtonAccept.Clicked += new EventHandler(on_evaluator_done);
-       }
-
-       private void on_evaluator_done (object o, EventArgs args) {
-               if(evalWin.Changed) {
-                       string versionAvailable = Server.Ping(false, "", ""); //false: don't do insertion
-                       if(versionAvailable != Constants.ServerOffline) { //false: don't do insertion
-                               ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Do you want 
to upload evaluator data now?"), "", "");
-                               confirmWin.Button_accept.Clicked += new 
EventHandler(on_evaluator_upload_accepted);
-                       } else 
-                               new DialogMessage(Constants.MessageTypes.WARNING, 
-                                               Catalog.GetString("Currently cannot upload.") + "\n\n" + 
Constants.ServerOffline);
-               }
-               else
-                       if(uploadSessionAfter)
-                               select_persons_to_discard ();
-
-       }
-
-       private void on_evaluator_upload_accepted (object o, EventArgs args) {
-               Server.ServerUploadEvaluator();
-               if(uploadSessionAfter)
-                       select_persons_to_discard ();
-       }
-
-       private void select_persons_to_discard () {
-               personNotUploadWin = PersonNotUploadWindow.Show(app1, currentSession.UniqueID);
-               personNotUploadWin.FakeButtonDone.Clicked += new 
EventHandler(on_select_persons_to_discard_done);
-       }
-       
-       private void on_select_persons_to_discard_done (object o, EventArgs args) {
-               server_upload_session();
-       }
-       */
-
-       private void on_menuitem_goto_server_website (object o, EventArgs args) {
-               /*
-               if(UtilAll.IsWindows())
-                       new DialogMessage(Constants.MessageTypes.INFO, 
-                                       "http://www.chronojump.org/server.html"; + "\n" + 
-                                       "http://www.chronojump.org/server_es.html";);
-               else
-                       System.Diagnostics.Process.Start(Constants.ChronojumpWebsite + 
System.IO.Path.DirectorySeparatorChar + "server.html");
-               */
-       }
-
-       /* 
-        * SERVER CODE
-        */
-
-       /*
-       private bool checkPersonsMissingData() 
-       {
-               ArrayList impossibleWeight = new ArrayList(1);
-               ArrayList undefinedCountry = new ArrayList(1); //country is required for server
-               ArrayList undefinedSport = new ArrayList(1);
-               
-               ArrayList notToUpload = SqlitePersonSessionNotUpload.SelectAll(currentSession.UniqueID);
-               ArrayList persons = SqlitePersonSession.SelectCurrentSessionPersons(
-                               currentSession.UniqueID,
-                               false); //means: do not returnPersonAndPSlist
-
-               foreach (Person person in persons) 
-               {
-                       if(! Util.FoundInArrayList(notToUpload, person.UniqueID.ToString())) 
-                       {
-                               //TODO: this is not needed if true at 
SqlitePersonSession.SelectCurrentSessionPersons
-                               PersonSession ps = SqlitePersonSession.Select(person.UniqueID, 
currentSession.UniqueID);
-                               if(ps.Weight <= 10 || ps.Weight >= 300)
-                                       impossibleWeight.Add(person);
-                               if(person.CountryID == Constants.CountryUndefinedID)
-                                       undefinedCountry.Add(person);
-                               if(ps.SportID == Constants.SportUndefinedID)
-                                       undefinedSport.Add(person);
-                               //speciallity and level not required, because person gui obligates to select 
them when sport is selected
-                       }
-               }
-
-               string weightString = "";
-               string countryString = "";
-               string sportString = "";
-               
-               int maxPeopleFail = 7;
-
-               if(impossibleWeight.Count > 0) {
-                       weightString += "\n\n" + Catalog.GetString("<b>Weight</b> of the following persons is 
not ok:") + "\n";
-                       string separator = "";
-                       int count=0;
-                       foreach(Person person in impossibleWeight) {
-                               weightString += separator + person.Name;
-                               separator = ", ";
-                               if(++count >= maxPeopleFail) {
-                                       weightString += "...";
-                                       break;
-                               }
-                       }
-               }
-
-               if(undefinedCountry.Count > 0) {
-                       countryString += "\n\n" + Catalog.GetString("<b>Country</b> of the following persons 
is undefined:") + "\n";
-                       string separator = "";
-                       int count=0;
-                       foreach(Person person in undefinedCountry) {
-                               countryString += separator + person.Name;
-                               separator = ", ";
-                               if(++count >= maxPeopleFail) {
-                                       countryString += "...";
-                                       break;
-                               }
-                       }
-               }
-
-               if(undefinedSport.Count > 0) {
-                       sportString += "\n\n" + Catalog.GetString("<b>Sport</b> of the following persons is 
undefined:") + "\n";
-                       string separator = "";
-                       int count=0;
-                       foreach(Person person in undefinedSport) {
-                               sportString += separator + person.Name;
-                               separator = ", ";
-                               if(++count >= maxPeopleFail) {
-                                       sportString += "...";
-                                       break;
-                               }
-                       }
-               }
-
-               if(weightString.Length > 0 || countryString.Length > 0 || sportString.Length > 0) {
-                       new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Please, fix this 
before uploading:") +
-                                               weightString + countryString + sportString + "\n\n" + 
-                                               Catalog.GetString("Or when upload session again, mark these 
persons as not to be uploaded.")
-                                               );
-                       return true; //data is missing
-               }
-               else
-                       return false; //data is ok
-
-       }
-                       
-       private void server_upload_session () 
-       {
-               int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
-               if(evalSID != Constants.ServerUndefinedID) {
-                       if(!checkPersonsMissingData()) {
-                               string message1 = ""; 
-                               if(currentSession.ServerUniqueID == Constants.ServerUndefinedID) 
-                                       message1 =  
-                                                       Catalog.GetString("Session will be uploaded to 
server.") + "\n" +  
-                                                       Catalog.GetString("Names, date of birth and 
descriptions of persons will be hidden.") + "\n\n" + 
-                                                       Catalog.GetString("You can upload again this session 
if you add more data or persons.");
-                               else
-                                       message1 =  
-                                                       Catalog.GetString("Session has been uploaded to 
server before.") + "\n" +  
-                                                       Catalog.GetString("Uploading new data.");
-
-                               message1 += "\n\n" + Catalog.GetString("All the uploaded data will be 
licensed as:") + 
-                                               "\n<b>" + Catalog.GetString("Creative Commons Attribution 
3.0") + "</b>";
-
-
-                               ConfirmWindow confirmWin = ConfirmWindow.Show(message1, 
-                                                       "<u>http://creativecommons.org/licenses/by/3.0/</u>", 
//label_link
-                                                       Catalog.GetString("Are you sure you want to upload 
this session to server?"));
-                               confirmWin.Button_accept.Clicked += new 
EventHandler(on_server_upload_session_accepted);
-                       }
-               }
-       }
-
-
-       private void on_server_upload_session_accepted (object o, EventArgs args) 
-       {
-               if(connectedAndCanI(Constants.ServerActionUploadSession)) {
-                       Server.InitializeSessionVariables(app1, currentSession, progName, progVersion);
-                       Server.ThreadStart();
-               }
-       }
-       */
-
-}
+/*
+ * This file is part of ChronoJump
+ *
+ * Chronojump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * Chronojump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+
+using System;
+using Gtk;
+using Gdk;
+using Glade;
+using System.IO.Ports;
+using Mono.Unix;
+using System.IO; //"File" things
+using System.Collections; //ArrayList
+using System.Collections.Generic; //List
+using System.Threading;
+
+public partial class ChronoJumpWindow 
+{
+               
+       /* ---------------------------------------------------------
+        * ----------------  SERVER CALLS --------------------------
+        *  --------------------------------------------------------
+        */
+
+       /* 
+        * SERVER CALLBACKS
+        */
+
+       bool serverEvaluatorDoing;
+       // upload session and it's persons (callback)
+       private void on_server_upload_session_pre (object o, EventArgs args) {
+               /*
+               //evaluator stuff
+               //Server.ServerUploadEvaluator();
+               string evalMessage = "";
+               int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
+               if(evalSID == Constants.ServerUndefinedID) 
+                       evalMessage = Catalog.GetString("Please, first fill evaluator data.");
+               else 
+                       evalMessage = Catalog.GetString("Please, first check evaluator data is ok.");
+               
+//             appbar2.Push ( 1, evalMessage );
+               
+               server_evaluator_data_and_after_upload_session();
+               */
+       }
+
+       private bool connectedAndCanI (string serverAction) {
+               string versionAvailable = Server.Ping(false, "", ""); //false: don't do insertion
+               if(versionAvailable != Constants.ServerOffline) { //false: don't do insertion
+                       if(Server.CanI(serverAction, progVersion))
+                               return true;
+                       else
+                               new DialogMessage(Constants.MessageTypes.WARNING, 
+                                               Catalog.GetString("Your version of Chronojump is too old for 
this.") + "\n\n" + 
+                                               Catalog.GetString("Please, update to new version: ") + 
versionAvailable + "\n");
+               } else 
+                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.ServerOffline);
+
+               return false;
+       }
+
+       private void on_menuitem_server_stats (object o, EventArgs args) {
+               /*
+               if(connectedAndCanI(Constants.ServerActionStats)) {
+                       ChronojumpServer myServer = new ChronojumpServer();
+                       LogB.SQL(myServer.ConnectDatabase());
+
+                       string [] statsServer = myServer.Stats();
+
+                       LogB.SQL(myServer.DisConnectDatabase());
+
+                       string [] statsMine = SqliteServer.StatsMine();
+
+                       new DialogServerStats(statsServer, statsMine);
+               }
+               */
+       }
+       
+       private void on_menuitem_server_query (object o, EventArgs args) {
+               /*
+               if(connectedAndCanI(Constants.ServerActionQuery)) {
+                       ChronojumpServer myServer = new ChronojumpServer();
+                       QueryServerWindow.Show(
+                                       preferences.digitsNumber,
+                                       myServer.SelectEvaluators(true)
+                                       );
+               }
+               */
+       }
+       
+       private void on_server_ping (object o, EventArgs args) {
+               /*
+               string str = Server.Ping(false, progName, progVersion); //don't do insertion (will show 
versionAvailable)
+               //show online or offline (not the next version of client available)
+               if(str != Constants.ServerOffline)
+                       str = Catalog.GetString(Constants.ServerOnline);
+               new DialogMessage(Constants.MessageTypes.INFO, str);
+               */
+       }
+
+       /*      
+       bool uploadSessionAfter;
+
+       //called when after that has to continue with upload session
+       private void server_evaluator_data_and_after_upload_session() {
+//             appbar2.Push ( 1, "" );
+               uploadSessionAfter = true;
+               server_evaluator_data (); 
+       }
+
+       //called when only has to be created/updated the evaluator (not update session)
+       //private void on_menuitem_server_evaluator_data_only (object o, EventArgs args) {
+       //      uploadSessionAfter = false;
+       //      server_evaluator_data (); 
+       //}
+       
+       
+       private void server_evaluator_data () {
+               ServerEvaluator myEval = SqliteServer.SelectEvaluator(1); 
+               evalWin = EvaluatorWindow.Show(myEval);
+               evalWin.FakeButtonAccept.Clicked += new EventHandler(on_evaluator_done);
+       }
+
+       private void on_evaluator_done (object o, EventArgs args) {
+               if(evalWin.Changed) {
+                       string versionAvailable = Server.Ping(false, "", ""); //false: don't do insertion
+                       if(versionAvailable != Constants.ServerOffline) { //false: don't do insertion
+                               ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Do you want 
to upload evaluator data now?"), "", "");
+                               confirmWin.Button_accept.Clicked += new 
EventHandler(on_evaluator_upload_accepted);
+                       } else 
+                               new DialogMessage(Constants.MessageTypes.WARNING, 
+                                               Catalog.GetString("Currently cannot upload.") + "\n\n" + 
Constants.ServerOffline);
+               }
+               else
+                       if(uploadSessionAfter)
+                               select_persons_to_discard ();
+
+       }
+
+       private void on_evaluator_upload_accepted (object o, EventArgs args) {
+               Server.ServerUploadEvaluator();
+               if(uploadSessionAfter)
+                       select_persons_to_discard ();
+       }
+
+       private void select_persons_to_discard () {
+               personNotUploadWin = PersonNotUploadWindow.Show(app1, currentSession.UniqueID);
+               personNotUploadWin.FakeButtonDone.Clicked += new 
EventHandler(on_select_persons_to_discard_done);
+       }
+       
+       private void on_select_persons_to_discard_done (object o, EventArgs args) {
+               server_upload_session();
+       }
+       */
+
+       private void on_menuitem_goto_server_website (object o, EventArgs args) {
+               /*
+               if(UtilAll.IsWindows())
+                       new DialogMessage(Constants.MessageTypes.INFO, 
+                                       "http://www.chronojump.org/server.html"; + "\n" + 
+                                       "http://www.chronojump.org/server_es.html";);
+               else
+                       System.Diagnostics.Process.Start(Constants.ChronojumpWebsite + 
System.IO.Path.DirectorySeparatorChar + "server.html");
+               */
+       }
+
+       /* 
+        * SERVER CODE
+        */
+
+       /*
+       private bool checkPersonsMissingData() 
+       {
+               ArrayList impossibleWeight = new ArrayList(1);
+               ArrayList undefinedCountry = new ArrayList(1); //country is required for server
+               ArrayList undefinedSport = new ArrayList(1);
+               
+               ArrayList notToUpload = SqlitePersonSessionNotUpload.SelectAll(currentSession.UniqueID);
+               ArrayList persons = SqlitePersonSession.SelectCurrentSessionPersons(
+                               currentSession.UniqueID,
+                               false); //means: do not returnPersonAndPSlist
+
+               foreach (Person person in persons) 
+               {
+                       if(! Util.FoundInArrayList(notToUpload, person.UniqueID.ToString())) 
+                       {
+                               //TODO: this is not needed if true at 
SqlitePersonSession.SelectCurrentSessionPersons
+                               PersonSession ps = SqlitePersonSession.Select(person.UniqueID, 
currentSession.UniqueID);
+                               if(ps.Weight <= 10 || ps.Weight >= 300)
+                                       impossibleWeight.Add(person);
+                               if(person.CountryID == Constants.CountryUndefinedID)
+                                       undefinedCountry.Add(person);
+                               if(ps.SportID == Constants.SportUndefinedID)
+                                       undefinedSport.Add(person);
+                               //speciallity and level not required, because person gui obligates to select 
them when sport is selected
+                       }
+               }
+
+               string weightString = "";
+               string countryString = "";
+               string sportString = "";
+               
+               int maxPeopleFail = 7;
+
+               if(impossibleWeight.Count > 0) {
+                       weightString += "\n\n" + Catalog.GetString("<b>Weight</b> of the following persons is 
not ok:") + "\n";
+                       string separator = "";
+                       int count=0;
+                       foreach(Person person in impossibleWeight) {
+                               weightString += separator + person.Name;
+                               separator = ", ";
+                               if(++count >= maxPeopleFail) {
+                                       weightString += "...";
+                                       break;
+                               }
+                       }
+               }
+
+               if(undefinedCountry.Count > 0) {
+                       countryString += "\n\n" + Catalog.GetString("<b>Country</b> of the following persons 
is undefined:") + "\n";
+                       string separator = "";
+                       int count=0;
+                       foreach(Person person in undefinedCountry) {
+                               countryString += separator + person.Name;
+                               separator = ", ";
+                               if(++count >= maxPeopleFail) {
+                                       countryString += "...";
+                                       break;
+                               }
+                       }
+               }
+
+               if(undefinedSport.Count > 0) {
+                       sportString += "\n\n" + Catalog.GetString("<b>Sport</b> of the following persons is 
undefined:") + "\n";
+                       string separator = "";
+                       int count=0;
+                       foreach(Person person in undefinedSport) {
+                               sportString += separator + person.Name;
+                               separator = ", ";
+                               if(++count >= maxPeopleFail) {
+                                       sportString += "...";
+                                       break;
+                               }
+                       }
+               }
+
+               if(weightString.Length > 0 || countryString.Length > 0 || sportString.Length > 0) {
+                       new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Please, fix this 
before uploading:") +
+                                               weightString + countryString + sportString + "\n\n" + 
+                                               Catalog.GetString("Or when upload session again, mark these 
persons as not to be uploaded.")
+                                               );
+                       return true; //data is missing
+               }
+               else
+                       return false; //data is ok
+
+       }
+                       
+       private void server_upload_session () 
+       {
+               int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
+               if(evalSID != Constants.ServerUndefinedID) {
+                       if(!checkPersonsMissingData()) {
+                               string message1 = ""; 
+                               if(currentSession.ServerUniqueID == Constants.ServerUndefinedID) 
+                                       message1 =  
+                                                       Catalog.GetString("Session will be uploaded to 
server.") + "\n" +  
+                                                       Catalog.GetString("Names, date of birth and 
descriptions of persons will be hidden.") + "\n\n" + 
+                                                       Catalog.GetString("You can upload again this session 
if you add more data or persons.");
+                               else
+                                       message1 =  
+                                                       Catalog.GetString("Session has been uploaded to 
server before.") + "\n" +  
+                                                       Catalog.GetString("Uploading new data.");
+
+                               message1 += "\n\n" + Catalog.GetString("All the uploaded data will be 
licensed as:") + 
+                                               "\n<b>" + Catalog.GetString("Creative Commons Attribution 
3.0") + "</b>";
+
+
+                               ConfirmWindow confirmWin = ConfirmWindow.Show(message1, 
+                                                       "<u>http://creativecommons.org/licenses/by/3.0/</u>", 
//label_link
+                                                       Catalog.GetString("Are you sure you want to upload 
this session to server?"));
+                               confirmWin.Button_accept.Clicked += new 
EventHandler(on_server_upload_session_accepted);
+                       }
+               }
+       }
+
+
+       private void on_server_upload_session_accepted (object o, EventArgs args) 
+       {
+               if(connectedAndCanI(Constants.ServerActionUploadSession)) {
+                       Server.InitializeSessionVariables(app1, currentSession, progName, progVersion);
+                       Server.ThreadStart();
+               }
+       }
+       */
+
+}
diff --git a/src/gui/preferences.cs b/src/gui/preferences.cs
index 29782fe..941a29e 100644
--- a/src/gui/preferences.cs
+++ b/src/gui/preferences.cs
@@ -1,1215 +1,1215 @@
-/*
- * This file is part of ChronoJump
- *
- * ChronoJump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * ChronoJump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
- */
-
-using System;
-using System.IO;
-using Gdk;
-using Gtk;
-using Glade;
-//using Gnome;
-//using GLib; //for Value
-using System.Text; //StringBuilder
-using System.Collections; //ArrayList
-using Mono.Unix;
-using System.Threading;
-using System.Globalization; //CultureInfo stuff
-
-using System.Diagnostics;  //Stopwatch
-
-
-/*
-using ICSharpCode.SharpZipLib.Tar;
-using ICSharpCode.SharpZipLib.GZip;
-using ICSharpCode.SharpZipLib;
-*/
-
-public class PreferencesWindow {
-       
-       [Widget] Gtk.Window preferences_win;
-       [Widget] Gtk.Notebook notebook;
-
-       //main tab
-       [Widget] Gtk.Button button_data_folder_open;
-
-       [Widget] Gtk.CheckButton check_backup_multimedia_and_encoder;
-       
-       [Widget] Gtk.Button button_db_backup;
-       [Widget] Gtk.Box hbox_backup_doing;
-       [Widget] Gtk.ProgressBar pulsebar;
-
-       
-       //jumps tab     
-       [Widget] Gtk.CheckButton checkbutton_power;
-       [Widget] Gtk.CheckButton checkbutton_stiffness;
-       [Widget] Gtk.CheckButton checkbutton_initial_speed;
-       [Widget] Gtk.CheckButton checkbutton_angle;
-       [Widget] Gtk.CheckButton checkbutton_show_tv_tc_index;
-       [Widget] Gtk.Box hbox_indexes;
-       [Widget] Gtk.RadioButton radiobutton_show_q_index;
-       [Widget] Gtk.RadioButton radiobutton_show_dj_index;
-       [Widget] Gtk.RadioButton radio_elevation_height;
-       [Widget] Gtk.RadioButton radio_elevation_tf;
-       [Widget] Gtk.RadioButton radio_weight_percent;
-       [Widget] Gtk.RadioButton radio_weight_kg;
-       [Widget] Gtk.RadioButton radio_use_heights_on_jump_indexes;
-       [Widget] Gtk.RadioButton radio_do_not_use_heights_on_jump_indexes;
-                       
-       //runs tab      
-       [Widget] Gtk.RadioButton radio_speed_ms;
-       [Widget] Gtk.RadioButton radio_speed_km;
-       [Widget] Gtk.RadioButton radio_runs_speed_start_arrival; 
-       [Widget] Gtk.RadioButton radio_runs_speed_start_leaving; 
-       [Widget] Gtk.Box vbox_runs_prevent_double_contact;
-       [Widget] Gtk.CheckButton checkbutton_runs_prevent_double_contact;
-       [Widget] Gtk.SpinButton spinbutton_runs_prevent_double_contact;
-       [Widget] Gtk.RadioButton radio_runs_prevent_double_contact_first;
-       [Widget] Gtk.RadioButton radio_runs_prevent_double_contact_average;
-       [Widget] Gtk.RadioButton radio_runs_prevent_double_contact_last;
-       [Widget] Gtk.Box vbox_runs_i_prevent_double_contact;
-       [Widget] Gtk.CheckButton checkbutton_runs_i_prevent_double_contact;
-       [Widget] Gtk.SpinButton spinbutton_runs_i_prevent_double_contact;
-       [Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_first;
-       [Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_average;
-       [Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_last;
-       
-       //encoder capture tab
-       [Widget] Gtk.SpinButton spin_encoder_capture_time;
-       [Widget] Gtk.SpinButton spin_encoder_capture_inactivity_end_time;
-       [Widget] Gtk.Box hbox_combo_main_variable;
-       [Widget] Gtk.ComboBox combo_main_variable;
-       [Widget] Gtk.SpinButton spin_encoder_capture_min_height_gravitatory;
-       [Widget] Gtk.SpinButton spin_encoder_capture_min_height_inertial;
-       [Widget] Gtk.CheckButton checkbutton_encoder_capture_fully_extended;
-       [Widget] Gtk.HBox hbox_encoder_capture_fully_extended;
-       [Widget] Gtk.SpinButton spin_encoder_capture_fully_extended;
-       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_best;
-       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_4top;
-       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_all;
-       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_none;
-       [Widget] Gtk.CheckButton check_show_start_and_duration;
-       
-       //encoder other tab
-       [Widget] Gtk.CheckButton checkbutton_encoder_propulsive;
-       [Widget] Gtk.SpinButton spin_encoder_smooth_con;
-       [Widget] Gtk.Label label_encoder_con;
-       [Widget] Gtk.RadioButton radio_encoder_1RM_nonweighted;
-       [Widget] Gtk.RadioButton radio_encoder_1RM_weighted;
-       [Widget] Gtk.RadioButton radio_encoder_1RM_weighted2;
-       [Widget] Gtk.RadioButton radio_encoder_1RM_weighted3;
-
-       //multimedia tab
-       [Widget] Gtk.CheckButton checkbutton_volume;
-       [Widget] Gtk.Box hbox_combo_camera;
-       [Widget] Gtk.ComboBox combo_camera;
-
-       //language tab
-       [Widget] Gtk.Box hbox_combo_language;
-       [Widget] Gtk.ComboBox combo_language;
-       [Widget] Gtk.RadioButton radio_language_detected;
-       [Widget] Gtk.RadioButton radio_language_force;
-       [Widget] Gtk.RadioButton radio_graphs_translate;
-       [Widget] Gtk.RadioButton radio_graphs_no_translate;
-       [Widget] Gtk.Box hbox_need_restart;
-               
-       //advanced tab
-       [Widget] Gtk.ComboBox combo_decimals;
-       [Widget] Gtk.CheckButton checkbutton_ask_deletion;
-       [Widget] Gtk.RadioButton radio_export_latin;
-       [Widget] Gtk.RadioButton radio_export_non_latin;
-       [Widget] Gtk.Label label_advanced_feedback;
-
-
-       [Widget] Gtk.Button button_accept;
-       [Widget] Gtk.Button button_cancel;
-       public Gtk.Button FakeButtonImported;
-       public Gtk.Button FakeButtonDebugModeStart;
-       
-       static PreferencesWindow PreferencesWindowBox;
-       
-       private Preferences preferences; //stored to update SQL if anything changed
-       private Thread thread;
-
-       string databaseURL;
-       string databaseTempURL;
-       
-       ListStore langsStore;
-
-
-       PreferencesWindow () {
-               Glade.XML gladeXML;
-               gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", 
"preferences_win", "chronojump");
-               gladeXML.Autoconnect(this);
-               
-               //put an icon to window
-               UtilGtk.IconWindow(preferences_win);
-
-               //database and log files stuff
-               databaseURL = Util.GetDatabaseDir() + System.IO.Path.DirectorySeparatorChar  + 
"chronojump.db";
-               databaseTempURL = Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar  + 
"chronojump.db";
-               
-               FakeButtonImported = new Gtk.Button();
-               FakeButtonDebugModeStart = new Gtk.Button();
-       }
-       
-       static public PreferencesWindow Show (Preferences preferences, Constants.Menuitem_modes menu_mode)
-       {
-               if (PreferencesWindowBox == null) {
-                       PreferencesWindowBox = new PreferencesWindow ();
-               }
-
-               if(menu_mode != Constants.Menuitem_modes.JUMPSSIMPLE && menu_mode != 
Constants.Menuitem_modes.JUMPSREACTIVE)
-                       PreferencesWindowBox.notebook.GetNthPage(1).Hide(); 
-               if(menu_mode != Constants.Menuitem_modes.RUNSSIMPLE && menu_mode != 
Constants.Menuitem_modes.RUNSINTERVALLIC)
-                       PreferencesWindowBox.notebook.GetNthPage(2).Hide(); 
-               if(menu_mode != Constants.Menuitem_modes.POWERGRAVITATORY && menu_mode != 
Constants.Menuitem_modes.POWERINERTIAL) {
-                       PreferencesWindowBox.notebook.GetNthPage(3).Hide();
-                       PreferencesWindowBox.notebook.GetNthPage(4).Hide();
-               }
-
-               PreferencesWindowBox.preferences = preferences;
-
-               PreferencesWindowBox.createComboLanguage();
-
-               //multimedia tab
-               if(preferences.volumeOn)  
-                       PreferencesWindowBox.checkbutton_volume.Active = true; 
-               else 
-                       PreferencesWindowBox.checkbutton_volume.Active = false; 
-
-               PreferencesWindowBox.createComboCamera(UtilVideo.GetVideoDevices(), 
preferences.videoDeviceNum);
-       
-
-               string [] decs = {"1", "2", "3"};
-               PreferencesWindowBox.combo_decimals.Active = UtilGtk.ComboMakeActive(
-                               decs, preferences.digitsNumber.ToString());
-
-               if(preferences.showPower)
-                       PreferencesWindowBox.checkbutton_power.Active = true; 
-               else
-                       PreferencesWindowBox.checkbutton_power.Active = false; 
-               
-               if(preferences.showStiffness)
-                       PreferencesWindowBox.checkbutton_stiffness.Active = true; 
-               else
-                       PreferencesWindowBox.checkbutton_stiffness.Active = false; 
-               
-               if(preferences.showInitialSpeed)  
-                       PreferencesWindowBox.checkbutton_initial_speed.Active = true; 
-               else 
-                       PreferencesWindowBox.checkbutton_initial_speed.Active = false; 
-               
-               if(preferences.showAngle)  
-                       PreferencesWindowBox.checkbutton_angle.Active = true; 
-               else 
-                       PreferencesWindowBox.checkbutton_angle.Active = false; 
-               
-
-               if(preferences.showQIndex || preferences.showDjIndex) { 
-                       PreferencesWindowBox.checkbutton_show_tv_tc_index.Active = true; 
-                       if(preferences.showQIndex) {
-                               PreferencesWindowBox.radiobutton_show_q_index.Active = true; 
-                               PreferencesWindowBox.radiobutton_show_dj_index.Active = false; 
-                       } else {
-                               PreferencesWindowBox.radiobutton_show_q_index.Active = false; 
-                               PreferencesWindowBox.radiobutton_show_dj_index.Active = true; 
-                       }
-               }
-               else {
-                       PreferencesWindowBox.checkbutton_show_tv_tc_index.Active = false; 
-                       PreferencesWindowBox.hbox_indexes.Hide();
-               }
-
-               if(preferences.askDeletion)  
-                       PreferencesWindowBox.checkbutton_ask_deletion.Active = true; 
-               else 
-                       PreferencesWindowBox.checkbutton_ask_deletion.Active = false; 
-               
-
-               if(preferences.weightStatsPercent)  
-                       PreferencesWindowBox.radio_weight_percent.Active = true; 
-               else 
-                       PreferencesWindowBox.radio_weight_kg.Active = true; 
-               
-
-               if(preferences.heightPreferred)  
-                       PreferencesWindowBox.radio_elevation_height.Active = true; 
-               else 
-                       PreferencesWindowBox.radio_elevation_tf.Active = true; 
-               
-
-               if(preferences.metersSecondsPreferred)  
-                       PreferencesWindowBox.radio_speed_ms.Active = true; 
-               else 
-                       PreferencesWindowBox.radio_speed_km.Active = true; 
-
-
-               if(preferences.runSpeedStartArrival)  
-                       PreferencesWindowBox.radio_runs_speed_start_arrival.Active = true; 
-               else 
-                       PreferencesWindowBox.radio_runs_speed_start_leaving.Active = true; 
-
-
-               //start of double contacts stuff ----
-               PreferencesWindowBox.checkbutton_runs_prevent_double_contact.Active = 
-                       (preferences.runDoubleContactsMode != Constants.DoubleContact.NONE);
-               PreferencesWindowBox.checkbutton_runs_i_prevent_double_contact.Active = 
-                       (preferences.runIDoubleContactsMode != Constants.DoubleContact.NONE);
-
-               PreferencesWindowBox.spinbutton_runs_prevent_double_contact.Value = 
-                       preferences.runDoubleContactsMS;
-               PreferencesWindowBox.spinbutton_runs_i_prevent_double_contact.Value = 
-                       preferences.runIDoubleContactsMS;
-                       
-               if(preferences.runDoubleContactsMode != Constants.DoubleContact.NONE) {
-                       if(preferences.runDoubleContactsMode == Constants.DoubleContact.FIRST)
-                               PreferencesWindowBox.radio_runs_prevent_double_contact_first.Active = true;
-                       else if(preferences.runDoubleContactsMode == Constants.DoubleContact.AVERAGE)
-                               PreferencesWindowBox.radio_runs_prevent_double_contact_average.Active = true;
-                       else // Constants.DoubleContact.LAST  DEFAULT
-                               PreferencesWindowBox.radio_runs_prevent_double_contact_last.Active = true;
-               }
-               if(preferences.runIDoubleContactsMode != Constants.DoubleContact.NONE) {
-                       if(preferences.runIDoubleContactsMode == Constants.DoubleContact.FIRST)
-                               PreferencesWindowBox.radio_runs_i_prevent_double_contact_first.Active = true;
-                       else if(preferences.runIDoubleContactsMode == Constants.DoubleContact.LAST)
-                               PreferencesWindowBox.radio_runs_i_prevent_double_contact_last.Active = true;
-                       else //Constants.DoubleContact.AVERAGE  DEFAULT
-                               PreferencesWindowBox.radio_runs_i_prevent_double_contact_average.Active = 
true;
-               }
-               //---- end of double contacts stuff             
-
-
-               if(preferences.CSVExportDecimalSeparator == "COMMA")
-                       PreferencesWindowBox.radio_export_latin.Active = true; 
-               else
-                       PreferencesWindowBox.radio_export_non_latin.Active = true; 
-
-       
-               //encoder capture -->
-               PreferencesWindowBox.spin_encoder_capture_time.Value = preferences.encoderCaptureTime;
-               PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value = 
preferences.encoderCaptureInactivityEndTime;
-               
-               PreferencesWindowBox.createComboEncoderCaptureMainVariable(
-                               Constants.GetEncoderVariablesCapture(preferences.encoderCaptureMainVariable));
-
-               PreferencesWindowBox.spin_encoder_capture_min_height_gravitatory.Value = 
preferences.encoderCaptureMinHeightGravitatory;
-               PreferencesWindowBox.spin_encoder_capture_min_height_inertial.Value = 
preferences.encoderCaptureMinHeightInertial;
-               PreferencesWindowBox.checkbutton_encoder_capture_fully_extended.Active = 
preferences.encoderCaptureCheckFullyExtended;
-               PreferencesWindowBox.spin_encoder_capture_fully_extended.Value = 
preferences.encoderCaptureCheckFullyExtendedValue;
-               PreferencesWindowBox.hbox_encoder_capture_fully_extended.Visible = 
preferences.encoderCaptureCheckFullyExtended;
-               
-               if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.BEST)
-                       PreferencesWindowBox.radio_encoder_auto_save_curve_best.Active = true;
-               else if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE)
-                       PreferencesWindowBox.radio_encoder_auto_save_curve_4top.Active = true;
-               else if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.ALL)
-                       PreferencesWindowBox.radio_encoder_auto_save_curve_all.Active = true;
-               else
-                       PreferencesWindowBox.radio_encoder_auto_save_curve_none.Active = true;
-       
-               PreferencesWindowBox.check_show_start_and_duration.Active = 
preferences.encoderShowStartAndDuration;
-
-
-               //encoder other -->
-               PreferencesWindowBox.checkbutton_encoder_propulsive.Active = preferences.encoderPropulsive;
-               
-               PreferencesWindowBox.spin_encoder_smooth_con.Value = preferences.encoderSmoothCon;
-
-               if(preferences.encoder1RMMethod == Constants.Encoder1RMMethod.NONWEIGHTED)
-                       PreferencesWindowBox.radio_encoder_1RM_nonweighted.Active = true;
-               else if(preferences.encoder1RMMethod == Constants.Encoder1RMMethod.WEIGHTED)
-                       PreferencesWindowBox.radio_encoder_1RM_weighted.Active = true;
-               else if(preferences.encoder1RMMethod == Constants.Encoder1RMMethod.WEIGHTED2)
-                       PreferencesWindowBox.radio_encoder_1RM_weighted2.Active = true;
-               else //(preferences.encoder1RMMethod == Constants.Encoder1RMMethod.WEIGHTED3)
-                       PreferencesWindowBox.radio_encoder_1RM_weighted3.Active = true;
-
-               //done here and not in glade to be shown with the decimal point of user language        
-               PreferencesWindowBox.label_encoder_con.Text = (0.7).ToString();
-       
-               //language -->
-               if(preferences.language == "")
-                       PreferencesWindowBox.radio_language_detected.Active = true;
-               else
-                       PreferencesWindowBox.radio_language_force.Active = true;
-
-               if(preferences.RGraphsTranslate)
-                       PreferencesWindowBox.radio_graphs_translate.Active = true;
-               else
-                       PreferencesWindowBox.radio_graphs_no_translate.Active = true;
-                       
-               //allow signal to be called
-               PreferencesWindowBox.hbox_language_signalOn = true;
-               
-               if(preferences.useHeightsOnJumpIndexes)
-                       PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active = true;
-               else
-                       PreferencesWindowBox.radio_do_not_use_heights_on_jump_indexes.Active = true;
-                       
-
-               PreferencesWindowBox.preferences_win.Show ();
-               return PreferencesWindowBox;
-       }
-       
-       private void createComboEncoderCaptureMainVariable(string v) {
-               combo_main_variable = ComboBox.NewText ();
-               string [] values = Constants.EncoderVariablesCaptureList;
-               UtilGtk.ComboUpdate(combo_main_variable, values, "");
-               combo_main_variable.Active = UtilGtk.ComboMakeActive(combo_main_variable, v.ToString());
-               
-               hbox_combo_main_variable.PackStart(combo_main_variable, false, false, 0);
-               hbox_combo_main_variable.ShowAll();
-               combo_main_variable.Sensitive = true;
-       }
-
-       
-       private void createComboCamera(string [] devices, int current) {
-               combo_camera = ComboBox.NewText ();
-
-               if(devices.Length == 0) {
-                       devices = Util.StringToStringArray(Constants.CameraNotFound);
-                       current = 0;
-               }
-               
-               UtilGtk.ComboUpdate(combo_camera, devices, "");
-               hbox_combo_camera.PackStart(combo_camera, true, true, 0);
-               hbox_combo_camera.ShowAll();
-
-               if(current >= devices.Length)
-                       current = 0;
-               
-               combo_camera.Active = UtilGtk.ComboMakeActive(devices, devices[current]);
-       }
-               
-       
-       private void on_checkbutton_encoder_capture_fully_extended_toggled(object obj, EventArgs args) {
-               hbox_encoder_capture_fully_extended.Visible = 
checkbutton_encoder_capture_fully_extended.Active;
-       }
-
-
-       // ---- Language stuff
-       
-       private void createComboLanguage() {
-               
-               combo_language = ComboBox.NewText ();
-               fillLanguages();
-
-               hbox_combo_language.PackStart(combo_language, false, false, 0);
-               hbox_combo_language.ShowAll();
-       }
-
-       //from Longomatch ;)
-       //(C) Andoni Morales Alastruey
-       bool hbox_language_signalOn = false;
-       void fillLanguages () {
-               int index = 0, active = 0;
-
-               langsStore = new ListStore(typeof(string), typeof(CultureInfo));
-
-               foreach (CultureInfo lang in UtilLanguage.Languages) {
-                       langsStore.AppendValues(lang.NativeName, lang);
-                       if (preferences.language != "" && lang.Name == preferences.language)
-                               active = index;
-                       index ++;
-               }
-               combo_language.Model = langsStore;
-               combo_language.Active = active;
-               combo_language.Changed += combo_language_changed;
-       }
-
-       private void on_radio_language_toggled (object obj, EventArgs args) {
-               hbox_combo_language.Sensitive = radio_language_force.Active;
-
-               if(hbox_language_signalOn)
-                       hbox_need_restart.Visible = true;
-       }
-       private void on_radio_translate_toggled (object obj, EventArgs args) {
-               if(hbox_language_signalOn)
-                       hbox_need_restart.Visible = true;
-       }
-       private void combo_language_changed (object obj, EventArgs args) {
-               if(hbox_language_signalOn)
-                       hbox_need_restart.Visible = true;
-       }
-
-
-       string getSelectedLanguage()
-       {
-               TreeIter iter;
-               CultureInfo info;
-
-               combo_language.GetActiveIter (out iter);
-               info = (CultureInfo) langsStore.GetValue (iter, 1);
-               if (info == null) {
-                       return "";
-               } else {
-                       return info.Name;
-               }
-       }
-
-       // ---- end of Language stuff
-
-                       
-       private void on_checkbutton_show_tv_tc_index_clicked (object o, EventArgs args) {
-               if(checkbutton_show_tv_tc_index.Active)
-                       hbox_indexes.Show();
-               else
-                       hbox_indexes.Hide();
-       }
-       
-       private void on_checkbutton_runs_prevent_double_contact_toggled (object o, EventArgs args) {
-               vbox_runs_prevent_double_contact.Visible = checkbutton_runs_prevent_double_contact.Active;
-       }
-       private void on_checkbutton_runs_i_prevent_double_contact_toggled (object o, EventArgs args) {
-               vbox_runs_i_prevent_double_contact.Visible = checkbutton_runs_i_prevent_double_contact.Active;
-       }
-
-               
-       void on_button_cancel_clicked (object o, EventArgs args)
-       {
-               PreferencesWindowBox.preferences_win.Hide();
-               PreferencesWindowBox = null;
-       }
-       
-       void on_preferences_delete_event (object o, DeleteEventArgs args)
-       {
-               //do not hide/exit if copyiing
-               if (thread != null && thread.IsAlive)
-                       args.RetVal = true;
-               else {
-                       PreferencesWindowBox.preferences_win.Hide();
-                       PreferencesWindowBox = null;
-               }
-       }
-       
-       void on_button_data_folder_open_clicked (object o, EventArgs args)
-       {
-               System.IO.FileInfo file1 = new System.IO.FileInfo(databaseURL); //potser cal una arrobar 
abans (a windows)
-               System.IO.FileInfo file2 = new System.IO.FileInfo(databaseTempURL); //potser cal una arrobar 
abans (a windows)
-
-               if(file1.Exists)
-                       System.Diagnostics.Process.Start(Util.GetParentDir(false)); 
-               else if(file2.Exists)
-                       System.Diagnostics.Process.Start(Util.GetDatabaseTempDir()); 
-               else
-                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.DatabaseNotFound);
-       }
-       
-       void on_button_db_restore_clicked (object o, EventArgs args)
-       {
-               /*
-                * TODO: problem is database stored is a chronojump.db or a folder (if images and videos were 
saved).
-                * FileChooserAction only lets you use one type
-                * In the future backup db as tgz or similar
-                */
-
-               /*
-               fc = new Gtk.FileChooserDialog(Catalog.GetString("Restore database from:"),
-                               preferences_win,
-                               FileChooserAction.SelectFolder,
-                               Catalog.GetString("Cancel"),ResponseType.Cancel,
-                               Catalog.GetString("Restore"),ResponseType.Accept
-                               );
-
-               ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are you sure you want to 
restore?"));
-               confirmWin.Button_accept.Clicked += new EventHandler(on_overwrite_file_accepted);
-               */
-       }
-
-       
-       void on_button_logs_folder_open_clicked (object o, EventArgs args)
-       {
-               string dir = UtilAll.GetLogsDir();
-               LogB.Information(dir);
-               
-               if( ! new System.IO.DirectoryInfo(dir).Exists) {
-                       try {
-                               Directory.CreateDirectory (dir);
-                       } catch {
-                               new DialogMessage(Constants.MessageTypes.WARNING, 
-                                               Catalog.GetString("Cannot create directory.") + "\n\n" + dir);
-                               return;
-                       }
-               }
-               
-               try {
-                       System.Diagnostics.Process.Start(dir); 
-               }
-               catch {
-                       new DialogMessage(Constants.MessageTypes.WARNING, 
-                                       Constants.DirectoryCannotOpen + "\n\n" + dir);
-               }
-       }
-       
-       void on_button_tmp_folder_open_clicked (object o, EventArgs args)
-       {
-               string dir = UtilAll.GetTempDir(); //potser cal una arrobar abans (a windows)
-               System.IO.FileInfo fInfo = new System.IO.FileInfo(dir);
-
-               try {
-                       if(fInfo.Exists)
-                               System.Diagnostics.Process.Start(dir);
-               } catch {
-                       new DialogMessage(Constants.MessageTypes.WARNING, 
-                                       Constants.DirectoryCannotOpen + "\n\n" + dir);
-               }
-
-               LogB.Warning(dir);
-       }
-
-
-
-       string fileDB;
-       string fileCopy;
-       Gtk.FileChooserDialog fc;
-       void on_button_db_backup_clicked (object o, EventArgs args)
-       {
-               System.IO.FileInfo file1 = new System.IO.FileInfo(databaseURL); //potser cal una arrobar 
abans (a windows)
-               System.IO.FileInfo file2 = new System.IO.FileInfo(databaseTempURL); //potser cal una arrobar 
abans (a windows)
-               fileDB = "";
-
-               long length1 = 0;
-               if(file1.Exists)
-                       length1 = file1.Length;
-               long length2 = 0;
-               if(file2.Exists)
-                       length2 = file2.Length;
-               
-               if(length1 == 0 && length2 == 0) 
-                       new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error. Cannot 
find database."));
-               else if(length1 > length2)
-                       fileDB = databaseURL;
-               else
-                       fileDB = databaseTempURL;
-
-               fc = new Gtk.FileChooserDialog(Catalog.GetString("Copy database to:"),
-                               preferences_win,
-                               FileChooserAction.SelectFolder,
-                               Catalog.GetString("Cancel"),ResponseType.Cancel,
-                               Catalog.GetString("Copy"),ResponseType.Accept
-                               );
-
-               if (fc.Run() == (int)ResponseType.Accept) 
-               {
-                       //if multimedia_and_encoder, then copy the folder. If not checked, then copy only the 
db file
-                       if(check_backup_multimedia_and_encoder.Active)
-                               fileCopy = fc.Filename + Path.DirectorySeparatorChar + "chronojump";
-                       else
-                               fileCopy = fc.Filename + Path.DirectorySeparatorChar + "chronojump_copy.db";
-
-                       try {
-                               fc.Hide ();
-                       
-                               bool exists = false;
-                               if(check_backup_multimedia_and_encoder.Active) {
-                                       if(Directory.Exists(fileCopy)) {
-                                               LogB.Information(string.Format("Directory {0} exists, created 
at {1}", 
-                                                                       fileCopy, 
Directory.GetCreationTime(fileCopy)));
-                                               exists = true;
-                                       }
-                               } else {
-                                       if (File.Exists(fileCopy)) {
-                                               LogB.Information(string.Format("File {0} exists with 
attributes {1}, created at {2}", 
-                                                                       fileCopy, 
File.GetAttributes(fileCopy), File.GetCreationTime(fileCopy)));
-                                               exists = true;
-                                       }
-                               }
-
-                               if(exists) {
-                                       LogB.Information("Overwrite...");
-                                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are 
you sure you want to overwrite: "), "", fileCopy);
-                                       confirmWin.Button_accept.Clicked += new 
EventHandler(on_overwrite_file_accepted);
-                               } else {
-                                       //if multimedia_and_encoder, then copy the folder. If not checked, 
then copy only the db file
-                                       if(check_backup_multimedia_and_encoder.Active)
-                                       {
-                                               thread = new Thread(new ThreadStart(copyRecursive));
-                                               GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
-               
-                                               backup_doing_sensitive_start_end(true); 
-                                               
-                                               LogB.ThreadStart(); 
-                                               thread.Start(); 
-                                       } else {
-                                               File.Copy(fileDB, fileCopy);
-                                       
-                                               string myString = string.Format(Catalog.GetString("Copied to 
{0}"), fileCopy);
-                                               new DialogMessage(Constants.MessageTypes.INFO, myString);
-                                       }
-                               }
-                       } 
-                       catch {
-                               string myString = string.Format(Catalog.GetString("Cannot copy to {0} "), 
fileCopy);
-                               new DialogMessage(Constants.MessageTypes.WARNING, myString);
-                       }
-               }
-               else {
-                       fc.Hide ();
-                       return ;
-               }
-               
-               //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
-               fc.Destroy();
-               
-       }
-       
-       void on_button_import_configuration_clicked (object o, EventArgs args)
-       {
-               fc = new Gtk.FileChooserDialog(Catalog.GetString("Import configuration file"),
-                               preferences_win,
-                               FileChooserAction.Open,
-                               Catalog.GetString("Cancel"),ResponseType.Cancel,
-                               Catalog.GetString("Import"),ResponseType.Accept
-                               );
-               
-               fc.Filter = new FileFilter();
-               //it can handle future archives like: chronojump_config_SOME_VENDOR.txt
-               //and it will be copied to chronojump_config.txt
-               fc.Filter.AddPattern("chronojump_config*.txt");
-       
-               bool success = false;   
-               if (fc.Run() == (int)ResponseType.Accept) 
-               {
-                       try {
-                               File.Copy(fc.Filename, UtilAll.GetConfigFileName(), true);
-                               LogB.Information("Imported configuration");
-
-                               //will launch configInit() from gui/chronojump.cs
-                               FakeButtonImported.Click();
-
-                               success = true;
-                       } catch {
-                               LogB.Warning("Catched! Configuration cannot be imported");
-                               new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error 
importing data."));
-                       }
-               }
-               //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
-               fc.Destroy();
-
-               if(success)
-                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Successfully 
imported."));
-       }
-       
-       private void on_overwrite_file_accepted(object o, EventArgs args)
-       {
-               try {
-                       //if multimedia_and_encoder, then copy the folder. If not checked, then copy only the 
db file
-                       if(check_backup_multimedia_and_encoder.Active) {
-                               Directory.Delete(fileCopy, true);
-                               thread = new Thread(new ThreadStart(copyRecursive));
-                               GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
-               
-                               backup_doing_sensitive_start_end(true); 
-                               
-                               LogB.ThreadStart(); 
-                               thread.Start(); 
-                       } else {
-                               File.Delete(fileCopy);
-                               File.Copy(fileDB, fileCopy);
-                                               
-                               fc.Hide ();
-                               string myString = string.Format(Catalog.GetString("Copied to {0}"), fileCopy);
-                               new DialogMessage(Constants.MessageTypes.INFO, myString);
-                       }
-               } catch {
-                       string myString = string.Format(Catalog.GetString("Cannot copy to {0} "), fileCopy);
-                       new DialogMessage(Constants.MessageTypes.WARNING, myString);
-               }
-       }
-
-       /*
-        * deprecated since 1.6.0. Use backup method below
-       */
-       private void copyRecursive() {
-               Util.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new 
DirectoryInfo(fileCopy));
-       }
-
-       /*
-        * Temprarily disabled
-        *
-       //from Longomatch
-       //https://raw.githubusercontent.com/ylatuya/longomatch/master/LongoMatch.DB/CouchbaseStorage.cs
-       private bool backup(string path)
-       {
-               try {   
-                       string storageName = path + Path.DirectorySeparatorChar + "chronojump_backup-" + 
DateTime.UtcNow.ToString() + ".tar.gz";
-                       using (FileStream fs = new FileStream (outputFilename, FileMode.Create, 
FileAccess.Write, FileShare.None)) {
-                               using (Stream gzipStream = new GZipOutputStream (fs)) {
-                                       using (TarArchive tarArchive = TarArchive.CreateOutputTarArchive 
(gzipStream)) {
-                                               //foreach (string n in new string[] {"", "-wal", "-shm"}) {
-                                               //      TarEntry tarEntry = TarEntry.CreateEntryFromFile (
-                                               //                      Path.Combine (Config.DBDir, 
storageName + ".cblite" + n));
-                                               //      tarArchive.WriteEntry (tarEntry, true);
-                                               //}
-                                               //AddDirectoryFilesToTar (tarArchive, Path.Combine 
(Config.DBDir, storageName + " attachments"), true);
-                                               AddDirectoryFilesToTar (tarArchive, Util.GetParentDir(false), 
true);
-                                       }
-                               }
-                       }
-                       //LastBackup = DateTime.UtcNow;
-               } catch (Exception ex) {
-                       LogB.Error (ex);
-                       return false;
-               }
-               return true;
-       }
-
-
-       //from Longomatch
-       //https://raw.githubusercontent.com/ylatuya/longomatch/master/LongoMatch.DB/CouchbaseStorage.cs
-       void AddDirectoryFilesToTar (TarArchive tarArchive, string sourceDirectory, bool recurse)
-       {
-               // Recursively add sub-folders
-               if (recurse) {
-                       string[] directories = Directory.GetDirectories (sourceDirectory);
-                       foreach (string directory in directories)
-                               AddDirectoryFilesToTar (tarArchive, directory, recurse);
-               }
-
-               // Add files
-               string[] filenames = Directory.GetFiles (sourceDirectory);
-               foreach (string filename in filenames) {
-                       TarEntry tarEntry = TarEntry.CreateEntryFromFile (filename);
-                       tarArchive.WriteEntry (tarEntry, true);
-               }
-       }
-       */
-
-       //encoder
-       private void on_button_inactivity_help_clicked (object o, EventArgs args)
-       {
-               new DialogMessage(Constants.MessageTypes.INFO, 
-                               Catalog.GetString("If a repetition has been found, test will end at selected 
inactivity seconds.") + "\n\n" +
-                               Catalog.GetString("If a repetition has not been found, test will end at 
selected inactivity seconds (x2).") + "\n" +
-                               Catalog.GetString("This will let the person to have more time to start 
movement.")
-                               );
-       }
-
-       
-       // ---- start SQL stress tests ---->
-
-       private void on_SQL_stress_test_safe_short_clicked (object o, EventArgs args) {
-               LogB.Information("start safe short stress test ---->");
-               sql_stress_test(1000);
-       }
-       private void on_SQL_stress_test_safe_long_clicked (object o, EventArgs args) {
-               LogB.Information("start safe long stress test ---->");
-               sql_stress_test(4000);
-       }
-       private void on_SQL_stress_test_not_safe_short_clicked (object o, EventArgs args) {
-               LogB.Information("start not safe short stress test ---->");
-               Sqlite.SafeClose = false;
-               sql_stress_test(1000);
-               Sqlite.SafeClose = true;
-       }
-       private void on_SQL_stress_test_not_safe_long_clicked (object o, EventArgs args) {
-               LogB.Information("start not safe long stress test ---->");
-               Sqlite.SafeClose = false;
-               sql_stress_test(4000);
-               Sqlite.SafeClose = true;
-       }
-       private void sql_stress_test (int times) {
-               Stopwatch sw = new Stopwatch();
-
-               sw.Start();
-
-               //trying if new way of Sqlite.Close disposing dbcmd fixes problems when multiple open / close 
connection
-               for(int i=0 ; i < times; i++) {
-                       LogB.Debug (" i=" + i.ToString());
-                       LogB.Debug(SqlitePreferences.Select("databaseVersion"));
-               }
-               sw.Stop();
-
-               string message = "Success!" + 
-                       " Done " + times + " times." + 
-                       " Elapsed " + sw.ElapsedMilliseconds + " ms";
-               LogB.Information(message);
-       
-               label_advanced_feedback.Text = message;
-       }
-
-       // <---- end SQL stress tests ----
-
-       private void on_debug_mode_clicked (object o, EventArgs args) {
-               //will be managed from gui/chronojump.cs
-               FakeButtonDebugModeStart.Click();
-       }
-       public void DebugActivated() {
-               label_advanced_feedback.Text = "Debug mode on while Chronojump is running.";
-       }
-
-       private bool PulseGTK ()
-       {
-               if ( ! thread.IsAlive ) {
-                       LogB.ThreadEnding();
-                       endPulse();
-
-                       LogB.ThreadEnded();
-                       return false;
-               }
-       
-               pulsebar.Pulse();
-               Thread.Sleep (50);
-               //LogB.Debug(thread.ThreadState.ToString());
-               return true;
-       }
-
-       private void endPulse() {
-               pulsebar.Fraction = 1;
-               backup_doing_sensitive_start_end(false);
-               fc.Hide ();
-               string myString = string.Format(Catalog.GetString("Copied to {0}"), fileCopy);
-               new DialogMessage(Constants.MessageTypes.INFO, myString);
-       }
-       
-       private void backup_doing_sensitive_start_end(bool start) 
-       {
-               hbox_backup_doing.Visible = start;
-       
-               button_db_backup.Sensitive = ! start;
-               button_data_folder_open.Sensitive = ! start;
-               
-               button_cancel.Sensitive = ! start;
-               button_accept.Sensitive = ! start;
-       }
-
-
-       //change stuff in Sqlite and in preferences object that will be retrieved by GetPreferences
-       void on_button_accept_clicked (object o, EventArgs args)
-       {
-               Sqlite.Open();
-
-               if( preferences.digitsNumber != Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals)) ) {
-                       SqlitePreferences.Update("digitsNumber", UtilGtk.ComboGetActive(combo_decimals), 
true);
-                       preferences.digitsNumber = Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals));
-               }
-               
-               if( preferences.showPower != PreferencesWindowBox.checkbutton_power.Active ) {
-                       SqlitePreferences.Update("showPower", 
PreferencesWindowBox.checkbutton_power.Active.ToString(), true);
-                       preferences.showPower = PreferencesWindowBox.checkbutton_power.Active;
-               }
-               
-               if( preferences.showStiffness != PreferencesWindowBox.checkbutton_stiffness.Active ) {
-                       SqlitePreferences.Update("showStiffness", 
PreferencesWindowBox.checkbutton_stiffness.Active.ToString(), true);
-                       preferences.showStiffness = PreferencesWindowBox.checkbutton_stiffness.Active;
-               }
-               
-               if( preferences.showInitialSpeed != PreferencesWindowBox.checkbutton_initial_speed.Active ) {
-                       SqlitePreferences.Update("showInitialSpeed", 
PreferencesWindowBox.checkbutton_initial_speed.Active.ToString(), true);
-                       preferences.showInitialSpeed = PreferencesWindowBox.checkbutton_initial_speed.Active;
-               }
-
-               if( preferences.showAngle != PreferencesWindowBox.checkbutton_angle.Active ) {
-                       SqlitePreferences.Update("showAngle", 
PreferencesWindowBox.checkbutton_angle.Active.ToString(), true);
-                       preferences.showAngle = PreferencesWindowBox.checkbutton_angle.Active;
-               }
-               
-               if(PreferencesWindowBox.checkbutton_show_tv_tc_index.Active) {
-                       SqlitePreferences.Update("showQIndex", 
PreferencesWindowBox.radiobutton_show_q_index.Active.ToString(), true);
-                       SqlitePreferences.Update("showDjIndex", 
PreferencesWindowBox.radiobutton_show_dj_index.Active.ToString(), true);
-                       preferences.showQIndex = PreferencesWindowBox.radiobutton_show_q_index.Active;
-                       preferences.showDjIndex = PreferencesWindowBox.radiobutton_show_dj_index.Active;
-               } else {
-                       SqlitePreferences.Update("showQIndex", "False", true);
-                       SqlitePreferences.Update("showDjIndex", "False", true);
-                       preferences.showQIndex = false;
-                       preferences.showDjIndex = false; 
-               }
-               
-               
-               if( preferences.askDeletion != PreferencesWindowBox.checkbutton_ask_deletion.Active ) {
-                       SqlitePreferences.Update("askDeletion", 
PreferencesWindowBox.checkbutton_ask_deletion.Active.ToString(), true);
-                       preferences.askDeletion = PreferencesWindowBox.checkbutton_ask_deletion.Active;
-               }
-
-               if( preferences.weightStatsPercent != PreferencesWindowBox.radio_weight_percent.Active ) {
-                       SqlitePreferences.Update("weightStatsPercent", 
PreferencesWindowBox.radio_weight_percent.Active.ToString(), true);
-                       preferences.weightStatsPercent = PreferencesWindowBox.radio_weight_percent.Active;
-               }
-
-               if( preferences.heightPreferred != PreferencesWindowBox.radio_elevation_height.Active ) {
-                       SqlitePreferences.Update("heightPreferred", 
PreferencesWindowBox.radio_elevation_height.Active.ToString(), true);
-                       preferences.heightPreferred = PreferencesWindowBox.radio_elevation_height.Active;
-               }
-
-               if( preferences.metersSecondsPreferred != PreferencesWindowBox.radio_speed_ms.Active ) {
-                       SqlitePreferences.Update("metersSecondsPreferred", 
PreferencesWindowBox.radio_speed_ms.Active.ToString(), true);
-                       preferences.metersSecondsPreferred = PreferencesWindowBox.radio_speed_ms.Active;
-               }
-               
-               if( preferences.runSpeedStartArrival != 
PreferencesWindowBox.radio_runs_speed_start_arrival.Active ) {
-                       SqlitePreferences.Update("runSpeedStartArrival", 
PreferencesWindowBox.radio_runs_speed_start_arrival.Active.ToString(), true);
-                       preferences.runSpeedStartArrival = 
PreferencesWindowBox.radio_runs_speed_start_arrival.Active;
-               }
-               
-               //start of double contacts stuff ----
-
-               //1 simple runs ----
-               
-               //1.1 was FIRST or AVERAGE or LAST and now will be NONE
-               if( (preferences.runDoubleContactsMode != Constants.DoubleContact.NONE) && 
-                               ! PreferencesWindowBox.checkbutton_runs_prevent_double_contact.Active) 
-               {
-                               SqlitePreferences.Update("runDoubleContactsMode", 
Constants.DoubleContact.NONE.ToString(), true);
-                               preferences.runDoubleContactsMode = Constants.DoubleContact.NONE;
-               }
-               else if(PreferencesWindowBox.checkbutton_runs_prevent_double_contact.Active) 
-               {
-                       //1.2 mode has changed between FIRST, AVERAGE or LAST
-                       if( PreferencesWindowBox.radio_runs_prevent_double_contact_first.Active &&
-                                       (preferences.runDoubleContactsMode != Constants.DoubleContact.FIRST) 
) {
-                               SqlitePreferences.Update("runDoubleContactsMode", 
Constants.DoubleContact.FIRST.ToString(), true);
-                               preferences.runDoubleContactsMode = Constants.DoubleContact.FIRST;
-                       }
-                       else if( PreferencesWindowBox.radio_runs_prevent_double_contact_average.Active &&
-                                       (preferences.runDoubleContactsMode != 
Constants.DoubleContact.AVERAGE) ) {
-                               SqlitePreferences.Update("runDoubleContactsMode", 
Constants.DoubleContact.AVERAGE.ToString(), true);
-                               preferences.runDoubleContactsMode = Constants.DoubleContact.AVERAGE;
-                       }
-                       else if( PreferencesWindowBox.radio_runs_prevent_double_contact_last.Active &&
-                                       (preferences.runDoubleContactsMode != Constants.DoubleContact.LAST) ) 
{
-                               SqlitePreferences.Update("runDoubleContactsMode", 
Constants.DoubleContact.LAST.ToString(), true);
-                               preferences.runDoubleContactsMode = Constants.DoubleContact.LAST;
-                       }
-
-                       if(preferences.runDoubleContactsMS != (int) 
PreferencesWindowBox.spinbutton_runs_prevent_double_contact.Value) {
-                               SqlitePreferences.Update("runDoubleContactsMS", 
-                                               
PreferencesWindowBox.spinbutton_runs_prevent_double_contact.Value.ToString(), true); //saved as string
-                               preferences.runDoubleContactsMS = (int) 
spinbutton_runs_prevent_double_contact.Value;
-                       }
-               }
-
-               //2 intervallic runs ----
-               
-               //2.1 was FIRST or AVERAGE or LAST and now will be NONE
-               if( (preferences.runIDoubleContactsMode != Constants.DoubleContact.NONE) && 
-                               ! PreferencesWindowBox.checkbutton_runs_i_prevent_double_contact.Active) 
-               {
-                               SqlitePreferences.Update("runIDoubleContactsMode", 
Constants.DoubleContact.NONE.ToString(), true);
-                               preferences.runIDoubleContactsMode = Constants.DoubleContact.NONE;
-               }
-               else if(PreferencesWindowBox.checkbutton_runs_i_prevent_double_contact.Active) 
-               {
-                       //2.2 mode has changed between FIRST, AVERAGE or LAST
-                       if( PreferencesWindowBox.radio_runs_i_prevent_double_contact_first.Active &&
-                                       (preferences.runIDoubleContactsMode != Constants.DoubleContact.FIRST) 
) {
-                               SqlitePreferences.Update("runIDoubleContactsMode", 
Constants.DoubleContact.FIRST.ToString(), true);
-                               preferences.runIDoubleContactsMode = Constants.DoubleContact.FIRST;
-                       }
-                       else if( PreferencesWindowBox.radio_runs_i_prevent_double_contact_average.Active &&
-                                       (preferences.runIDoubleContactsMode != 
Constants.DoubleContact.AVERAGE) ) {
-                               SqlitePreferences.Update("runIDoubleContactsMode", 
Constants.DoubleContact.AVERAGE.ToString(), true);
-                               preferences.runIDoubleContactsMode = Constants.DoubleContact.AVERAGE;
-                       }
-                       else if( PreferencesWindowBox.radio_runs_i_prevent_double_contact_last.Active &&
-                                       (preferences.runIDoubleContactsMode != Constants.DoubleContact.LAST) 
) {
-                               SqlitePreferences.Update("runIDoubleContactsMode", 
Constants.DoubleContact.LAST.ToString(), true);
-                               preferences.runIDoubleContactsMode = Constants.DoubleContact.LAST;
-                       }
-                       
-                       if(preferences.runIDoubleContactsMS != (int) 
PreferencesWindowBox.spinbutton_runs_i_prevent_double_contact.Value) {
-                               SqlitePreferences.Update("runIDoubleContactsMS", 
-                                               
PreferencesWindowBox.spinbutton_runs_i_prevent_double_contact.Value.ToString(), true); //saved as string
-                               preferences.runIDoubleContactsMS = (int) 
spinbutton_runs_i_prevent_double_contact.Value;
-                       }
-               }
-
-               //---- end of double contacts stuff
-               
-               //encoder capture ----
-       
-               preferences.encoderCaptureTime = preferencesChange(
-                               "encoderCaptureTime",
-                               preferences.encoderCaptureTime,
-                               (int) PreferencesWindowBox.spin_encoder_capture_time.Value);
-
-               preferences.encoderCaptureInactivityEndTime = preferencesChange(
-                               "encoderCaptureInactivityEndTime",
-                               preferences.encoderCaptureInactivityEndTime,
-                               (int) PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value);
-
-       
-               Constants.EncoderVariablesCapture mainVariable = Constants.SetEncoderVariablesCapture(
-                               UtilGtk.ComboGetActive(PreferencesWindowBox.combo_main_variable));
-               if( preferences.encoderCaptureMainVariable != mainVariable ) {
-                       SqlitePreferences.Update("encoderCaptureMainVariable", mainVariable.ToString(), true);
-                       preferences.encoderCaptureMainVariable = mainVariable;
-               }
-               
-               preferences.encoderCaptureMinHeightGravitatory = preferencesChange(
-                               "encoderCaptureMinHeightGravitatory",
-                               preferences.encoderCaptureMinHeightGravitatory,
-                               (int) PreferencesWindowBox.spin_encoder_capture_min_height_gravitatory.Value);
-       
-               preferences.encoderCaptureMinHeightInertial = preferencesChange(
-                               "encoderCaptureMinHeightInertial",
-                               preferences.encoderCaptureMinHeightInertial,
-                               (int) PreferencesWindowBox.spin_encoder_capture_min_height_inertial.Value);
-
-               preferences.encoderCaptureCheckFullyExtended = preferencesChange(
-                               "encoderCaptureCheckFullyExtended",
-                               preferences.encoderCaptureCheckFullyExtended,
-                               PreferencesWindowBox.checkbutton_encoder_capture_fully_extended.Active);
-               
-               preferences.encoderCaptureCheckFullyExtendedValue = preferencesChange(
-                               "encoderCaptureCheckFullyExtendedValue",
-                               preferences.encoderCaptureCheckFullyExtendedValue,
-                               (int) PreferencesWindowBox.spin_encoder_capture_fully_extended.Value);
-
-               if(PreferencesWindowBox.radio_encoder_auto_save_curve_best.Active) {
-                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.BEST.ToString(), true);
-                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.BEST;
-               }
-               else if(PreferencesWindowBox.radio_encoder_auto_save_curve_4top.Active) {
-                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE.ToString(), true);
-                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE;
-               }
-               else if(PreferencesWindowBox.radio_encoder_auto_save_curve_all.Active) {
-                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.ALL.ToString(), true);
-                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.ALL;
-               }
-               else {
-                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.NONE.ToString(), true);
-                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.NONE;
-               }
-
-               preferences.encoderShowStartAndDuration = preferencesChange(
-                               "encoderShowStartAndDuration",
-                               preferences.encoderShowStartAndDuration,
-                               PreferencesWindowBox.check_show_start_and_duration.Active);
-               
-
-               //---- end of encoder capture
-               
-               //encoder other ----
-               
-               preferences.encoderPropulsive = preferencesChange(
-                               "encoderPropulsive",
-                               preferences.encoderPropulsive,
-                               PreferencesWindowBox.checkbutton_encoder_propulsive.Active);
-               
-               preferences.encoderSmoothCon = preferencesChange(
-                               "encoderSmoothCon",
-                               preferences.encoderSmoothCon,
-                               (double) PreferencesWindowBox.spin_encoder_smooth_con.Value);
-               
-               Constants.Encoder1RMMethod encoder1RMMethod;
-               if(PreferencesWindowBox.radio_encoder_1RM_nonweighted.Active)
-                       encoder1RMMethod = Constants.Encoder1RMMethod.NONWEIGHTED;
-               else if(PreferencesWindowBox.radio_encoder_1RM_weighted.Active)
-                       encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED;
-               else if(PreferencesWindowBox.radio_encoder_1RM_weighted2.Active)
-                       encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED2;
-               else // (PreferencesWindowBox.radio_encoder_1RM_weighted3.Active)
-                       encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED3;
-
-               SqlitePreferences.Update("encoder1RMMethod", encoder1RMMethod.ToString(), true);
-               preferences.encoder1RMMethod = encoder1RMMethod;
-               
-               //---- end of encoder other
-               
-               //multimedia ----
-               if( preferences.volumeOn != PreferencesWindowBox.checkbutton_volume.Active ) {
-                       SqlitePreferences.Update("volumeOn", 
PreferencesWindowBox.checkbutton_volume.Active.ToString(), true);
-                       preferences.volumeOn = PreferencesWindowBox.checkbutton_volume.Active;
-               }
-
-               if( preferences.videoDeviceNum != UtilGtk.ComboGetActivePos(combo_camera) ) {
-                       SqlitePreferences.Update("videoDevice", 
UtilGtk.ComboGetActivePos(combo_camera).ToString(), true);
-                       preferences.videoDeviceNum = UtilGtk.ComboGetActivePos(combo_camera);
-               }
-               
-
-               if(PreferencesWindowBox.radio_export_latin.Active) {
-                       SqlitePreferences.Update("CSVExportDecimalSeparator","COMMA", true); 
-                       preferences.CSVExportDecimalSeparator = "COMMA";
-               }
-               else {
-                       SqlitePreferences.Update("CSVExportDecimalSeparator","POINT", true); 
-                       preferences.CSVExportDecimalSeparator = "POINT";
-               }
-       
-               string selectedLanguage = getSelectedLanguage();
-
-               //if there was a language on SQL but now "detected" is selected, put "" in language on SQL
-               if(preferences.language != "" && radio_language_detected.Active) {
-                       SqlitePreferences.Update("language", "", true);
-                       preferences.language = "";
-               }
-               //if force a language, and SQL language is != than selected language, change language on SQL
-               else if(radio_language_force.Active && preferences.language != selectedLanguage) {
-                       SqlitePreferences.Update("language", selectedLanguage, true);
-                       preferences.language = selectedLanguage;
-               }
-
-
-               if( preferences.RGraphsTranslate != PreferencesWindowBox.radio_graphs_translate.Active ) {
-                       SqlitePreferences.Update("RGraphsTranslate", 
-                                       PreferencesWindowBox.radio_graphs_translate.Active.ToString(), true);
-                       preferences.RGraphsTranslate = PreferencesWindowBox.radio_graphs_translate.Active;
-               }
-
-               if( preferences.useHeightsOnJumpIndexes != 
PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active ) {
-                       SqlitePreferences.Update("useHeightsOnJumpIndexes", 
-                                       
PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active.ToString(), true);
-                       preferences.useHeightsOnJumpIndexes = 
PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active;
-               }
-
-
-               Sqlite.Close();
-
-               PreferencesWindowBox.preferences_win.Hide();
-               PreferencesWindowBox = null;
-       }
-
-       private bool preferencesChange(string prefName, bool prefValue, bool bNew) 
-       {
-               if(prefValue != bNew)
-                       SqlitePreferences.Update(prefName, bNew.ToString(), true);
-               
-               return bNew;
-       }
-       private int preferencesChange(string prefName, int prefValue, int iNew) 
-       {
-               if(prefValue != iNew)
-                       SqlitePreferences.Update(prefName, iNew.ToString(), true);
-               
-               return iNew;
-       }
-       private double preferencesChange(string prefName, double prefValue, double dNew) 
-       {
-               if(prefValue != dNew)
-                       SqlitePreferences.Update(prefName, Util.ConvertToPoint(dNew), true);
-               
-               return dNew;
-       }
-
-       public Button Button_accept 
-       {
-               set { button_accept = value; }
-               get { return button_accept;  }
-       }
-
-       public Preferences GetPreferences 
-       {
-               get { return preferences;  }
-       }
-
-}
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using System.IO;
+using Gdk;
+using Gtk;
+using Glade;
+//using Gnome;
+//using GLib; //for Value
+using System.Text; //StringBuilder
+using System.Collections; //ArrayList
+using Mono.Unix;
+using System.Threading;
+using System.Globalization; //CultureInfo stuff
+
+using System.Diagnostics;  //Stopwatch
+
+
+/*
+using ICSharpCode.SharpZipLib.Tar;
+using ICSharpCode.SharpZipLib.GZip;
+using ICSharpCode.SharpZipLib;
+*/
+
+public class PreferencesWindow {
+       
+       [Widget] Gtk.Window preferences_win;
+       [Widget] Gtk.Notebook notebook;
+
+       //main tab
+       [Widget] Gtk.Button button_data_folder_open;
+
+       [Widget] Gtk.CheckButton check_backup_multimedia_and_encoder;
+       
+       [Widget] Gtk.Button button_db_backup;
+       [Widget] Gtk.Box hbox_backup_doing;
+       [Widget] Gtk.ProgressBar pulsebar;
+
+       
+       //jumps tab     
+       [Widget] Gtk.CheckButton checkbutton_power;
+       [Widget] Gtk.CheckButton checkbutton_stiffness;
+       [Widget] Gtk.CheckButton checkbutton_initial_speed;
+       [Widget] Gtk.CheckButton checkbutton_angle;
+       [Widget] Gtk.CheckButton checkbutton_show_tv_tc_index;
+       [Widget] Gtk.Box hbox_indexes;
+       [Widget] Gtk.RadioButton radiobutton_show_q_index;
+       [Widget] Gtk.RadioButton radiobutton_show_dj_index;
+       [Widget] Gtk.RadioButton radio_elevation_height;
+       [Widget] Gtk.RadioButton radio_elevation_tf;
+       [Widget] Gtk.RadioButton radio_weight_percent;
+       [Widget] Gtk.RadioButton radio_weight_kg;
+       [Widget] Gtk.RadioButton radio_use_heights_on_jump_indexes;
+       [Widget] Gtk.RadioButton radio_do_not_use_heights_on_jump_indexes;
+                       
+       //runs tab      
+       [Widget] Gtk.RadioButton radio_speed_ms;
+       [Widget] Gtk.RadioButton radio_speed_km;
+       [Widget] Gtk.RadioButton radio_runs_speed_start_arrival; 
+       [Widget] Gtk.RadioButton radio_runs_speed_start_leaving; 
+       [Widget] Gtk.Box vbox_runs_prevent_double_contact;
+       [Widget] Gtk.CheckButton checkbutton_runs_prevent_double_contact;
+       [Widget] Gtk.SpinButton spinbutton_runs_prevent_double_contact;
+       [Widget] Gtk.RadioButton radio_runs_prevent_double_contact_first;
+       [Widget] Gtk.RadioButton radio_runs_prevent_double_contact_average;
+       [Widget] Gtk.RadioButton radio_runs_prevent_double_contact_last;
+       [Widget] Gtk.Box vbox_runs_i_prevent_double_contact;
+       [Widget] Gtk.CheckButton checkbutton_runs_i_prevent_double_contact;
+       [Widget] Gtk.SpinButton spinbutton_runs_i_prevent_double_contact;
+       [Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_first;
+       [Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_average;
+       [Widget] Gtk.RadioButton radio_runs_i_prevent_double_contact_last;
+       
+       //encoder capture tab
+       [Widget] Gtk.SpinButton spin_encoder_capture_time;
+       [Widget] Gtk.SpinButton spin_encoder_capture_inactivity_end_time;
+       [Widget] Gtk.Box hbox_combo_main_variable;
+       [Widget] Gtk.ComboBox combo_main_variable;
+       [Widget] Gtk.SpinButton spin_encoder_capture_min_height_gravitatory;
+       [Widget] Gtk.SpinButton spin_encoder_capture_min_height_inertial;
+       [Widget] Gtk.CheckButton checkbutton_encoder_capture_fully_extended;
+       [Widget] Gtk.HBox hbox_encoder_capture_fully_extended;
+       [Widget] Gtk.SpinButton spin_encoder_capture_fully_extended;
+       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_best;
+       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_4top;
+       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_all;
+       [Widget] Gtk.RadioButton radio_encoder_auto_save_curve_none;
+       [Widget] Gtk.CheckButton check_show_start_and_duration;
+       
+       //encoder other tab
+       [Widget] Gtk.CheckButton checkbutton_encoder_propulsive;
+       [Widget] Gtk.SpinButton spin_encoder_smooth_con;
+       [Widget] Gtk.Label label_encoder_con;
+       [Widget] Gtk.RadioButton radio_encoder_1RM_nonweighted;
+       [Widget] Gtk.RadioButton radio_encoder_1RM_weighted;
+       [Widget] Gtk.RadioButton radio_encoder_1RM_weighted2;
+       [Widget] Gtk.RadioButton radio_encoder_1RM_weighted3;
+
+       //multimedia tab
+       [Widget] Gtk.CheckButton checkbutton_volume;
+       [Widget] Gtk.Box hbox_combo_camera;
+       [Widget] Gtk.ComboBox combo_camera;
+
+       //language tab
+       [Widget] Gtk.Box hbox_combo_language;
+       [Widget] Gtk.ComboBox combo_language;
+       [Widget] Gtk.RadioButton radio_language_detected;
+       [Widget] Gtk.RadioButton radio_language_force;
+       [Widget] Gtk.RadioButton radio_graphs_translate;
+       [Widget] Gtk.RadioButton radio_graphs_no_translate;
+       [Widget] Gtk.Box hbox_need_restart;
+               
+       //advanced tab
+       [Widget] Gtk.ComboBox combo_decimals;
+       [Widget] Gtk.CheckButton checkbutton_ask_deletion;
+       [Widget] Gtk.RadioButton radio_export_latin;
+       [Widget] Gtk.RadioButton radio_export_non_latin;
+       [Widget] Gtk.Label label_advanced_feedback;
+
+
+       [Widget] Gtk.Button button_accept;
+       [Widget] Gtk.Button button_cancel;
+       public Gtk.Button FakeButtonImported;
+       public Gtk.Button FakeButtonDebugModeStart;
+       
+       static PreferencesWindow PreferencesWindowBox;
+       
+       private Preferences preferences; //stored to update SQL if anything changed
+       private Thread thread;
+
+       string databaseURL;
+       string databaseTempURL;
+       
+       ListStore langsStore;
+
+
+       PreferencesWindow () {
+               Glade.XML gladeXML;
+               gladeXML = Glade.XML.FromAssembly (Util.GetGladePath() + "chronojump.glade", 
"preferences_win", "chronojump");
+               gladeXML.Autoconnect(this);
+               
+               //put an icon to window
+               UtilGtk.IconWindow(preferences_win);
+
+               //database and log files stuff
+               databaseURL = Util.GetDatabaseDir() + System.IO.Path.DirectorySeparatorChar  + 
"chronojump.db";
+               databaseTempURL = Util.GetDatabaseTempDir() + System.IO.Path.DirectorySeparatorChar  + 
"chronojump.db";
+               
+               FakeButtonImported = new Gtk.Button();
+               FakeButtonDebugModeStart = new Gtk.Button();
+       }
+       
+       static public PreferencesWindow Show (Preferences preferences, Constants.Menuitem_modes menu_mode)
+       {
+               if (PreferencesWindowBox == null) {
+                       PreferencesWindowBox = new PreferencesWindow ();
+               }
+
+               if(menu_mode != Constants.Menuitem_modes.JUMPSSIMPLE && menu_mode != 
Constants.Menuitem_modes.JUMPSREACTIVE)
+                       PreferencesWindowBox.notebook.GetNthPage(1).Hide(); 
+               if(menu_mode != Constants.Menuitem_modes.RUNSSIMPLE && menu_mode != 
Constants.Menuitem_modes.RUNSINTERVALLIC)
+                       PreferencesWindowBox.notebook.GetNthPage(2).Hide(); 
+               if(menu_mode != Constants.Menuitem_modes.POWERGRAVITATORY && menu_mode != 
Constants.Menuitem_modes.POWERINERTIAL) {
+                       PreferencesWindowBox.notebook.GetNthPage(3).Hide();
+                       PreferencesWindowBox.notebook.GetNthPage(4).Hide();
+               }
+
+               PreferencesWindowBox.preferences = preferences;
+
+               PreferencesWindowBox.createComboLanguage();
+
+               //multimedia tab
+               if(preferences.volumeOn)  
+                       PreferencesWindowBox.checkbutton_volume.Active = true; 
+               else 
+                       PreferencesWindowBox.checkbutton_volume.Active = false; 
+
+               PreferencesWindowBox.createComboCamera(UtilVideo.GetVideoDevices(), 
preferences.videoDeviceNum);
+       
+
+               string [] decs = {"1", "2", "3"};
+               PreferencesWindowBox.combo_decimals.Active = UtilGtk.ComboMakeActive(
+                               decs, preferences.digitsNumber.ToString());
+
+               if(preferences.showPower)
+                       PreferencesWindowBox.checkbutton_power.Active = true; 
+               else
+                       PreferencesWindowBox.checkbutton_power.Active = false; 
+               
+               if(preferences.showStiffness)
+                       PreferencesWindowBox.checkbutton_stiffness.Active = true; 
+               else
+                       PreferencesWindowBox.checkbutton_stiffness.Active = false; 
+               
+               if(preferences.showInitialSpeed)  
+                       PreferencesWindowBox.checkbutton_initial_speed.Active = true; 
+               else 
+                       PreferencesWindowBox.checkbutton_initial_speed.Active = false; 
+               
+               if(preferences.showAngle)  
+                       PreferencesWindowBox.checkbutton_angle.Active = true; 
+               else 
+                       PreferencesWindowBox.checkbutton_angle.Active = false; 
+               
+
+               if(preferences.showQIndex || preferences.showDjIndex) { 
+                       PreferencesWindowBox.checkbutton_show_tv_tc_index.Active = true; 
+                       if(preferences.showQIndex) {
+                               PreferencesWindowBox.radiobutton_show_q_index.Active = true; 
+                               PreferencesWindowBox.radiobutton_show_dj_index.Active = false; 
+                       } else {
+                               PreferencesWindowBox.radiobutton_show_q_index.Active = false; 
+                               PreferencesWindowBox.radiobutton_show_dj_index.Active = true; 
+                       }
+               }
+               else {
+                       PreferencesWindowBox.checkbutton_show_tv_tc_index.Active = false; 
+                       PreferencesWindowBox.hbox_indexes.Hide();
+               }
+
+               if(preferences.askDeletion)  
+                       PreferencesWindowBox.checkbutton_ask_deletion.Active = true; 
+               else 
+                       PreferencesWindowBox.checkbutton_ask_deletion.Active = false; 
+               
+
+               if(preferences.weightStatsPercent)  
+                       PreferencesWindowBox.radio_weight_percent.Active = true; 
+               else 
+                       PreferencesWindowBox.radio_weight_kg.Active = true; 
+               
+
+               if(preferences.heightPreferred)  
+                       PreferencesWindowBox.radio_elevation_height.Active = true; 
+               else 
+                       PreferencesWindowBox.radio_elevation_tf.Active = true; 
+               
+
+               if(preferences.metersSecondsPreferred)  
+                       PreferencesWindowBox.radio_speed_ms.Active = true; 
+               else 
+                       PreferencesWindowBox.radio_speed_km.Active = true; 
+
+
+               if(preferences.runSpeedStartArrival)  
+                       PreferencesWindowBox.radio_runs_speed_start_arrival.Active = true; 
+               else 
+                       PreferencesWindowBox.radio_runs_speed_start_leaving.Active = true; 
+
+
+               //start of double contacts stuff ----
+               PreferencesWindowBox.checkbutton_runs_prevent_double_contact.Active = 
+                       (preferences.runDoubleContactsMode != Constants.DoubleContact.NONE);
+               PreferencesWindowBox.checkbutton_runs_i_prevent_double_contact.Active = 
+                       (preferences.runIDoubleContactsMode != Constants.DoubleContact.NONE);
+
+               PreferencesWindowBox.spinbutton_runs_prevent_double_contact.Value = 
+                       preferences.runDoubleContactsMS;
+               PreferencesWindowBox.spinbutton_runs_i_prevent_double_contact.Value = 
+                       preferences.runIDoubleContactsMS;
+                       
+               if(preferences.runDoubleContactsMode != Constants.DoubleContact.NONE) {
+                       if(preferences.runDoubleContactsMode == Constants.DoubleContact.FIRST)
+                               PreferencesWindowBox.radio_runs_prevent_double_contact_first.Active = true;
+                       else if(preferences.runDoubleContactsMode == Constants.DoubleContact.AVERAGE)
+                               PreferencesWindowBox.radio_runs_prevent_double_contact_average.Active = true;
+                       else // Constants.DoubleContact.LAST  DEFAULT
+                               PreferencesWindowBox.radio_runs_prevent_double_contact_last.Active = true;
+               }
+               if(preferences.runIDoubleContactsMode != Constants.DoubleContact.NONE) {
+                       if(preferences.runIDoubleContactsMode == Constants.DoubleContact.FIRST)
+                               PreferencesWindowBox.radio_runs_i_prevent_double_contact_first.Active = true;
+                       else if(preferences.runIDoubleContactsMode == Constants.DoubleContact.LAST)
+                               PreferencesWindowBox.radio_runs_i_prevent_double_contact_last.Active = true;
+                       else //Constants.DoubleContact.AVERAGE  DEFAULT
+                               PreferencesWindowBox.radio_runs_i_prevent_double_contact_average.Active = 
true;
+               }
+               //---- end of double contacts stuff             
+
+
+               if(preferences.CSVExportDecimalSeparator == "COMMA")
+                       PreferencesWindowBox.radio_export_latin.Active = true; 
+               else
+                       PreferencesWindowBox.radio_export_non_latin.Active = true; 
+
+       
+               //encoder capture -->
+               PreferencesWindowBox.spin_encoder_capture_time.Value = preferences.encoderCaptureTime;
+               PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value = 
preferences.encoderCaptureInactivityEndTime;
+               
+               PreferencesWindowBox.createComboEncoderCaptureMainVariable(
+                               Constants.GetEncoderVariablesCapture(preferences.encoderCaptureMainVariable));
+
+               PreferencesWindowBox.spin_encoder_capture_min_height_gravitatory.Value = 
preferences.encoderCaptureMinHeightGravitatory;
+               PreferencesWindowBox.spin_encoder_capture_min_height_inertial.Value = 
preferences.encoderCaptureMinHeightInertial;
+               PreferencesWindowBox.checkbutton_encoder_capture_fully_extended.Active = 
preferences.encoderCaptureCheckFullyExtended;
+               PreferencesWindowBox.spin_encoder_capture_fully_extended.Value = 
preferences.encoderCaptureCheckFullyExtendedValue;
+               PreferencesWindowBox.hbox_encoder_capture_fully_extended.Visible = 
preferences.encoderCaptureCheckFullyExtended;
+               
+               if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.BEST)
+                       PreferencesWindowBox.radio_encoder_auto_save_curve_best.Active = true;
+               else if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE)
+                       PreferencesWindowBox.radio_encoder_auto_save_curve_4top.Active = true;
+               else if(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.ALL)
+                       PreferencesWindowBox.radio_encoder_auto_save_curve_all.Active = true;
+               else
+                       PreferencesWindowBox.radio_encoder_auto_save_curve_none.Active = true;
+       
+               PreferencesWindowBox.check_show_start_and_duration.Active = 
preferences.encoderShowStartAndDuration;
+
+
+               //encoder other -->
+               PreferencesWindowBox.checkbutton_encoder_propulsive.Active = preferences.encoderPropulsive;
+               
+               PreferencesWindowBox.spin_encoder_smooth_con.Value = preferences.encoderSmoothCon;
+
+               if(preferences.encoder1RMMethod == Constants.Encoder1RMMethod.NONWEIGHTED)
+                       PreferencesWindowBox.radio_encoder_1RM_nonweighted.Active = true;
+               else if(preferences.encoder1RMMethod == Constants.Encoder1RMMethod.WEIGHTED)
+                       PreferencesWindowBox.radio_encoder_1RM_weighted.Active = true;
+               else if(preferences.encoder1RMMethod == Constants.Encoder1RMMethod.WEIGHTED2)
+                       PreferencesWindowBox.radio_encoder_1RM_weighted2.Active = true;
+               else //(preferences.encoder1RMMethod == Constants.Encoder1RMMethod.WEIGHTED3)
+                       PreferencesWindowBox.radio_encoder_1RM_weighted3.Active = true;
+
+               //done here and not in glade to be shown with the decimal point of user language        
+               PreferencesWindowBox.label_encoder_con.Text = (0.7).ToString();
+       
+               //language -->
+               if(preferences.language == "")
+                       PreferencesWindowBox.radio_language_detected.Active = true;
+               else
+                       PreferencesWindowBox.radio_language_force.Active = true;
+
+               if(preferences.RGraphsTranslate)
+                       PreferencesWindowBox.radio_graphs_translate.Active = true;
+               else
+                       PreferencesWindowBox.radio_graphs_no_translate.Active = true;
+                       
+               //allow signal to be called
+               PreferencesWindowBox.hbox_language_signalOn = true;
+               
+               if(preferences.useHeightsOnJumpIndexes)
+                       PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active = true;
+               else
+                       PreferencesWindowBox.radio_do_not_use_heights_on_jump_indexes.Active = true;
+                       
+
+               PreferencesWindowBox.preferences_win.Show ();
+               return PreferencesWindowBox;
+       }
+       
+       private void createComboEncoderCaptureMainVariable(string v) {
+               combo_main_variable = ComboBox.NewText ();
+               string [] values = Constants.EncoderVariablesCaptureList;
+               UtilGtk.ComboUpdate(combo_main_variable, values, "");
+               combo_main_variable.Active = UtilGtk.ComboMakeActive(combo_main_variable, v.ToString());
+               
+               hbox_combo_main_variable.PackStart(combo_main_variable, false, false, 0);
+               hbox_combo_main_variable.ShowAll();
+               combo_main_variable.Sensitive = true;
+       }
+
+       
+       private void createComboCamera(string [] devices, int current) {
+               combo_camera = ComboBox.NewText ();
+
+               if(devices.Length == 0) {
+                       devices = Util.StringToStringArray(Constants.CameraNotFound);
+                       current = 0;
+               }
+               
+               UtilGtk.ComboUpdate(combo_camera, devices, "");
+               hbox_combo_camera.PackStart(combo_camera, true, true, 0);
+               hbox_combo_camera.ShowAll();
+
+               if(current >= devices.Length)
+                       current = 0;
+               
+               combo_camera.Active = UtilGtk.ComboMakeActive(devices, devices[current]);
+       }
+               
+       
+       private void on_checkbutton_encoder_capture_fully_extended_toggled(object obj, EventArgs args) {
+               hbox_encoder_capture_fully_extended.Visible = 
checkbutton_encoder_capture_fully_extended.Active;
+       }
+
+
+       // ---- Language stuff
+       
+       private void createComboLanguage() {
+               
+               combo_language = ComboBox.NewText ();
+               fillLanguages();
+
+               hbox_combo_language.PackStart(combo_language, false, false, 0);
+               hbox_combo_language.ShowAll();
+       }
+
+       //from Longomatch ;)
+       //(C) Andoni Morales Alastruey
+       bool hbox_language_signalOn = false;
+       void fillLanguages () {
+               int index = 0, active = 0;
+
+               langsStore = new ListStore(typeof(string), typeof(CultureInfo));
+
+               foreach (CultureInfo lang in UtilLanguage.Languages) {
+                       langsStore.AppendValues(lang.NativeName, lang);
+                       if (preferences.language != "" && lang.Name == preferences.language)
+                               active = index;
+                       index ++;
+               }
+               combo_language.Model = langsStore;
+               combo_language.Active = active;
+               combo_language.Changed += combo_language_changed;
+       }
+
+       private void on_radio_language_toggled (object obj, EventArgs args) {
+               hbox_combo_language.Sensitive = radio_language_force.Active;
+
+               if(hbox_language_signalOn)
+                       hbox_need_restart.Visible = true;
+       }
+       private void on_radio_translate_toggled (object obj, EventArgs args) {
+               if(hbox_language_signalOn)
+                       hbox_need_restart.Visible = true;
+       }
+       private void combo_language_changed (object obj, EventArgs args) {
+               if(hbox_language_signalOn)
+                       hbox_need_restart.Visible = true;
+       }
+
+
+       string getSelectedLanguage()
+       {
+               TreeIter iter;
+               CultureInfo info;
+
+               combo_language.GetActiveIter (out iter);
+               info = (CultureInfo) langsStore.GetValue (iter, 1);
+               if (info == null) {
+                       return "";
+               } else {
+                       return info.Name;
+               }
+       }
+
+       // ---- end of Language stuff
+
+                       
+       private void on_checkbutton_show_tv_tc_index_clicked (object o, EventArgs args) {
+               if(checkbutton_show_tv_tc_index.Active)
+                       hbox_indexes.Show();
+               else
+                       hbox_indexes.Hide();
+       }
+       
+       private void on_checkbutton_runs_prevent_double_contact_toggled (object o, EventArgs args) {
+               vbox_runs_prevent_double_contact.Visible = checkbutton_runs_prevent_double_contact.Active;
+       }
+       private void on_checkbutton_runs_i_prevent_double_contact_toggled (object o, EventArgs args) {
+               vbox_runs_i_prevent_double_contact.Visible = checkbutton_runs_i_prevent_double_contact.Active;
+       }
+
+               
+       void on_button_cancel_clicked (object o, EventArgs args)
+       {
+               PreferencesWindowBox.preferences_win.Hide();
+               PreferencesWindowBox = null;
+       }
+       
+       void on_preferences_delete_event (object o, DeleteEventArgs args)
+       {
+               //do not hide/exit if copyiing
+               if (thread != null && thread.IsAlive)
+                       args.RetVal = true;
+               else {
+                       PreferencesWindowBox.preferences_win.Hide();
+                       PreferencesWindowBox = null;
+               }
+       }
+       
+       void on_button_data_folder_open_clicked (object o, EventArgs args)
+       {
+               System.IO.FileInfo file1 = new System.IO.FileInfo(databaseURL); //potser cal una arrobar 
abans (a windows)
+               System.IO.FileInfo file2 = new System.IO.FileInfo(databaseTempURL); //potser cal una arrobar 
abans (a windows)
+
+               if(file1.Exists)
+                       System.Diagnostics.Process.Start(Util.GetParentDir(false)); 
+               else if(file2.Exists)
+                       System.Diagnostics.Process.Start(Util.GetDatabaseTempDir()); 
+               else
+                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.DatabaseNotFound);
+       }
+       
+       void on_button_db_restore_clicked (object o, EventArgs args)
+       {
+               /*
+                * TODO: problem is database stored is a chronojump.db or a folder (if images and videos were 
saved).
+                * FileChooserAction only lets you use one type
+                * In the future backup db as tgz or similar
+                */
+
+               /*
+               fc = new Gtk.FileChooserDialog(Catalog.GetString("Restore database from:"),
+                               preferences_win,
+                               FileChooserAction.SelectFolder,
+                               Catalog.GetString("Cancel"),ResponseType.Cancel,
+                               Catalog.GetString("Restore"),ResponseType.Accept
+                               );
+
+               ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are you sure you want to 
restore?"));
+               confirmWin.Button_accept.Clicked += new EventHandler(on_overwrite_file_accepted);
+               */
+       }
+
+       
+       void on_button_logs_folder_open_clicked (object o, EventArgs args)
+       {
+               string dir = UtilAll.GetLogsDir();
+               LogB.Information(dir);
+               
+               if( ! new System.IO.DirectoryInfo(dir).Exists) {
+                       try {
+                               Directory.CreateDirectory (dir);
+                       } catch {
+                               new DialogMessage(Constants.MessageTypes.WARNING, 
+                                               Catalog.GetString("Cannot create directory.") + "\n\n" + dir);
+                               return;
+                       }
+               }
+               
+               try {
+                       System.Diagnostics.Process.Start(dir); 
+               }
+               catch {
+                       new DialogMessage(Constants.MessageTypes.WARNING, 
+                                       Constants.DirectoryCannotOpen + "\n\n" + dir);
+               }
+       }
+       
+       void on_button_tmp_folder_open_clicked (object o, EventArgs args)
+       {
+               string dir = UtilAll.GetTempDir(); //potser cal una arrobar abans (a windows)
+               System.IO.FileInfo fInfo = new System.IO.FileInfo(dir);
+
+               try {
+                       if(fInfo.Exists)
+                               System.Diagnostics.Process.Start(dir);
+               } catch {
+                       new DialogMessage(Constants.MessageTypes.WARNING, 
+                                       Constants.DirectoryCannotOpen + "\n\n" + dir);
+               }
+
+               LogB.Warning(dir);
+       }
+
+
+
+       string fileDB;
+       string fileCopy;
+       Gtk.FileChooserDialog fc;
+       void on_button_db_backup_clicked (object o, EventArgs args)
+       {
+               System.IO.FileInfo file1 = new System.IO.FileInfo(databaseURL); //potser cal una arrobar 
abans (a windows)
+               System.IO.FileInfo file2 = new System.IO.FileInfo(databaseTempURL); //potser cal una arrobar 
abans (a windows)
+               fileDB = "";
+
+               long length1 = 0;
+               if(file1.Exists)
+                       length1 = file1.Length;
+               long length2 = 0;
+               if(file2.Exists)
+                       length2 = file2.Length;
+               
+               if(length1 == 0 && length2 == 0) 
+                       new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error. Cannot 
find database."));
+               else if(length1 > length2)
+                       fileDB = databaseURL;
+               else
+                       fileDB = databaseTempURL;
+
+               fc = new Gtk.FileChooserDialog(Catalog.GetString("Copy database to:"),
+                               preferences_win,
+                               FileChooserAction.SelectFolder,
+                               Catalog.GetString("Cancel"),ResponseType.Cancel,
+                               Catalog.GetString("Copy"),ResponseType.Accept
+                               );
+
+               if (fc.Run() == (int)ResponseType.Accept) 
+               {
+                       //if multimedia_and_encoder, then copy the folder. If not checked, then copy only the 
db file
+                       if(check_backup_multimedia_and_encoder.Active)
+                               fileCopy = fc.Filename + Path.DirectorySeparatorChar + "chronojump";
+                       else
+                               fileCopy = fc.Filename + Path.DirectorySeparatorChar + "chronojump_copy.db";
+
+                       try {
+                               fc.Hide ();
+                       
+                               bool exists = false;
+                               if(check_backup_multimedia_and_encoder.Active) {
+                                       if(Directory.Exists(fileCopy)) {
+                                               LogB.Information(string.Format("Directory {0} exists, created 
at {1}", 
+                                                                       fileCopy, 
Directory.GetCreationTime(fileCopy)));
+                                               exists = true;
+                                       }
+                               } else {
+                                       if (File.Exists(fileCopy)) {
+                                               LogB.Information(string.Format("File {0} exists with 
attributes {1}, created at {2}", 
+                                                                       fileCopy, 
File.GetAttributes(fileCopy), File.GetCreationTime(fileCopy)));
+                                               exists = true;
+                                       }
+                               }
+
+                               if(exists) {
+                                       LogB.Information("Overwrite...");
+                                       ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString("Are 
you sure you want to overwrite: "), "", fileCopy);
+                                       confirmWin.Button_accept.Clicked += new 
EventHandler(on_overwrite_file_accepted);
+                               } else {
+                                       //if multimedia_and_encoder, then copy the folder. If not checked, 
then copy only the db file
+                                       if(check_backup_multimedia_and_encoder.Active)
+                                       {
+                                               thread = new Thread(new ThreadStart(copyRecursive));
+                                               GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+               
+                                               backup_doing_sensitive_start_end(true); 
+                                               
+                                               LogB.ThreadStart(); 
+                                               thread.Start(); 
+                                       } else {
+                                               File.Copy(fileDB, fileCopy);
+                                       
+                                               string myString = string.Format(Catalog.GetString("Copied to 
{0}"), fileCopy);
+                                               new DialogMessage(Constants.MessageTypes.INFO, myString);
+                                       }
+                               }
+                       } 
+                       catch {
+                               string myString = string.Format(Catalog.GetString("Cannot copy to {0} "), 
fileCopy);
+                               new DialogMessage(Constants.MessageTypes.WARNING, myString);
+                       }
+               }
+               else {
+                       fc.Hide ();
+                       return ;
+               }
+               
+               //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
+               fc.Destroy();
+               
+       }
+       
+       void on_button_import_configuration_clicked (object o, EventArgs args)
+       {
+               fc = new Gtk.FileChooserDialog(Catalog.GetString("Import configuration file"),
+                               preferences_win,
+                               FileChooserAction.Open,
+                               Catalog.GetString("Cancel"),ResponseType.Cancel,
+                               Catalog.GetString("Import"),ResponseType.Accept
+                               );
+               
+               fc.Filter = new FileFilter();
+               //it can handle future archives like: chronojump_config_SOME_VENDOR.txt
+               //and it will be copied to chronojump_config.txt
+               fc.Filter.AddPattern("chronojump_config*.txt");
+       
+               bool success = false;   
+               if (fc.Run() == (int)ResponseType.Accept) 
+               {
+                       try {
+                               File.Copy(fc.Filename, UtilAll.GetConfigFileName(), true);
+                               LogB.Information("Imported configuration");
+
+                               //will launch configInit() from gui/chronojump.cs
+                               FakeButtonImported.Click();
+
+                               success = true;
+                       } catch {
+                               LogB.Warning("Catched! Configuration cannot be imported");
+                               new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error 
importing data."));
+                       }
+               }
+               //Don't forget to call Destroy() or the FileChooserDialog window won't get closed.
+               fc.Destroy();
+
+               if(success)
+                       new DialogMessage(Constants.MessageTypes.INFO, Catalog.GetString("Successfully 
imported."));
+       }
+       
+       private void on_overwrite_file_accepted(object o, EventArgs args)
+       {
+               try {
+                       //if multimedia_and_encoder, then copy the folder. If not checked, then copy only the 
db file
+                       if(check_backup_multimedia_and_encoder.Active) {
+                               Directory.Delete(fileCopy, true);
+                               thread = new Thread(new ThreadStart(copyRecursive));
+                               GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
+               
+                               backup_doing_sensitive_start_end(true); 
+                               
+                               LogB.ThreadStart(); 
+                               thread.Start(); 
+                       } else {
+                               File.Delete(fileCopy);
+                               File.Copy(fileDB, fileCopy);
+                                               
+                               fc.Hide ();
+                               string myString = string.Format(Catalog.GetString("Copied to {0}"), fileCopy);
+                               new DialogMessage(Constants.MessageTypes.INFO, myString);
+                       }
+               } catch {
+                       string myString = string.Format(Catalog.GetString("Cannot copy to {0} "), fileCopy);
+                       new DialogMessage(Constants.MessageTypes.WARNING, myString);
+               }
+       }
+
+       /*
+        * deprecated since 1.6.0. Use backup method below
+       */
+       private void copyRecursive() {
+               Util.CopyFilesRecursively(new DirectoryInfo(Util.GetParentDir(false)), new 
DirectoryInfo(fileCopy));
+       }
+
+       /*
+        * Temprarily disabled
+        *
+       //from Longomatch
+       //https://raw.githubusercontent.com/ylatuya/longomatch/master/LongoMatch.DB/CouchbaseStorage.cs
+       private bool backup(string path)
+       {
+               try {   
+                       string storageName = path + Path.DirectorySeparatorChar + "chronojump_backup-" + 
DateTime.UtcNow.ToString() + ".tar.gz";
+                       using (FileStream fs = new FileStream (outputFilename, FileMode.Create, 
FileAccess.Write, FileShare.None)) {
+                               using (Stream gzipStream = new GZipOutputStream (fs)) {
+                                       using (TarArchive tarArchive = TarArchive.CreateOutputTarArchive 
(gzipStream)) {
+                                               //foreach (string n in new string[] {"", "-wal", "-shm"}) {
+                                               //      TarEntry tarEntry = TarEntry.CreateEntryFromFile (
+                                               //                      Path.Combine (Config.DBDir, 
storageName + ".cblite" + n));
+                                               //      tarArchive.WriteEntry (tarEntry, true);
+                                               //}
+                                               //AddDirectoryFilesToTar (tarArchive, Path.Combine 
(Config.DBDir, storageName + " attachments"), true);
+                                               AddDirectoryFilesToTar (tarArchive, Util.GetParentDir(false), 
true);
+                                       }
+                               }
+                       }
+                       //LastBackup = DateTime.UtcNow;
+               } catch (Exception ex) {
+                       LogB.Error (ex);
+                       return false;
+               }
+               return true;
+       }
+
+
+       //from Longomatch
+       //https://raw.githubusercontent.com/ylatuya/longomatch/master/LongoMatch.DB/CouchbaseStorage.cs
+       void AddDirectoryFilesToTar (TarArchive tarArchive, string sourceDirectory, bool recurse)
+       {
+               // Recursively add sub-folders
+               if (recurse) {
+                       string[] directories = Directory.GetDirectories (sourceDirectory);
+                       foreach (string directory in directories)
+                               AddDirectoryFilesToTar (tarArchive, directory, recurse);
+               }
+
+               // Add files
+               string[] filenames = Directory.GetFiles (sourceDirectory);
+               foreach (string filename in filenames) {
+                       TarEntry tarEntry = TarEntry.CreateEntryFromFile (filename);
+                       tarArchive.WriteEntry (tarEntry, true);
+               }
+       }
+       */
+
+       //encoder
+       private void on_button_inactivity_help_clicked (object o, EventArgs args)
+       {
+               new DialogMessage(Constants.MessageTypes.INFO, 
+                               Catalog.GetString("If a repetition has been found, test will end at selected 
inactivity seconds.") + "\n\n" +
+                               Catalog.GetString("If a repetition has not been found, test will end at 
selected inactivity seconds (x2).") + "\n" +
+                               Catalog.GetString("This will let the person to have more time to start 
movement.")
+                               );
+       }
+
+       
+       // ---- start SQL stress tests ---->
+
+       private void on_SQL_stress_test_safe_short_clicked (object o, EventArgs args) {
+               LogB.Information("start safe short stress test ---->");
+               sql_stress_test(1000);
+       }
+       private void on_SQL_stress_test_safe_long_clicked (object o, EventArgs args) {
+               LogB.Information("start safe long stress test ---->");
+               sql_stress_test(4000);
+       }
+       private void on_SQL_stress_test_not_safe_short_clicked (object o, EventArgs args) {
+               LogB.Information("start not safe short stress test ---->");
+               Sqlite.SafeClose = false;
+               sql_stress_test(1000);
+               Sqlite.SafeClose = true;
+       }
+       private void on_SQL_stress_test_not_safe_long_clicked (object o, EventArgs args) {
+               LogB.Information("start not safe long stress test ---->");
+               Sqlite.SafeClose = false;
+               sql_stress_test(4000);
+               Sqlite.SafeClose = true;
+       }
+       private void sql_stress_test (int times) {
+               Stopwatch sw = new Stopwatch();
+
+               sw.Start();
+
+               //trying if new way of Sqlite.Close disposing dbcmd fixes problems when multiple open / close 
connection
+               for(int i=0 ; i < times; i++) {
+                       LogB.Debug (" i=" + i.ToString());
+                       LogB.Debug(SqlitePreferences.Select("databaseVersion"));
+               }
+               sw.Stop();
+
+               string message = "Success!" + 
+                       " Done " + times + " times." + 
+                       " Elapsed " + sw.ElapsedMilliseconds + " ms";
+               LogB.Information(message);
+       
+               label_advanced_feedback.Text = message;
+       }
+
+       // <---- end SQL stress tests ----
+
+       private void on_debug_mode_clicked (object o, EventArgs args) {
+               //will be managed from gui/chronojump.cs
+               FakeButtonDebugModeStart.Click();
+       }
+       public void DebugActivated() {
+               label_advanced_feedback.Text = "Debug mode on while Chronojump is running.";
+       }
+
+       private bool PulseGTK ()
+       {
+               if ( ! thread.IsAlive ) {
+                       LogB.ThreadEnding();
+                       endPulse();
+
+                       LogB.ThreadEnded();
+                       return false;
+               }
+       
+               pulsebar.Pulse();
+               Thread.Sleep (50);
+               //LogB.Debug(thread.ThreadState.ToString());
+               return true;
+       }
+
+       private void endPulse() {
+               pulsebar.Fraction = 1;
+               backup_doing_sensitive_start_end(false);
+               fc.Hide ();
+               string myString = string.Format(Catalog.GetString("Copied to {0}"), fileCopy);
+               new DialogMessage(Constants.MessageTypes.INFO, myString);
+       }
+       
+       private void backup_doing_sensitive_start_end(bool start) 
+       {
+               hbox_backup_doing.Visible = start;
+       
+               button_db_backup.Sensitive = ! start;
+               button_data_folder_open.Sensitive = ! start;
+               
+               button_cancel.Sensitive = ! start;
+               button_accept.Sensitive = ! start;
+       }
+
+
+       //change stuff in Sqlite and in preferences object that will be retrieved by GetPreferences
+       void on_button_accept_clicked (object o, EventArgs args)
+       {
+               Sqlite.Open();
+
+               if( preferences.digitsNumber != Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals)) ) {
+                       SqlitePreferences.Update("digitsNumber", UtilGtk.ComboGetActive(combo_decimals), 
true);
+                       preferences.digitsNumber = Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals));
+               }
+               
+               if( preferences.showPower != PreferencesWindowBox.checkbutton_power.Active ) {
+                       SqlitePreferences.Update("showPower", 
PreferencesWindowBox.checkbutton_power.Active.ToString(), true);
+                       preferences.showPower = PreferencesWindowBox.checkbutton_power.Active;
+               }
+               
+               if( preferences.showStiffness != PreferencesWindowBox.checkbutton_stiffness.Active ) {
+                       SqlitePreferences.Update("showStiffness", 
PreferencesWindowBox.checkbutton_stiffness.Active.ToString(), true);
+                       preferences.showStiffness = PreferencesWindowBox.checkbutton_stiffness.Active;
+               }
+               
+               if( preferences.showInitialSpeed != PreferencesWindowBox.checkbutton_initial_speed.Active ) {
+                       SqlitePreferences.Update("showInitialSpeed", 
PreferencesWindowBox.checkbutton_initial_speed.Active.ToString(), true);
+                       preferences.showInitialSpeed = PreferencesWindowBox.checkbutton_initial_speed.Active;
+               }
+
+               if( preferences.showAngle != PreferencesWindowBox.checkbutton_angle.Active ) {
+                       SqlitePreferences.Update("showAngle", 
PreferencesWindowBox.checkbutton_angle.Active.ToString(), true);
+                       preferences.showAngle = PreferencesWindowBox.checkbutton_angle.Active;
+               }
+               
+               if(PreferencesWindowBox.checkbutton_show_tv_tc_index.Active) {
+                       SqlitePreferences.Update("showQIndex", 
PreferencesWindowBox.radiobutton_show_q_index.Active.ToString(), true);
+                       SqlitePreferences.Update("showDjIndex", 
PreferencesWindowBox.radiobutton_show_dj_index.Active.ToString(), true);
+                       preferences.showQIndex = PreferencesWindowBox.radiobutton_show_q_index.Active;
+                       preferences.showDjIndex = PreferencesWindowBox.radiobutton_show_dj_index.Active;
+               } else {
+                       SqlitePreferences.Update("showQIndex", "False", true);
+                       SqlitePreferences.Update("showDjIndex", "False", true);
+                       preferences.showQIndex = false;
+                       preferences.showDjIndex = false; 
+               }
+               
+               
+               if( preferences.askDeletion != PreferencesWindowBox.checkbutton_ask_deletion.Active ) {
+                       SqlitePreferences.Update("askDeletion", 
PreferencesWindowBox.checkbutton_ask_deletion.Active.ToString(), true);
+                       preferences.askDeletion = PreferencesWindowBox.checkbutton_ask_deletion.Active;
+               }
+
+               if( preferences.weightStatsPercent != PreferencesWindowBox.radio_weight_percent.Active ) {
+                       SqlitePreferences.Update("weightStatsPercent", 
PreferencesWindowBox.radio_weight_percent.Active.ToString(), true);
+                       preferences.weightStatsPercent = PreferencesWindowBox.radio_weight_percent.Active;
+               }
+
+               if( preferences.heightPreferred != PreferencesWindowBox.radio_elevation_height.Active ) {
+                       SqlitePreferences.Update("heightPreferred", 
PreferencesWindowBox.radio_elevation_height.Active.ToString(), true);
+                       preferences.heightPreferred = PreferencesWindowBox.radio_elevation_height.Active;
+               }
+
+               if( preferences.metersSecondsPreferred != PreferencesWindowBox.radio_speed_ms.Active ) {
+                       SqlitePreferences.Update("metersSecondsPreferred", 
PreferencesWindowBox.radio_speed_ms.Active.ToString(), true);
+                       preferences.metersSecondsPreferred = PreferencesWindowBox.radio_speed_ms.Active;
+               }
+               
+               if( preferences.runSpeedStartArrival != 
PreferencesWindowBox.radio_runs_speed_start_arrival.Active ) {
+                       SqlitePreferences.Update("runSpeedStartArrival", 
PreferencesWindowBox.radio_runs_speed_start_arrival.Active.ToString(), true);
+                       preferences.runSpeedStartArrival = 
PreferencesWindowBox.radio_runs_speed_start_arrival.Active;
+               }
+               
+               //start of double contacts stuff ----
+
+               //1 simple runs ----
+               
+               //1.1 was FIRST or AVERAGE or LAST and now will be NONE
+               if( (preferences.runDoubleContactsMode != Constants.DoubleContact.NONE) && 
+                               ! PreferencesWindowBox.checkbutton_runs_prevent_double_contact.Active) 
+               {
+                               SqlitePreferences.Update("runDoubleContactsMode", 
Constants.DoubleContact.NONE.ToString(), true);
+                               preferences.runDoubleContactsMode = Constants.DoubleContact.NONE;
+               }
+               else if(PreferencesWindowBox.checkbutton_runs_prevent_double_contact.Active) 
+               {
+                       //1.2 mode has changed between FIRST, AVERAGE or LAST
+                       if( PreferencesWindowBox.radio_runs_prevent_double_contact_first.Active &&
+                                       (preferences.runDoubleContactsMode != Constants.DoubleContact.FIRST) 
) {
+                               SqlitePreferences.Update("runDoubleContactsMode", 
Constants.DoubleContact.FIRST.ToString(), true);
+                               preferences.runDoubleContactsMode = Constants.DoubleContact.FIRST;
+                       }
+                       else if( PreferencesWindowBox.radio_runs_prevent_double_contact_average.Active &&
+                                       (preferences.runDoubleContactsMode != 
Constants.DoubleContact.AVERAGE) ) {
+                               SqlitePreferences.Update("runDoubleContactsMode", 
Constants.DoubleContact.AVERAGE.ToString(), true);
+                               preferences.runDoubleContactsMode = Constants.DoubleContact.AVERAGE;
+                       }
+                       else if( PreferencesWindowBox.radio_runs_prevent_double_contact_last.Active &&
+                                       (preferences.runDoubleContactsMode != Constants.DoubleContact.LAST) ) 
{
+                               SqlitePreferences.Update("runDoubleContactsMode", 
Constants.DoubleContact.LAST.ToString(), true);
+                               preferences.runDoubleContactsMode = Constants.DoubleContact.LAST;
+                       }
+
+                       if(preferences.runDoubleContactsMS != (int) 
PreferencesWindowBox.spinbutton_runs_prevent_double_contact.Value) {
+                               SqlitePreferences.Update("runDoubleContactsMS", 
+                                               
PreferencesWindowBox.spinbutton_runs_prevent_double_contact.Value.ToString(), true); //saved as string
+                               preferences.runDoubleContactsMS = (int) 
spinbutton_runs_prevent_double_contact.Value;
+                       }
+               }
+
+               //2 intervallic runs ----
+               
+               //2.1 was FIRST or AVERAGE or LAST and now will be NONE
+               if( (preferences.runIDoubleContactsMode != Constants.DoubleContact.NONE) && 
+                               ! PreferencesWindowBox.checkbutton_runs_i_prevent_double_contact.Active) 
+               {
+                               SqlitePreferences.Update("runIDoubleContactsMode", 
Constants.DoubleContact.NONE.ToString(), true);
+                               preferences.runIDoubleContactsMode = Constants.DoubleContact.NONE;
+               }
+               else if(PreferencesWindowBox.checkbutton_runs_i_prevent_double_contact.Active) 
+               {
+                       //2.2 mode has changed between FIRST, AVERAGE or LAST
+                       if( PreferencesWindowBox.radio_runs_i_prevent_double_contact_first.Active &&
+                                       (preferences.runIDoubleContactsMode != Constants.DoubleContact.FIRST) 
) {
+                               SqlitePreferences.Update("runIDoubleContactsMode", 
Constants.DoubleContact.FIRST.ToString(), true);
+                               preferences.runIDoubleContactsMode = Constants.DoubleContact.FIRST;
+                       }
+                       else if( PreferencesWindowBox.radio_runs_i_prevent_double_contact_average.Active &&
+                                       (preferences.runIDoubleContactsMode != 
Constants.DoubleContact.AVERAGE) ) {
+                               SqlitePreferences.Update("runIDoubleContactsMode", 
Constants.DoubleContact.AVERAGE.ToString(), true);
+                               preferences.runIDoubleContactsMode = Constants.DoubleContact.AVERAGE;
+                       }
+                       else if( PreferencesWindowBox.radio_runs_i_prevent_double_contact_last.Active &&
+                                       (preferences.runIDoubleContactsMode != Constants.DoubleContact.LAST) 
) {
+                               SqlitePreferences.Update("runIDoubleContactsMode", 
Constants.DoubleContact.LAST.ToString(), true);
+                               preferences.runIDoubleContactsMode = Constants.DoubleContact.LAST;
+                       }
+                       
+                       if(preferences.runIDoubleContactsMS != (int) 
PreferencesWindowBox.spinbutton_runs_i_prevent_double_contact.Value) {
+                               SqlitePreferences.Update("runIDoubleContactsMS", 
+                                               
PreferencesWindowBox.spinbutton_runs_i_prevent_double_contact.Value.ToString(), true); //saved as string
+                               preferences.runIDoubleContactsMS = (int) 
spinbutton_runs_i_prevent_double_contact.Value;
+                       }
+               }
+
+               //---- end of double contacts stuff
+               
+               //encoder capture ----
+       
+               preferences.encoderCaptureTime = preferencesChange(
+                               "encoderCaptureTime",
+                               preferences.encoderCaptureTime,
+                               (int) PreferencesWindowBox.spin_encoder_capture_time.Value);
+
+               preferences.encoderCaptureInactivityEndTime = preferencesChange(
+                               "encoderCaptureInactivityEndTime",
+                               preferences.encoderCaptureInactivityEndTime,
+                               (int) PreferencesWindowBox.spin_encoder_capture_inactivity_end_time.Value);
+
+       
+               Constants.EncoderVariablesCapture mainVariable = Constants.SetEncoderVariablesCapture(
+                               UtilGtk.ComboGetActive(PreferencesWindowBox.combo_main_variable));
+               if( preferences.encoderCaptureMainVariable != mainVariable ) {
+                       SqlitePreferences.Update("encoderCaptureMainVariable", mainVariable.ToString(), true);
+                       preferences.encoderCaptureMainVariable = mainVariable;
+               }
+               
+               preferences.encoderCaptureMinHeightGravitatory = preferencesChange(
+                               "encoderCaptureMinHeightGravitatory",
+                               preferences.encoderCaptureMinHeightGravitatory,
+                               (int) PreferencesWindowBox.spin_encoder_capture_min_height_gravitatory.Value);
+       
+               preferences.encoderCaptureMinHeightInertial = preferencesChange(
+                               "encoderCaptureMinHeightInertial",
+                               preferences.encoderCaptureMinHeightInertial,
+                               (int) PreferencesWindowBox.spin_encoder_capture_min_height_inertial.Value);
+
+               preferences.encoderCaptureCheckFullyExtended = preferencesChange(
+                               "encoderCaptureCheckFullyExtended",
+                               preferences.encoderCaptureCheckFullyExtended,
+                               PreferencesWindowBox.checkbutton_encoder_capture_fully_extended.Active);
+               
+               preferences.encoderCaptureCheckFullyExtendedValue = preferencesChange(
+                               "encoderCaptureCheckFullyExtendedValue",
+                               preferences.encoderCaptureCheckFullyExtendedValue,
+                               (int) PreferencesWindowBox.spin_encoder_capture_fully_extended.Value);
+
+               if(PreferencesWindowBox.radio_encoder_auto_save_curve_best.Active) {
+                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.BEST.ToString(), true);
+                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.BEST;
+               }
+               else if(PreferencesWindowBox.radio_encoder_auto_save_curve_4top.Active) {
+                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE.ToString(), true);
+                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.FROM4TOPENULTIMATE;
+               }
+               else if(PreferencesWindowBox.radio_encoder_auto_save_curve_all.Active) {
+                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.ALL.ToString(), true);
+                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.ALL;
+               }
+               else {
+                       SqlitePreferences.Update("encoderAutoSaveCurve", 
Constants.EncoderAutoSaveCurve.NONE.ToString(), true);
+                       preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.NONE;
+               }
+
+               preferences.encoderShowStartAndDuration = preferencesChange(
+                               "encoderShowStartAndDuration",
+                               preferences.encoderShowStartAndDuration,
+                               PreferencesWindowBox.check_show_start_and_duration.Active);
+               
+
+               //---- end of encoder capture
+               
+               //encoder other ----
+               
+               preferences.encoderPropulsive = preferencesChange(
+                               "encoderPropulsive",
+                               preferences.encoderPropulsive,
+                               PreferencesWindowBox.checkbutton_encoder_propulsive.Active);
+               
+               preferences.encoderSmoothCon = preferencesChange(
+                               "encoderSmoothCon",
+                               preferences.encoderSmoothCon,
+                               (double) PreferencesWindowBox.spin_encoder_smooth_con.Value);
+               
+               Constants.Encoder1RMMethod encoder1RMMethod;
+               if(PreferencesWindowBox.radio_encoder_1RM_nonweighted.Active)
+                       encoder1RMMethod = Constants.Encoder1RMMethod.NONWEIGHTED;
+               else if(PreferencesWindowBox.radio_encoder_1RM_weighted.Active)
+                       encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED;
+               else if(PreferencesWindowBox.radio_encoder_1RM_weighted2.Active)
+                       encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED2;
+               else // (PreferencesWindowBox.radio_encoder_1RM_weighted3.Active)
+                       encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED3;
+
+               SqlitePreferences.Update("encoder1RMMethod", encoder1RMMethod.ToString(), true);
+               preferences.encoder1RMMethod = encoder1RMMethod;
+               
+               //---- end of encoder other
+               
+               //multimedia ----
+               if( preferences.volumeOn != PreferencesWindowBox.checkbutton_volume.Active ) {
+                       SqlitePreferences.Update("volumeOn", 
PreferencesWindowBox.checkbutton_volume.Active.ToString(), true);
+                       preferences.volumeOn = PreferencesWindowBox.checkbutton_volume.Active;
+               }
+
+               if( preferences.videoDeviceNum != UtilGtk.ComboGetActivePos(combo_camera) ) {
+                       SqlitePreferences.Update("videoDevice", 
UtilGtk.ComboGetActivePos(combo_camera).ToString(), true);
+                       preferences.videoDeviceNum = UtilGtk.ComboGetActivePos(combo_camera);
+               }
+               
+
+               if(PreferencesWindowBox.radio_export_latin.Active) {
+                       SqlitePreferences.Update("CSVExportDecimalSeparator","COMMA", true); 
+                       preferences.CSVExportDecimalSeparator = "COMMA";
+               }
+               else {
+                       SqlitePreferences.Update("CSVExportDecimalSeparator","POINT", true); 
+                       preferences.CSVExportDecimalSeparator = "POINT";
+               }
+       
+               string selectedLanguage = getSelectedLanguage();
+
+               //if there was a language on SQL but now "detected" is selected, put "" in language on SQL
+               if(preferences.language != "" && radio_language_detected.Active) {
+                       SqlitePreferences.Update("language", "", true);
+                       preferences.language = "";
+               }
+               //if force a language, and SQL language is != than selected language, change language on SQL
+               else if(radio_language_force.Active && preferences.language != selectedLanguage) {
+                       SqlitePreferences.Update("language", selectedLanguage, true);
+                       preferences.language = selectedLanguage;
+               }
+
+
+               if( preferences.RGraphsTranslate != PreferencesWindowBox.radio_graphs_translate.Active ) {
+                       SqlitePreferences.Update("RGraphsTranslate", 
+                                       PreferencesWindowBox.radio_graphs_translate.Active.ToString(), true);
+                       preferences.RGraphsTranslate = PreferencesWindowBox.radio_graphs_translate.Active;
+               }
+
+               if( preferences.useHeightsOnJumpIndexes != 
PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active ) {
+                       SqlitePreferences.Update("useHeightsOnJumpIndexes", 
+                                       
PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active.ToString(), true);
+                       preferences.useHeightsOnJumpIndexes = 
PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active;
+               }
+
+
+               Sqlite.Close();
+
+               PreferencesWindowBox.preferences_win.Hide();
+               PreferencesWindowBox = null;
+       }
+
+       private bool preferencesChange(string prefName, bool prefValue, bool bNew) 
+       {
+               if(prefValue != bNew)
+                       SqlitePreferences.Update(prefName, bNew.ToString(), true);
+               
+               return bNew;
+       }
+       private int preferencesChange(string prefName, int prefValue, int iNew) 
+       {
+               if(prefValue != iNew)
+                       SqlitePreferences.Update(prefName, iNew.ToString(), true);
+               
+               return iNew;
+       }
+       private double preferencesChange(string prefName, double prefValue, double dNew) 
+       {
+               if(prefValue != dNew)
+                       SqlitePreferences.Update(prefName, Util.ConvertToPoint(dNew), true);
+               
+               return dNew;
+       }
+
+       public Button Button_accept 
+       {
+               set { button_accept = value; }
+               get { return button_accept;  }
+       }
+
+       public Preferences GetPreferences 
+       {
+               get { return preferences;  }
+       }
+
+}
diff --git a/src/json.cs b/src/json.cs
index ecd469d..bb930ce 100644
--- a/src/json.cs
+++ b/src/json.cs
@@ -1,246 +1,246 @@
-/*
- * This file is part of ChronoJump
- *
- * ChronoJump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * ChronoJump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- * Copyright (C) 2016 Carles Pina & Xavier de Blas
- */
-
-using System;
-using System.Net;
-using System.Web;
-using System.IO;
-using System.Json;
-using System.Text;
-using System.Collections.Generic; //Dictionary
-using Mono.Unix;
-
-
-public class Json
-{
-       public string ResultMessage;
-       string serverUrl = "http://api.chronojump.org:8080";;
-
-
-       public Json()
-       {
-               ResultMessage = "";
-       }
-
-       public bool PostCrashLog(string email, string comments) 
-       {
-               string filePath = UtilAll.GetLogFileOld();
-
-               if(! File.Exists(filePath)) {
-                       this.ResultMessage = Catalog.GetString("Could not send file.\nIt does not exist.");
-                       return false;
-               }
-
-               if(comments != null && comments != "")
-                       Util.InsertTextBeginningOfFile(
-                                       "----------\nUser comments:\n" + comments + "\n----------\n", 
filePath);
-
-               // Create a request using a URL that can receive a post. 
-               WebRequest request = WebRequest.Create (serverUrl + "/backtrace/" + UtilAll.ReadVersion() + 
"-" + email);
-
-               // Set the Method property of the request to POST.
-               request.Method = "POST";
-
-               // Create POST data and convert it to a byte array.
-               byte[] byteArray = readFile(filePath);
-
-               // Set the ContentType property of the WebRequest.
-               request.ContentType = "application/x-www-form-urlencoded";
-
-               // Set the ContentLength property of the WebRequest.
-               request.ContentLength = byteArray.Length;
-
-               // Get the request stream.
-               Stream dataStream;
-               try {
-                       dataStream = request.GetRequestStream ();
-               } catch {
-                       LogB.Warning("Error sending datastream");
-                       this.ResultMessage = Catalog.GetString("Could not send file.") + "\n" + 
-                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
-                                               serverUrl);
-                       return false;
-               }
-
-               // Write the data to the request stream.
-               dataStream.Write (byteArray, 0, byteArray.Length);
-
-               // Close the Stream object.
-               dataStream.Close ();
-        
-               // Get the response.
-               WebResponse response;
-               try {
-                       response = request.GetResponse ();
-               } catch {
-                       LogB.Warning("Error getting response");
-                       this.ResultMessage = Catalog.GetString("Could not send file.") + "\n" + 
-                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
-                                               serverUrl);
-                       return false;
-               }
-
-               // Display the status.
-               LogB.Information(((HttpWebResponse)response).StatusDescription);
-
-               // Get the stream containing content returned by the server.
-               dataStream = response.GetResponseStream ();
-
-               // Open the stream using a StreamReader for easy access.
-               StreamReader reader = new StreamReader (dataStream);
-
-               // Read the content.
-               string responseFromServer = reader.ReadToEnd ();
-
-               // Display the content.
-               LogB.Information(responseFromServer);
-
-               // Clean up the streams.
-               reader.Close ();
-               dataStream.Close ();
-               response.Close ();    
-
-
-               JsonValue result = JsonValue.Parse(responseFromServer);
-               string crash_id = result["crash_id"];
-               LogB.Information("crash_id: ", crash_id);
-
-               this.ResultMessage = Catalog.GetString("Log sent. Thank you.");
-               return true;
-       }
-       
-       private byte[] readFile(string filePath)
-       {
-               return System.IO.File.ReadAllBytes(filePath); 
-       }
-
-
-       //public bool ChronojumpUpdated = true;
-       public bool GetLastVersion(string currentVersion) 
-       {
-               // Create a request using a URL that can receive a post. 
-               WebRequest request = WebRequest.Create (serverUrl + "/version");
-               
-               // Set the Method property of the request to GET.
-               request.Method = "GET";
-               
-               // Set the ContentType property of the WebRequest.
-               //request.ContentType = "application/x-www-form-urlencoded";
-               
-               HttpWebResponse response;
-               try {
-                       response = (HttpWebResponse) request.GetResponse();
-               } catch {
-                       this.ResultMessage = 
-                               Catalog.GetString("Could not get last version.") + "\n" +
-                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
-                               serverUrl);
-                       return false;
-               }
-
-               string responseFromServer;
-               using (var sr = new StreamReader(response.GetResponseStream()))
-               {
-                       responseFromServer = sr.ReadToEnd();
-               }
-
-               //this prints:
-               // {"stable": "1.4.9"}
-               //this.ResultMessage = "Last version published: " + responseFromServer;
-               
-               string [] strFull = responseFromServer.Split(new char[] {':'});
-               int startPos = strFull[1].IndexOf('"') +1;
-               int endPos = strFull[1].LastIndexOf('"') -2;
-
-               string lastVersionPublished = strFull[1].Substring(startPos,endPos); //1.4.9
-                       
-               string updateStr = "";
-               if(currentVersion != lastVersionPublished)
-                       updateStr = "\n\n" + Catalog.GetString("Update software at ") + "www.chronojump.org";
-                       
-               this.ResultMessage =            
-                       Catalog.GetString("Installed version is: ") + currentVersion + "\n" + 
-                       Catalog.GetString("Last version published: ") + lastVersionPublished +
-                       updateStr;
-               
-               //ChronojumpUpdated = (currentVersion == ResultMessage);
-
-               return true;
-       }
-
-       public bool Ping(string osVersion, string cjVersion, string machineID) 
-       {
-               // Create a request using a URL that can receive a post. 
-               WebRequest request = WebRequest.Create (serverUrl + "/ping");
-
-               // Set the Method property of the request to POST.
-               request.Method = "POST";
-
-               // Set the ContentType property of the WebRequest.
-               request.ContentType = "application/json";
-
-               // Creates the json object
-               JsonObject json = new JsonObject();
-               json.Add("os_version", osVersion);
-               json.Add("cj_version", cjVersion);
-               json.Add("machine_id", machineID);
-
-               // Converts it to a String
-               String js = json.ToString();
-
-               // Writes the json object into the request dataStream
-               Stream dataStream;
-               try {
-                       dataStream = request.GetRequestStream ();
-               } catch {
-                       this.ResultMessage = 
-                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
-                               serverUrl);
-                       return false;
-               }
-               dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-
-               dataStream.Close ();
-
-               // Get the response.
-               WebResponse response;
-               try {
-                       response = request.GetResponse ();
-               } catch {
-                       this.ResultMessage = 
-                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
-                               serverUrl);
-                       return false;
-               }
-
-               // Display the status (will be 201, CREATED)
-               Console.WriteLine (((HttpWebResponse)response).StatusDescription);
-
-               // Clean up the streams.
-               dataStream.Close ();
-               response.Close ();
-               
-               this.ResultMessage = "Ping sent.";
-               return true;
-       }
-
-
-       ~Json() {}
-}
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Copyright (C) 2016 Carles Pina & Xavier de Blas
+ */
+
+using System;
+using System.Net;
+using System.Web;
+using System.IO;
+using System.Json;
+using System.Text;
+using System.Collections.Generic; //Dictionary
+using Mono.Unix;
+
+
+public class Json
+{
+       public string ResultMessage;
+       string serverUrl = "http://api.chronojump.org:8080";;
+
+
+       public Json()
+       {
+               ResultMessage = "";
+       }
+
+       public bool PostCrashLog(string email, string comments) 
+       {
+               string filePath = UtilAll.GetLogFileOld();
+
+               if(! File.Exists(filePath)) {
+                       this.ResultMessage = Catalog.GetString("Could not send file.\nIt does not exist.");
+                       return false;
+               }
+
+               if(comments != null && comments != "")
+                       Util.InsertTextBeginningOfFile(
+                                       "----------\nUser comments:\n" + comments + "\n----------\n", 
filePath);
+
+               // Create a request using a URL that can receive a post. 
+               WebRequest request = WebRequest.Create (serverUrl + "/backtrace/" + UtilAll.ReadVersion() + 
"-" + email);
+
+               // Set the Method property of the request to POST.
+               request.Method = "POST";
+
+               // Create POST data and convert it to a byte array.
+               byte[] byteArray = readFile(filePath);
+
+               // Set the ContentType property of the WebRequest.
+               request.ContentType = "application/x-www-form-urlencoded";
+
+               // Set the ContentLength property of the WebRequest.
+               request.ContentLength = byteArray.Length;
+
+               // Get the request stream.
+               Stream dataStream;
+               try {
+                       dataStream = request.GetRequestStream ();
+               } catch {
+                       LogB.Warning("Error sending datastream");
+                       this.ResultMessage = Catalog.GetString("Could not send file.") + "\n" + 
+                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
+                                               serverUrl);
+                       return false;
+               }
+
+               // Write the data to the request stream.
+               dataStream.Write (byteArray, 0, byteArray.Length);
+
+               // Close the Stream object.
+               dataStream.Close ();
+        
+               // Get the response.
+               WebResponse response;
+               try {
+                       response = request.GetResponse ();
+               } catch {
+                       LogB.Warning("Error getting response");
+                       this.ResultMessage = Catalog.GetString("Could not send file.") + "\n" + 
+                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
+                                               serverUrl);
+                       return false;
+               }
+
+               // Display the status.
+               LogB.Information(((HttpWebResponse)response).StatusDescription);
+
+               // Get the stream containing content returned by the server.
+               dataStream = response.GetResponseStream ();
+
+               // Open the stream using a StreamReader for easy access.
+               StreamReader reader = new StreamReader (dataStream);
+
+               // Read the content.
+               string responseFromServer = reader.ReadToEnd ();
+
+               // Display the content.
+               LogB.Information(responseFromServer);
+
+               // Clean up the streams.
+               reader.Close ();
+               dataStream.Close ();
+               response.Close ();    
+
+
+               JsonValue result = JsonValue.Parse(responseFromServer);
+               string crash_id = result["crash_id"];
+               LogB.Information("crash_id: ", crash_id);
+
+               this.ResultMessage = Catalog.GetString("Log sent. Thank you.");
+               return true;
+       }
+       
+       private byte[] readFile(string filePath)
+       {
+               return System.IO.File.ReadAllBytes(filePath); 
+       }
+
+
+       //public bool ChronojumpUpdated = true;
+       public bool GetLastVersion(string currentVersion) 
+       {
+               // Create a request using a URL that can receive a post. 
+               WebRequest request = WebRequest.Create (serverUrl + "/version");
+               
+               // Set the Method property of the request to GET.
+               request.Method = "GET";
+               
+               // Set the ContentType property of the WebRequest.
+               //request.ContentType = "application/x-www-form-urlencoded";
+               
+               HttpWebResponse response;
+               try {
+                       response = (HttpWebResponse) request.GetResponse();
+               } catch {
+                       this.ResultMessage = 
+                               Catalog.GetString("Could not get last version.") + "\n" +
+                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
+                               serverUrl);
+                       return false;
+               }
+
+               string responseFromServer;
+               using (var sr = new StreamReader(response.GetResponseStream()))
+               {
+                       responseFromServer = sr.ReadToEnd();
+               }
+
+               //this prints:
+               // {"stable": "1.4.9"}
+               //this.ResultMessage = "Last version published: " + responseFromServer;
+               
+               string [] strFull = responseFromServer.Split(new char[] {':'});
+               int startPos = strFull[1].IndexOf('"') +1;
+               int endPos = strFull[1].LastIndexOf('"') -2;
+
+               string lastVersionPublished = strFull[1].Substring(startPos,endPos); //1.4.9
+                       
+               string updateStr = "";
+               if(currentVersion != lastVersionPublished)
+                       updateStr = "\n\n" + Catalog.GetString("Update software at ") + "www.chronojump.org";
+                       
+               this.ResultMessage =            
+                       Catalog.GetString("Installed version is: ") + currentVersion + "\n" + 
+                       Catalog.GetString("Last version published: ") + lastVersionPublished +
+                       updateStr;
+               
+               //ChronojumpUpdated = (currentVersion == ResultMessage);
+
+               return true;
+       }
+
+       public bool Ping(string osVersion, string cjVersion, string machineID) 
+       {
+               // Create a request using a URL that can receive a post. 
+               WebRequest request = WebRequest.Create (serverUrl + "/ping");
+
+               // Set the Method property of the request to POST.
+               request.Method = "POST";
+
+               // Set the ContentType property of the WebRequest.
+               request.ContentType = "application/json";
+
+               // Creates the json object
+               JsonObject json = new JsonObject();
+               json.Add("os_version", osVersion);
+               json.Add("cj_version", cjVersion);
+               json.Add("machine_id", machineID);
+
+               // Converts it to a String
+               String js = json.ToString();
+
+               // Writes the json object into the request dataStream
+               Stream dataStream;
+               try {
+                       dataStream = request.GetRequestStream ();
+               } catch {
+                       this.ResultMessage = 
+                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
+                               serverUrl);
+                       return false;
+               }
+               dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
+
+               dataStream.Close ();
+
+               // Get the response.
+               WebResponse response;
+               try {
+                       response = request.GetResponse ();
+               } catch {
+                       this.ResultMessage = 
+                               string.Format(Catalog.GetString("You are not connected to the Internet\nor 
{0} server is down."), 
+                               serverUrl);
+                       return false;
+               }
+
+               // Display the status (will be 201, CREATED)
+               Console.WriteLine (((HttpWebResponse)response).StatusDescription);
+
+               // Clean up the streams.
+               dataStream.Close ();
+               response.Close ();
+               
+               this.ResultMessage = "Ping sent.";
+               return true;
+       }
+
+
+       ~Json() {}
+}
diff --git a/src/log.cs b/src/log.cs
index f12a8b4..e773bdc 100644
--- a/src/log.cs
+++ b/src/log.cs
@@ -65,14 +65,14 @@ public class Log
        
 
                //this does not write until exit
-               //StreamWriter sw = new StreamWriter(new BufferedStream(new 
FileStream(UtilAll.GetLogFileCurrent(), FileMode.Create)));
+               //StreamWriter sw = new StreamWriter(new BufferedStream(new 
FileStream(UtilAll.GetLogFileCurrent(), FileMode.Create)));
 
                //this writes all the time
-               StreamWriter sw = new StreamWriter(new FileStream(UtilAll.GetLogFileCurrent(), 
FileMode.Create));
+               StreamWriter sw = new StreamWriter(new FileStream(UtilAll.GetLogFileCurrent(), 
FileMode.Create));
 
-               System.Console.SetOut(sw);
-               System.Console.SetError(sw);
-               sw.AutoFlush = true;
+               System.Console.SetOut(sw);
+               System.Console.SetError(sw);
+               sw.AutoFlush = true;
        }
 
        public static void End() 
diff --git a/src/server.cs b/src/server.cs
index eb1997d..263136d 100644
--- a/src/server.cs
+++ b/src/server.cs
@@ -1,684 +1,684 @@
-/*
- * This file is part of ChronoJump
- *
- * ChronoJump is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *   the Free Software Foundation; either version 2 of the License, or   
- *    (at your option) any later version.
- *    
- * ChronoJump is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
- *    GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- *  Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
- */
-
-using System;
-using System.Data;
-using System.Text; //StringBuilder
-using System.Threading;
-using Mono.Unix;
-using Gtk;
-using Gdk;
-using Glade;
-using System.Net;
-using System.Collections;
-
-//test comment
-
-public class Server
-{
-       public static bool CanI(string action, string clientVersion) {
-               try {
-                       ChronojumpServer myServer = new ChronojumpServer();
-                       return myServer.CanINew(action, clientVersion);
-               } catch {
-                       return false;
-               }
-       }
-
-       /*
-       private static string getIP() {
-               string strHostName = "";
-               strHostName = System.Net.Dns.GetHostName();
-               IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);
-               IPAddress[] addr = ipEntry.AddressList;
-               return addr[addr.Length-1].ToString();
-       }
-       */
-
-       public static string Ping(bool doInsertion, string progName, string progVersion) {
-               try {
-                       ChronojumpServer myServer = new ChronojumpServer();
-                       LogB.Information(myServer.ConnectDatabase());
-               
-                       int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
-                       string machineID = SqlitePreferences.Select("machineID");
-
-                       ServerPing myPing = new ServerPing(evalSID, progName + " " + progVersion, 
UtilAll.GetOS(), 
-                                       //getIP(), DateTime.Now); //evaluator IP, date
-                                       machineID, DateTime.Now); //evaluator machineID, date
-
-                       //if !doIsertion nothing will be uploaded,
-                       //is ok for uploadPerson to know if server is online
-                       string versionAvailable = myServer.UploadPing(myPing, doInsertion);
-                       
-                       LogB.Information(myServer.DisConnectDatabase());
-                       return versionAvailable;
-               } catch (Exception e){
-                       LogB.Information("Server Connection", e.Message);
-                       return Constants.ServerOffline;
-               }
-       }
-       
-       /* 
-        * server session update 
-        */
-
-       static Thread thread;
-
-       public static SessionUploadWindow sessionUploadWin;
-       [Widget] static Gtk.Window app1;
-       
-       static Session currentSession;
-       static string progName;
-       static string progVersion;
-
-       static bool serverSessionError;
-       static bool needUpdateServerSession;
-       static bool updatingServerSession;
-       static SessionUploadPersonData sessionUploadPersonData;
-       static int progressBarPersonsNum;
-       static int countPersons;
-                       
-       public static void InitializeSessionVariables(Gtk.Window mainApp, Session session, string 
programName, string programVersion) {
-               app1 = mainApp;
-               currentSession = session;
-               progName = programName;
-               progVersion = programVersion;
-
-               serverSessionError = false;
-               needUpdateServerSession = false;
-               updatingServerSession = false;
-               sessionUploadPersonData = new SessionUploadPersonData();
-               countPersons = 0;
-               progressBarPersonsNum = 0;
-       }
-                       
-       public static void ThreadStart() {
-               thread = new Thread(new ThreadStart(on_server_upload_session_started));
-               GLib.Idle.Add (new GLib.IdleHandler (pulseGTKServer));
-               thread.Start(); 
-       }
-       
-       private static bool pulseGTKServer ()
-       {
-               if(! thread.IsAlive) {
-                       sessionUploadWin.UploadFinished();
-                       LogB.Information("dying");
-                       return false;
-               }
-
-               if (serverSessionError) {
-                       new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error uploading 
session to server"));
-                       return false;
-               }
-
-               //need to do this, if not it crashes because chronopicWin gets died by thread ending
-               sessionUploadWin = SessionUploadWindow.Show(app1);
-                       
-               if(countPersons == 0)
-                       sessionUploadWin.PulseProgressbar();
-
-               //activity on pulsebar
-               sessionUploadWin.UpdatePulsebar();
-
-               if(needUpdateServerSession && !updatingServerSession) {
-                       //prevent that FillData is called again with same data
-                       updatingServerSession = true;
-
-                       //update progressBar
-                       sessionUploadWin.UpdateProgressbar(
-                                       Util.DivideSafeFraction(++countPersons, progressBarPersonsNum));
-
-                       //fill data
-                       sessionUploadWin.FillData(sessionUploadPersonData);
-
-                       //not need to update until there's more data coming from the other thread
-                       updatingServerSession = false;
-                       needUpdateServerSession = false;
-               }
-               
-               Thread.Sleep (50);
-               LogB.Debug(thread.ThreadState.ToString());
-               return true;
-       }
-       
-       private static void on_server_upload_session_started () 
-       {
-               int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
-
-               try {   
-                       ChronojumpServer myServer = new ChronojumpServer();
-                       LogB.Information(myServer.ConnectDatabase());
-               
-                       int state = (int) Constants.ServerSessionStates.UPLOADINGSESSION;
-                       //create ServerSession based on Session currentSession
-                       ServerSession serverSession = new ServerSession(currentSession, evalSID, progName + " 
" + progVersion, 
-                                       UtilAll.GetOS(), DateTime.Now, state); 
-
-                       //if uploading session for first time
-                       if(currentSession.ServerUniqueID == Constants.ServerUndefinedID) 
-                       {
-                               //upload ServerSession
-                               int idAtServer = myServer.UploadSession(serverSession);
-
-                               //update session currentSession (serverUniqueID) on client database
-                               currentSession.ServerUniqueID = idAtServer;
-                               SqliteSession.UpdateServerUniqueID(currentSession.UniqueID, 
currentSession.ServerUniqueID);
-                       }
-
-                       state = (int) Constants.ServerSessionStates.UPLOADINGDATA;
-                       myServer.UpdateSession(currentSession.ServerUniqueID, state); 
-
-                       sessionUploadPersonData.testTypes = "";
-                       string testTypesSeparator = "";
-                       sessionUploadPersonData.sports = "";
-                       string sportsSeparator = "";
-
-                       //upload persons (updating also person.serverUniqueID locally)
-                       ArrayList persons = SqlitePersonSession.SelectCurrentSessionPersons(
-                                       serverSession.UniqueID,
-                                       false); //means: do not returnPersonAndPSlist
-                       
-                       Constants.UploadCodes uCode;
-                       ArrayList notToUpload = 
SqlitePersonSessionNotUpload.SelectAll(currentSession.UniqueID);
-                       
-                       //store in variable for updating progressBar from other thread
-                       progressBarPersonsNum = persons.Count - notToUpload.Count;
-
-                       foreach(Person p in persons) {
-                               Person person = p;
-
-                               //do not continue with this person if has been banned to upload
-                               if(Util.FoundInArrayList(notToUpload, person.UniqueID.ToString())) 
-                                       continue;
-
-                               PersonSession ps = SqlitePersonSession.Select(person.UniqueID, 
currentSession.UniqueID);  
-
-                               //check person if exists
-                               if(person.ServerUniqueID != Constants.ServerUndefinedID) 
-                                       uCode = Constants.UploadCodes.EXISTS;
-                               else {
-                                       uCode = Constants.UploadCodes.OK;
-
-                                       person = serverUploadPerson(myServer, person, serverSession.UniqueID);
-                               }
-                                       
-                               //if sport is user defined, upload it
-                               //and when upload the person, do it with new sportID
-                               Sport sport = SqliteSport.Select(false, ps.SportID);
-                               //but record old sport ID because locally will be a change in serverUniqueID
-                               //(with slite update)
-                               //but local sport has not to be changed
-                               int sportUserDefinedLocal = -1;
-
-                               if(sport.UserDefined) {
-                                       sportUserDefinedLocal = sport.UniqueID;
-
-                                       //this will be uploaded
-                                       int newSport = myServer.UploadSport(sport);
-                                       if(newSport != -1) {
-                                               ps.SportID = newSport;
-                                               sessionUploadPersonData.sports += sportsSeparator + 
sport.Name;
-                                               sportsSeparator = ", ";
-                                       }
-                               }
-
-                               //a person can be in the database for one session, 
-                               //but maybe now we add jumps from another session and we should add an entry 
at personsession
-                               serverUploadPersonSessionIfNeeded(myServer, person.ServerUniqueID, 
-                                               currentSession.ServerUniqueID, ps, sportUserDefinedLocal);
-
-                               //other thread updates the gui:
-                               sessionUploadPersonData.person = person;
-                               sessionUploadPersonData.personCode = uCode;
-
-                               //upload jumps
-                               int countU = 0;                                 
-                               int countE = 0;                                 
-                               int countS = 0;                                 
-
-                               string [] jumps = SqliteJump.SelectJumps(false, currentSession.UniqueID, 
person.UniqueID, "", "",
-                                               Sqlite.Orders_by.DEFAULT, -1);
-                               Sqlite.Open();
-                               foreach(string myJump in jumps) {
-                                       string [] js = myJump.Split(new char[] {':'});
-                                       //select jump
-                                       Jump test = SqliteJump.SelectJumpData(Convert.ToInt32(js[1]), true); 
//uniqueID
-                                       //fix it to server person, session keys
-                                       test.PersonID = person.ServerUniqueID;
-                                       test.SessionID = currentSession.ServerUniqueID;
-
-                                       //if test is not simulated and has not been uploaded,
-                                       //see if it's type is not predefined and is not in the database
-                                       //then upload it first
-                                       if(test.Simulated == 0) {
-                                               //upload jumpType if is user defined and doesn't exists in 
server database
-                                               //JumpType type = new JumpType(test.Type);
-                                               JumpType type = 
SqliteJumpType.SelectAndReturnJumpType(test.Type, true);
-                                               if( ! type.IsPredefined) {
-                                                       //Console.WriteLine("USER DEFINED TEST: " + 
test.Type);
-                                                       //
-                                                       //this uploads the new type, as it's user created, it 
will be like this
-                                                       //eg: for user defined jumpType: "supra" of 
evaluatorServerID: 9
-                                                       //at server will be "supra-9"
-                                                       //then two problems get solved:
-                                                       //1.- every evaluator that uploads a type will have a 
different name 
-                                                       //than other evaluator uploading a type that is named 
the same but could be different 
-                                                       //(one can think that "supra" is another thing
-                                                       //2- when the same evaluator upload some supra's, 
only a new type is created
-                                       
-                                                       //test.Type = myServer.UploadJumpType(type, evalSID);
-                                                       //int testType = (int) Constants.TestTypes.JUMP;
-                                                       //string insertedType = 
myServer.UploadTestType(Constants.TestTypes.JUMP, type, evalSID);
-                                                       //string insertedType = 
myServer.UploadTestType(testType, type, evalSID);
-                                                       string insertedType = myServer.UploadJumpType(type, 
evalSID);
-                                                       if(insertedType != "-1") {
-                                                               //record type in test (with the "-7" if it's 
done by evaluator 7)
-                                                               test.Type = insertedType;
-
-                                                               //show user uploaded type (without the "-7")
-                                                               sessionUploadPersonData.testTypes += 
testTypesSeparator + type.Name;
-                                                               testTypesSeparator = ", ";
-                                                       }
-                                       
-                                                       //test.Type in the server will have the correct name 
"supra-9" 
-                                               } 
-                                       }
-
-                                       //upload... (if not because of simulated or uploaded before, report 
also the user)
-                                       uCode = serverUploadTest(myServer, Constants.TestTypes.JUMP, 
Constants.JumpTable, test);
-
-                                       if(uCode == Constants.UploadCodes.OK)
-                                               countU ++;
-                                       else if(uCode == Constants.UploadCodes.EXISTS)
-                                               countE ++;
-                                       else //SIMULATED
-                                               countS ++;
-                               }
-                               Sqlite.Close();
-
-                               //other thread updates the gui:
-                               sessionUploadPersonData.jumpsU = countU;
-                               sessionUploadPersonData.jumpsE = countE;
-                               sessionUploadPersonData.jumpsS = countS;
-
-                               //upload jumpsRj
-                               countU = 0;                                     
-                               countE = 0;                                     
-                               countS = 0;                                     
-
-                               string [] jumpsRj = SqliteJumpRj.SelectJumps(false, currentSession.UniqueID, 
person.UniqueID, "", "");
-                               Sqlite.Open();
-                               foreach(string myJump in jumpsRj) {
-                                       string [] js = myJump.Split(new char[] {':'});
-                                       //select jump
-                                       JumpRj test = SqliteJumpRj.SelectJumpData(Constants.JumpRjTable, 
Convert.ToInt32(js[1]), true); //uniqueID
-                                       //fix it to server person, session keys
-                                       test.PersonID = person.ServerUniqueID;
-                                       test.SessionID = currentSession.ServerUniqueID;
-                                       
-                                       if(test.Simulated == 0) {
-                                               JumpType type = 
SqliteJumpType.SelectAndReturnJumpRjType(test.Type, true);
-                                               if( ! type.IsPredefined) {
-                                                       string insertedType = myServer.UploadJumpRjType(type, 
evalSID);
-                                                       if(insertedType != "-1") {
-                                                               test.Type = insertedType;
-                                                               sessionUploadPersonData.testTypes += 
testTypesSeparator + type.Name;
-                                                               testTypesSeparator = ", ";
-                                                       }
-                                               } 
-                                       }
-                                       
-                                       //upload...
-                                       uCode = serverUploadTest(myServer, Constants.TestTypes.JUMP_RJ, 
Constants.JumpRjTable, test);
-
-                                       if(uCode == Constants.UploadCodes.OK)
-                                               countU ++;
-                                       else if(uCode == Constants.UploadCodes.EXISTS)
-                                               countE ++;
-                                       else //SIMULATED
-                                               countS ++;
-                               }
-                               Sqlite.Close();
-
-                               //other thread updates the gui:
-                               sessionUploadPersonData.jumpsRjU = countU;
-                               sessionUploadPersonData.jumpsRjE = countE;
-                               sessionUploadPersonData.jumpsRjS = countS;
-
-                               //upload runs
-                               countU = 0;                                     
-                               countE = 0;                                     
-                               countS = 0;                                     
-
-                               string [] runs = SqliteRun.SelectRuns(false, currentSession.UniqueID, 
person.UniqueID, "",
-                                               Sqlite.Orders_by.DEFAULT, -1);
-
-                               Sqlite.Open();
-                               foreach(string myRun in runs) {
-                                       string [] js = myRun.Split(new char[] {':'});
-                                       //select run
-                                       Run test = SqliteRun.SelectRunData(Convert.ToInt32(js[1]), true); 
//uniqueID
-                                       //fix it to server person, session keys
-                                       test.PersonID = person.ServerUniqueID;
-                                       test.SessionID = currentSession.ServerUniqueID;
-
-                                       if(test.Simulated == 0) {
-                                               RunType type = 
SqliteRunType.SelectAndReturnRunType(test.Type, true);
-                                               if( ! type.IsPredefined) {
-                                                       string insertedType = myServer.UploadRunType(type, 
evalSID);
-                                                       if(insertedType != "-1") {
-                                                               test.Type = insertedType;
-                                                               sessionUploadPersonData.testTypes += 
testTypesSeparator + type.Name;
-                                                               testTypesSeparator = ", ";
-                                                       }
-                                               }
-                                       }
-
-                                       //upload...
-                                       uCode = serverUploadTest(myServer, Constants.TestTypes.RUN, 
Constants.RunTable, test);
-
-                                       if(uCode == Constants.UploadCodes.OK)
-                                               countU ++;
-                                       else if(uCode == Constants.UploadCodes.EXISTS)
-                                               countE ++;
-                                       else //SIMULATED
-                                               countS ++;
-                               }
-                               Sqlite.Close();
-
-                               //other thread updates the gui:
-                               sessionUploadPersonData.runsU = countU;
-                               sessionUploadPersonData.runsE = countE;
-                               sessionUploadPersonData.runsS = countS;
-
-                               //upload runs intervallic
-                               countU = 0;                                     
-                               countE = 0;                                     
-                               countS = 0;                                     
-
-                               string [] runsI = SqliteRunInterval.SelectRuns(false, 
currentSession.UniqueID, person.UniqueID, "");
-                               Sqlite.Open();
-                               foreach(string myRun in runsI) {
-                                       string [] js = myRun.Split(new char[] {':'});
-                                       //select run
-                                       RunInterval test = 
SqliteRunInterval.SelectRunData(Constants.RunIntervalTable, Convert.ToInt32(js[1]), true); //uniqueID
-                                       //fix it to server person, session keys
-                                       test.PersonID = person.ServerUniqueID;
-                                       test.SessionID = currentSession.ServerUniqueID;
-                                       
-                                       if(test.Simulated == 0) {
-                                               RunType type = 
SqliteRunIntervalType.SelectAndReturnRunIntervalType(test.Type, true);
-                                               if( ! type.IsPredefined) {
-                                                       string insertedType = 
myServer.UploadRunIntervalType(type, evalSID);
-                                                       if(insertedType != "-1") {
-                                                               test.Type = insertedType;
-                                                               sessionUploadPersonData.testTypes += 
testTypesSeparator + type.Name;
-                                                               testTypesSeparator = ", ";
-                                                       }
-                                               } 
-                                       }
-                                       //upload...
-                                       uCode = serverUploadTest(myServer, Constants.TestTypes.RUN_I, 
Constants.RunIntervalTable, test);
-
-                                       if(uCode == Constants.UploadCodes.OK)
-                                               countU ++;
-                                       else if(uCode == Constants.UploadCodes.EXISTS)
-                                               countE ++;
-                                       else //SIMULATED
-                                               countS ++;
-                               }
-                               Sqlite.Close();
-
-                               //other thread updates the gui:
-                               sessionUploadPersonData.runsIU = countU;
-                               sessionUploadPersonData.runsIE = countE;
-                               sessionUploadPersonData.runsIS = countS;
-
-                               //upload reaction times
-                               countU = 0;                                     
-                               countE = 0;                                     
-                               countS = 0;                                     
-
-                               string [] rts = SqliteReactionTime.SelectReactionTimes(false, 
currentSession.UniqueID, person.UniqueID, "",
-                                               Sqlite.Orders_by.DEFAULT, -1);
-
-                               Sqlite.Open();
-                               foreach(string myRt in rts) {
-                                       string [] js = myRt.Split(new char[] {':'});
-                                       //select rt
-                                       ReactionTime test = 
SqliteReactionTime.SelectReactionTimeData(Convert.ToInt32(js[1]), true); //uniqueID
-                                       //fix it to server person, session keys
-                                       test.PersonID = person.ServerUniqueID;
-                                       test.SessionID = currentSession.ServerUniqueID;
-                                       //upload...
-                                       uCode = serverUploadTest(myServer, Constants.TestTypes.RT, 
Constants.ReactionTimeTable, test);
-
-                                       if(uCode == Constants.UploadCodes.OK)
-                                               countU ++;
-                                       else if(uCode == Constants.UploadCodes.EXISTS)
-                                               countE ++;
-                                       else //SIMULATED
-                                               countS ++;
-                               }
-                               Sqlite.Close();
-
-                               //other thread updates the gui:
-                               sessionUploadPersonData.rtsU = countU;
-                               sessionUploadPersonData.rtsE = countE;
-                               sessionUploadPersonData.rtsS = countS;
-
-                               //upload pulses
-                               countU = 0;                                     
-                               countE = 0;                                     
-                               countS = 0;                                     
-
-                               string [] pulses = SqlitePulse.SelectPulses(false, currentSession.UniqueID, 
person.UniqueID);
-                               Sqlite.Open();
-                               foreach(string myPulse in pulses) {
-                                       string [] js = myPulse.Split(new char[] {':'});
-                                       //select pulse
-                                       Pulse test = SqlitePulse.SelectPulseData(Convert.ToInt32(js[1]), 
true); //uniqueID
-                                       //fix it to server person, session keys
-                                       test.PersonID = person.ServerUniqueID;
-                                       test.SessionID = currentSession.ServerUniqueID;
-                                       //upload...
-                                       uCode = serverUploadTest(myServer, Constants.TestTypes.PULSE, 
Constants.PulseTable, test);
-
-                                       if(uCode == Constants.UploadCodes.OK)
-                                               countU ++;
-                                       else if(uCode == Constants.UploadCodes.EXISTS)
-                                               countE ++;
-                                       else //SIMULATED
-                                               countS ++;
-                               }
-                               Sqlite.Close();
-
-                               //other thread updates the gui:
-                               sessionUploadPersonData.pulsesU = countU;
-                               sessionUploadPersonData.pulsesE = countE;
-                               sessionUploadPersonData.pulsesS = countS;
-
-                               //upload multiChronopic
-                               countU = 0;                                     
-                               countE = 0;                                     
-                               countS = 0;                                     
-
-                               string [] mcs = SqliteMultiChronopic.SelectTests(false, 
currentSession.UniqueID, person.UniqueID);
-                               Sqlite.Open();
-                               foreach(string mc in mcs) {
-                                       string [] js = mc.Split(new char[] {':'});
-                                       //select mc
-                                       MultiChronopic test = 
SqliteMultiChronopic.SelectMultiChronopicData(Convert.ToInt32(js[1]), true); //uniqueID
-                                       //fix it to server person, session keys
-                                       test.PersonID = person.ServerUniqueID;
-                                       test.SessionID = currentSession.ServerUniqueID;
-                                       //upload...
-                                       uCode = serverUploadTest(myServer, 
Constants.TestTypes.MULTICHRONOPIC, Constants.MultiChronopicTable, test);
-
-                                       if(uCode == Constants.UploadCodes.OK)
-                                               countU ++;
-                                       else if(uCode == Constants.UploadCodes.EXISTS)
-                                               countE ++;
-                                       else //SIMULATED
-                                               countS ++;
-                               }
-                               Sqlite.Close();
-
-                               //other thread updates the gui:
-                               sessionUploadPersonData.mcsU = countU;
-                               sessionUploadPersonData.mcsE = countE;
-                               sessionUploadPersonData.mcsS = countS;
-
-                               needUpdateServerSession = true;
-                               while(needUpdateServerSession) {
-                                       //wait until data is printed on the other thread
-                               }
-
-                       }
-                                                               
-                       state = (int) Constants.ServerSessionStates.DONE;
-                       //myServer.UpdateSession(currentSession.ServerUniqueID, (ServerSessionStates)  
Constants.ServerSessionStates.DONE); 
-                       myServer.UpdateSession(currentSession.ServerUniqueID, state); 
-
-                       LogB.Information(myServer.DisConnectDatabase());
-               } catch {
-                       //other thread updates the gui:
-                       serverSessionError = true;
-               }
-       }
-       
-       
-       //upload a person
-       private static Person serverUploadPerson(ChronojumpServer myServer, Person person, int 
serverSessionID) 
-       {
-               int idAtServer = myServer.UploadPerson(person, serverSessionID);
-
-               //update person (serverUniqueID) on client database
-               person.ServerUniqueID = idAtServer;
-
-               SqlitePerson.Update(person);
-
-               return person;
-       }
-
-       private static void serverUploadPersonSessionIfNeeded(ChronojumpServer myServer, 
-                       int personServerID, int sessionServerID, PersonSession ps, int sportUserDefinedLocal)
-       {
-               //when update locally, don't put the user defined sport id at server
-               if(sportUserDefinedLocal != -1)
-                       ps.SportID = sportUserDefinedLocal;
-
-               ps.UniqueID = -1;
-               ps.PersonID = personServerID;
-               ps.SessionID = sessionServerID;
-
-               myServer.UploadPersonSessionIfNeeded(ps);
-       }
-
-       //upload a test
-       private static Constants.UploadCodes serverUploadTest(ChronojumpServer myServer, Constants.TestTypes 
type, string tableName, Event myTest) 
-       {
-               Constants.UploadCodes uCode;
-
-               if(myTest.Simulated == Constants.Simulated) {
-                       //Test is simulated, don't upload
-                       uCode = Constants.UploadCodes.SIMULATED;
-               } else if(myTest.Simulated > 0) {
-                       //Test is already uploaded, don't upload
-                       uCode = Constants.UploadCodes.EXISTS;
-               } else {
-                       int idAtServer = -1;
-                       switch (type) {
-                               case Constants.TestTypes.JUMP :
-                                       Jump jump = (Jump)myTest;
-                                       idAtServer = myServer.UploadJump(jump);
-                                       break;
-                               case Constants.TestTypes.JUMP_RJ :
-                                       JumpRj jumpRj = (JumpRj)myTest;
-                                       idAtServer = myServer.UploadJumpRj(jumpRj);
-                                       break;
-                               case Constants.TestTypes.RUN :
-                                       Run run = (Run)myTest;
-                                       idAtServer = myServer.UploadRun(run);
-                                       break;
-                               case Constants.TestTypes.RUN_I :
-                                       RunInterval runI = (RunInterval)myTest;
-                                       idAtServer = myServer.UploadRunI(runI);
-                                       break;
-                               case Constants.TestTypes.RT :
-                                       ReactionTime rt = (ReactionTime)myTest;
-                                       idAtServer = myServer.UploadRT(rt);
-                                       break;
-                               case Constants.TestTypes.PULSE :
-                                       Pulse pulse = (Pulse)myTest;
-                                       idAtServer = myServer.UploadPulse(pulse);
-                                       break;
-                               case Constants.TestTypes.MULTICHRONOPIC :
-                                       MultiChronopic mc = (MultiChronopic)myTest;
-                                       idAtServer = myServer.UploadMultiChronopic(mc);
-                                       break;
-                       }
-
-                       
-                       //update test (simulated) on client database
-                       myTest.Simulated = idAtServer;
-                       SqliteEvent.UpdateSimulated(true, tableName, myTest.UniqueID, idAtServer);
-                       
-                       uCode = Constants.UploadCodes.OK;
-               }
-               return uCode;
-       }
-
-       public static void ServerUploadEvaluator () {
-               try {
-                       ChronojumpServer myServer = new ChronojumpServer();
-                       LogB.Information(myServer.ConnectDatabase());
-                       
-                       ServerEvaluator myEval = SqliteServer.SelectEvaluator(1);
-
-                       bool success = false;
-                       int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
-                       if(evalSID == Constants.ServerUndefinedID) {
-                               string idCode = myServer.UploadEvaluator(myEval);
-                               myEval.Code = Util.FetchName(idCode);
-
-                               myEval.Update(false);
-
-                               evalSID = Util.FetchID(idCode);
-                               SqlitePreferences.Update("evaluatorServerID", evalSID.ToString(), false);
-                               success = true;
-                       } else 
-                               success = myServer.EditEvaluator(myEval, evalSID);
-                               
-                       if(success)
-                               new DialogMessage(Constants.MessageTypes.INFO, 
-                                               string.Format(Catalog.GetString("Successfully Uploaded 
evaluator with ID: {0}"), evalSID));
-                       else
-                               new DialogMessage(Constants.MessageTypes.WARNING, 
-                                               string.Format(Catalog.GetString("Evaluator {0} has not been 
correctly uploaded. Maybe codes doesn't match."), evalSID));
-                       
-                       LogB.Information(myServer.DisConnectDatabase());
-               } catch {
-                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.ServerOffline);
-               }
-       }
-       
-}
+/*
+ * This file is part of ChronoJump
+ *
+ * ChronoJump is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or   
+ *    (at your option) any later version.
+ *    
+ * ChronoJump is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
+ *    GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  Copyright (C) 2004-2016   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using System;
+using System.Data;
+using System.Text; //StringBuilder
+using System.Threading;
+using Mono.Unix;
+using Gtk;
+using Gdk;
+using Glade;
+using System.Net;
+using System.Collections;
+
+//test comment
+
+public class Server
+{
+       public static bool CanI(string action, string clientVersion) {
+               try {
+                       ChronojumpServer myServer = new ChronojumpServer();
+                       return myServer.CanINew(action, clientVersion);
+               } catch {
+                       return false;
+               }
+       }
+
+       /*
+       private static string getIP() {
+               string strHostName = "";
+               strHostName = System.Net.Dns.GetHostName();
+               IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName);
+               IPAddress[] addr = ipEntry.AddressList;
+               return addr[addr.Length-1].ToString();
+       }
+       */
+
+       public static string Ping(bool doInsertion, string progName, string progVersion) {
+               try {
+                       ChronojumpServer myServer = new ChronojumpServer();
+                       LogB.Information(myServer.ConnectDatabase());
+               
+                       int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
+                       string machineID = SqlitePreferences.Select("machineID");
+
+                       ServerPing myPing = new ServerPing(evalSID, progName + " " + progVersion, 
UtilAll.GetOS(), 
+                                       //getIP(), DateTime.Now); //evaluator IP, date
+                                       machineID, DateTime.Now); //evaluator machineID, date
+
+                       //if !doIsertion nothing will be uploaded,
+                       //is ok for uploadPerson to know if server is online
+                       string versionAvailable = myServer.UploadPing(myPing, doInsertion);
+                       
+                       LogB.Information(myServer.DisConnectDatabase());
+                       return versionAvailable;
+               } catch (Exception e){
+                       LogB.Information("Server Connection", e.Message);
+                       return Constants.ServerOffline;
+               }
+       }
+       
+       /* 
+        * server session update 
+        */
+
+       static Thread thread;
+
+       public static SessionUploadWindow sessionUploadWin;
+       [Widget] static Gtk.Window app1;
+       
+       static Session currentSession;
+       static string progName;
+       static string progVersion;
+
+       static bool serverSessionError;
+       static bool needUpdateServerSession;
+       static bool updatingServerSession;
+       static SessionUploadPersonData sessionUploadPersonData;
+       static int progressBarPersonsNum;
+       static int countPersons;
+                       
+       public static void InitializeSessionVariables(Gtk.Window mainApp, Session session, string 
programName, string programVersion) {
+               app1 = mainApp;
+               currentSession = session;
+               progName = programName;
+               progVersion = programVersion;
+
+               serverSessionError = false;
+               needUpdateServerSession = false;
+               updatingServerSession = false;
+               sessionUploadPersonData = new SessionUploadPersonData();
+               countPersons = 0;
+               progressBarPersonsNum = 0;
+       }
+                       
+       public static void ThreadStart() {
+               thread = new Thread(new ThreadStart(on_server_upload_session_started));
+               GLib.Idle.Add (new GLib.IdleHandler (pulseGTKServer));
+               thread.Start(); 
+       }
+       
+       private static bool pulseGTKServer ()
+       {
+               if(! thread.IsAlive) {
+                       sessionUploadWin.UploadFinished();
+                       LogB.Information("dying");
+                       return false;
+               }
+
+               if (serverSessionError) {
+                       new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("Error uploading 
session to server"));
+                       return false;
+               }
+
+               //need to do this, if not it crashes because chronopicWin gets died by thread ending
+               sessionUploadWin = SessionUploadWindow.Show(app1);
+                       
+               if(countPersons == 0)
+                       sessionUploadWin.PulseProgressbar();
+
+               //activity on pulsebar
+               sessionUploadWin.UpdatePulsebar();
+
+               if(needUpdateServerSession && !updatingServerSession) {
+                       //prevent that FillData is called again with same data
+                       updatingServerSession = true;
+
+                       //update progressBar
+                       sessionUploadWin.UpdateProgressbar(
+                                       Util.DivideSafeFraction(++countPersons, progressBarPersonsNum));
+
+                       //fill data
+                       sessionUploadWin.FillData(sessionUploadPersonData);
+
+                       //not need to update until there's more data coming from the other thread
+                       updatingServerSession = false;
+                       needUpdateServerSession = false;
+               }
+               
+               Thread.Sleep (50);
+               LogB.Debug(thread.ThreadState.ToString());
+               return true;
+       }
+       
+       private static void on_server_upload_session_started () 
+       {
+               int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
+
+               try {   
+                       ChronojumpServer myServer = new ChronojumpServer();
+                       LogB.Information(myServer.ConnectDatabase());
+               
+                       int state = (int) Constants.ServerSessionStates.UPLOADINGSESSION;
+                       //create ServerSession based on Session currentSession
+                       ServerSession serverSession = new ServerSession(currentSession, evalSID, progName + " 
" + progVersion, 
+                                       UtilAll.GetOS(), DateTime.Now, state); 
+
+                       //if uploading session for first time
+                       if(currentSession.ServerUniqueID == Constants.ServerUndefinedID) 
+                       {
+                               //upload ServerSession
+                               int idAtServer = myServer.UploadSession(serverSession);
+
+                               //update session currentSession (serverUniqueID) on client database
+                               currentSession.ServerUniqueID = idAtServer;
+                               SqliteSession.UpdateServerUniqueID(currentSession.UniqueID, 
currentSession.ServerUniqueID);
+                       }
+
+                       state = (int) Constants.ServerSessionStates.UPLOADINGDATA;
+                       myServer.UpdateSession(currentSession.ServerUniqueID, state); 
+
+                       sessionUploadPersonData.testTypes = "";
+                       string testTypesSeparator = "";
+                       sessionUploadPersonData.sports = "";
+                       string sportsSeparator = "";
+
+                       //upload persons (updating also person.serverUniqueID locally)
+                       ArrayList persons = SqlitePersonSession.SelectCurrentSessionPersons(
+                                       serverSession.UniqueID,
+                                       false); //means: do not returnPersonAndPSlist
+                       
+                       Constants.UploadCodes uCode;
+                       ArrayList notToUpload = 
SqlitePersonSessionNotUpload.SelectAll(currentSession.UniqueID);
+                       
+                       //store in variable for updating progressBar from other thread
+                       progressBarPersonsNum = persons.Count - notToUpload.Count;
+
+                       foreach(Person p in persons) {
+                               Person person = p;
+
+                               //do not continue with this person if has been banned to upload
+                               if(Util.FoundInArrayList(notToUpload, person.UniqueID.ToString())) 
+                                       continue;
+
+                               PersonSession ps = SqlitePersonSession.Select(person.UniqueID, 
currentSession.UniqueID);  
+
+                               //check person if exists
+                               if(person.ServerUniqueID != Constants.ServerUndefinedID) 
+                                       uCode = Constants.UploadCodes.EXISTS;
+                               else {
+                                       uCode = Constants.UploadCodes.OK;
+
+                                       person = serverUploadPerson(myServer, person, serverSession.UniqueID);
+                               }
+                                       
+                               //if sport is user defined, upload it
+                               //and when upload the person, do it with new sportID
+                               Sport sport = SqliteSport.Select(false, ps.SportID);
+                               //but record old sport ID because locally will be a change in serverUniqueID
+                               //(with slite update)
+                               //but local sport has not to be changed
+                               int sportUserDefinedLocal = -1;
+
+                               if(sport.UserDefined) {
+                                       sportUserDefinedLocal = sport.UniqueID;
+
+                                       //this will be uploaded
+                                       int newSport = myServer.UploadSport(sport);
+                                       if(newSport != -1) {
+                                               ps.SportID = newSport;
+                                               sessionUploadPersonData.sports += sportsSeparator + 
sport.Name;
+                                               sportsSeparator = ", ";
+                                       }
+                               }
+
+                               //a person can be in the database for one session, 
+                               //but maybe now we add jumps from another session and we should add an entry 
at personsession
+                               serverUploadPersonSessionIfNeeded(myServer, person.ServerUniqueID, 
+                                               currentSession.ServerUniqueID, ps, sportUserDefinedLocal);
+
+                               //other thread updates the gui:
+                               sessionUploadPersonData.person = person;
+                               sessionUploadPersonData.personCode = uCode;
+
+                               //upload jumps
+                               int countU = 0;                                 
+                               int countE = 0;                                 
+                               int countS = 0;                                 
+
+                               string [] jumps = SqliteJump.SelectJumps(false, currentSession.UniqueID, 
person.UniqueID, "", "",
+                                               Sqlite.Orders_by.DEFAULT, -1);
+                               Sqlite.Open();
+                               foreach(string myJump in jumps) {
+                                       string [] js = myJump.Split(new char[] {':'});
+                                       //select jump
+                                       Jump test = SqliteJump.SelectJumpData(Convert.ToInt32(js[1]), true); 
//uniqueID
+                                       //fix it to server person, session keys
+                                       test.PersonID = person.ServerUniqueID;
+                                       test.SessionID = currentSession.ServerUniqueID;
+
+                                       //if test is not simulated and has not been uploaded,
+                                       //see if it's type is not predefined and is not in the database
+                                       //then upload it first
+                                       if(test.Simulated == 0) {
+                                               //upload jumpType if is user defined and doesn't exists in 
server database
+                                               //JumpType type = new JumpType(test.Type);
+                                               JumpType type = 
SqliteJumpType.SelectAndReturnJumpType(test.Type, true);
+                                               if( ! type.IsPredefined) {
+                                                       //Console.WriteLine("USER DEFINED TEST: " + 
test.Type);
+                                                       //
+                                                       //this uploads the new type, as it's user created, it 
will be like this
+                                                       //eg: for user defined jumpType: "supra" of 
evaluatorServerID: 9
+                                                       //at server will be "supra-9"
+                                                       //then two problems get solved:
+                                                       //1.- every evaluator that uploads a type will have a 
different name 
+                                                       //than other evaluator uploading a type that is named 
the same but could be different 
+                                                       //(one can think that "supra" is another thing
+                                                       //2- when the same evaluator upload some supra's, 
only a new type is created
+                                       
+                                                       //test.Type = myServer.UploadJumpType(type, evalSID);
+                                                       //int testType = (int) Constants.TestTypes.JUMP;
+                                                       //string insertedType = 
myServer.UploadTestType(Constants.TestTypes.JUMP, type, evalSID);
+                                                       //string insertedType = 
myServer.UploadTestType(testType, type, evalSID);
+                                                       string insertedType = myServer.UploadJumpType(type, 
evalSID);
+                                                       if(insertedType != "-1") {
+                                                               //record type in test (with the "-7" if it's 
done by evaluator 7)
+                                                               test.Type = insertedType;
+
+                                                               //show user uploaded type (without the "-7")
+                                                               sessionUploadPersonData.testTypes += 
testTypesSeparator + type.Name;
+                                                               testTypesSeparator = ", ";
+                                                       }
+                                       
+                                                       //test.Type in the server will have the correct name 
"supra-9" 
+                                               } 
+                                       }
+
+                                       //upload... (if not because of simulated or uploaded before, report 
also the user)
+                                       uCode = serverUploadTest(myServer, Constants.TestTypes.JUMP, 
Constants.JumpTable, test);
+
+                                       if(uCode == Constants.UploadCodes.OK)
+                                               countU ++;
+                                       else if(uCode == Constants.UploadCodes.EXISTS)
+                                               countE ++;
+                                       else //SIMULATED
+                                               countS ++;
+                               }
+                               Sqlite.Close();
+
+                               //other thread updates the gui:
+                               sessionUploadPersonData.jumpsU = countU;
+                               sessionUploadPersonData.jumpsE = countE;
+                               sessionUploadPersonData.jumpsS = countS;
+
+                               //upload jumpsRj
+                               countU = 0;                                     
+                               countE = 0;                                     
+                               countS = 0;                                     
+
+                               string [] jumpsRj = SqliteJumpRj.SelectJumps(false, currentSession.UniqueID, 
person.UniqueID, "", "");
+                               Sqlite.Open();
+                               foreach(string myJump in jumpsRj) {
+                                       string [] js = myJump.Split(new char[] {':'});
+                                       //select jump
+                                       JumpRj test = SqliteJumpRj.SelectJumpData(Constants.JumpRjTable, 
Convert.ToInt32(js[1]), true); //uniqueID
+                                       //fix it to server person, session keys
+                                       test.PersonID = person.ServerUniqueID;
+                                       test.SessionID = currentSession.ServerUniqueID;
+                                       
+                                       if(test.Simulated == 0) {
+                                               JumpType type = 
SqliteJumpType.SelectAndReturnJumpRjType(test.Type, true);
+                                               if( ! type.IsPredefined) {
+                                                       string insertedType = myServer.UploadJumpRjType(type, 
evalSID);
+                                                       if(insertedType != "-1") {
+                                                               test.Type = insertedType;
+                                                               sessionUploadPersonData.testTypes += 
testTypesSeparator + type.Name;
+                                                               testTypesSeparator = ", ";
+                                                       }
+                                               } 
+                                       }
+                                       
+                                       //upload...
+                                       uCode = serverUploadTest(myServer, Constants.TestTypes.JUMP_RJ, 
Constants.JumpRjTable, test);
+
+                                       if(uCode == Constants.UploadCodes.OK)
+                                               countU ++;
+                                       else if(uCode == Constants.UploadCodes.EXISTS)
+                                               countE ++;
+                                       else //SIMULATED
+                                               countS ++;
+                               }
+                               Sqlite.Close();
+
+                               //other thread updates the gui:
+                               sessionUploadPersonData.jumpsRjU = countU;
+                               sessionUploadPersonData.jumpsRjE = countE;
+                               sessionUploadPersonData.jumpsRjS = countS;
+
+                               //upload runs
+                               countU = 0;                                     
+                               countE = 0;                                     
+                               countS = 0;                                     
+
+                               string [] runs = SqliteRun.SelectRuns(false, currentSession.UniqueID, 
person.UniqueID, "",
+                                               Sqlite.Orders_by.DEFAULT, -1);
+
+                               Sqlite.Open();
+                               foreach(string myRun in runs) {
+                                       string [] js = myRun.Split(new char[] {':'});
+                                       //select run
+                                       Run test = SqliteRun.SelectRunData(Convert.ToInt32(js[1]), true); 
//uniqueID
+                                       //fix it to server person, session keys
+                                       test.PersonID = person.ServerUniqueID;
+                                       test.SessionID = currentSession.ServerUniqueID;
+
+                                       if(test.Simulated == 0) {
+                                               RunType type = 
SqliteRunType.SelectAndReturnRunType(test.Type, true);
+                                               if( ! type.IsPredefined) {
+                                                       string insertedType = myServer.UploadRunType(type, 
evalSID);
+                                                       if(insertedType != "-1") {
+                                                               test.Type = insertedType;
+                                                               sessionUploadPersonData.testTypes += 
testTypesSeparator + type.Name;
+                                                               testTypesSeparator = ", ";
+                                                       }
+                                               }
+                                       }
+
+                                       //upload...
+                                       uCode = serverUploadTest(myServer, Constants.TestTypes.RUN, 
Constants.RunTable, test);
+
+                                       if(uCode == Constants.UploadCodes.OK)
+                                               countU ++;
+                                       else if(uCode == Constants.UploadCodes.EXISTS)
+                                               countE ++;
+                                       else //SIMULATED
+                                               countS ++;
+                               }
+                               Sqlite.Close();
+
+                               //other thread updates the gui:
+                               sessionUploadPersonData.runsU = countU;
+                               sessionUploadPersonData.runsE = countE;
+                               sessionUploadPersonData.runsS = countS;
+
+                               //upload runs intervallic
+                               countU = 0;                                     
+                               countE = 0;                                     
+                               countS = 0;                                     
+
+                               string [] runsI = SqliteRunInterval.SelectRuns(false, 
currentSession.UniqueID, person.UniqueID, "");
+                               Sqlite.Open();
+                               foreach(string myRun in runsI) {
+                                       string [] js = myRun.Split(new char[] {':'});
+                                       //select run
+                                       RunInterval test = 
SqliteRunInterval.SelectRunData(Constants.RunIntervalTable, Convert.ToInt32(js[1]), true); //uniqueID
+                                       //fix it to server person, session keys
+                                       test.PersonID = person.ServerUniqueID;
+                                       test.SessionID = currentSession.ServerUniqueID;
+                                       
+                                       if(test.Simulated == 0) {
+                                               RunType type = 
SqliteRunIntervalType.SelectAndReturnRunIntervalType(test.Type, true);
+                                               if( ! type.IsPredefined) {
+                                                       string insertedType = 
myServer.UploadRunIntervalType(type, evalSID);
+                                                       if(insertedType != "-1") {
+                                                               test.Type = insertedType;
+                                                               sessionUploadPersonData.testTypes += 
testTypesSeparator + type.Name;
+                                                               testTypesSeparator = ", ";
+                                                       }
+                                               } 
+                                       }
+                                       //upload...
+                                       uCode = serverUploadTest(myServer, Constants.TestTypes.RUN_I, 
Constants.RunIntervalTable, test);
+
+                                       if(uCode == Constants.UploadCodes.OK)
+                                               countU ++;
+                                       else if(uCode == Constants.UploadCodes.EXISTS)
+                                               countE ++;
+                                       else //SIMULATED
+                                               countS ++;
+                               }
+                               Sqlite.Close();
+
+                               //other thread updates the gui:
+                               sessionUploadPersonData.runsIU = countU;
+                               sessionUploadPersonData.runsIE = countE;
+                               sessionUploadPersonData.runsIS = countS;
+
+                               //upload reaction times
+                               countU = 0;                                     
+                               countE = 0;                                     
+                               countS = 0;                                     
+
+                               string [] rts = SqliteReactionTime.SelectReactionTimes(false, 
currentSession.UniqueID, person.UniqueID, "",
+                                               Sqlite.Orders_by.DEFAULT, -1);
+
+                               Sqlite.Open();
+                               foreach(string myRt in rts) {
+                                       string [] js = myRt.Split(new char[] {':'});
+                                       //select rt
+                                       ReactionTime test = 
SqliteReactionTime.SelectReactionTimeData(Convert.ToInt32(js[1]), true); //uniqueID
+                                       //fix it to server person, session keys
+                                       test.PersonID = person.ServerUniqueID;
+                                       test.SessionID = currentSession.ServerUniqueID;
+                                       //upload...
+                                       uCode = serverUploadTest(myServer, Constants.TestTypes.RT, 
Constants.ReactionTimeTable, test);
+
+                                       if(uCode == Constants.UploadCodes.OK)
+                                               countU ++;
+                                       else if(uCode == Constants.UploadCodes.EXISTS)
+                                               countE ++;
+                                       else //SIMULATED
+                                               countS ++;
+                               }
+                               Sqlite.Close();
+
+                               //other thread updates the gui:
+                               sessionUploadPersonData.rtsU = countU;
+                               sessionUploadPersonData.rtsE = countE;
+                               sessionUploadPersonData.rtsS = countS;
+
+                               //upload pulses
+                               countU = 0;                                     
+                               countE = 0;                                     
+                               countS = 0;                                     
+
+                               string [] pulses = SqlitePulse.SelectPulses(false, currentSession.UniqueID, 
person.UniqueID);
+                               Sqlite.Open();
+                               foreach(string myPulse in pulses) {
+                                       string [] js = myPulse.Split(new char[] {':'});
+                                       //select pulse
+                                       Pulse test = SqlitePulse.SelectPulseData(Convert.ToInt32(js[1]), 
true); //uniqueID
+                                       //fix it to server person, session keys
+                                       test.PersonID = person.ServerUniqueID;
+                                       test.SessionID = currentSession.ServerUniqueID;
+                                       //upload...
+                                       uCode = serverUploadTest(myServer, Constants.TestTypes.PULSE, 
Constants.PulseTable, test);
+
+                                       if(uCode == Constants.UploadCodes.OK)
+                                               countU ++;
+                                       else if(uCode == Constants.UploadCodes.EXISTS)
+                                               countE ++;
+                                       else //SIMULATED
+                                               countS ++;
+                               }
+                               Sqlite.Close();
+
+                               //other thread updates the gui:
+                               sessionUploadPersonData.pulsesU = countU;
+                               sessionUploadPersonData.pulsesE = countE;
+                               sessionUploadPersonData.pulsesS = countS;
+
+                               //upload multiChronopic
+                               countU = 0;                                     
+                               countE = 0;                                     
+                               countS = 0;                                     
+
+                               string [] mcs = SqliteMultiChronopic.SelectTests(false, 
currentSession.UniqueID, person.UniqueID);
+                               Sqlite.Open();
+                               foreach(string mc in mcs) {
+                                       string [] js = mc.Split(new char[] {':'});
+                                       //select mc
+                                       MultiChronopic test = 
SqliteMultiChronopic.SelectMultiChronopicData(Convert.ToInt32(js[1]), true); //uniqueID
+                                       //fix it to server person, session keys
+                                       test.PersonID = person.ServerUniqueID;
+                                       test.SessionID = currentSession.ServerUniqueID;
+                                       //upload...
+                                       uCode = serverUploadTest(myServer, 
Constants.TestTypes.MULTICHRONOPIC, Constants.MultiChronopicTable, test);
+
+                                       if(uCode == Constants.UploadCodes.OK)
+                                               countU ++;
+                                       else if(uCode == Constants.UploadCodes.EXISTS)
+                                               countE ++;
+                                       else //SIMULATED
+                                               countS ++;
+                               }
+                               Sqlite.Close();
+
+                               //other thread updates the gui:
+                               sessionUploadPersonData.mcsU = countU;
+                               sessionUploadPersonData.mcsE = countE;
+                               sessionUploadPersonData.mcsS = countS;
+
+                               needUpdateServerSession = true;
+                               while(needUpdateServerSession) {
+                                       //wait until data is printed on the other thread
+                               }
+
+                       }
+                                                               
+                       state = (int) Constants.ServerSessionStates.DONE;
+                       //myServer.UpdateSession(currentSession.ServerUniqueID, (ServerSessionStates)  
Constants.ServerSessionStates.DONE); 
+                       myServer.UpdateSession(currentSession.ServerUniqueID, state); 
+
+                       LogB.Information(myServer.DisConnectDatabase());
+               } catch {
+                       //other thread updates the gui:
+                       serverSessionError = true;
+               }
+       }
+       
+       
+       //upload a person
+       private static Person serverUploadPerson(ChronojumpServer myServer, Person person, int 
serverSessionID) 
+       {
+               int idAtServer = myServer.UploadPerson(person, serverSessionID);
+
+               //update person (serverUniqueID) on client database
+               person.ServerUniqueID = idAtServer;
+
+               SqlitePerson.Update(person);
+
+               return person;
+       }
+
+       private static void serverUploadPersonSessionIfNeeded(ChronojumpServer myServer, 
+                       int personServerID, int sessionServerID, PersonSession ps, int sportUserDefinedLocal)
+       {
+               //when update locally, don't put the user defined sport id at server
+               if(sportUserDefinedLocal != -1)
+                       ps.SportID = sportUserDefinedLocal;
+
+               ps.UniqueID = -1;
+               ps.PersonID = personServerID;
+               ps.SessionID = sessionServerID;
+
+               myServer.UploadPersonSessionIfNeeded(ps);
+       }
+
+       //upload a test
+       private static Constants.UploadCodes serverUploadTest(ChronojumpServer myServer, Constants.TestTypes 
type, string tableName, Event myTest) 
+       {
+               Constants.UploadCodes uCode;
+
+               if(myTest.Simulated == Constants.Simulated) {
+                       //Test is simulated, don't upload
+                       uCode = Constants.UploadCodes.SIMULATED;
+               } else if(myTest.Simulated > 0) {
+                       //Test is already uploaded, don't upload
+                       uCode = Constants.UploadCodes.EXISTS;
+               } else {
+                       int idAtServer = -1;
+                       switch (type) {
+                               case Constants.TestTypes.JUMP :
+                                       Jump jump = (Jump)myTest;
+                                       idAtServer = myServer.UploadJump(jump);
+                                       break;
+                               case Constants.TestTypes.JUMP_RJ :
+                                       JumpRj jumpRj = (JumpRj)myTest;
+                                       idAtServer = myServer.UploadJumpRj(jumpRj);
+                                       break;
+                               case Constants.TestTypes.RUN :
+                                       Run run = (Run)myTest;
+                                       idAtServer = myServer.UploadRun(run);
+                                       break;
+                               case Constants.TestTypes.RUN_I :
+                                       RunInterval runI = (RunInterval)myTest;
+                                       idAtServer = myServer.UploadRunI(runI);
+                                       break;
+                               case Constants.TestTypes.RT :
+                                       ReactionTime rt = (ReactionTime)myTest;
+                                       idAtServer = myServer.UploadRT(rt);
+                                       break;
+                               case Constants.TestTypes.PULSE :
+                                       Pulse pulse = (Pulse)myTest;
+                                       idAtServer = myServer.UploadPulse(pulse);
+                                       break;
+                               case Constants.TestTypes.MULTICHRONOPIC :
+                                       MultiChronopic mc = (MultiChronopic)myTest;
+                                       idAtServer = myServer.UploadMultiChronopic(mc);
+                                       break;
+                       }
+
+                       
+                       //update test (simulated) on client database
+                       myTest.Simulated = idAtServer;
+                       SqliteEvent.UpdateSimulated(true, tableName, myTest.UniqueID, idAtServer);
+                       
+                       uCode = Constants.UploadCodes.OK;
+               }
+               return uCode;
+       }
+
+       public static void ServerUploadEvaluator () {
+               try {
+                       ChronojumpServer myServer = new ChronojumpServer();
+                       LogB.Information(myServer.ConnectDatabase());
+                       
+                       ServerEvaluator myEval = SqliteServer.SelectEvaluator(1);
+
+                       bool success = false;
+                       int evalSID = Convert.ToInt32(SqlitePreferences.Select("evaluatorServerID"));
+                       if(evalSID == Constants.ServerUndefinedID) {
+                               string idCode = myServer.UploadEvaluator(myEval);
+                               myEval.Code = Util.FetchName(idCode);
+
+                               myEval.Update(false);
+
+                               evalSID = Util.FetchID(idCode);
+                               SqlitePreferences.Update("evaluatorServerID", evalSID.ToString(), false);
+                               success = true;
+                       } else 
+                               success = myServer.EditEvaluator(myEval, evalSID);
+                               
+                       if(success)
+                               new DialogMessage(Constants.MessageTypes.INFO, 
+                                               string.Format(Catalog.GetString("Successfully Uploaded 
evaluator with ID: {0}"), evalSID));
+                       else
+                               new DialogMessage(Constants.MessageTypes.WARNING, 
+                                               string.Format(Catalog.GetString("Evaluator {0} has not been 
correctly uploaded. Maybe codes doesn't match."), evalSID));
+                       
+                       LogB.Information(myServer.DisConnectDatabase());
+               } catch {
+                       new DialogMessage(Constants.MessageTypes.WARNING, Constants.ServerOffline);
+               }
+       }
+       
+}
diff --git a/src/util.cs b/src/util.cs
index 3b51ff8..5997375 100644
--- a/src/util.cs
+++ b/src/util.cs
@@ -1166,15 +1166,15 @@ public class Util
                else if(UtilAll.GetOSEnum() == UtilAll.OperatingSystems.MACOSX)
                        rBin = Constants.ROSX;
 
-               pinfo = new ProcessStartInfo();
-               pinfo.FileName=rBin;
-               pinfo.Arguments ="CMD BATCH --no-save " + rScript +" " + outputFile;
-               pinfo.CreateNoWindow = true;
+               pinfo = new ProcessStartInfo();
+               pinfo.FileName=rBin;
+               pinfo.Arguments ="CMD BATCH --no-save " + rScript +" " + outputFile;
+               pinfo.CreateNoWindow = true;
                pinfo.UseShellExecute = false;
        
                try {   
-                       r = new Process();
-                               r.StartInfo = pinfo;
+                       r = new Process();
+                               r.StartInfo = pinfo;
                                r.Start();
                        r.WaitForExit();
                        //while ( ! ( File.Exists(outputFile) || CancelRScript) );
diff --git a/src/utilAll.cs b/src/utilAll.cs
index 939bcd3..65924d2 100644
--- a/src/utilAll.cs
+++ b/src/utilAll.cs
@@ -21,7 +21,7 @@
 using System;
 using System.Diagnostics;      //for detect OS
 using System.IO;               //for detect OS
-using System.Reflection; // Read Version
+using System.Reflection; // Read Version
 
 //this class tries to be a space for methods that are used in different classes
 //in chronojump and chronojump_mini
@@ -30,10 +30,10 @@ public class UtilAll
 {
        static bool printedOS = false;
 
-       public static string ReadVersion() {
+       public static string ReadVersion() {
                Version version = Assembly.GetExecutingAssembly().GetName().Version;
-               return version.ToString();
-       }       
+               return version.ToString();
+       }       
        
 
        //Adapted from Mono. A developer's notebook. p 244
diff --git a/testing-stuff/json_get.cs b/testing-stuff/json_get.cs
index c295cad..80e665f 100644
--- a/testing-stuff/json_get.cs
+++ b/testing-stuff/json_get.cs
@@ -1,49 +1,49 @@
-//Carles Pina
-//compile:  mcs json_get.cs /reference:System.Json.dll
-
-using System;
-using System.Net;
-using System.Web;
-using System.IO;
-using System.Json;
-
-public class JsonTest
-{
-       static public void Main()
-       {
-               // Create a request using a URL that can receive a GET. 
-               WebRequest request = WebRequest.Create ("http://api.chronojump.org:8080/version";);
-
-               // Set the Method property of the request to POST.
-               request.Method = "GET";
-               
-               // Get the response.
-               WebResponse response = request.GetResponse ();
-               
-               // Display the status.
-               Console.WriteLine ("StatusDescription:" + ((HttpWebResponse)response).StatusDescription);
-
-        Stream dataStream;
-               
-               // Get the stream containing content returned by the server.
-               dataStream = response.GetResponseStream ();
-               
-               // Open the stream using a StreamReader for easy access.
-               StreamReader reader = new StreamReader (dataStream);
-               
-               // Read the content.
-               string responseFromServer = reader.ReadToEnd ();
-               
-               // Display the content.
-               Console.WriteLine (responseFromServer);
-               
-               // Clean up the streams.
-               reader.Close ();
-               dataStream.Close ();
-               response.Close ();    
-
-               JsonValue result = JsonValue.Parse(responseFromServer);
-               string stable_version = result["stable"];
-               Console.WriteLine("stable version is: "+ stable_version);
-       }
-}
+//Carles Pina
+//compile:  mcs json_get.cs /reference:System.Json.dll
+
+using System;
+using System.Net;
+using System.Web;
+using System.IO;
+using System.Json;
+
+public class JsonTest
+{
+       static public void Main()
+       {
+               // Create a request using a URL that can receive a GET. 
+               WebRequest request = WebRequest.Create ("http://api.chronojump.org:8080/version";);
+
+               // Set the Method property of the request to POST.
+               request.Method = "GET";
+               
+               // Get the response.
+               WebResponse response = request.GetResponse ();
+               
+               // Display the status.
+               Console.WriteLine ("StatusDescription:" + ((HttpWebResponse)response).StatusDescription);
+
+        Stream dataStream;
+               
+               // Get the stream containing content returned by the server.
+               dataStream = response.GetResponseStream ();
+               
+               // Open the stream using a StreamReader for easy access.
+               StreamReader reader = new StreamReader (dataStream);
+               
+               // Read the content.
+               string responseFromServer = reader.ReadToEnd ();
+               
+               // Display the content.
+               Console.WriteLine (responseFromServer);
+               
+               // Clean up the streams.
+               reader.Close ();
+               dataStream.Close ();
+               response.Close ();    
+
+               JsonValue result = JsonValue.Parse(responseFromServer);
+               string stable_version = result["stable"];
+               Console.WriteLine("stable version is: "+ stable_version);
+       }
+}
diff --git a/testing-stuff/json_ping.cs b/testing-stuff/json_ping.cs
index 5a0ec12..12eb0e0 100644
--- a/testing-stuff/json_ping.cs
+++ b/testing-stuff/json_ping.cs
@@ -1,49 +1,49 @@
-//Carles Pina
-//compile:  mcs json_ping.cs /reference:System.Json.dll
-//Good reference: http://computerbeacon.net/blog/creating-jsonobjects-in-c
-
-using System;
-using System.Net;
-using System.Web;
-using System.IO;
-using System.Json;
-using System.Text;
-
-public class JsonTest
-{
-       static public void Main()
-       {
-               // Create a request using a URL that can receive a post. 
-               WebRequest request = WebRequest.Create ("http://api.chronojump.org:8080/ping";);
-
-               // Set the Method property of the request to POST.
-               request.Method = "POST";
-               
-               // Set the ContentType property of the WebRequest.
-               request.ContentType = "application/json";
-
-        // Creates the json object
-        JsonObject json = new JsonObject();
-        json.Add("os_version", "Linux");
-        json.Add("cj_version", "0.99");
-
-        // Converts it to a String
-        String js = json.ToString();
-
-        // Writes the json object into the request dataStream
-        Stream dataStream = request.GetRequestStream ();
-               dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
-               
-               dataStream.Close ();
-               
-               // Get the response.
-               WebResponse response = request.GetResponse ();
-               
-               // Display the status (will be 201, CREATED)
-               Console.WriteLine (((HttpWebResponse)response).StatusDescription);
-               
-               // Clean up the streams.
-               dataStream.Close ();
-               response.Close ();    
-       }
-}
+//Carles Pina
+//compile:  mcs json_ping.cs /reference:System.Json.dll
+//Good reference: http://computerbeacon.net/blog/creating-jsonobjects-in-c
+
+using System;
+using System.Net;
+using System.Web;
+using System.IO;
+using System.Json;
+using System.Text;
+
+public class JsonTest
+{
+       static public void Main()
+       {
+               // Create a request using a URL that can receive a post. 
+               WebRequest request = WebRequest.Create ("http://api.chronojump.org:8080/ping";);
+
+               // Set the Method property of the request to POST.
+               request.Method = "POST";
+               
+               // Set the ContentType property of the WebRequest.
+               request.ContentType = "application/json";
+
+        // Creates the json object
+        JsonObject json = new JsonObject();
+        json.Add("os_version", "Linux");
+        json.Add("cj_version", "0.99");
+
+        // Converts it to a String
+        String js = json.ToString();
+
+        // Writes the json object into the request dataStream
+        Stream dataStream = request.GetRequestStream ();
+               dataStream.Write (Encoding.UTF8.GetBytes(js), 0, js.Length);
+               
+               dataStream.Close ();
+               
+               // Get the response.
+               WebResponse response = request.GetResponse ();
+               
+               // Display the status (will be 201, CREATED)
+               Console.WriteLine (((HttpWebResponse)response).StatusDescription);
+               
+               // Clean up the streams.
+               dataStream.Close ();
+               response.Close ();    
+       }
+}
diff --git a/testing-stuff/json_post.cs b/testing-stuff/json_post.cs
index 2348f79..ae6b2e2 100644
--- a/testing-stuff/json_post.cs
+++ b/testing-stuff/json_post.cs
@@ -1,91 +1,91 @@
-//Carles Pina
-//compile:  mcs json_post.cs /reference:System.Json.dll
-
-using System;
-using System.Net;
-using System.Web;
-using System.IO;
-using System.Json;
-
-public class JsonTest
-{
-       static private string getLogsDir() 
-       {
-               return Path.Combine(
-                               Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
-                               "Chronojump" + Path.DirectorySeparatorChar + "logs");
-       }
-
-       static private byte[] readFile(string filePath)
-       {
-               return System.IO.File.ReadAllBytes(filePath); 
-       }
-
-       static public void Main()
-       {
-               string filePath = getLogsDir() + Path.DirectorySeparatorChar + "log_chronojump.txt";
-
-               if(! File.Exists(filePath)) {
-                       Console.WriteLine("Could not send file. It does not exist.");
-                       return;
-               }
-
-               // Create a request using a URL that can receive a post. 
-               WebRequest request = WebRequest.Create ("http://api.chronojump.org:8080/backtrace";);
-
-               // Set the Method property of the request to POST.
-               request.Method = "POST";
-               
-               // Create POST data and convert it to a byte array.
-               byte[] byteArray = readFile(filePath);
-               
-               // Set the ContentType property of the WebRequest.
-               request.ContentType = "application/x-www-form-urlencoded";
-               
-               // Set the ContentLength property of the WebRequest.
-               request.ContentLength = byteArray.Length;
-               
-               // Get the request stream.
-               Stream dataStream;
-               try {
-                        dataStream = request.GetRequestStream ();
-               } catch {
-                       Console.WriteLine("Could not send file. You are not connected to the Internet or 
server is down.");
-                       return;
-               }
-               
-               // Write the data to the request stream.
-               dataStream.Write (byteArray, 0, byteArray.Length);
-               
-               // Close the Stream object.
-               dataStream.Close ();
-               
-               // Get the response.
-               WebResponse response = request.GetResponse ();
-               
-               // Display the status.
-               Console.WriteLine (((HttpWebResponse)response).StatusDescription);
-               
-               // Get the stream containing content returned by the server.
-               dataStream = response.GetResponseStream ();
-               
-               // Open the stream using a StreamReader for easy access.
-               StreamReader reader = new StreamReader (dataStream);
-               
-               // Read the content.
-               string responseFromServer = reader.ReadToEnd ();
-               
-               // Display the content.
-               Console.WriteLine (responseFromServer);
-               
-               // Clean up the streams.
-               reader.Close ();
-               dataStream.Close ();
-               response.Close ();    
-
-
-               JsonValue result = JsonValue.Parse(responseFromServer);
-               string crash_id = result["crash_id"];
-               Console.WriteLine("crash_id: "+ crash_id);
-       }
-}
+//Carles Pina
+//compile:  mcs json_post.cs /reference:System.Json.dll
+
+using System;
+using System.Net;
+using System.Web;
+using System.IO;
+using System.Json;
+
+public class JsonTest
+{
+       static private string getLogsDir() 
+       {
+               return Path.Combine(
+                               Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
+                               "Chronojump" + Path.DirectorySeparatorChar + "logs");
+       }
+
+       static private byte[] readFile(string filePath)
+       {
+               return System.IO.File.ReadAllBytes(filePath); 
+       }
+
+       static public void Main()
+       {
+               string filePath = getLogsDir() + Path.DirectorySeparatorChar + "log_chronojump.txt";
+
+               if(! File.Exists(filePath)) {
+                       Console.WriteLine("Could not send file. It does not exist.");
+                       return;
+               }
+
+               // Create a request using a URL that can receive a post. 
+               WebRequest request = WebRequest.Create ("http://api.chronojump.org:8080/backtrace";);
+
+               // Set the Method property of the request to POST.
+               request.Method = "POST";
+               
+               // Create POST data and convert it to a byte array.
+               byte[] byteArray = readFile(filePath);
+               
+               // Set the ContentType property of the WebRequest.
+               request.ContentType = "application/x-www-form-urlencoded";
+               
+               // Set the ContentLength property of the WebRequest.
+               request.ContentLength = byteArray.Length;
+               
+               // Get the request stream.
+               Stream dataStream;
+               try {
+                        dataStream = request.GetRequestStream ();
+               } catch {
+                       Console.WriteLine("Could not send file. You are not connected to the Internet or 
server is down.");
+                       return;
+               }
+               
+               // Write the data to the request stream.
+               dataStream.Write (byteArray, 0, byteArray.Length);
+               
+               // Close the Stream object.
+               dataStream.Close ();
+               
+               // Get the response.
+               WebResponse response = request.GetResponse ();
+               
+               // Display the status.
+               Console.WriteLine (((HttpWebResponse)response).StatusDescription);
+               
+               // Get the stream containing content returned by the server.
+               dataStream = response.GetResponseStream ();
+               
+               // Open the stream using a StreamReader for easy access.
+               StreamReader reader = new StreamReader (dataStream);
+               
+               // Read the content.
+               string responseFromServer = reader.ReadToEnd ();
+               
+               // Display the content.
+               Console.WriteLine (responseFromServer);
+               
+               // Clean up the streams.
+               reader.Close ();
+               dataStream.Close ();
+               response.Close ();    
+
+
+               JsonValue result = JsonValue.Parse(responseFromServer);
+               string crash_id = result["crash_id"];
+               Console.WriteLine("crash_id: "+ crash_id);
+       }
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]