FModel/FModel/Utils/FWindows.cs
2020-05-14 17:12:20 +02:00

22 lines
621 B
C#

using System;
using System.Linq;
using System.Windows;
namespace FModel.Utils
{
static class FWindows
{
public static bool IsWindowOpen<T>(string name = "") where T : Window
{
return string.IsNullOrEmpty(name)
? Application.Current.Windows.OfType<T>().Any()
: Application.Current.Windows.OfType<T>().Any(w => w.Title.Equals(name));
}
public static Window GetOpenedWindow<T>(string name) where T : Window
{
return Application.Current.Windows.OfType<T>().FirstOrDefault(w => w.Title.Equals(name));
}
}
}