diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs index 689ce5be7..58606f36f 100644 --- a/Greenshot/Forms/SettingsForm.cs +++ b/Greenshot/Forms/SettingsForm.cs @@ -44,10 +44,13 @@ namespace Greenshot { private static CoreConfiguration coreConfiguration = IniConfig.GetIniSection(); private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection(); private ToolTip toolTip = new ToolTip(); - private bool inHotkey = false; + private bool inHotkey = false; public SettingsForm() : base() { InitializeComponent(); + + // Make sure the store isn't called to early, that's why we do it manually + ManualStoreFields = true; } protected override void OnLoad(EventArgs e) { @@ -392,7 +395,10 @@ namespace Greenshot { void Settings_okayClick(object sender, System.EventArgs e) { if (CheckSettings()) { + GreenshotPlugin.Controls.HotkeyControl.UnregisterHotkeys(); SaveSettings(); + StoreFields(); + MainForm.RegisterHotkeys(); DialogResult = DialogResult.OK; } else { this.tabcontrol.SelectTab(this.tab_output); diff --git a/GreenshotPlugin/Controls/GreenshotForm.cs b/GreenshotPlugin/Controls/GreenshotForm.cs index 3a8e8a2dc..9924ff703 100644 --- a/GreenshotPlugin/Controls/GreenshotForm.cs +++ b/GreenshotPlugin/Controls/GreenshotForm.cs @@ -16,6 +16,7 @@ namespace GreenshotPlugin.Controls { private IComponentChangeService m_changeService; private bool isDesignModeLanguageSet = false; private bool applyLanguageManually = false; + private bool storeFieldsManually = false; private IDictionary designTimeControls; private IDictionary designTimeToolStripItems; @@ -34,6 +35,15 @@ namespace GreenshotPlugin.Controls { } } + protected bool ManualStoreFields { + get { + return storeFieldsManually; + } + set { + storeFieldsManually = value; + } + } + /// /// Code to initialize the language etc during design time /// @@ -101,7 +111,7 @@ namespace GreenshotPlugin.Controls { /// /// protected override void OnClosed(EventArgs e) { - if (!this.DesignMode) { + if (!this.DesignMode && !storeFieldsManually) { if (DialogResult == DialogResult.OK) { LOG.Info("Form was closed with OK: storing field values."); StoreFields(); @@ -438,6 +448,13 @@ namespace GreenshotPlugin.Controls { } TextBox textBox = controlObject as TextBox; if (textBox != null) { + HotkeyControl hotkeyControl = textBox as HotkeyControl; + if (hotkeyControl != null) { + string hotkeyString = hotkeyControl.ToString(); + iniValue.Value = hotkeyString; + iniDirty = true; + continue; + } iniValue.UseValueOrDefault(textBox.Text); iniDirty = true; continue; @@ -448,12 +465,6 @@ namespace GreenshotPlugin.Controls { iniDirty = true; continue; } - HotkeyControl hotkeyControl = controlObject as HotkeyControl; - if (hotkeyControl != null) { - iniValue.Value = hotkeyControl.ToString(); - iniDirty = true; - continue; - } } } }