[chronojump] MultiChronopic and Run Analysis work again



commit 619631764df2062a9c478fe0244808d1f7b1a50b
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Mar 5 21:54:24 2010 +0800

    MultiChronopic and Run Analysis work again

 glade/chronojump.glade |  453 ++++++++----------------------------------------
 src/gui/chronojump.cs  |  186 ++++++---------------
 src/gui/chronopic.cs   |   35 ++++-
 3 files changed, 153 insertions(+), 521 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index dfb7c2f..e440b19 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -20230,16 +20230,74 @@ by you</property>
                                 <child>
                                   <widget class="GtkVBox" id="vbox170">
                                     <property name="visible">True</property>
+                                    <property name="orientation">vertical</property>
                                     <child>
-                                      <widget class="GtkHBox" id="hbox338">
+                                      <widget class="GtkHBox" id="hbox_multi_chronopic_buttons">
                                         <property name="visible">True</property>
+                                        <property name="spacing">14</property>
+                                        <child>
+                                          <widget class="GtkHBox" id="hbox3">
+                                            <property name="visible">True</property>
+                                            <child>
+                                              <widget class="GtkCheckButton" id="check_multi_sync">
+                                                <property name="label" translatable="yes">Sync</property>
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="receives_default">False</property>
+                                                <property name="has_tooltip">True</property>
+                                                <property name="tooltip" translatable="yes">Synchronize chronopics</property>
+                                                <property name="use_underline">True</property>
+                                                <property name="active">True</property>
+                                                <property name="draw_indicator">True</property>
+                                              </widget>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">False</property>
+                                                <property name="position">0</property>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <widget class="GtkCheckButton" id="check_multi_delete_first">
+                                                <property name="label" translatable="yes">Delete first</property>
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="receives_default">False</property>
+                                                <property name="has_tooltip">True</property>
+                                                <property name="tooltip" translatable="yes">Delete first TC and TF of each chronopic</property>
+                                                <property name="use_underline">True</property>
+                                                <property name="active">True</property>
+                                                <property name="draw_indicator">True</property>
+                                              </widget>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="fill">False</property>
+                                                <property name="position">1</property>
+                                              </packing>
+                                            </child>
+                                            <child>
+                                              <widget class="GtkButton" id="button_multi_chronopic_start">
+                                                <property name="label" translatable="yes">Multi Chronopic test</property>
+                                                <property name="visible">True</property>
+                                                <property name="can_focus">True</property>
+                                                <property name="receives_default">True</property>
+                                                <property name="use_underline">True</property>
+                                                <signal name="clicked" handler="on_multi_chronopic_start_clicked"/>
+                                                <signal name="enter" handler="on_button_enter"/>
+                                              </widget>
+                                              <packing>
+                                                <property name="expand">False</property>
+                                                <property name="position">2</property>
+                                              </packing>
+                                            </child>
+                                          </widget>
+                                          <packing>
+                                            <property name="padding">4</property>
+                                            <property name="position">0</property>
+                                          </packing>
+                                        </child>
                                         <child>
-                                          <widget class="GtkTable" id="table_multi_chronopic_buttons">
+                                          <widget class="GtkHBox" id="hbox4">
                                             <property name="visible">True</property>
-                                            <property name="n_rows">2</property>
-                                            <property name="n_columns">2</property>
-                                            <property name="column_spacing">10</property>
-                                            <property name="row_spacing">2</property>
                                             <child>
                                               <widget class="GtkHBox" id="hbox348">
                                                 <property name="visible">True</property>
@@ -20286,30 +20344,16 @@ by you</property>
                                                   </widget>
                                                   <packing>
                                                     <property name="expand">False</property>
+                                                    <property name="pack_type">end</property>
                                                     <property name="position">1</property>
                                                   </packing>
                                                 </child>
                                               </widget>
                                               <packing>
