Commit c5badd71 authored by Xavier de Blas's avatar Xavier de Blas

Preferences stuff refactored

parent 9f1ad911
......@@ -15,6 +15,7 @@ SOURCES = \
../src/run.cs\
../src/person.cs\
../src/personSession.cs\
../src/preferences.cs\
../src/pulse.cs\
../src/reactionTime.cs\
../src/session.cs\
......
......@@ -29065,7 +29065,7 @@ To differentiate between male and female, use the values 1/0, or m/f, or M/F on
</widget>
</child>
</widget>
<widget class="GtkWindow" id="preferences">
<widget class="GtkWindow" id="preferences_win">
<property name="height_request">450</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
......@@ -132,6 +132,7 @@ SOURCES = \
multiChronopicType.cs\
session.cs\
exportSession.cs\
preferences.cs\
treeViewEvent.cs\
treeViewPerson.cs\
treeViewJump.cs\
......
This diff is collapsed.
......@@ -188,12 +188,6 @@ public partial class ChronoJumpWindow
private static bool encoderProcessProblems;
private static bool encoderProcessFinish;
//smooth preferences on Sqlite since 1.3.7
bool encoderPropulsive;
double encoderSmoothCon;
//bool capturingRotaryInertial;
EncoderCaptureOptionsWindow encoderCaptureOptionsWin;
EncoderConfigurationWindow encoder_configuration_win;
......@@ -337,7 +331,7 @@ public partial class ChronoJumpWindow
}
void on_button_encoder_capture_options_clicked (object o, EventArgs args) {
encoderCaptureOptionsWin.View(repetitiveConditionsWin, volumeOn);
encoderCaptureOptionsWin.View(repetitiveConditionsWin, preferences.volumeOn);
}
private void on_encoder_capture_options_closed(object o, EventArgs args) {
......@@ -346,7 +340,7 @@ public partial class ChronoJumpWindow
}
private void on_button_encoder_bells_clicked(object o, EventArgs args) {
repetitiveConditionsWin.View(Constants.BellModes.ENCODER, volumeOn);
repetitiveConditionsWin.View(Constants.BellModes.ENCODER, preferences.volumeOn);
}
private bool encoderCheckPort() {
......@@ -669,7 +663,7 @@ public partial class ChronoJumpWindow
private string getEncoderAnalysisOptions(bool captureOrAnalyze) {
string analysisOptions = "-";
if(encoderPropulsive)
if(preferences.encoderPropulsive)
analysisOptions = "p";
return analysisOptions;
......@@ -718,14 +712,12 @@ public partial class ChronoJumpWindow
"none", //analysisVariables (not needed in create curves). Cannot be blank
analysisOptions,
encoderConfigurationCurrent,
Util.ConvertToPoint(encoderSmoothCon), //R decimal: '.'
Util.ConvertToPoint(preferences.encoderSmoothCon), //R decimal: '.'
0, //curve is not used here
image_encoder_width, image_encoder_height,
CSVExportDecimalSeparator
preferences.CSVExportDecimalSeparator
);
//capturingRotaryInertial = false;
EncoderStruct es = new EncoderStruct(
UtilEncoder.GetEncoderDataTempFileName(),
UtilEncoder.GetEncoderGraphTempFileName(),
......@@ -740,7 +732,7 @@ public partial class ChronoJumpWindow
"-(" + Util.ConvertToPoint(findMass(Constants.MassType.DISPLACED)) + "Kg)",
es,
false, //do not use neuromuscularProfile script
RGraphsTranslate
preferences.RGraphsTranslate
);
if(result)
......@@ -930,7 +922,7 @@ public partial class ChronoJumpWindow
}
protected void on_encoder_show_curves_row_delete_pre (object o, EventArgs args) {
if(askDeletion) {
if(preferences.askDeletion) {
ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString(
"Are you sure you want to delete this repetition?"), "", "");
confirmWin.Button_accept.Clicked += new EventHandler(on_encoder_show_curves_row_delete);
......@@ -1330,7 +1322,7 @@ public partial class ChronoJumpWindow
}
protected void on_encoder_load_signal_row_delete_pre (object o, EventArgs args) {
if(askDeletion) {
if(preferences.askDeletion) {
ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString(
"Are you sure you want to delete this set?"), Catalog.GetString("Saved repetitions related to this set will also be deleted."), "");
confirmWin.Button_accept.Clicked += new EventHandler(on_encoder_load_signal_row_delete);
......@@ -1415,11 +1407,11 @@ public partial class ChronoJumpWindow
"none", //analysisVariables (not needed in create curves). Cannot be blank
analysisOptions,
encoderConfigurationCurrent,
Util.ConvertToPoint(encoderSmoothCon), //R decimal: '.'
Util.ConvertToPoint(preferences.encoderSmoothCon), //R decimal: '.'
-1,
image_encoder_width,
image_encoder_height,
CSVExportDecimalSeparator
preferences.CSVExportDecimalSeparator
);
string dataFileName = UtilEncoder.GetEncoderDataTempFileName();
......@@ -1438,7 +1430,7 @@ public partial class ChronoJumpWindow
"-(" + displacedMass + "Kg)",
encoderStruct,
false, //do not use neuromuscularProfile script
RGraphsTranslate
preferences.RGraphsTranslate
);
//encoder_pulsebar_capture.Text = string.Format(Catalog.GetString(
......@@ -1563,7 +1555,7 @@ public partial class ChronoJumpWindow
void on_button_encoder_delete_signal_clicked (object o, EventArgs args)
{
if(askDeletion) {
if(preferences.askDeletion) {
ConfirmWindow confirmWin = ConfirmWindow.Show(Catalog.GetString(
"Are you sure you want to delete this set?"), Catalog.GetString("Saved repetitions related to this set will also be deleted."), "");
confirmWin.Button_accept.Clicked += new EventHandler(on_button_encoder_delete_signal_accepted);
......@@ -1773,7 +1765,7 @@ public partial class ChronoJumpWindow
button_video_play_this_test_encoder.Sensitive = false;
//copy video
if(videoOn) {
if(preferences.videoOn) {
if(Util.CopyTempVideo(currentSession.UniqueID,
Constants.TestTypes.ENCODER,
Convert.ToInt32(encoderSignalUniqueID))) {
......@@ -2290,11 +2282,11 @@ public partial class ChronoJumpWindow
analysisVariables,
analysisOptions,
encoderConfigurationCurrent,
Util.ConvertToPoint(encoderSmoothCon), //R decimal: '.'
Util.ConvertToPoint(preferences.encoderSmoothCon), //R decimal: '.'
myCurveNum,
image_encoder_width,
image_encoder_height,
CSVExportDecimalSeparator
preferences.CSVExportDecimalSeparator
);
......@@ -2407,11 +2399,11 @@ public partial class ChronoJumpWindow
analysisVariables,
analysisOptions,
encoderConfigurationCurrent,
Util.ConvertToPoint(encoderSmoothCon), //R decimal: '.'
Util.ConvertToPoint(preferences.encoderSmoothCon), //R decimal: '.'
Convert.ToInt32(UtilGtk.ComboGetActive(combo_encoder_analyze_curve_num_combo)),
image_encoder_width,
image_encoder_height,
CSVExportDecimalSeparator
preferences.CSVExportDecimalSeparator
);
dataFileName = UtilEncoder.GetEncoderDataTempFileName();
......@@ -2442,7 +2434,7 @@ public partial class ChronoJumpWindow
UtilEncoder.RunEncoderGraphNoRDotNet(titleStr, encoderStruct,
encoderAnalysis == "neuromuscularProfile",
RGraphsTranslate);
preferences.RGraphsTranslate);
}
private void on_check_encoder_analyze_signal_or_curves_toggled (object obj, EventArgs args) {
......@@ -3750,7 +3742,7 @@ public partial class ChronoJumpWindow
//propulsive stuff
int propulsiveEnd = curveToRreduced.Length;
rengine.Evaluate("g <- 9.81");
if(encoderPropulsive) {
if(preferences.encoderPropulsive) {
//check if propulsive phase ends
Log.WriteLine("accel$y");
//rengine.Evaluate("print(accel$y)");
......@@ -3963,14 +3955,14 @@ public partial class ChronoJumpWindow
if(mainVariableHigher != -1 && d >= mainVariableHigher) {
my_pen = pen_green_encoder_capture;
//play sound if value is high, volumeOn == true, is last value, capturing
if(volumeOn && count == data.Count -1 && capturing)
Util.PlaySound(Constants.SoundTypes.GOOD, volumeOn);
if(preferences.volumeOn && count == data.Count -1 && capturing)
Util.PlaySound(Constants.SoundTypes.GOOD, preferences.volumeOn);
}
else if(mainVariableLower != -1 && d <= mainVariableLower) {
my_pen = pen_red_encoder_capture;
//play sound if value is low, volumeOn == true, is last value, capturing
if(volumeOn && count == data.Count -1 && capturing)
Util.PlaySound(Constants.SoundTypes.BAD, volumeOn);
if(preferences.volumeOn && count == data.Count -1 && capturing)
Util.PlaySound(Constants.SoundTypes.BAD, preferences.volumeOn);
}
else
my_pen = pen_azul_encoder_capture;
......@@ -4601,14 +4593,14 @@ public partial class ChronoJumpWindow
bool needToAutoSaveCurve = false;
if(
encoderSignalUniqueID == "-1" && //if we just captured
(encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.ALL ||
encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.BESTMEANPOWER) )
(preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.ALL ||
preferences.encoderAutoSaveCurve == Constants.EncoderAutoSaveCurve.BESTMEANPOWER) )
needToAutoSaveCurve = true;
encoder_pulsebar_capture.Text = encoderSaveSignalOrCurve("signal", 0); //this updates encoderSignalUniqueID
if(needToAutoSaveCurve)
encoderCaptureSaveCurvesAllNoneBest(encoderAutoSaveCurve);
encoderCaptureSaveCurvesAllNoneBest(preferences.encoderAutoSaveCurve);
} else
encoder_pulsebar_capture.Text = "";
......@@ -4780,7 +4772,7 @@ public partial class ChronoJumpWindow
private void encoderStartVideoRecord() {
Log.WriteLine("Starting video");
checkbutton_video_encoder.Sensitive = false;
if(videoOn) {
if(preferences.videoOn) {
capturer.ClickRec();
label_video_feedback_encoder.Text = "Rec.";
}
......@@ -4790,7 +4782,7 @@ public partial class ChronoJumpWindow
private void encoderStopVideoRecord() {
Log.WriteLine("Stopping video");
checkbutton_video_encoder.Sensitive = true;
if(videoOn) {
if(preferences.videoOn) {
label_video_feedback_encoder.Text = "";
capturer.ClickStop();
videoCapturePrepare(false); //if error, show message
......
......@@ -278,7 +278,7 @@ public partial class ChronoJumpWindow
eventHasEnded = false;
checkbutton_video.Sensitive = false;
if(videoOn) {
if(preferences.videoOn) {
capturer.ClickRec();
//label_video_feedback.Text = Catalog.GetString("Recording");
label_video_feedback.Text = "Rec.";
......@@ -1002,52 +1002,52 @@ Log.WriteLine("Preparing reactive A");
double tcNow, double tcPerson, double tcSession)
{
if(tcNow > 0) {
event_execute_label_jump_simple_tc_now.Text = "<b>" + Util.TrimDecimals(tcNow.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_jump_simple_tc_now.Text = "<b>" + Util.TrimDecimals(tcNow.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_jump_simple_tc_now.UseMarkup = true;
event_execute_label_jump_simple_tc_person.Text = Util.TrimDecimals(tcPerson.ToString(), prefsDigitsNumber);
event_execute_label_jump_simple_tc_session.Text = Util.TrimDecimals(tcSession.ToString(), prefsDigitsNumber);
event_execute_label_jump_simple_tc_person.Text = Util.TrimDecimals(tcPerson.ToString(), preferences.digitsNumber);
event_execute_label_jump_simple_tc_session.Text = Util.TrimDecimals(tcSession.ToString(), preferences.digitsNumber);
} else {
event_execute_label_jump_simple_tc_now.Text = "";
event_execute_label_jump_simple_tc_person.Text = "";
event_execute_label_jump_simple_tc_session.Text = "";
}
event_execute_label_jump_simple_tf_now.Text = "<b>" + Util.TrimDecimals(tvNow.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_jump_simple_tf_now.Text = "<b>" + Util.TrimDecimals(tvNow.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_jump_simple_tf_now.UseMarkup = true;
event_execute_label_jump_simple_tf_person.Text = Util.TrimDecimals(tvPerson.ToString(), prefsDigitsNumber);
event_execute_label_jump_simple_tf_session.Text = Util.TrimDecimals(tvSession.ToString(), prefsDigitsNumber);
event_execute_label_jump_simple_tf_person.Text = Util.TrimDecimals(tvPerson.ToString(), preferences.digitsNumber);
event_execute_label_jump_simple_tf_session.Text = Util.TrimDecimals(tvSession.ToString(), preferences.digitsNumber);
//current height is calculated from tvNow
//heightPerson and heightSession is calculated for every jump, then done the AVG, then send here
event_execute_label_jump_simple_height_now.Text = "<b>" + Util.TrimDecimals(
Util.GetHeightInCentimeters(tvNow.ToString()) , prefsDigitsNumber) + "</b>";
Util.GetHeightInCentimeters(tvNow.ToString()) , preferences.digitsNumber) + "</b>";
event_execute_label_jump_simple_height_now.UseMarkup = true;
event_execute_label_jump_simple_height_person.Text = Util.TrimDecimals(heightPerson.ToString(), prefsDigitsNumber);
event_execute_label_jump_simple_height_session.Text = Util.TrimDecimals(heightSession.ToString(), prefsDigitsNumber);
event_execute_label_jump_simple_height_person.Text = Util.TrimDecimals(heightPerson.ToString(), preferences.digitsNumber);
event_execute_label_jump_simple_height_session.Text = Util.TrimDecimals(heightSession.ToString(), preferences.digitsNumber);
}
private void printLabelsRunSimple (double timeNow, double timePerson, double timeSession, double speedNow, double speedPerson, double speedSession) {
event_execute_label_run_simple_time_now.Text = "<b>" + Util.TrimDecimals(timeNow.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_run_simple_time_now.Text = "<b>" + Util.TrimDecimals(timeNow.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_run_simple_time_now.UseMarkup = true;
event_execute_label_run_simple_time_person.Text = Util.TrimDecimals(timePerson.ToString(), prefsDigitsNumber);
event_execute_label_run_simple_time_session.Text = Util.TrimDecimals(timeSession.ToString(), prefsDigitsNumber);
event_execute_label_run_simple_time_person.Text = Util.TrimDecimals(timePerson.ToString(), preferences.digitsNumber);
event_execute_label_run_simple_time_session.Text = Util.TrimDecimals(timeSession.ToString(), preferences.digitsNumber);
event_execute_label_run_simple_speed_now.Text = "<b>" + Util.TrimDecimals(speedNow.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_run_simple_speed_now.Text = "<b>" + Util.TrimDecimals(speedNow.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_run_simple_speed_now.UseMarkup = true;
event_execute_label_run_simple_speed_person.Text = Util.TrimDecimals(speedPerson.ToString(), prefsDigitsNumber);
event_execute_label_run_simple_speed_session.Text = Util.TrimDecimals(speedSession.ToString(), prefsDigitsNumber);
event_execute_label_run_simple_speed_person.Text = Util.TrimDecimals(speedPerson.ToString(), preferences.digitsNumber);
event_execute_label_run_simple_speed_session.Text = Util.TrimDecimals(speedSession.ToString(), preferences.digitsNumber);
}
private void printLabelsReactionTime (double timeNow, double timePerson, double timeSession) {
event_execute_label_reaction_time_now.Text = "<b>" + Util.TrimDecimals(timeNow.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_reaction_time_now.Text = "<b>" + Util.TrimDecimals(timeNow.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_reaction_time_now.UseMarkup = true;
event_execute_label_reaction_time_person.Text = Util.TrimDecimals(timePerson.ToString(), prefsDigitsNumber);
event_execute_label_reaction_time_session.Text = Util.TrimDecimals(timeSession.ToString(), prefsDigitsNumber);
event_execute_label_reaction_time_person.Text = Util.TrimDecimals(timePerson.ToString(), preferences.digitsNumber);
event_execute_label_reaction_time_session.Text = Util.TrimDecimals(timeSession.ToString(), preferences.digitsNumber);
}
//used on simple tests
......@@ -1374,22 +1374,22 @@ Log.WriteLine("Preparing reactive A");
* these Log.writeLines are useful to don't "get the thread dead"
* without them , sometimes drawingarea is not painted
*/
event_execute_label_jump_reactive_tc_now.Text = "<b>" + Util.TrimDecimals(lastTc.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_jump_reactive_tc_now.Text = "<b>" + Util.TrimDecimals(lastTc.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_jump_reactive_tc_now.UseMarkup = true;
event_execute_label_jump_reactive_tc_avg.Text = Util.TrimDecimals(avgTC.ToString(), prefsDigitsNumber);
event_execute_label_jump_reactive_tc_avg.Text = Util.TrimDecimals(avgTC.ToString(), preferences.digitsNumber);
event_execute_label_jump_reactive_tf_now.Text = "<b>" + Util.TrimDecimals(lastTv.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_jump_reactive_tf_now.Text = "<b>" + Util.TrimDecimals(lastTv.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_jump_reactive_tf_now.UseMarkup = true;
event_execute_label_jump_reactive_tf_avg.Text = Util.TrimDecimals(avgTV.ToString(), prefsDigitsNumber);
event_execute_label_jump_reactive_tf_avg.Text = Util.TrimDecimals(avgTV.ToString(), preferences.digitsNumber);
if(lastTc > 0) {
event_execute_label_jump_reactive_tf_tc_now.Text = "<b>" + Util.TrimDecimals((lastTv/lastTc).ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_jump_reactive_tf_tc_now.Text = "<b>" + Util.TrimDecimals((lastTv/lastTc).ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_jump_reactive_tf_tc_now.UseMarkup = true;
} else
event_execute_label_jump_reactive_tf_tc_now.Text = "0";
if(avgTC > 0)
event_execute_label_jump_reactive_tf_tc_avg.Text = Util.TrimDecimals((avgTV/avgTC).ToString(), prefsDigitsNumber);
event_execute_label_jump_reactive_tf_tc_avg.Text = Util.TrimDecimals((avgTV/avgTC).ToString(), preferences.digitsNumber);
else
event_execute_label_jump_reactive_tf_tc_avg.Text = "0";
}
......@@ -1501,15 +1501,15 @@ Log.WriteLine("Preparing reactive A");
plotSimulatedMessageIfNeededAtCenter(ancho, alto);
}
event_execute_label_run_interval_time_now.Text = "<b>" + Util.TrimDecimals(lastTime.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_run_interval_time_now.Text = "<b>" + Util.TrimDecimals(lastTime.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_run_interval_time_now.UseMarkup = true;
event_execute_label_run_interval_time_avg.Text = Util.TrimDecimals(avgTime.ToString(), prefsDigitsNumber);
event_execute_label_run_interval_time_avg.Text = Util.TrimDecimals(avgTime.ToString(), preferences.digitsNumber);
event_execute_label_run_interval_speed_now.Text = "<b>" + Util.TrimDecimals((distance / lastTime).ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_run_interval_speed_now.Text = "<b>" + Util.TrimDecimals((distance / lastTime).ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_run_interval_speed_now.UseMarkup = true;
event_execute_label_run_interval_speed_avg.Text = Util.TrimDecimals((distanceTotal / Util.GetTotalTime(timesString)).ToString(), prefsDigitsNumber);
event_execute_label_run_interval_speed_avg.Text = Util.TrimDecimals((distanceTotal / Util.GetTotalTime(timesString)).ToString(), preferences.digitsNumber);
}
private void paintPulse (Gtk.DrawingArea drawingarea, double lastTime, string timesString, double avgTime, int pulses,
......@@ -1564,10 +1564,10 @@ Log.WriteLine("Preparing reactive A");
plotSimulatedMessageIfNeededAtCenter(ancho, alto);
}
event_execute_label_pulse_now.Text = "<b>" + Util.TrimDecimals(lastTime.ToString(), prefsDigitsNumber) + "</b>";
event_execute_label_pulse_now.Text = "<b>" + Util.TrimDecimals(lastTime.ToString(), preferences.digitsNumber) + "</b>";
event_execute_label_pulse_now.UseMarkup = true;
event_execute_label_pulse_avg.Text = Util.TrimDecimals(avgTime.ToString(), prefsDigitsNumber);
event_execute_label_pulse_avg.Text = Util.TrimDecimals(avgTime.ToString(), preferences.digitsNumber);
}
double multiChronopicGetX(int ancho, double time, double timeOld, double timeTotal) {
......@@ -1842,14 +1842,14 @@ Log.WriteLine("Preparing reactive A");
currentEventExecute.PrepareEventGraphJumpReactiveObject.lastTc,
currentEventExecute.PrepareEventGraphJumpReactiveObject.tvString,
currentEventExecute.PrepareEventGraphJumpReactiveObject.tcString,
volumeOn, repetitiveConditionsWin);
preferences.volumeOn, repetitiveConditionsWin);
}
break;
case EventType.Types.RUN:
if(thisRunIsSimple)
PrepareRunSimpleGraph(currentEventExecute.PrepareEventGraphRunSimpleObject);
else {
bool volumeOnHere = volumeOn;
bool volumeOnHere = preferences.volumeOn;
//do not play good or bad sounds at RSA because we need to hear the GO sound
if(currentRunIntervalType.IsRSA)
volumeOnHere = false;
......@@ -1895,7 +1895,7 @@ Log.WriteLine("Preparing reactive A");
eventHasEnded = true;
checkbutton_video.Sensitive = true;
if(videoOn) {
if(preferences.videoOn) {
label_video_feedback.Text = "";
capturer.ClickStop();
videoCapturePrepare(false); //if error, show message
......@@ -2021,7 +2021,7 @@ Log.WriteLine("Preparing reactive A");
hideButtons();
checkbutton_video.Sensitive = true;
if(videoOn) {
if(preferences.videoOn) {
//it will be recorded on temp, but chronojump will move it to chronojump/multimedia folders
label_video_feedback.Text = "";
capturer.ClickStop();
......
This diff is collapsed.
......@@ -859,19 +859,19 @@ public partial class ChronoJumpWindow {
statisticApplyTo,
treeview_stats,
sendSelectedSessions,
prefsDigitsNumber,
preferences.digitsNumber,
checkbutton_stats_sex.Active,
statsJumpsType,
limit,
heightPreferred,
weightPercentPreferred,
preferences.heightPreferred,
preferences.weightStatsPercent,
markedRows,
evolution_mark_consecutives,
graphROptions,
graph,
toReport, //always false in this class
RGraphsTranslate,
useHeightsOnJumpIndexes
preferences.RGraphsTranslate,
preferences.useHeightsOnJumpIndexes
);
//if we just made a graph, store is not made,
......
/*
* This file is part of ChronoJump
*
* ChronoJump is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ChronoJump is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Copyright (C) 2004-2014 Xavier de Blas <xaviblas@gmail.com>
*/
using System;
using System.Data;
public class Preferences
{
/*
* these are sent to preferences window
*/
public int digitsNumber;
public bool showHeight;
public bool showPower;
public bool showInitialSpeed;
public bool showAngle;
public bool showQIndex;
public bool showDjIndex;
public bool askDeletion;
public bool weightStatsPercent; //AKA weightPercentPreferred
public bool heightPreferred;
public bool metersSecondsPreferred;
public bool encoderPropulsive;
public double encoderSmoothCon;
public int videoDeviceNum; //AKA videoDevice
public Constants.Encoder1RMMethod encoder1RMMethod;
public string CSVExportDecimalSeparator;
public bool RGraphsTranslate;
public bool useHeightsOnJumpIndexes;
public Constants.EncoderAutoSaveCurve encoderAutoSaveCurve;
/*
* these are NOT sent to preferences window
*/
public bool allowFinishRjAfterTime;
public bool volumeOn;
public bool videoOn;
public int evaluatorServerID;
public string versionAvailable;
public bool runSpeedStartArrival;
public bool runISpeedStartArrival;
public string machineID;
public Constants.MultimediaStorage multimediaStorage;
public string databaseVersion;
/*
* these are unused on SqlitePreferences.SelectAll
*/
//public string chronopicPort;
//public bool simulated;
//public string language;
//public double encoderSmoothEccCon; //unused
//public double inertialmomentum; //unused
public Preferences() {
}
public static Preferences LoadAllFromSqlite() {
return SqlitePreferences.SelectAll();
}
/*
public Preferences(
string databaseVersion, string chronopicPort, int digitsNumber,
bool showHeight, bool showPower, bool showInitialSpeed, bool showAngle,
bool showQIndex, bool showDjIndex,
bool simulated bool weightStatsPercent, bool askDeletion,
bool heightPreferred, bool metersSecondsPreferred,
string language, bool allowFinishRjAfterTime,
bool volumeOn, bool videoOn, bool evaluatorServerID,
string versionAvailable, bool runSpeedStartArrival, bool runISpeedStartArrival,
string machineID, Constants.MultimediaStorage multimediaStorage,
bool encoderPropulsive, double encoderSmoothCon,
int videoDeviceNum, Constants.Encoder1RMMethod encoder1RMMethod,
string CSVExportDecimalSeparator, bool RGraphsTranslate,
bool useHeightsOnJumpIndexes, Constants.EncoderAutoSaveCurve encoderAutoSaveCurve
)
{
this.databaseVersion = databaseVersion;
this.chronopicPort = chronopicPort;
this.digitsNumber = digitsNumber;
this.showHeight = showHeight;
this.showPower = showPower;
this.showInitialSpeed = showInitialSpeed;
this.showAngle = showAngle;
this.showQIndex = showQIndex;
this.showDjIndex = showDjIndex;
this.simulated = simulated;
this.weightStatsPercent =
this.askDeletion = askDeletion;
this.heightPreferred = heightPreferred;
this.metersSecondsPreferred = metersSeconsPreferred;
this.language = language;
this.allowFinishRjAfterTime = allowFinishRjAfterTime;
this.volumeOn = volumeOn;
this.videoOn = videoOn;
this.evaluatorServerID = evaluatorServerID;
this.versionAvailable = versionAvailable;
this.runSpeedStartArrival = runSpeedStartArrival;
this.runISpeedStartArrival = runISpeedStartArrival;
this.machineID = machineID;
this.multimediaStorage = multimediaStorage;
this.encoderPropulsive = encoderPropulsive;
this.encoderSmoothCon = encoderSmoothCon;
this.videoDeviceNum = videoDeviceNum;
this.encoder1RMMethod = encoder1RMMethod;
this.CSVExportDecimalSeparator = CSVExportDecimalSeparator;
this.RGraphsTranslate = RGraphsTranslate;
this.useHeightsOnJumpIndexes = useHeightsOnJumpIndexes;
this.encoderAutoSaveCurve = encoderAutoSaveCurve;
}
*/
~Preferences() {}
}
......@@ -130,5 +130,90 @@ class SqlitePreferences : Sqlite
return myReturn;
}
public static Preferences SelectAll ()
{
dbcon.Open();
dbcmd.CommandText = "SELECT * FROM " + Constants.PreferencesTable;
Log.WriteLine(dbcmd.CommandText.ToString());
dbcmd.ExecuteNonQuery();
SqliteDataReader reader;
reader = dbcmd.ExecuteReader();
Preferences preferences = new Preferences();
while(reader.Read()) {
//these are sent to preferences window
if(reader[0].ToString() == "digitsNumber")
preferences.digitsNumber = Convert.ToInt32(reader[1].ToString());
else if(reader[0].ToString() == "showHeight")
preferences.showHeight = reader[1].ToString() == "True";
else if(reader[0].ToString() == "showPower")
preferences.showPower = reader[1].ToString() == "True";
else if(reader[0].ToString() == "showInitialSpeed")
preferences.showInitialSpeed = reader[1].ToString() == "True";
else if(reader[0].ToString() == "showAngle")
preferences.showAngle = reader[1].ToString() == "True";
else if(reader[0].ToString() == "showQIndex")
preferences.showQIndex = reader[1].ToString() == "True";
else if(reader[0].ToString() == "showDjIndex")
preferences.showDjIndex = reader[1].ToString() == "True";
else if(reader[0].ToString() == "askDeletion")
preferences.askDeletion = reader[1].ToString() == "True";
else if(reader[0].ToString() == "weightStatsPercent")
preferences.weightStatsPercent = reader[1].ToString() == "True";
else if(reader[0].ToString() == "heightPreferred")
preferences.heightPreferred = reader[1].ToString() == "True";
else if(reader[0].ToString() == "metersSecondsPreferred")
preferences.metersSecondsPreferred = reader[1].ToString() == "True";
else if(reader[0].ToString() == "encoderPropulsive")
preferences.encoderPropulsive = reader[1].ToString() == "True";
else if(reader[0].ToString() == "encoderSmoothCon")
preferences.encoderSmoothCon = Convert.ToDouble(
Util.ChangeDecimalSeparator(reader[1].ToString()));
else if(reader[0].ToString() == "videoDevice")
preferences.videoDeviceNum = Convert.ToInt32(reader[1].ToString());
else if(reader[0].ToString() == "CSVExportDecimalSeparator")
preferences.CSVExportDecimalSeparator = reader[1].ToString();
else if(reader[0].ToString() == "RGraphsTranslate")
preferences.RGraphsTranslate = reader[1].ToString() == "True";
else if(reader[0].ToString() == "useHeightsOnJumpIndexes")
preferences.useHeightsOnJumpIndexes = reader[1].ToString() == "True";
else if(reader[0].ToString() == "encoderAutoSaveCurve")
preferences.encoderAutoSaveCurve = (Constants.EncoderAutoSaveCurve)
Enum.Parse(typeof(Constants.EncoderAutoSaveCurve), reader[1].ToString());
else if(reader[0].ToString() == "encoder1RMMethod")
preferences.encoder1RMMethod = (Constants.Encoder1RMMethod)
Enum.Parse(typeof(Constants.Encoder1RMMethod), reader[1].ToString());
//these are NOT sent to preferences window
else if(reader[0].ToString() == "allowFinishRjAfterTime")
preferences.allowFinishRjAfterTime = reader[1].ToString() == "True";
else if(reader[0].ToString() == "volumeOn")
preferences.volumeOn = reader[1].ToString() == "True";
else if(reader[0].ToString() == "videoOn")
preferences.videoOn = reader[1].ToString() == "True";
else if(reader[0].ToString() == "evaluatorServerID")
preferences.evaluatorServerID = Convert.ToInt32(reader[1].ToString());
else if(reader[0].ToString() == "versionAvailable")
preferences.versionAvailable = reader[1].ToString();
else if(reader[0].ToString() == "runSpeedStartArrival")
preferences.runSpeedStartArrival = reader[1].ToString() == "True";
else if(reader[0].ToString() == "runISpeedStartArrival")
preferences.runISpeedStartArrival = reader[1].ToString() == "True";
else if(reader[0].ToString() == "machineID")
preferences.machineID = reader[1].ToString();
else if(reader[0].ToString() == "multimediaStorage")
preferences.multimediaStorage = (Constants.MultimediaStorage)
Enum.Parse(typeof(Constants.MultimediaStorage), reader[1].ToString());
else if(reader[0].ToString() == "databaseVersion")