[chronojump] Cleaned code on today restTime commits



commit e0d174f92043e8554603eeed827fe7f40417453f
Author: Xavier de Blas <xaviblas gmail com>
Date:   Tue Sep 19 16:05:06 2017 +0200

    Cleaned code on today restTime commits

 src/Makefile.am       |    1 +
 src/gui/chronojump.cs |  103 +-----------------------------------
 src/gui/restTime.cs   |  139 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 142 insertions(+), 101 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 7521d10..52eabe6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,6 +26,7 @@ SOURCES = \
        gui/jump.cs\
        gui/jumpsProfile.cs\
        gui/jumpType.cs\
+       gui/restTime.cs\
        gui/run.cs\
        gui/runType.cs\
        gui/reactionTime.cs\
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 7d1b47a..f3d61a3 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -305,30 +305,6 @@ public partial class ChronoJumpWindow
        [Widget] Gtk.Button button_person_add_single;
        [Widget] Gtk.Button button_person_add_multiple;
 
-       [Widget] Gtk.Label label_contacts_rest_time_1_name;
-       [Widget] Gtk.Label label_contacts_rest_time_2_name;
-       [Widget] Gtk.Label label_contacts_rest_time_3_name;
-       [Widget] Gtk.Label label_contacts_rest_time_4_name;
-       [Widget] Gtk.Label label_contacts_rest_time_5_name;
-
-       [Widget] Gtk.Label label_contacts_rest_time_1_time;
-       [Widget] Gtk.Label label_contacts_rest_time_2_time;
-       [Widget] Gtk.Label label_contacts_rest_time_3_time;
-       [Widget] Gtk.Label label_contacts_rest_time_4_time;
-       [Widget] Gtk.Label label_contacts_rest_time_5_time;
-
-       [Widget] Gtk.Label label_encoder_rest_time_1_name;
-       [Widget] Gtk.Label label_encoder_rest_time_2_name;
-       [Widget] Gtk.Label label_encoder_rest_time_3_name;
-       [Widget] Gtk.Label label_encoder_rest_time_4_name;
-       [Widget] Gtk.Label label_encoder_rest_time_5_name;
-
-       [Widget] Gtk.Label label_encoder_rest_time_1_time;
-       [Widget] Gtk.Label label_encoder_rest_time_2_time;
-       [Widget] Gtk.Label label_encoder_rest_time_3_time;
-       [Widget] Gtk.Label label_encoder_rest_time_4_time;
-       [Widget] Gtk.Label label_encoder_rest_time_5_time;
-
        [Widget] Gtk.Notebook notebook_execute;
        [Widget] Gtk.Notebook notebook_results;
        [Widget] Gtk.Notebook notebook_options_top;
@@ -494,11 +470,6 @@ public partial class ChronoJumpWindow
        //to control method that is updating restTimes on treeview_persons
        bool updatingRestTimes = false;
 
-       List<Gtk.Label> labels_rest_time_contacts_names;
-       List<Gtk.Label> labels_rest_time_contacts_times;
-       List<Gtk.Label> labels_rest_time_encoder_names;
-       List<Gtk.Label> labels_rest_time_encoder_times;
-
        //only called the first time the software runs
        //and only on windows
        private void on_language_clicked(object o, EventArgs args) {
@@ -4130,54 +4101,6 @@ public partial class ChronoJumpWindow
                chronojumpWindowTestsNext();
        }
 
