[chronojump] Encoder: Done Exercise info and add
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] Encoder: Done Exercise info and add
- Date: Sun, 3 Jun 2012 19:57:51 +0000 (UTC)
commit 7196cf1fbc23726091ff54b16f36b7c3c1bbd342
Author: Xavier de Blas <xaviblas gmail com>
Date: Sun Jun 3 21:56:34 2012 +0200
Encoder: Done Exercise info and add
glade/chronojump.glade | 153 ++++++++++++++++++++++++++++++++++++++-------
src/constants.cs | 2 +-
src/encoder.cs | 10 ++-
src/gui/chronojump.cs | 2 +
src/gui/encoder.cs | 133 +++++++++++++++++++++++++++++++++------
src/gui/genericWindow.cs | 137 +++++++++++++++++++++++++++++++++++++++--
src/sqlite/encoder.cs | 42 ++++++++-----
7 files changed, 408 insertions(+), 71 deletions(-)
---
diff --git a/glade/chronojump.glade b/glade/chronojump.glade
index 33c9f2c..c079e54 100644
--- a/glade/chronojump.glade
+++ b/glade/chronojump.glade
@@ -5810,18 +5810,6 @@ suitable for agility tests)</property>
</widget>
</child>
</widget>
- <widget class="GtkWindow" id="pulse_extra">
- <property name="visible">True</property>
- <property name="border_width">10</property>
- <property name="title" translatable="yes">pulse extra data</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="type_hint">dialog</property>
- <signal name="delete_event" handler="on_delete_event"/>
- <child>
- <placeholder/>
- </child>
- </widget>
<widget class="GtkDialog" id="dialog_calendar">
<property name="visible">True</property>
<property name="modal">True</property>
@@ -11162,6 +11150,38 @@ comments</property>
</packing>
</child>
<child>
+ <widget class="GtkHBox" id="hbox_error">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkImage" id="image_error">
+ <property name="visible">True</property>
+ <property name="stock">gtk-no</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label_error">
+ <property name="visible">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="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkVBox" id="vbox_data">
<property name="visible">True</property>
<property name="spacing">4</property>
@@ -11178,12 +11198,33 @@ comments</property>
</packing>
</child>
<child>
- <widget class="GtkSpinButton" id="spin_int">
+ <widget class="GtkHBox" id="hbox_spin_int">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="adjustment">10 0 300 1 10 0</property>
- <property name="snap_to_ticks">True</property>
- <property name="numeric">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label_spin_int">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">label</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkSpinButton" id="spin_int">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="adjustment">10 0 300 1 10 0</property>
+ <property name="snap_to_ticks">True</property>
+ <property name="numeric">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
@@ -11196,7 +11237,7 @@ comments</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">â</property>
- <property name="adjustment">0 0 300 0.01 10 10</property>
+ <property name="adjustment">0 0 300 0.01 10 0</property>
<property name="digits">2</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
@@ -11221,7 +11262,7 @@ comments</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">â</property>
- <property name="adjustment">0 0 8 1 1 1</property>
+ <property name="adjustment">0 0 8 1 1 0</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
<property name="update_policy">if-valid</property>
@@ -11256,7 +11297,7 @@ comments</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">â</property>
- <property name="adjustment">0 0 11 0.01 1 1</property>
+ <property name="adjustment">0 0 11 0.01 1 0</property>
<property name="digits">2</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
@@ -11289,6 +11330,70 @@ comments</property>
</packing>
</child>
<child>
+ <widget class="GtkHBox" id="hbox_entry2">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label_entry2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">label</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="entry2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox_entry3">
+ <property name="visible">True</property>
+ <property name="spacing">10</property>
+ <child>
+ <widget class="GtkLabel" id="label_entry3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">label</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkEntry" id="entry3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
+ <child>
<widget class="GtkScrolledWindow" id="scrolled_window_textview">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -11303,7 +11408,7 @@ comments</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">4</property>
+ <property name="position">6</property>
</packing>
</child>
<child>
@@ -11319,12 +11424,12 @@ comments</property>
</child>
</widget>
<packing>
- <property name="position">5</property>
+ <property name="position">7</property>
</packing>
</child>
</widget>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -11369,7 +11474,7 @@ comments</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">10</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</widget>
diff --git a/src/constants.cs b/src/constants.cs
index 1adba9c..c61b26b 100644
--- a/src/constants.cs
+++ b/src/constants.cs
@@ -533,7 +533,7 @@ public class Constants
//height mentric contains 2 spins
public enum GenericWindowShow {
- ENTRY, SPININT, SPINDOUBLE, HEIGHTMETRIC, TEXTVIEW, TREEVIEW
+ ENTRY, ENTRY2, ENTRY3, SPININT, SPINDOUBLE, HEIGHTMETRIC, TEXTVIEW, TREEVIEW
}
public const string PrefVersionAvailable = "versionAvailable";
diff --git a/src/encoder.cs b/src/encoder.cs
index 4623f1c..fdbcb9a 100644
--- a/src/encoder.cs
+++ b/src/encoder.cs
@@ -259,15 +259,19 @@ public class EncoderSQL
public class EncoderExercise
{
- public EncoderExercise() {
- }
-
public int uniqueID;
public string name;
public int percentBodyWeight;
public string ressistance;
public string description;
+ public EncoderExercise() {
+ }
+
+ public EncoderExercise(string name) {
+ this.name = name;
+ }
+
public EncoderExercise(int uniqueID, string name, int percentBodyWeight, string ressistance, string description)
{
this.uniqueID = uniqueID;
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index 546399a..a4cb446 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -2379,6 +2379,8 @@ public partial class ChronoJumpWindow
genericWin = GenericWindow.Show(Catalog.GetString("Select number of persons to add") + "\n" +
Catalog.GetString("If you want to add more than 40 persons, do this process two times.")
, Constants.GenericWindowShow.SPININT);
+
+ genericWin.LabelSpinInt = "";
genericWin.SetSpinRange(1.0, 40.0);
genericWin.Button_accept.Clicked += new EventHandler(on_person_add_multiple_prepared);
}
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index c38c13a..fb36e52 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -109,8 +109,6 @@ public partial class ChronoJumpWindow
//TODO: single curve, and side, checkbox to show1 param, 2 or three
//TODO: powerbars with checkbox to show1 param, 2 or three
//TODO: on capture (quasi-realtime), show powerbars or curves or both
- //
- //TODO: exercises info, exercises add
private void encoderInitializeStuff() {
@@ -171,7 +169,7 @@ public partial class ChronoJumpWindow
(int) spin_encoder_capture_min_height.Value,
Convert.ToInt32(
Util.FindOnArray(':', 2, 3, UtilGtk.ComboGetActive(combo_encoder_exercise),
- encoderExercisesTranslationAndBodyPWeight) ),
+ encoderExercisesTranslationAndBodyPWeight) ), //ex.percentBodyWeight
findMass(true),
Util.ConvertToPoint((double) spin_encoder_smooth.Value), //R decimal: '.'
findEccon(true), //force ecS (ecc-conc separated)
@@ -238,7 +236,7 @@ public partial class ChronoJumpWindow
(int) spin_encoder_capture_min_height.Value,
Convert.ToInt32(
Util.FindOnArray(':', 2, 3, UtilGtk.ComboGetActive(combo_encoder_exercise),
- encoderExercisesTranslationAndBodyPWeight) ),
+ encoderExercisesTranslationAndBodyPWeight) ), //ex.percentBodyWeight
findMass(true),
findEccon(true), //force ecS (ecc-conc separated)
"curves",
@@ -536,7 +534,8 @@ public partial class ChronoJumpWindow
writer.WriteLine("exerciseName,mass,smoothingOne,dateTime,fullURL,eccon");
foreach(EncoderSQL eSQL in data) {
double mass = Convert.ToDouble(eSQL.extraWeight); //TODO: future problem if this has '%'
- EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(eSQL.exerciseID)[0];
+ EncoderExercise ex = (EncoderExercise)
+ SqliteEncoder.SelectEncoderExercises(eSQL.exerciseID,false)[0];
mass += bodyMass * ex.percentBodyWeight / 100.0;
writer.WriteLine(ex.name + "," + mass.ToString() + "," +
@@ -660,20 +659,24 @@ public partial class ChronoJumpWindow
protected void createEncoderCombos() {
//create combo exercises
combo_encoder_exercise = ComboBox.NewText ();
- ArrayList encoderExercises = SqliteEncoder.SelectEncoderExercises(-1);
+ ArrayList encoderExercises = SqliteEncoder.SelectEncoderExercises(-1, false);
encoderExercisesTranslationAndBodyPWeight = new String [encoderExercises.Count];
string [] exerciseNamesToCombo = new String [encoderExercises.Count];
int i =0;
foreach(EncoderExercise ex in encoderExercises) {
+ string nameTranslated = ex.name;
+ //do not translated user created exercises
+ //this names are in SqliteEncoder.initializeTableEncoderExercise()
+ if(ex.name == "Bench press" || ex.name == "Squat" || ex.name == "Jump")
+ nameTranslated = Catalog.GetString(ex.name);
encoderExercisesTranslationAndBodyPWeight[i] =
- ex.uniqueID + ":" + ex.name + ":" + Catalog.GetString(ex.name) + ":" + ex.percentBodyWeight;
+ ex.uniqueID + ":" + ex.name + ":" + nameTranslated + ":" + ex.percentBodyWeight;
exerciseNamesToCombo[i] = Catalog.GetString(ex.name);
i++;
}
UtilGtk.ComboUpdate(combo_encoder_exercise, exerciseNamesToCombo, "");
combo_encoder_exercise.Active = UtilGtk.ComboMakeActive(combo_encoder_exercise,
Catalog.GetString(((EncoderExercise) encoderExercises[0]).name));
- combo_encoder_exercise.Changed += new EventHandler (on_combo_encoder_exercise_changed);
//create combo eccon
string [] comboEcconOptions = { "Concentric", "Eccentric-concentric" };
@@ -700,7 +703,6 @@ public partial class ChronoJumpWindow
UtilGtk.ComboUpdate(combo_encoder_laterality, comboLateralityOptions, "");
combo_encoder_laterality.Active = UtilGtk.ComboMakeActive(combo_encoder_laterality,
Catalog.GetString(comboLateralityOptions[0]));
- combo_encoder_laterality.Changed += new EventHandler (on_combo_encoder_laterality_changed);
//pack combos
@@ -717,11 +719,6 @@ public partial class ChronoJumpWindow
combo_encoder_laterality.Sensitive = true;
}
- void on_combo_encoder_exercise_changed (object o, EventArgs args)
- {
- //TODO
- }
-
void on_combo_encoder_eccon_changed (object o, EventArgs args)
{
/*
@@ -736,19 +733,113 @@ public partial class ChronoJumpWindow
*/
}
- void on_combo_encoder_laterality_changed (object o, EventArgs args)
- {
- //TODO
- }
-
void on_button_encoder_exercise_info_clicked (object o, EventArgs args)
{
- //TODO
+ int exerciseID = Convert.ToInt32(
+ Util.FindOnArray(':', 2, 0, UtilGtk.ComboGetActive(combo_encoder_exercise),
+ encoderExercisesTranslationAndBodyPWeight) ); //exerciseID
+ EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(exerciseID,false)[0];
+
+ ArrayList bigArray = new ArrayList();
+
+ ArrayList a1 = new ArrayList();
+ ArrayList a2 = new ArrayList();
+ ArrayList a3 = new ArrayList();
+ ArrayList a4 = new ArrayList();
+
+ //0 is the widgget to show; 1 is the editable; 2 id default value
+ a1.Add(Constants.GenericWindowShow.ENTRY); a1.Add(false); a1.Add(ex.name);
+ bigArray.Add(a1);
+
+ a2.Add(Constants.GenericWindowShow.SPININT); a2.Add(false); a2.Add("");
+ bigArray.Add(a2);
+
+ a3.Add(Constants.GenericWindowShow.ENTRY2); a3.Add(false); a3.Add(ex.ressistance);
+ bigArray.Add(a3);
+
+ a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(false); a4.Add(ex.description);
+ bigArray.Add(a4);
+
+ genericWin = GenericWindow.Show(Catalog.GetString("Encoder exercise name:"), bigArray);
+ genericWin.LabelSpinInt = Catalog.GetString("Displaced body weight") + " (%)";
+ genericWin.SetSpinRange(ex.percentBodyWeight, ex.percentBodyWeight); //done this because IsEditable does not affect the cursors
+ genericWin.LabelEntry2 = Catalog.GetString("Ressitance");
+ genericWin.LabelEntry3 = Catalog.GetString("Description");
+ genericWin.ShowButtonCancel(false);
+ genericWin.SetButtonAcceptLabel(Catalog.GetString("Close"));
}
void on_button_encoder_exercise_add_clicked (object o, EventArgs args)
{
- //TODO
+ ArrayList bigArray = new ArrayList();
+
+ ArrayList a1 = new ArrayList();
+ ArrayList a2 = new ArrayList();
+ ArrayList a3 = new ArrayList();
+ ArrayList a4 = new ArrayList();
+
+ //0 is the widgget to show; 1 is the editable; 2 id default value
+ a1.Add(Constants.GenericWindowShow.ENTRY); a1.Add(true); a1.Add("");
+ bigArray.Add(a1);
+
+ a2.Add(Constants.GenericWindowShow.SPININT); a2.Add(true); a2.Add("");
+ bigArray.Add(a2);
+
+ a3.Add(Constants.GenericWindowShow.ENTRY2); a3.Add(true); a3.Add("");
+ bigArray.Add(a3);
+
+ a4.Add(Constants.GenericWindowShow.ENTRY3); a4.Add(true); a4.Add("");
+ bigArray.Add(a4);
+
+ genericWin = GenericWindow.Show(
+ Catalog.GetString("Write the name of the encoder exercise:"), bigArray);
+ genericWin.LabelSpinInt = Catalog.GetString("Displaced body weight") + " (%)";
+ genericWin.SetSpinRange(0, 100);
+ genericWin.LabelEntry2 = Catalog.GetString("Ressitance");
+ genericWin.LabelEntry3 = Catalog.GetString("Description");
+ genericWin.SetButtonAcceptLabel(Catalog.GetString("Add"));
+
+ genericWin.HideOnAccept = false;
+
+ genericWin.Button_accept.Clicked += new EventHandler(on_button_encoder_exercise_add_accepted);
+ }
+
+ void on_button_encoder_exercise_add_accepted (object o, EventArgs args)
+ {
+ string name = Util.RemoveTildeAndColonAndDot(genericWin.EntrySelected);
+
+ Log.WriteLine("Trying to insert: " + name);
+ if(name == "")
+ genericWin.SetLabelError(Catalog.GetString("Error: Missing name of exercise."));
+ else if (Sqlite.Exists(Constants.EncoderExerciseTable, name))
+ genericWin.SetLabelError(string.Format(Catalog.GetString(
+ "Error: An exercise named '{0}' already exists."), name));
+ else {
+ SqliteEncoder.InsertExercise(false, name, genericWin.SpinIntSelected,
+ genericWin.Entry2Selected, genericWin.Entry3Selected);
+
+ ArrayList encoderExercises = SqliteEncoder.SelectEncoderExercises(-1, false);
+ encoderExercisesTranslationAndBodyPWeight = new String [encoderExercises.Count];
+ string [] exerciseNamesToCombo = new String [encoderExercises.Count];
+ int i =0;
+ foreach(EncoderExercise ex in encoderExercises) {
+ string nameTranslated = ex.name;
+ //do not translated user created exercises
+ //this names are in SqliteEncoder.initializeTableEncoderExercise()
+ if(ex.name == "Bench press" || ex.name == "Squat" || ex.name == "Jump")
+ nameTranslated = Catalog.GetString(ex.name);
+ encoderExercisesTranslationAndBodyPWeight[i] =
+ ex.uniqueID + ":" + ex.name + ":" + nameTranslated + ":" + ex.percentBodyWeight;
+ exerciseNamesToCombo[i] = Catalog.GetString(ex.name);
+ i++;
+ }
+ UtilGtk.ComboUpdate(combo_encoder_exercise, exerciseNamesToCombo, "");
+ combo_encoder_exercise.Active = UtilGtk.ComboMakeActive(combo_encoder_exercise, name);
+
+ genericWin.Button_accept.Clicked -= new EventHandler(on_button_encoder_exercise_add_accepted);
+ genericWin.HideAndNull();
+ Log.WriteLine("done");
+ }
}
diff --git a/src/gui/genericWindow.cs b/src/gui/genericWindow.cs
index 6c08a92..6ce5393 100644
--- a/src/gui/genericWindow.cs
+++ b/src/gui/genericWindow.cs
@@ -31,9 +31,15 @@ public class GenericWindow
{
[Widget] Gtk.Window generic_window;
[Widget] Gtk.Label label_header;
+ [Widget] Gtk.Box hbox_error;
+ [Widget] Gtk.Label label_error;
[Widget] Gtk.Label label_generic_name;
[Widget] Gtk.Entry entry;
+
+ [Widget] Gtk.Box hbox_spin_int;
+ [Widget] Gtk.Label label_spin_int;
[Widget] Gtk.SpinButton spin_int;
+
[Widget] Gtk.SpinButton spin_double;
[Widget] Gtk.Box hbox_height_metric;
[Widget] Gtk.SpinButton spin_feet;
@@ -44,10 +50,18 @@ public class GenericWindow
[Widget] Gtk.TreeView treeview;
[Widget] Gtk.Button button_accept;
[Widget] Gtk.Button button_cancel;
+
+ [Widget] Gtk.Box hbox_entry2;
+ [Widget] Gtk.Label label_entry2;
+ [Widget] Gtk.Entry entry2;
+ [Widget] Gtk.Box hbox_entry3;
+ [Widget] Gtk.Label label_entry3;
+ [Widget] Gtk.Entry entry3;
static GenericWindow GenericWindowBox;
private TreeStore store;
+ public bool HideOnAccept;
public GenericWindow ()
{
@@ -59,31 +73,102 @@ public class GenericWindow
UtilGtk.IconWindow(generic_window);
}
- static public GenericWindow Show (string textHeader, Constants.GenericWindowShow stuff)
+ //for some widgets
+ static public GenericWindow Show (string textHeader, ArrayList array)
{
if (GenericWindowBox == null) {
GenericWindowBox = new GenericWindow();
}
- GenericWindowBox.showHideWidgets(stuff);
+
+ GenericWindowBox.hideWidgets();
+
+ foreach(ArrayList widgetArray in array)
+ GenericWindowBox.showWidgetsPowerful(widgetArray);
+
GenericWindowBox.label_header.Text = textHeader;
+ GenericWindowBox.generic_window.Show ();
+ GenericWindowBox.HideOnAccept = true;
+
+ return GenericWindowBox;
+ }
+
+ //for only one widget
+ static public GenericWindow Show (string textHeader, Constants.GenericWindowShow stuff)
+ {
+ if (GenericWindowBox == null) {
+ GenericWindowBox = new GenericWindow();
+ }
+
+ GenericWindowBox.hideWidgets();
+ GenericWindowBox.showWidget(stuff);
+ GenericWindowBox.label_header.Text = textHeader;
GenericWindowBox.generic_window.Show ();
+ GenericWindowBox.HideOnAccept = true;
return GenericWindowBox;
}
- void showHideWidgets(Constants.GenericWindowShow stuff) {
+ void hideWidgets() {
+ hbox_error.Hide();
entry.Hide();
- spin_int.Hide();
+ hbox_entry2.Hide();
+ hbox_entry3.Hide();
+ hbox_spin_int.Hide();
spin_double.Hide();
hbox_height_metric.Hide();
scrolled_window_textview.Hide();
scrolled_window_treeview.Hide();
+ }
+
+ void showWidgetsPowerful (ArrayList widgetArray) {
+ Constants.GenericWindowShow stuff = (Constants.GenericWindowShow) widgetArray[0];
+ bool editable = (bool) widgetArray[1];
+ string text = (string) widgetArray[2];
+
+ if(stuff == Constants.GenericWindowShow.ENTRY) {
+ entry.Show();
+ entry.IsEditable = editable;
+ entry.Text = text;
+ }
+ else if(stuff == Constants.GenericWindowShow.ENTRY2) {
+ hbox_entry2.Show();
+ entry2.IsEditable = editable;
+ entry2.Text = text;
+ }
+ else if(stuff == Constants.GenericWindowShow.ENTRY3) {
+ hbox_entry3.Show();
+ entry3.IsEditable = editable;
+ entry3.Text = text;
+ }
+ else if(stuff == Constants.GenericWindowShow.SPININT) {
+ hbox_spin_int.Show();
+ spin_int.IsEditable = editable;
+ }
+ else if(stuff == Constants.GenericWindowShow.SPINDOUBLE) {
+ spin_double.Show();
+ spin_double.IsEditable = editable;
+ }
+ else if(stuff == Constants.GenericWindowShow.HEIGHTMETRIC) {
+ hbox_height_metric.Show();
+ }
+ else if(stuff == Constants.GenericWindowShow.TEXTVIEW) {
+ scrolled_window_textview.Show();
+ }
+ else { //if(stuff == Constants.GenericWindowShow.TREEVIEW)
+ scrolled_window_treeview.Show();
+ }
+ }
+ void showWidget(Constants.GenericWindowShow stuff) {
if(stuff == Constants.GenericWindowShow.ENTRY)
entry.Show();
+ else if(stuff == Constants.GenericWindowShow.ENTRY2)
+ hbox_entry2.Show();
+ else if(stuff == Constants.GenericWindowShow.ENTRY3)
+ hbox_entry3.Show();
else if(stuff == Constants.GenericWindowShow.SPININT)
- spin_int.Show();
+ hbox_spin_int.Show();
else if(stuff == Constants.GenericWindowShow.SPINDOUBLE)
spin_double.Show();
else if(stuff == Constants.GenericWindowShow.HEIGHTMETRIC)
@@ -94,6 +179,17 @@ public class GenericWindow
scrolled_window_treeview.Show();
}
+ public void SetLabelError(string text) {
+ label_error.Text = text;
+ hbox_error.Show();
+ }
+
+ public void SetSpinValue(int num) {
+ spin_int.Value = num;
+ }
+ public void SetSpinRange(int min, int max) {
+ spin_int.SetRange(min, max);
+ }
public void SetSpinRange(double min, double max) {
spin_int.SetRange(min, max);
}
@@ -199,19 +295,46 @@ public class GenericWindow
protected void on_button_accept_clicked (object o, EventArgs args)
{
- GenericWindowBox.generic_window.Hide();
+ if(HideOnAccept)
+ GenericWindowBox.generic_window.Hide();
//GenericWindowBox = null;
}
+ //when ! HideOnAccept, use this to close window
+ public void HideAndNull() {
+ GenericWindowBox.generic_window.Hide();
+ GenericWindowBox = null;
+ }
+
public Button Button_accept {
set { button_accept = value; }
get { return button_accept; }
}
-
+
public string EntrySelected {
+ set { entry.Text = value; }
get { return entry.Text.ToString(); }
}
+
+ public string LabelEntry2 {
+ set { label_entry2.Text = value; }
+ }
+ public string Entry2Selected {
+ set { entry2.Text = value; }
+ get { return entry2.Text.ToString(); }
+ }
+
+ public string LabelEntry3 {
+ set { label_entry3.Text = value; }
+ }
+ public string Entry3Selected {
+ set { entry3.Text = value; }
+ get { return entry3.Text.ToString(); }
+ }
+ public string LabelSpinInt {
+ set { label_spin_int.Text = value; }
+ }
public int SpinIntSelected {
get { return (int) spin_int.Value; }
}
diff --git a/src/sqlite/encoder.cs b/src/sqlite/encoder.cs
index fb5c86d..7f22eb4 100644
--- a/src/sqlite/encoder.cs
+++ b/src/sqlite/encoder.cs
@@ -224,7 +224,10 @@ class SqliteEncoder : Sqlite
if(! dbconOpened)
dbcon.Close();
}
-
+
+ //Note: if this names change, or there are new, change them on both:
+ //gui/encoder createEncoderCombos();
+ //gui/encoder on_button_encoder_exercise_add_accepted (object o, EventArgs args)
protected internal static void initializeTableEncoderExercise()
{
string [] iniEncoderExercises = {
@@ -242,15 +245,18 @@ class SqliteEncoder : Sqlite
//if submited a -1, returns an especific EncoderExercise that can be read like this
//EncoderExercise ex = (EncoderExercise) SqliteEncoder.SelectEncoderExercises(eSQL.exerciseID)[0];
- public static ArrayList SelectEncoderExercises(int uniqueID)
+ public static ArrayList SelectEncoderExercises(int uniqueID, bool onlyNames)
{
dbcon.Open();
string uniqueIDStr = "";
if(uniqueID != -1)
uniqueIDStr = " WHERE " + Constants.EncoderExerciseTable + ".uniqueID = " + uniqueID;
-
- dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderExerciseTable + uniqueIDStr;
+
+ if(onlyNames)
+ dbcmd.CommandText = "SELECT name FROM " + Constants.EncoderExerciseTable + uniqueIDStr;
+ else
+ dbcmd.CommandText = "SELECT * FROM " + Constants.EncoderExerciseTable + uniqueIDStr;
Log.WriteLine(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
@@ -260,20 +266,26 @@ class SqliteEncoder : Sqlite
ArrayList array = new ArrayList(1);
EncoderExercise ex = new EncoderExercise();
- while(reader.Read()) {
- ex = new EncoderExercise (
- Convert.ToInt32(reader[0].ToString()), //uniqueID
- reader[1].ToString(), //name
- Convert.ToInt32(reader[2].ToString()), //percentBodyWeight
- reader[3].ToString(), //ressistance
- reader[4].ToString() //description
- );
- array.Add(ex);
+
+ if(onlyNames) {
+ while(reader.Read()) {
+ ex = new EncoderExercise (reader[0].ToString());
+ array.Add(ex);
+ }
+ } else {
+ while(reader.Read()) {
+ ex = new EncoderExercise (
+ Convert.ToInt32(reader[0].ToString()), //uniqueID
+ reader[1].ToString(), //name
+ Convert.ToInt32(reader[2].ToString()), //percentBodyWeight
+ reader[3].ToString(), //ressistance
+ reader[4].ToString() //description
+ );
+ array.Add(ex);
+ }
}
reader.Close();
-
- //close database connection
dbcon.Close();
return array;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]