diff --git a/Wox/Helper/WindowOpener.cs b/Wox/Helper/WindowOpener.cs new file mode 100644 index 0000000000..c7804adb55 --- /dev/null +++ b/Wox/Helper/WindowOpener.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; + +namespace Wox.Helper +{ + public static class WindowOpener + { + public static T Open(params object[] args) where T : Window + { + var window = Application.Current.Windows.OfType().FirstOrDefault(x => x.GetType() == typeof(T)) + ?? (T)Activator.CreateInstance(typeof(T), args); + window.Show(); + window.Focus(); + Application.Current.MainWindow.Hide(); + + return (T)window; + } + } +} \ No newline at end of file diff --git a/Wox/MainWindow.xaml.cs b/Wox/MainWindow.xaml.cs index 8d25b745c0..014dd8abf1 100644 --- a/Wox/MainWindow.xaml.cs +++ b/Wox/MainWindow.xaml.cs @@ -517,7 +517,7 @@ namespace Wox public void OpenSettingDialog() { - new SettingWindow(this).Show(); + WindowOpener.Open(this); } public void ShowCurrentResultItemTooltip(string text) diff --git a/Wox/Wox.csproj b/Wox/Wox.csproj index 2084efca31..f952240371 100644 --- a/Wox/Wox.csproj +++ b/Wox/Wox.csproj @@ -119,6 +119,7 @@ + CustomPluginHotkeySetting.xaml