mirror of
https://github.com/microsoft/PowerToys.git
synced 2024-12-13 19:19:23 +08:00
245cffc4f7
1. remove unnecessary events from MainViewModel 2. remove usage of Obsolete api (show, hide etc) 3. fix space problem in #660 4. part of #486 5. fix up/down key bug introduced in 92b7ca6a1bafd254e39ee92812ff691906cd85c1 6. fix #678
20 lines
559 B
C#
20 lines
559 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);
|
|
Application.Current.MainWindow.Hide();
|
|
window.Show();
|
|
window.Focus();
|
|
|
|
return (T)window;
|
|
}
|
|
}
|
|
} |