diff --git a/Views/MainWindow.xaml.cs b/Views/MainWindow.xaml.cs index bc28e34..be60ede 100644 --- a/Views/MainWindow.xaml.cs +++ b/Views/MainWindow.xaml.cs @@ -51,7 +51,6 @@ namespace unison public async void ConnectToMPD() { - Trace.WriteLine("Trying to connect..."); _connected = await _mpd.MpdCommandConnectionStart(_mpdHost, _mpdPort, _mpdPassword); if (_connected) { @@ -212,17 +211,11 @@ namespace unison public void Settings_Clicked(object sender, RoutedEventArgs e) { + SettingsWindow.Show(); + SettingsWindow.Activate(); + if (SettingsWindow.WindowState == WindowState.Minimized) - { SettingsWindow.WindowState = WindowState.Normal; - SettingsWindow.Show(); - SettingsWindow.Activate(); - } - else - { - SettingsWindow.Hide(); - SettingsWindow.WindowState = WindowState.Minimized; - } } private void Window_Closing(object sender, CancelEventArgs e) diff --git a/Views/Settings.xaml.cs b/Views/Settings.xaml.cs index 5777c29..221b680 100644 --- a/Views/Settings.xaml.cs +++ b/Views/Settings.xaml.cs @@ -5,6 +5,7 @@ using System.Reflection; using System.Text.RegularExpressions; using System.Windows; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Navigation; namespace unison @@ -36,6 +37,7 @@ namespace unison public Settings() { + InitHwnd(); InitializeComponent(); DataContext = this; @@ -84,5 +86,11 @@ namespace unison WindowState = WindowState.Minimized; Hide(); } + + public void InitHwnd() + { + WindowInteropHelper helper = new(this); + helper.EnsureHandle(); + } } } \ No newline at end of file