mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-14 19:49:15 +08:00
b22a4501cc
1. introduce variable 2. part of #389 3. refactoring program suffix in program plugin 4. 全局变量一时爽,代码重构火葬场
20 lines
539 B
C#
20 lines
539 B
C#
using System;
|
|
using System.Linq;
|
|
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);
|
|
App.API.HideApp();
|
|
window.Show();
|
|
window.Focus();
|
|
|
|
return (T)window;
|
|
}
|
|
}
|
|
} |