2014-04-12 01:16:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
namespace Wox.Helper
|
|
|
|
|
{
|
2016-03-28 10:09:57 +08:00
|
|
|
|
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-05-25 08:00:10 +08:00
|
|
|
|
Application.Current.MainWindow.Hide();
|
2016-03-28 10:09:57 +08:00
|
|
|
|
window.Show();
|
|
|
|
|
window.Focus();
|
|
|
|
|
|
|
|
|
|
return (T)window;
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-12 01:16:59 +08:00
|
|
|
|
}
|