Index: src/DeltaShell/DeltaShell.Gui/Forms/OptionsDialog/GeneralOptionsControl.cs =================================================================== diff -u -r8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9 -r5fc71a385897af92ccb092f2f969b5709afab85a --- src/DeltaShell/DeltaShell.Gui/Forms/OptionsDialog/GeneralOptionsControl.cs (.../GeneralOptionsControl.cs) (revision 8f6ae890fed8e8eae3a32f9c0498a10f82e0ddf9) +++ src/DeltaShell/DeltaShell.Gui/Forms/OptionsDialog/GeneralOptionsControl.cs (.../GeneralOptionsControl.cs) (revision 5fc71a385897af92ccb092f2f969b5709afab85a) @@ -12,20 +12,70 @@ { private ApplicationSettingsBase userSettings; + private bool initializingControls; + public GeneralOptionsControl() { InitializeComponent(); } public ApplicationSettingsBase UserSettings { - get { return userSettings; } - set - { + get + { + return userSettings; + } + set + { UpdateUserSettings(value); } } + public string ColorTheme + { + get + { + return (string) comboBoxTheme.SelectedItem; + } + set + { + comboBoxTheme.SelectedItem = value; + } + } + + // TODO: Call this method + public Action OnAcceptChanges { get; set; } + + public string Title + { + get + { + return Resources.GeneralOptionsControl_Title_General; + } + } + + public string Category + { + get + { + return Resources.GeneralOptionsControl_Title_General; + } + } + + public void AcceptChanges() + { + SetValuesToSettings(); + if (OnAcceptChanges != null) + { + OnAcceptChanges(this); + } + } + + public void DeclineChanges() + { + SetSettingsValuesToControls(); + } + /// /// Safe call because of linkdemand /// @@ -42,24 +92,24 @@ /// private void SetSettingsValuesToControls() { - checkBoxStartPage.Checked = (bool)userSettings["showStartPage"]; + checkBoxStartPage.Checked = (bool) userSettings["showStartPage"]; - SetSettingsToNumberFormatControls((string)userSettings["realNumberFormat"]); + SetSettingsToNumberFormatControls((string) userSettings["realNumberFormat"]); } /// /// Ok clicked. /// private void SetValuesToSettings() { - if ((bool)userSettings["showStartPage"] != checkBoxStartPage.Checked) + if ((bool) userSettings["showStartPage"] != checkBoxStartPage.Checked) { userSettings["showStartPage"] = checkBoxStartPage.Checked; } string newRealNumberFormat = GetRealNumberFormatFromControls(); - if ((string)userSettings["realNumberFormat"] != newRealNumberFormat) + if ((string) userSettings["realNumberFormat"] != newRealNumberFormat) { userSettings["realNumberFormat"] = newRealNumberFormat; RegionalSettingsManager.RealNumberFormat = newRealNumberFormat; @@ -69,27 +119,31 @@ private string GetRealNumberFormatFromControls() { string format = ""; - var numDecimals = (int)upDownNumberOfDecimals.Value; + var numDecimals = (int) upDownNumberOfDecimals.Value; if (radioButtonCompactNotation.Checked) + { format = "G"; + } else if (radioButtonNumberNotation.Checked) + { format = "N"; + } else if (radioButtonScientificNotation.Checked) + { format = "E"; + } else { throw new Exception(Resources.GeneralOptionsControl_GetRealNumberFormatFromControls_None_of_the_radiobuttons_is_selected__impossible); } - return format + numDecimals ; + return format + numDecimals; } - private bool initializingControls; - - void UpdateRealNumberFormattingSample() + private void UpdateRealNumberFormattingSample() { - if (initializingControls) + if (initializingControls) { return; // controls are being initializing, inconsistent state } @@ -107,15 +161,17 @@ private void SetSettingsToNumberFormatControls(string numberFormat) { if (numberFormat == null || string.IsNullOrEmpty(numberFormat)) + { numberFormat = "G5"; //set default + } initializingControls = true; int decimals = 5; //default Int32.TryParse(numberFormat.Substring(1), out decimals); upDownNumberOfDecimals.Value = decimals; - switch(numberFormat[0]) + switch (numberFormat[0]) { case 'G': radioButtonCompactNotation.Checked = true; @@ -155,42 +211,6 @@ UpdateRealNumberFormattingSample(); } - private void comboBoxTheme_SelectedIndexChanged(object sender, EventArgs e) - { - - } - - public string ColorTheme - { - get { return (string) comboBoxTheme.SelectedItem; } - set { comboBoxTheme.SelectedItem = value; } - } - - // TODO: Call this method - public Action OnAcceptChanges { get; set; } - - public string Title - { - get { return Resources.GeneralOptionsControl_Title_General; } - } - - public string Category - { - get { return Resources.GeneralOptionsControl_Title_General; } - } - - public void AcceptChanges() - { - SetValuesToSettings(); - if (OnAcceptChanges != null) - { - OnAcceptChanges(this); - } - } - - public void DeclineChanges() - { - SetSettingsValuesToControls(); - } + private void comboBoxTheme_SelectedIndexChanged(object sender, EventArgs e) {} } } \ No newline at end of file