-                                                <property name="left_attach">1</property>
-                                                <property name="right_attach">2</property>
-                                                <property name="x_options">GTK_FILL</property>
-                                              </packing>
-                                            </child>
-                                            <child>
-                                              <widget class="GtkButton" id="button_multi_chronopic_start">
-                                                <property name="label" translatable="yes">Multi Chronopic test</property>
-                                                <property name="visible">True</property>
-                                                <property name="can_focus">True</property>
-                                                <property name="receives_default">False</property>
-                                                <property name="use_underline">True</property>
-                                                <signal name="clicked" handler="on_multi_chronopic_start_clicked"/>
-                                                <signal name="enter" handler="on_button_enter"/>
-                                              </widget>
-                                              <packing>
-                                                <property name="top_attach">1</property>
-                                                <property name="bottom_attach">2</property>
-                                                <property name="x_options">GTK_FILL</property>
+                                                <property name="expand">False</property>
+                                                <property name="padding">4</property>
+                                                <property name="pack_type">end</property>
+                                                <property name="position">2</property>
                                               </packing>
                                             </child>
                                             <child>
@@ -20317,370 +20361,19 @@ by you</property>
                                                 <property name="label" translatable="yes">Run analysis</property>
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
-                                                <property name="receives_default">False</property>
+                                                <property name="receives_default">True</property>
                                                 <property name="use_underline">True</property>
                                                 <signal name="clicked" handler="on_multi_chronopic_start_clicked"/>
                                                 <signal name="enter" handler="on_button_enter"/>
                                               </widget>
                                               <packing>
