2014-04-12 01:16:59 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
namespace Wox.Helper
|
|
|
|
|
{
|
2015-02-21 21:57:00 +08:00
|
|
|
|
public static class SingletonWindowOpener
|
2014-04-12 01:16:59 +08:00
|
|
|
|
{
|
|
|
|
|
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);
|
2014-04-12 19:01:29 +08:00
|
|
|
|
Application.Current.MainWindow.Hide();
|
2014-04-12 01:16:59 +08:00
|
|
|
|
window.Show();
|
|
|
|
|
window.Focus();
|
|
|
|
|
|
|
|
|
|
return (T)window;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|