Skip to content

Commit

Permalink
Merge pull request #146 from VisualLinux/Single-instance_Preferences
Browse files Browse the repository at this point in the history
Preferences view opens only once (Bugfix #134)
  • Loading branch information
hnrkndrssn authored May 10, 2017
2 parents 52becca + e4d9c34 commit fef48d6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion src/Carnac/CarnacTrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,7 +41,17 @@ public CarnacTrayIcon()
void NotifyIconClick(object sender, MouseEventArgs mouseEventArgs)
{
if (mouseEventArgs.Button == MouseButtons.Left)
OpenPreferences();
{
var preferencesWindow = Application.Current.Windows.Cast<Window>().FirstOrDefault(x => x.Name == "PreferencesViewWindow");
if (preferencesWindow != null)
{
preferencesWindow.Activate();
}
else
{
OpenPreferences();
}
}
}

public void Dispose()
Expand Down
3 changes: 2 additions & 1 deletion src/Carnac/UI/PreferencesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down

0 comments on commit fef48d6

Please sign in to comment.