-                                                <property name="left_attach">1</property>
-                                                <property name="right_attach">2</property>
-                                                <property name="top_attach">1</property>
-                                                <property name="bottom_attach">2</property>
-                                                <property name="x_options">GTK_FILL</property>
-                                              </packing>
-                                            </child>
-                                            <child>
-                                              <widget class="GtkHBox" id="hbox352">
-                                                <property name="visible">True</property>
-                                                <property name="spacing">4</property>
-                                                <child>
-                                                  <widget class="GtkCheckButton" id="check_multi_sync">
-                                                    <property name="label" translatable="yes">Sync</property>
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">True</property>
-                                                    <property name="receives_default">False</property>
-                                                    <property name="tooltip" translatable="yes">Synchronize chronopics</property>
-                                                    <property name="use_underline">True</property>
-                                                    <property name="active">True</property>
-                                                    <property name="draw_indicator">True</property>
-                                                  </widget>
-                                                  <packing>
-                                                    <property name="expand">False</property>
-                                                    <property name="fill">False</property>
-                                                    <property name="position">0</property>
-                                                  </packing>
-                                                </child>
-                                                <child>
-                                                  <widget class="GtkCheckButton" id="check_multi_delete_first">
-                                                    <property name="label" translatable="yes">Delete first</property>
-                                                    <property name="visible">True</property>
-                                                    <property name="can_focus">True</property>
-                                                    <property name="receives_default">False</property>
-                                                    <property name="tooltip" translatable="yes">Delete first TC and TF of each chronopic</property>
-                                                    <property name="use_underline">True</property>
-                                                    <property name="active">True</property>
-                                                    <property name="draw_indicator">True</property>
-                                                  </widget>
-                                                  <packing>
-                                                    <property name="expand">False</property>
-                                                    <property name="fill">False</property>
-                                                    <property name="position">1</property>
-                                                  </packing>
-                                                </child>
-                                              </widget>
-                                              <packing>
-                                                <property name="x_options">GTK_FILL</property>
-                                                <property name="y_options">GTK_FILL</property>
-                                              </packing>
-                                            </child>
-                                          </widget>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="fill">False</property>
-                                            <property name="position">0</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <widget class="GtkFrame" id="frame46">
-                                            <property name="label_xalign">0</property>
-                                            <property name="shadow_type">none</property>
-                                            <child>
-                                              <widget class="GtkAlignment" id="alignment139">
-                                                <property name="visible">True</property>
-                                                <property name="left_padding">12</property>
-                                                <child>
-                                                  <widget class="GtkHBox" id="hbox339">
-                                                    <property name="visible">True</property>
-                                                    <property name="spacing">12</property>
-                                                    <child>
-                                                      <widget class="GtkHBox" id="hbox340">
-                                                        <property name="visible">True</property>
-                                                        <property name="spacing">6</property>
-                                                        <child>
-                                                          <widget class="GtkHBox" id="hbox341">
-                                                            <property name="visible">True</property>
-                                                            <property name="spacing">2</property>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label692">
-                                                            <property name="visible">True</property>
-                                                            <property name="label">1</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkVBox" id="vbox185">
-                                                            <property name="visible">True</property>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image_cp1_no">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-no</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image_cp1_yes">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-yes</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                          </widget>
-                                                          <packing>
-                                                            <property name="position">0</property>
-                                                          </packing>
-                                                        </child>
-                                                        <child>
-                                                          <widget class="GtkHBox" id="hbox342">
-                                                            <property name="visible">True</property>
-                                                            <property name="spacing">2</property>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label693">
-                                                            <property name="visible">True</property>
-                                                            <property name="label">2</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkVBox" id="vbox186">
-                                                            <property name="visible">True</property>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image_cp2_no">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-no</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image_cp2_yes">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-yes</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                          </widget>
-                                                          <packing>
-                                                            <property name="position">1</property>
-                                                          </packing>
-                                                        </child>
-                                                        <child>
-                                                          <widget class="GtkHBox" id="hbox343">
-                                                            <property name="visible">True</property>
-                                                            <property name="spacing">2</property>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label694">
-                                                            <property name="visible">True</property>
-                                                            <property name="label">3</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkVBox" id="vbox187">
-                                                            <property name="visible">True</property>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image_cp3_no">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-no</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image_cp3_yes">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-yes</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                          </widget>
-                                                          <packing>
-                                                            <property name="position">2</property>
-                                                          </packing>
-                                                        </child>
-                                                        <child>
-                                                          <widget class="GtkHBox" id="hbox344">
-                                                            <property name="visible">True</property>
-                                                            <property name="spacing">2</property>
-                                                            <child>
-                                                            <widget class="GtkLabel" id="label695">
-                                                            <property name="visible">True</property>
-                                                            <property name="label">4</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkVBox" id="vbox188">
-                                                            <property name="visible">True</property>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image_cp4_no">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-no</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image_cp4_yes">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-yes</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                          </widget>
-                                                          <packing>
-                                                            <property name="position">3</property>
-                                                          </packing>
-                                                        </child>
-                                                      </widget>
-                                                      <packing>
-                                                        <property name="position">0</property>
-                                                      </packing>
-                                                    </child>
-                                                    <child>
-                                                      <widget class="GtkTable" id="table67">
-                                                        <property name="visible">True</property>
-                                                        <child>
-                                                          <widget class="GtkHBox" id="hbox345">
-                                                            <property name="visible">True</property>
-                                                            <child>
-                                                            <widget class="GtkHBox" id="hbox346">
-                                                            <property name="visible">True</property>
-                                                            <child>
-                                                            <widget class="GtkVBox" id="vbox189">
-                                                            <property name="visible">True</property>
-                                                            <child>
-                                                            <widget class="GtkComboBox" id="combo_port_linux">
-                                                            <property name="visible">True</property>
-                                                            <property name="items">/dev/ttyUSB?
-</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkComboBox" id="combo_port_windows">
-                                                            <property name="visible">True</property>
-                                                            <property name="items">COM?</property>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">0</property>
-                                                            </packing>
-                                                            </child>
-                                                            <child>
-                                                            <widget class="GtkButton" id="button_connect_cp">
-                                                            <property name="visible">True</property>
-                                                            <property name="can_focus">True</property>
-                                                            <property name="receives_default">False</property>
-                                                            <signal name="clicked" handler="on_button_connect_cp_clicked"/>
-                                                            <child>
-                                                            <widget class="GtkImage" id="image4233">
-                                                            <property name="visible">True</property>
-                                                            <property name="stock">gtk-connect</property>
-                                                            </widget>
-                                                            </child>
-                                                            </widget>
-                                                            <packing>
-                                                            <property name="expand">False</property>
-                                                            <property name="fill">False</property>
-                                                            <property name="position">1</property>
-                                                            </packing>
-                                                            </child>
-                                                          </widget>
-                                                          <packing>
-                                                            <property name="x_options">GTK_EXPAND | GTK_SHRINK</property>
-                                                            <property name="y_options">GTK_FILL</property>
-                                                          </packing>
-                                                        </child>
-                                                      </widget>
-                                                      <packing>
-                                                        <property name="position">1</property>
-                                                      </packing>
-                                                    </child>
-                                                  </widget>
-                                                </child>
-                                              </widget>
-                                            </child>
-                                            <child>
-                                              <widget class="GtkLabel" id="label691">
-                                                <property name="visible">True</property>
-                                                <property name="label" translatable="yes">&lt;b&gt;Connected Chronopics&lt;/b&gt;</property>
-                                                <property name="use_markup">True</property>
-                                              </widget>
-                                              <packing>
-                                                <property name="type">label_item</property>
+                                                <property name="expand">False</property>
+                                                <property name="pack_type">end</property>
+                                                <property name="position">0</property>
                                               </packing>
                                             </child>
                                           </widget>
                                           <packing>
