diff --git a/App.xaml.cs b/App.xaml.cs index efa027c..d09da39 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -48,7 +48,6 @@ public partial class App : System.Windows.Application _server.Start(State.Settings.LocalPort); CreateTrayIcon(); - ShowMainWindow(); } public void SaveState() @@ -69,6 +68,17 @@ public partial class App : System.Windows.Application MainWindow.Activate(); } + public void ToggleMainWindow() + { + if (MainWindow?.IsVisible == true) + { + MainWindow.Hide(); + return; + } + + ShowMainWindow(); + } + private void RegisterActivationListener() { if (_activateEvent is null) @@ -96,7 +106,7 @@ public partial class App : System.Windows.Application { if (args.Button == Forms.MouseButtons.Left) { - Dispatcher.Invoke(ShowMainWindow); + Dispatcher.Invoke(ToggleMainWindow); } }; UpdateTrayMenu();