PowerToys/Wox/Helper/SingletonWindowOpener.cs

20 lines
539 B
C#
Raw Normal View History

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);
2016-02-12 15:22:01 +08:00
App.API.HideApp();
window.Show();
window.Focus();
return (T)window;
}
}
}