-                                            <property name="expand">False</property>
-                                            <property name="pack_type">end</property>
                                             <property name="position">1</property>
                                           </packing>
                                         </child>
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 7fd1308..f6bfb67 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -165,7 +165,7 @@ public class ChronoJumpWindow
 	[Widget] Gtk.MenuItem menuitem_run_analysis;
 	[Widget] Gtk.Button button_edit_selected_multi_chronopic;
 	[Widget] Gtk.Button button_delete_selected_multi_chronopic;
-	[Widget] Gtk.Table table_multi_chronopic_buttons;
+	[Widget] Gtk.Box hbox_multi_chronopic_buttons;
 	[Widget] Gtk.Button button_multi_chronopic_start;
 	[Widget] Gtk.Button button_run_analysis;
 	[Widget] Gtk.Entry entry_run_analysis_distance;
@@ -454,7 +454,7 @@ public class ChronoJumpWindow
 		createComboRunsInterval();
 		//reaction_times has no combo
 		createComboPulses();
-		//createComboMultiChronopic();
+		createComboMultiChronopic();
 		createdStatsWin = false;
 
 		
@@ -1562,18 +1562,6 @@ public class ChronoJumpWindow
 					myTreeViewMultiChronopic.ExpandState, 2);
 	}
 
-	private void on_button_connect_cp_clicked (object o, EventArgs args) {
-	/*
-		if(image_cp2_no.Visible)
-			currentCp = 2;
-		else if(image_cp3_no.Visible)
-			currentCp = 3;
-		else if(image_cp4_no.Visible)
-			currentCp = 4;
-		prepareChronopicConnection();
-		*/
-	}
-
 	private void on_treeview_multi_chronopic_cursor_changed (object o, EventArgs args) {
 		Log.WriteLine("Cursor changed");
 		// don't select if it's a person, 
@@ -1685,36 +1673,14 @@ public class ChronoJumpWindow
 		combo_pulses.Sensitive = false;
 	}
 
-	/*
 	private void createComboMultiChronopic() 
 	{
-		table_multi_chronopic_buttons.Sensitive = false;
 		menuitem_multi_chronopic_start.Sensitive = false;
 		menuitem_run_analysis.Sensitive = false;
-		button_connect_cp.Sensitive = false;
-		image_cp1_yes.Hide();
-		image_cp2_yes.Hide();
-		image_cp3_yes.Hide();
-		image_cp4_yes.Hide();
-
-		if(Util.IsWindows()) {
-			combo_port_windows.Sensitive = false;
-			combo_port_linux.Hide();
-			string [] comboWindowsOptions = new string[257];
-			for (int count = 0, i=1; i <= 257; i ++)
-				comboWindowsOptions[i-1] = "COM" + i;
-
-			UtilGtk.ComboUpdate(combo_port_windows, comboWindowsOptions, comboWindowsOptions[0]);
-			combo_port_windows.Changed += new EventHandler (on_combo_multi_chronopic_changed);
-		} else {
-			combo_port_linux.Sensitive = false;
-			combo_port_windows.Hide();
-			UtilGtk.ComboUpdate(combo_port_linux, Constants.ComboPortLinuxOptions, Constants.ComboPortLinuxOptions[0]);
-			combo_port_linux.Active = 0; //first option
-			combo_port_linux.Changed += new EventHandler (on_combo_multi_chronopic_changed);
-		}
+		button_multi_chronopic_start.Sensitive = false;
+		button_run_analysis.Sensitive = false;
+		entry_run_analysis_distance.Sensitive = false;
 	}
-	*/
 
 	private void on_combo_jumps_changed(object o, EventArgs args) {
 		//combo_jumps.Changed -= new EventHandler (on_combo_jumps_changed);
@@ -1778,22 +1744,6 @@ public class ChronoJumpWindow
 		fillTreeView_pulses(myText);
 	}
 