-       private void initializeRestTimeLabels()
-       {
-               labels_rest_time_contacts_names = new List<Gtk.Label>();
-               labels_rest_time_contacts_times = new List<Gtk.Label>();
-               labels_rest_time_encoder_names = new List<Gtk.Label>();
-               labels_rest_time_encoder_times = new List<Gtk.Label>();
-
-               labels_rest_time_contacts_names.Add(label_contacts_rest_time_1_name);
-               labels_rest_time_contacts_names.Add(label_contacts_rest_time_2_name);
-               labels_rest_time_contacts_names.Add(label_contacts_rest_time_3_name);
-               labels_rest_time_contacts_names.Add(label_contacts_rest_time_4_name);
-               labels_rest_time_contacts_names.Add(label_contacts_rest_time_5_name);
-
-               labels_rest_time_contacts_times.Add(label_contacts_rest_time_1_time);
-               labels_rest_time_contacts_times.Add(label_contacts_rest_time_2_time);
-               labels_rest_time_contacts_times.Add(label_contacts_rest_time_3_time);
-               labels_rest_time_contacts_times.Add(label_contacts_rest_time_4_time);
-               labels_rest_time_contacts_times.Add(label_contacts_rest_time_5_time);
-
-               labels_rest_time_encoder_names.Add(label_encoder_rest_time_1_name);
-               labels_rest_time_encoder_names.Add(label_encoder_rest_time_2_name);
-               labels_rest_time_encoder_names.Add(label_encoder_rest_time_3_name);
-               labels_rest_time_encoder_names.Add(label_encoder_rest_time_4_name);
-               labels_rest_time_encoder_names.Add(label_encoder_rest_time_5_name);
-
-               labels_rest_time_encoder_times.Add(label_encoder_rest_time_1_time);
-               labels_rest_time_encoder_times.Add(label_encoder_rest_time_2_time);
-               labels_rest_time_encoder_times.Add(label_encoder_rest_time_3_time);
-               labels_rest_time_encoder_times.Add(label_encoder_rest_time_4_time);
-               labels_rest_time_encoder_times.Add(label_encoder_rest_time_5_time);
-       }
-
-       private void labels_rest_time_contacts_clean()
-       {
-               for(int i=0; i < 5; i ++) {
-                       ((Gtk.Label) labels_rest_time_contacts_names[i]).Text = "";
-                       ((Gtk.Label) labels_rest_time_contacts_times[i]).Text = "";
-               }
-       }
-
-       private void labels_rest_time_encoder_clean()
-       {
-               for(int i=0; i < 5; i ++) {
-                       ((Gtk.Label) labels_rest_time_encoder_names[i]).Text = "";
-                       ((Gtk.Label) labels_rest_time_encoder_times[i]).Text = "";
-               }
-       }
-
        //called each second and after a test
        bool updateRestTimes()
        {
@@ -4201,31 +4124,9 @@ public partial class ChronoJumpWindow
                if(current_menuitem_mode == Constants.Menuitem_modes.POWERGRAVITATORY ||
                               current_menuitem_mode == Constants.Menuitem_modes.POWERINERTIAL)
                {
-                       labels_rest_time_encoder_clean();
-                       List<LastTestTime> listLastMin = restTime.LastMinList();
-                       int count = 0;
-                       foreach(LastTestTime ltt in listLastMin)
-                       {
-                               if(count < 5) //only 5 values
-                               {
-                                       ((Gtk.Label) labels_rest_time_encoder_names[count]).Text = 
ltt.PersonName;
-                                       ((Gtk.Label) labels_rest_time_encoder_times[count]).Text = 
ltt.RestedTime;
-                                       count ++;
-                               }
-                       }
+                       updateTopRestTimesEncoder();
                } else {
-                       labels_rest_time_contacts_clean();
-                       List<LastTestTime> listLastMin = restTime.LastMinList();
-                       int count = 0;
-                       foreach(LastTestTime ltt in listLastMin)
-                       {
-                               if(count < 5) //only 5 values
-                               {
-                                       ((Gtk.Label) labels_rest_time_contacts_names[count]).Text = 
ltt.PersonName;
-                                       ((Gtk.Label) labels_rest_time_contacts_times[count]).Text = 
ltt.RestedTime;
-                                       count ++;
-                               }
-                       }
+                       updateTopRestTimesContacts();
                }
 
                return true;
diff --git a/src/gui/restTime.cs b/src/gui/restTime.cs
new file mode 100644
index 0000000..45efcf7
--- /dev/null
+++ b/src/gui/restTime.cs
@@ -0,0 +1,139 @@
+/*
+ * 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) 2017   Xavier de Blas <xaviblas gmail com> 
+ */
+
+using Gtk;
+using Glade;
+using System.Collections.Generic; //List
+
+/*
+ * All this code is related to top restTimes shown on app1 top
+ * when configChronojump.PersonWinHide
+ */
+
+public partial class ChronoJumpWindow 
+{
+       [Widget] Gtk.Label label_contacts_rest_time_1_name;
+       [Widget] Gtk.Label label_contacts_rest_time_2_name;
+       [Widget] Gtk.Label label_contacts_rest_time_3_name;
+       [Widget] Gtk.Label label_contacts_rest_time_4_name;
+       [Widget] Gtk.Label label_contacts_rest_time_5_name;
+
+       [Widget] Gtk.Label label_contacts_rest_time_1_time;
+       [Widget] Gtk.Label label_contacts_rest_time_2_time;
+       [Widget] Gtk.Label label_contacts_rest_time_3_time;
+       [Widget] Gtk.Label label_contacts_rest_time_4_time;
+       [Widget] Gtk.Label label_contacts_rest_time_5_time;
+
+       [Widget] Gtk.Label label_encoder_rest_time_1_name;
+       [Widget] Gtk.Label label_encoder_rest_time_2_name;
+       [Widget] Gtk.Label label_encoder_rest_time_3_name;
+       [Widget] Gtk.Label label_encoder_rest_time_4_name;
+       [Widget] Gtk.Label label_encoder_rest_time_5_name;
+
+       [Widget] Gtk.Label label_encoder_rest_time_1_time;
+       [Widget] Gtk.Label label_encoder_rest_time_2_time;
+       [Widget] Gtk.Label label_encoder_rest_time_3_time;
+       [Widget] Gtk.Label label_encoder_rest_time_4_time;
+       [Widget] Gtk.Label label_encoder_rest_time_5_time;
+
+       List<Gtk.Label> labels_rest_time_contacts_names;
+       List<Gtk.Label> labels_rest_time_contacts_times;
+       List<Gtk.Label> labels_rest_time_encoder_names;
+       List<Gtk.Label> labels_rest_time_encoder_times;
+
+       private void initializeRestTimeLabels()
+       {
+               labels_rest_time_contacts_names = new List<Gtk.Label>();
+               labels_rest_time_contacts_times = new List<Gtk.Label>();
+               labels_rest_time_encoder_names = new List<Gtk.Label>();
+               labels_rest_time_encoder_times = new List<Gtk.Label>();
+
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_1_name);
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_2_name);
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_3_name);
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_4_name);
+               labels_rest_time_contacts_names.Add(label_contacts_rest_time_5_name);
+
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_1_time);
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_2_time);
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_3_time);
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_4_time);
+               labels_rest_time_contacts_times.Add(label_contacts_rest_time_5_time);
+
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_1_name);
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_2_name);
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_3_name);
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_4_name);
+               labels_rest_time_encoder_names.Add(label_encoder_rest_time_5_name);
+
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_1_time);
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_2_time);
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_3_time);
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_4_time);
+               labels_rest_time_encoder_times.Add(label_encoder_rest_time_5_time);
+       }
+
+       private void labels_rest_time_contacts_clean()
+       {
+               for(int i=0; i < 5; i ++) {
+                       ((Gtk.Label) labels_rest_time_contacts_names[i]).Text = "";
+                       ((Gtk.Label) labels_rest_time_contacts_times[i]).Text = "";
+               }
+       }
+       private void labels_rest_time_encoder_clean()
+       {
+               for(int i=0; i < 5; i ++) {
+                       ((Gtk.Label) labels_rest_time_encoder_names[i]).Text = "";
+                       ((Gtk.Label) labels_rest_time_encoder_times[i]).Text = "";
+               }
+       }
+
+       private void updateTopRestTimesContacts()
+       {
+               labels_rest_time_contacts_clean();
+               List<LastTestTime> listLastMin = restTime.LastMinList();
+               int count = 0;
+               foreach(LastTestTime ltt in listLastMin)
+               {
+                       if(count < 5) //only 5 values
+                       {
+                               ((Gtk.Label) labels_rest_time_contacts_names[count]).Text = ltt.PersonName;
+                               ((Gtk.Label) labels_rest_time_contacts_times[count]).Text = ltt.RestedTime;
+                               count ++;
+                       }
+               }
+       }
+       private void updateTopRestTimesEncoder()
+       {
+               labels_rest_time_encoder_clean();
+               List<LastTestTime> listLastMin = restTime.LastMinList();
+               int count = 0;
+               foreach(LastTestTime ltt in listLastMin)
+               {
+                       if(count < 5) //only 5 values
+                       {
+                               ((Gtk.Label) labels_rest_time_encoder_names[count]).Text = ltt.PersonName;
+                               ((Gtk.Label) labels_rest_time_encoder_times[count]).Text = ltt.RestedTime;
+                               count ++;
+                       }
+               }
+       }
+}
+


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