diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 8f6f8d1..bb2ccc9 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -39,5 +39,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.2.0.2")] -[assembly: AssemblyFileVersion("1.2.0.2")] +[assembly: AssemblyVersion("1.2.0.4")] +[assembly: AssemblyFileVersion("1.2.0.4")] diff --git a/UserInterface/AppContextMenu.cs b/UserInterface/AppContextMenu.cs index 71ff59c..815bf15 100644 --- a/UserInterface/AppContextMenu.cs +++ b/UserInterface/AppContextMenu.cs @@ -28,15 +28,8 @@ namespace SystemTrayMenu.Helper ImageScaling = ToolStripItemImageScaling.SizeToFit, Text = Translator.GetText("Settings"), }; - settings.Click += Settings_Click; - static void Settings_Click(object sender, EventArgs e) - { - SettingsForm settingsForm = new(); - if (settingsForm.ShowDialog() == DialogResult.OK) - { - AppRestart.ByConfigChange(); - } - } + + settings.Click += (sender, e) => SettingsForm.ShowSingleInstance(); menu.Items.Add(settings); diff --git a/UserInterface/Menu.cs b/UserInterface/Menu.cs index 46e4083..8f36238 100644 --- a/UserInterface/Menu.cs +++ b/UserInterface/Menu.cs @@ -893,11 +893,7 @@ namespace SystemTrayMenu.UserInterface { if (e.Button == MouseButtons.Left) { - SettingsForm settingsForm = new(); - if (settingsForm.ShowDialog() == DialogResult.OK) - { - AppRestart.ByConfigChange(); - } + SettingsForm.ShowSingleInstance(); } } @@ -987,6 +983,13 @@ namespace SystemTrayMenu.UserInterface private void Menu_MouseUp(object sender, MouseEventArgs e) { mouseDown = false; + if (Properties.Settings.Default.UseCustomLocation) + { + if (!SettingsForm.IsOpen()) + { + Properties.Settings.Default.Save(); + } + } } } } \ No newline at end of file diff --git a/UserInterface/SettingsForm.cs b/UserInterface/SettingsForm.cs index bde2f48..4549a90 100644 --- a/UserInterface/SettingsForm.cs +++ b/UserInterface/SettingsForm.cs @@ -25,6 +25,7 @@ namespace SystemTrayMenu.UserInterface private const string Command = @"Software\Classes\directory\shell\SystemTrayMenu_SetAsRootFolder\command"; private static readonly Icon SystemTrayMenu = Resources.SystemTrayMenu; + private static SettingsForm settingsForm; private readonly ColorConverter colorConverter = new(); private bool inHotkey; @@ -441,6 +442,31 @@ namespace SystemTrayMenu.UserInterface textBoxColorArrowHoverBackgroundDarkMode.Text = Settings.Default.ColorArrowHoverBackgroundDarkMode; } + internal static void ShowSingleInstance() + { + if (IsOpen()) + { + settingsForm.Activate(); + } + else + { + using (settingsForm = new()) + { + if (settingsForm.ShowDialog() == DialogResult.OK) + { + AppRestart.ByConfigChange(); + } + } + + settingsForm = null; + } + } + + internal static bool IsOpen() + { + return settingsForm != null; + } + /// /// Gets NewHotKey. ///