-	/*
-	private void on_combo_multi_chronopic_changed(object o, EventArgs args) {
-		ComboBox combo = o as ComboBox;
-		if (o == null)
-			return;
-		
-		bool portOk = true;
-		if(UtilGtk.ComboGetActive(combo) == Constants.ChronopicDefaultPortWindows ||
-				UtilGtk.ComboGetActive(combo) == Constants.ChronopicDefaultPortLinux) 
-			portOk = false;
-
-		if (o == combo_port_linux || o == combo_port_windows) 
-			button_connect_cp.Sensitive = portOk;
-	}
-	*/
-	
 
 	/* ---------------------------------------------------------
 	 * ----------------  DELETE EVENT, QUIT  -----------------------
@@ -2207,72 +2157,6 @@ public class ChronoJumpWindow
 	}
 
 
-	void on_radiobutton_simulated (object o, EventArgs args)
-	{
-	/*
-		Log.WriteLine(string.Format("RAD - simul. cpRunning: {0}", cpRunning));
-		if(menuitem_simulated.Active) {
-			Log.WriteLine("RadioSimulated - ACTIVE");
-			simulated = true;
-			SqlitePreferences.Update("simulated", simulated.ToString(), false);
-
-			//close connection with chronopic if initialized
-			if(cpRunning) {
-				serialPortsClose();
-
-				table_multi_chronopic_buttons.Sensitive = false;
-				combo_port_windows.Sensitive = false;
-				combo_port_linux.Sensitive = false;
-		
-				//regenerate combos (maybe some ports have been deleted on using before going to simulated)
-				if(Util.IsWindows()) {
-					string [] comboWindowsOptions = new string[257];
-					for (int count = 0, i=1; i <= 257; i ++)
-						comboWindowsOptions[i-1] = "COM" + i;
-					UtilGtk.ComboUpdate(combo_port_windows, comboWindowsOptions, comboWindowsOptions[0]);
-				} else {
-					UtilGtk.ComboUpdate(combo_port_linux, Constants.ComboPortLinuxOptions, Constants.ComboPortLinuxOptions[0]);
-					combo_port_linux.Active = 0; //first option
-				}
-			}
-			Log.WriteLine("cpclosed");
-			cpRunning = false;
-		}
-		else
-			Log.WriteLine("RadioSimulated - INACTIVE");
-		
-		Log.WriteLine("all done");
-		*/
-	}
-	
-	void on_radiobutton_chronopic (object o, EventArgs args)
-	{
-		/*
-		Log.WriteLine(string.Format("RAD - chrono. cpRunning: {0}", cpRunning));
-		if(! preferencesLoaded)
-			return;
-
-		if(! menuitem_chronopic.Active) {
-			appbar2.Push( 1, Catalog.GetString("Changed to simulated mode"));
-			Log.WriteLine("RadioChronopic - INACTIVE");
-			return;
-		}
-
-		if(chronopicPort == Constants.ChronopicDefaultPortWindows ||
-				chronopicPort == Constants.ChronopicDefaultPortLinux) {
-			new DialogMessage(Constants.MessageTypes.WARNING, Catalog.GetString("You need to configurate the Chronopic port at preferences."));
-			menuitem_simulated.Active = true;
-			return;
-		}
-
-		Log.WriteLine("RadioChronopic - ACTIVE");
-	
-		currentCp = 1;
-		prepareChronopicConnection();
-		*/
-	}
-
-
 	private void on_preferences_activate (object o, EventArgs args) {
 		PreferencesWindow myWin = PreferencesWindow.Show(
 				prefsDigitsNumber, showHeight, showPower, showInitialSpeed, showAngle, showQIndex, showDjIndex, 
@@ -3904,8 +3788,31 @@ Console.WriteLine("X");
 	 *  --------------------------------------------------------
 	 */
 
+	private void on_menuitem_chronopic_activate (object o, EventArgs args) {
+		chronopicWin = ChronopicWindow.View();
+		chronopicWin.FakeWindowDone.Clicked += new EventHandler(on_chronopic_window_done);
+	}
+	
+	private void on_chronopic_window_done (object o, EventArgs args) {
+		chronopicWin.FakeWindowDone.Clicked -= new EventHandler(on_chronopic_window_done);
+		if(chronopicWin.NumConnected()>=2) {
+			menuitem_multi_chronopic_start.Sensitive = true;
+			menuitem_run_analysis.Sensitive = true;
+			button_multi_chronopic_start.Sensitive = true;
+			entry_run_analysis_distance.Sensitive = true;
+			on_entry_run_analysis_distance_changed (o, args);
+		} else {
+			menuitem_multi_chronopic_start.Sensitive = false;
+			menuitem_run_analysis.Sensitive = false;
+			button_multi_chronopic_start.Sensitive = false;
+			entry_run_analysis_distance.Sensitive = false;
+			button_run_analysis.Sensitive = false;
+		}
+	}
+
 	private void on_entry_run_analysis_distance_changed (object o, EventArgs args) {
-		if(Util.IsNumber(entry_run_analysis_distance.Text, false) && entry_run_analysis_distance.Text != "0") {
+		if(Util.IsNumber(entry_run_analysis_distance.Text, false) && entry_run_analysis_distance.Text != "0" &&
+				chronopicWin.NumConnected()>=2) {
 			menuitem_run_analysis.Sensitive = true;
 			button_run_analysis.Sensitive = true;
 		} else {
@@ -3915,7 +3822,6 @@ Console.WriteLine("X");
 	}
 
 	private void on_multi_chronopic_start_clicked (object o, EventArgs args) {
-		/*
 		Log.WriteLine("multi chronopic accepted");
 		
 		if(o == (object) button_multi_chronopic_start || o == (object) menuitem_multi_chronopic_start) 
@@ -3961,45 +3867,53 @@ Console.WriteLine("X");
 		if(currentMultiChronopicType.SyncNeeded && check_multi_sync.Active)
 			syncNeeded = true;
 
-		if(image_cp2_no.Visible)
+		int numConnected = chronopicWin.NumConnected();
+
+		if(numConnected == 1)
 			currentEventExecute = new MultiChronopicExecute(
 					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, 
 					currentSession.UniqueID, currentMultiChronopicType.Name, 
-					cp, syncNeeded, check_multi_delete_first.Active, 
+					chronopicWin.CP, 
+					syncNeeded, check_multi_delete_first.Active, 
 					entry_run_analysis_distance.Text.ToString(),
 					appbar2, app1);
-		else if(image_cp2_yes.Visible && image_cp3_no.Visible)
+		else if(numConnected == 2)
 			currentEventExecute = new MultiChronopicExecute(
 					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, 
 					currentSession.UniqueID, currentMultiChronopicType.Name,  
-					cp, cp2, syncNeeded, check_multi_delete_first.Active, 
+					chronopicWin.CP, chronopicWin.CP2, 
+					syncNeeded, check_multi_delete_first.Active, 
 					entry_run_analysis_distance.Text.ToString(),
 					appbar2, app1);
-		else if(image_cp3_yes.Visible && image_cp4_no.Visible)
+		else if(numConnected == 3)
 			currentEventExecute = new MultiChronopicExecute(
 					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, 
 					currentSession.UniqueID, currentMultiChronopicType.Name,
-					cp, cp2, cp3, syncNeeded, check_multi_delete_first.Active, 
+					chronopicWin.CP, chronopicWin.CP2, chronopicWin.CP3, 
+					syncNeeded, check_multi_delete_first.Active, 
 					entry_run_analysis_distance.Text.ToString(),
 					appbar2, app1);
-		else if(image_cp4_yes.Visible)
+		else if(numConnected == 4)
 			currentEventExecute = new MultiChronopicExecute(
 					eventExecuteWin, currentPerson.UniqueID, currentPerson.Name, 
 					currentSession.UniqueID, currentMultiChronopicType.Name,
-					cp, cp2, cp3, cp4, syncNeeded, check_multi_delete_first.Active, 
+					chronopicWin.CP, chronopicWin.CP2, chronopicWin.CP3, chronopicWin.CP4,
+					syncNeeded, check_multi_delete_first.Active, 
 					entry_run_analysis_distance.Text.ToString(),
 					appbar2, app1);
 
 		//if(!chronopicWin.Connected)	
 		//	currentEventExecute.SimulateInitValues(rand);
 
+		//TODO: MANAGE THE SENSITIVE OF WIDGETS!!!
+		//and what happens if no chronopic connected
+
 
 		//mark to only get inside on_multi_chronopic_finished one time
 		multiFinishing = false;
 		currentEventExecute.Manage();
 
 		currentEventExecute.FakeButtonFinished.Clicked += new EventHandler(on_multi_chronopic_finished);
-		*/
 	}
 
 	bool multiFinishing;
@@ -4951,7 +4865,7 @@ Console.WriteLine("X");
 		menuRunsSensitive(false);
 		menuOtherSensitive(false);
 		menuToolsSensitive(false);
-
+		
 		vbox_image_test.Sensitive = false;
 		frame_persons.Sensitive = false;
 		button_recup_per.Sensitive = false;
@@ -5025,6 +4939,8 @@ Console.WriteLine("X");
 		menuJumpsSensitive(false);
 		menuRunsSensitive(false);
 		menuOtherSensitive(false);
+			
+		hbox_multi_chronopic_buttons.Sensitive = false;
 	}
    
 	private void sensitiveGuiEventDone () {
@@ -5064,6 +4980,7 @@ Console.WriteLine("X");
 					break;
 				case EventType.Types.MULTICHRONOPIC:
 					Log.WriteLine("sensitiveGuiEventDone multichronopic");
+					hbox_multi_chronopic_buttons.Sensitive = true;
 					break;
 				default:
 					Log.WriteLine("sensitiveGuiEventDone default");
@@ -5153,9 +5070,6 @@ Console.WriteLine("X");
 		Console.WriteLine(myString[5]);
 	}
 
-	private void on_menuitem_chronopic_activate (object o, EventArgs args) {
-		chronopicWin = ChronopicWindow.View();
-	}
 	private void on_menuitem_server_activate (object o, EventArgs args) {
 		Log.WriteLine("SERVER");
 	}
diff --git a/src/gui/chronopic.cs b/src/gui/chronopic.cs
index 542a7ed..4baa425 100644
--- a/src/gui/chronopic.cs
+++ b/src/gui/chronopic.cs
@@ -82,7 +82,9 @@ public class ChronopicWindow
 	bool needUpdateChronopicWin;
 	bool updateChronopicWinValuesState;
 	string updateChronopicWinValuesMessage;
-	[Widget] Gtk.Button fakeChronopicButton; //raised when chronopic detection ended
+
+	[Widget] Gtk.Button fakeConnectionButton; //raised when chronopic detection ended
+	[Widget] Gtk.Button fakeWindowDone; //raised when chronopic detection ended
 
 	bool isWindows;	
 
@@ -160,6 +162,8 @@ public class ChronopicWindow
 		
 		//don't show until View is called
 		//ChronopicWindowBox.chronopic_window.Show ();
+
+		ChronopicWindowBox.fakeWindowDone = new Gtk.Button();
 		
 		return ChronopicWindowBox;
 	}
@@ -333,7 +337,7 @@ public class ChronopicWindow
 	protected bool PulseGTK ()
 	{
 		if(needUpdateChronopicWin || ! thread.IsAlive) {
-			fakeChronopicButton.Click();
+			fakeConnectionButton.Click();
 			Log.Write("dying");
 			return false;
 		}
@@ -621,8 +625,8 @@ public class ChronopicWindow
 
 		chronopicConnectionWin.Button_cancel.Clicked += new EventHandler(on_chronopic_cancelled);
 		
-		fakeChronopicButton = new Gtk.Button();
-		fakeChronopicButton.Clicked += new EventHandler(on_chronopic_detection_ended);
+		fakeConnectionButton = new Gtk.Button();
+		fakeConnectionButton.Clicked += new EventHandler(on_chronopic_detection_ended);
 
 		thread = new Thread(new ThreadStart(waitChronopicStart));
 		GLib.Idle.Add (new GLib.IdleHandler (PulseGTK));
@@ -800,16 +804,32 @@ public class ChronopicWindow
 	void on_button_close_clicked (object o, EventArgs args)
 	{
 		Log.WriteLine("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();
 		args.RetVal = true;
 		ChronopicWindowBox.chronopic_window.Hide();
 	}
 
+	public bool IsConnected(int numCP) {
+		//int count = 1;
+		//foreach(ChronopicPortData a in cpd) 
+		//	Log.WriteLine(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 Chronopic CP {
@@ -827,9 +847,14 @@ public class ChronopicWindow
 	public Chronopic CP4 {
 		get { return cp4; }
 	}
-	
+
+	//connected to a Chronopic	
 	public bool Connected {
 		get { return connected; }
 	}
+	
+	public Button FakeWindowDone {
+		get { return fakeWindowDone; }
+	}
 
 }



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