mirror of
https://github.com/chylex/Backup-Essentials.git
synced 2024-09-14 09:42:50 +02:00
39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
using BackupEssentials.Pages;
|
|
using BackupEssentials.Utils;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Windows.Controls;
|
|
|
|
namespace BackupEssentials{
|
|
static class AppPageManager{
|
|
private static Dictionary<Type,Page> cached = new Dictionary<Type,Page>();
|
|
|
|
public static T GetPage<T>() where T : Page, new(){
|
|
if (cached.ContainsKey(typeof(T)))return (T)cached[typeof(T)];
|
|
|
|
T page = new T();
|
|
cached[typeof(T)] = page;
|
|
return page;
|
|
}
|
|
|
|
public static Page GetPage(Type type){
|
|
if (cached.ContainsKey(type))return cached[type];
|
|
|
|
Page page = (Page)Activator.CreateInstance(type);
|
|
cached[type] = page;
|
|
return page;
|
|
}
|
|
|
|
public static void ResetUI(){
|
|
App.Current.MainWindow.UpdateBindings();
|
|
|
|
foreach(Page page in cached.Values){
|
|
page.UpdateBindings();
|
|
|
|
IPageResetUI reset = page as IPageResetUI;
|
|
if (reset != null)reset.OnReset();
|
|
}
|
|
}
|
|
}
|
|
}
|