mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-12 18:29:24 +08:00
commit
1d27ffbffb
22
Wox/Helper/WindowOpener.cs
Normal file
22
Wox/Helper/WindowOpener.cs
Normal file
@ -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<T>(params object[] args) where T : Window
|
||||
{
|
||||
var window = Application.Current.Windows.OfType<Window>().FirstOrDefault(x => x.GetType() == typeof(T))
|
||||
?? (T)Activator.CreateInstance(typeof(T), args);
|
||||
window.Show();
|
||||
window.Focus();
|
||||
Application.Current.MainWindow.Hide();
|
||||
|
||||
return (T)window;
|
||||
}
|
||||
}
|
||||
}
|
@ -517,7 +517,7 @@ namespace Wox
|
||||
|
||||
public void OpenSettingDialog()
|
||||
{
|
||||
new SettingWindow(this).Show();
|
||||
WindowOpener.Open<SettingWindow>(this);
|
||||
}
|
||||
|
||||
public void ShowCurrentResultItemTooltip(string text)
|
||||
|
@ -119,6 +119,7 @@
|
||||
<Compile Include="Helper\SyntaxSugars.cs" />
|
||||
<Compile Include="Helper\WallpaperPathRetrieval.cs" />
|
||||
<Compile Include="Helper\WindowIntelopHelper.cs" />
|
||||
<Compile Include="Helper\WindowOpener.cs" />
|
||||
<Compile Include="OpacityModeConverter.cs" />
|
||||
<Compile Include="CustomPluginHotkeySetting.xaml.cs">
|
||||
<DependentUpon>CustomPluginHotkeySetting.xaml</DependentUpon>
|
||||
|
Loading…
Reference in New Issue
Block a user