mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
Use variable instead of global static method
1. introduce variable 2. part of #389 3. refactoring program suffix in program plugin 4. 全局变量一时爽,代码重构火葬场
This commit is contained in:
@@ -4,17 +4,17 @@ using System.Windows;
|
||||
|
||||
namespace Wox.Helper
|
||||
{
|
||||
public static class SingletonWindowOpener
|
||||
{
|
||||
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);
|
||||
public static class SingletonWindowOpener
|
||||
{
|
||||
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);
|
||||
App.API.HideApp();
|
||||
window.Show();
|
||||
window.Focus();
|
||||
|
||||
return (T)window;
|
||||
}
|
||||
}
|
||||
window.Show();
|
||||
window.Focus();
|
||||
|
||||
return (T)window;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user