Files
BeWoPlaner/SharedLauncher/Information/Session.cs
2021-09-30 15:31:13 +02:00

64 lines
2.1 KiB
C#

using BS.SharedLauncher.Windows;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
namespace BS.SharedLauncher.Information
{
public static class Session
{
public static DirectoryInfo DirectoryRoot { get; set; }
public static string DirectoryRootString { get; set; }
public static string Assembly2LaunchName { get; set; }
public static PropertyChangedEventHandler PropertyChanged { get; set; }
public static IMainWindow MainWindow { get; set; }
public static Application Application { get; set; }
public static Dispatcher Dispatcher { get; set; }
private static Dictionary<string, Timer> Timers { get; set; }
static Session()
{
Timers = new Dictionary<string, Timer>();
}
public static void AddTimer(string name, Timer t)
{
if (Timers.ContainsKey(name))
return;
Timers.Add(name, t);
}
public static Window GetWindow() => MainWindow as Window;
public static void ShowError(string message, Exception ex, bool showDetails)
=> MainWindow.ShowError(message, ex, showDetails);
public static void ShowError(string message, string submessage, bool showDetails)
=> MainWindow.ShowError(message, submessage, showDetails);
public static void ShowError(Exception ex)
=> MainWindow.ShowError("Exception", ex, true);
public static void ShowError(string s)
=> MainWindow.ShowError("Fehler", s, true);
public static void FirePropertyChanged(string pPropertyName)
=> PropertyChanged?.Invoke(null, new PropertyChangedEventArgs(pPropertyName));
public static object FindResource(object key)
=> Application.FindResource(key);
public static void BeginInvokeNormal(Action action)
=> Dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
}
}