diff --git a/src/Carnac/CarnacTrayIcon.cs b/src/Carnac/CarnacTrayIcon.cs index 4dcfa5dc..cf776940 100644 --- a/src/Carnac/CarnacTrayIcon.cs +++ b/src/Carnac/CarnacTrayIcon.cs @@ -2,6 +2,8 @@ using System.Drawing; using System.Reflection; using System.Windows.Forms; +using System.Linq; +using System.Windows; using Application = System.Windows.Application; namespace Carnac @@ -39,7 +41,17 @@ public CarnacTrayIcon() void NotifyIconClick(object sender, MouseEventArgs mouseEventArgs) { if (mouseEventArgs.Button == MouseButtons.Left) - OpenPreferences(); + { + var preferencesWindow = Application.Current.Windows.Cast().FirstOrDefault(x => x.Name == "PreferencesViewWindow"); + if (preferencesWindow != null) + { + preferencesWindow.Activate(); + } + else + { + OpenPreferences(); + } + } } public void Dispose() diff --git a/src/Carnac/UI/PreferencesView.xaml b/src/Carnac/UI/PreferencesView.xaml index 2c303198..bcbcecac 100644 --- a/src/Carnac/UI/PreferencesView.xaml +++ b/src/Carnac/UI/PreferencesView.xaml @@ -11,7 +11,8 @@ Foreground="{DynamicResource BlackBrush}" d:DataContext="{d:DesignInstance ui:PreferencesViewModel}" mc:Ignorable="d" ShowTitleBar="False" ShowMinButton="False" ShowMaxRestoreButton="False" - SaveWindowPosition="True" utilities:DesignTimeHelper.Background="Black"> + SaveWindowPosition="True" utilities:DesignTimeHelper.Background="Black" + Name="PreferencesViewWindow">