ComboGetActivePos() public static method

public static ComboGetActivePos ( ComboBox myCombo ) : int
myCombo ComboBox
return int
Ejemplo n.º 1
0
    private void on_button_add_exercise_clicked(object o, EventArgs args)
    {
        int treeviewNum;

        if (o == (object)button_add1)
        {
            treeviewNum = 1;
        }
        else if (o == (object)button_add2)
        {
            treeviewNum = 2;
        }
        else
        {
            treeviewNum = 3;
        }

        int selectedPos = UtilGtk.ComboGetActivePos(combo_select);

        on_button_add_exercise_do(selectedPos, treeviewNum);
    }
Ejemplo n.º 2
0
    //change stuff in Sqlite and in preferences object that will be retrieved by GetPreferences
    void on_button_accept_clicked(object o, EventArgs args)
    {
        Sqlite.Open();

        if (preferences.digitsNumber != Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals)))
        {
            SqlitePreferences.Update("digitsNumber", UtilGtk.ComboGetActive(combo_decimals), true);
            preferences.digitsNumber = Convert.ToInt32(UtilGtk.ComboGetActive(combo_decimals));
        }

        if (preferences.showPower != PreferencesWindowBox.checkbutton_power.Active)
        {
            SqlitePreferences.Update("showPower", PreferencesWindowBox.checkbutton_power.Active.ToString(), true);
            preferences.showPower = PreferencesWindowBox.checkbutton_power.Active;
        }

        if (preferences.showStiffness != PreferencesWindowBox.checkbutton_stiffness.Active)
        {
            SqlitePreferences.Update("showStiffness", PreferencesWindowBox.checkbutton_stiffness.Active.ToString(), true);
            preferences.showStiffness = PreferencesWindowBox.checkbutton_stiffness.Active;
        }

        if (preferences.showInitialSpeed != PreferencesWindowBox.checkbutton_initial_speed.Active)
        {
            SqlitePreferences.Update("showInitialSpeed", PreferencesWindowBox.checkbutton_initial_speed.Active.ToString(), true);
            preferences.showInitialSpeed = PreferencesWindowBox.checkbutton_initial_speed.Active;
        }

        if (preferences.showAngle != PreferencesWindowBox.checkbutton_angle.Active)
        {
            SqlitePreferences.Update("showAngle", PreferencesWindowBox.checkbutton_angle.Active.ToString(), true);
            preferences.showAngle = PreferencesWindowBox.checkbutton_angle.Active;
        }

        if (PreferencesWindowBox.checkbutton_show_tv_tc_index.Active)
        {
            SqlitePreferences.Update("showQIndex", PreferencesWindowBox.radiobutton_show_q_index.Active.ToString(), true);
            SqlitePreferences.Update("showDjIndex", PreferencesWindowBox.radiobutton_show_dj_index.Active.ToString(), true);
            preferences.showQIndex  = PreferencesWindowBox.radiobutton_show_q_index.Active;
            preferences.showDjIndex = PreferencesWindowBox.radiobutton_show_dj_index.Active;
        }
        else
        {
            SqlitePreferences.Update("showQIndex", "False", true);
            SqlitePreferences.Update("showDjIndex", "False", true);
            preferences.showQIndex  = false;
            preferences.showDjIndex = false;
        }


        if (preferences.askDeletion != PreferencesWindowBox.checkbutton_ask_deletion.Active)
        {
            SqlitePreferences.Update("askDeletion", PreferencesWindowBox.checkbutton_ask_deletion.Active.ToString(), true);
            preferences.askDeletion = PreferencesWindowBox.checkbutton_ask_deletion.Active;
        }

        if (preferences.weightStatsPercent != PreferencesWindowBox.radio_weight_percent.Active)
        {
            SqlitePreferences.Update("weightStatsPercent", PreferencesWindowBox.radio_weight_percent.Active.ToString(), true);
            preferences.weightStatsPercent = PreferencesWindowBox.radio_weight_percent.Active;
        }

        if (preferences.heightPreferred != PreferencesWindowBox.radio_elevation_height.Active)
        {
            SqlitePreferences.Update("heightPreferred", PreferencesWindowBox.radio_elevation_height.Active.ToString(), true);
            preferences.heightPreferred = PreferencesWindowBox.radio_elevation_height.Active;
        }

        if (preferences.metersSecondsPreferred != PreferencesWindowBox.radio_speed_ms.Active)
        {
            SqlitePreferences.Update("metersSecondsPreferred", PreferencesWindowBox.radio_speed_ms.Active.ToString(), true);
            preferences.metersSecondsPreferred = PreferencesWindowBox.radio_speed_ms.Active;
        }

        if (preferences.runSpeedStartArrival != PreferencesWindowBox.radio_runs_speed_start_arrival.Active)
        {
            SqlitePreferences.Update("runSpeedStartArrival", PreferencesWindowBox.radio_runs_speed_start_arrival.Active.ToString(), true);
            preferences.runSpeedStartArrival = PreferencesWindowBox.radio_runs_speed_start_arrival.Active;
        }

        //start of double contacts stuff ----

        //1 simple runs ----

        //1.1 was FIRST or AVERAGE or LAST and now will be NONE
        if ((preferences.runDoubleContactsMode != Constants.DoubleContact.NONE) &&
            !PreferencesWindowBox.checkbutton_runs_prevent_double_contact.Active)
        {
            SqlitePreferences.Update("runDoubleContactsMode", Constants.DoubleContact.NONE.ToString(), true);
            preferences.runDoubleContactsMode = Constants.DoubleContact.NONE;
        }
        else if (PreferencesWindowBox.checkbutton_runs_prevent_double_contact.Active)
        {
            //1.2 mode has changed between FIRST, AVERAGE or LAST
            if (PreferencesWindowBox.radio_runs_prevent_double_contact_first.Active &&
                (preferences.runDoubleContactsMode != Constants.DoubleContact.FIRST))
            {
                SqlitePreferences.Update("runDoubleContactsMode", Constants.DoubleContact.FIRST.ToString(), true);
                preferences.runDoubleContactsMode = Constants.DoubleContact.FIRST;
            }
            else if (PreferencesWindowBox.radio_runs_prevent_double_contact_average.Active &&
                     (preferences.runDoubleContactsMode != Constants.DoubleContact.AVERAGE))
            {
                SqlitePreferences.Update("runDoubleContactsMode", Constants.DoubleContact.AVERAGE.ToString(), true);
                preferences.runDoubleContactsMode = Constants.DoubleContact.AVERAGE;
            }
            else if (PreferencesWindowBox.radio_runs_prevent_double_contact_last.Active &&
                     (preferences.runDoubleContactsMode != Constants.DoubleContact.LAST))
            {
                SqlitePreferences.Update("runDoubleContactsMode", Constants.DoubleContact.LAST.ToString(), true);
                preferences.runDoubleContactsMode = Constants.DoubleContact.LAST;
            }

            if (preferences.runDoubleContactsMS != (int)PreferencesWindowBox.spinbutton_runs_prevent_double_contact.Value)
            {
                SqlitePreferences.Update("runDoubleContactsMS",
                                         PreferencesWindowBox.spinbutton_runs_prevent_double_contact.Value.ToString(), true);        //saved as string
                preferences.runDoubleContactsMS = (int)spinbutton_runs_prevent_double_contact.Value;
            }
        }

        //2 intervallic runs ----

        //2.1 was FIRST or AVERAGE or LAST and now will be NONE
        if ((preferences.runIDoubleContactsMode != Constants.DoubleContact.NONE) &&
            !PreferencesWindowBox.checkbutton_runs_i_prevent_double_contact.Active)
        {
            SqlitePreferences.Update("runIDoubleContactsMode", Constants.DoubleContact.NONE.ToString(), true);
            preferences.runIDoubleContactsMode = Constants.DoubleContact.NONE;
        }
        else if (PreferencesWindowBox.checkbutton_runs_i_prevent_double_contact.Active)
        {
            //2.2 mode has changed between FIRST, AVERAGE or LAST
            if (PreferencesWindowBox.radio_runs_i_prevent_double_contact_first.Active &&
                (preferences.runIDoubleContactsMode != Constants.DoubleContact.FIRST))
            {
                SqlitePreferences.Update("runIDoubleContactsMode", Constants.DoubleContact.FIRST.ToString(), true);
                preferences.runIDoubleContactsMode = Constants.DoubleContact.FIRST;
            }
            else if (PreferencesWindowBox.radio_runs_i_prevent_double_contact_average.Active &&
                     (preferences.runIDoubleContactsMode != Constants.DoubleContact.AVERAGE))
            {
                SqlitePreferences.Update("runIDoubleContactsMode", Constants.DoubleContact.AVERAGE.ToString(), true);
                preferences.runIDoubleContactsMode = Constants.DoubleContact.AVERAGE;
            }
            else if (PreferencesWindowBox.radio_runs_i_prevent_double_contact_last.Active &&
                     (preferences.runIDoubleContactsMode != Constants.DoubleContact.LAST))
            {
                SqlitePreferences.Update("runIDoubleContactsMode", Constants.DoubleContact.LAST.ToString(), true);
                preferences.runIDoubleContactsMode = Constants.DoubleContact.LAST;
            }

            if (preferences.runIDoubleContactsMS != (int)PreferencesWindowBox.spinbutton_runs_i_prevent_double_contact.Value)
            {
                SqlitePreferences.Update("runIDoubleContactsMS",
                                         PreferencesWindowBox.spinbutton_runs_i_prevent_double_contact.Value.ToString(), true);        //saved as string
                preferences.runIDoubleContactsMS = (int)spinbutton_runs_i_prevent_double_contact.Value;
            }
        }

        //---- end of double contacts stuff


        if (preferences.encoderPropulsive != PreferencesWindowBox.checkbutton_encoder_propulsive.Active)
        {
            SqlitePreferences.Update("encoderPropulsive",
                                     PreferencesWindowBox.checkbutton_encoder_propulsive.Active.ToString(), true);
            preferences.encoderPropulsive = PreferencesWindowBox.checkbutton_encoder_propulsive.Active;
        }

        if (preferences.encoderSmoothCon != (double)PreferencesWindowBox.spin_encoder_smooth_con.Value)
        {
            SqlitePreferences.Update("encoderSmoothCon", Util.ConvertToPoint(
                                         (double)PreferencesWindowBox.spin_encoder_smooth_con.Value), true);
            preferences.encoderSmoothCon = (double)PreferencesWindowBox.spin_encoder_smooth_con.Value;
        }

        if (preferences.videoDeviceNum != UtilGtk.ComboGetActivePos(combo_camera))
        {
            SqlitePreferences.Update("videoDevice", UtilGtk.ComboGetActivePos(combo_camera).ToString(), true);
            preferences.videoDeviceNum = UtilGtk.ComboGetActivePos(combo_camera);
        }


        if (PreferencesWindowBox.radio_export_latin.Active)
        {
            SqlitePreferences.Update("CSVExportDecimalSeparator", "COMMA", true);
            preferences.CSVExportDecimalSeparator = "COMMA";
        }
        else
        {
            SqlitePreferences.Update("CSVExportDecimalSeparator", "POINT", true);
            preferences.CSVExportDecimalSeparator = "POINT";
        }

        string selectedLanguage = getSelectedLanguage();

        //if there was a language on SQL but now "detected" is selected, put "" in language on SQL
        if (preferences.language != "" && radio_language_detected.Active)
        {
            SqlitePreferences.Update("language", "", true);
            preferences.language = "";
        }
        //if force a language, and SQL language is != than selected language, change language on SQL
        else if (radio_language_force.Active && preferences.language != selectedLanguage)
        {
            SqlitePreferences.Update("language", selectedLanguage, true);
            preferences.language = selectedLanguage;
        }


        if (preferences.RGraphsTranslate != PreferencesWindowBox.radio_graphs_translate.Active)
        {
            SqlitePreferences.Update("RGraphsTranslate",
                                     PreferencesWindowBox.radio_graphs_translate.Active.ToString(), true);
            preferences.RGraphsTranslate = PreferencesWindowBox.radio_graphs_translate.Active;
        }

        if (preferences.useHeightsOnJumpIndexes != PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active)
        {
            SqlitePreferences.Update("useHeightsOnJumpIndexes",
                                     PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active.ToString(), true);
            preferences.useHeightsOnJumpIndexes = PreferencesWindowBox.radio_use_heights_on_jump_indexes.Active;
        }

        if (PreferencesWindowBox.radio_encoder_auto_save_curve_best.Active)
        {
            SqlitePreferences.Update("encoderAutoSaveCurve", Constants.EncoderAutoSaveCurve.BEST.ToString(), true);
            preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.BEST;
        }
        else if (PreferencesWindowBox.radio_encoder_auto_save_curve_all.Active)
        {
            SqlitePreferences.Update("encoderAutoSaveCurve", Constants.EncoderAutoSaveCurve.ALL.ToString(), true);
            preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.ALL;
        }
        else
        {
            SqlitePreferences.Update("encoderAutoSaveCurve", Constants.EncoderAutoSaveCurve.NONE.ToString(), true);
            preferences.encoderAutoSaveCurve = Constants.EncoderAutoSaveCurve.NONE;
        }

        Constants.Encoder1RMMethod encoder1RMMethod;
        if (PreferencesWindowBox.radio_encoder_1RM_nonweighted.Active)
        {
            encoder1RMMethod = Constants.Encoder1RMMethod.NONWEIGHTED;
        }
        else if (PreferencesWindowBox.radio_encoder_1RM_weighted.Active)
        {
            encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED;
        }
        else if (PreferencesWindowBox.radio_encoder_1RM_weighted2.Active)
        {
            encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED2;
        }
        else         // (PreferencesWindowBox.radio_encoder_1RM_weighted3.Active)
        {
            encoder1RMMethod = Constants.Encoder1RMMethod.WEIGHTED3;
        }

        SqlitePreferences.Update("encoder1RMMethod", encoder1RMMethod.ToString(), true);
        preferences.encoder1RMMethod = encoder1RMMethod;

        Sqlite.Close();

        PreferencesWindowBox.preferences_win.Hide();
        PreferencesWindowBox = null;
    }