mirror of
https://github.com/chylex/Backup-Essentials.git
synced 2025-08-10 06:40:41 +02:00
Added a page switch handler
This commit is contained in:
parent
ac17dbe561
commit
25b4fcf670
BackupEssentials
@ -27,13 +27,18 @@ namespace BackupEssentials{
|
||||
InitializeComponent();
|
||||
Instance = this;
|
||||
|
||||
Loaded += (args, sender) => {
|
||||
Loaded += (sender, args) => {
|
||||
Dispatcher.BeginInvoke(DispatcherPriority.Loaded,new Action(() => {
|
||||
DataStorage.Load();
|
||||
}));
|
||||
};
|
||||
|
||||
Closed += (args, sender) => {
|
||||
Closing += (sender, args) => {
|
||||
IPageSwitchHandler switchHandler = ContentFrame.Content as IPageSwitchHandler;
|
||||
if (switchHandler != null && switchHandler.OnSwitch())args.Cancel = true;
|
||||
};
|
||||
|
||||
Closed += (sender, args) => {
|
||||
DataStorage.Save(true);
|
||||
ExplorerIntegration.Refresh(true);
|
||||
};
|
||||
@ -126,6 +131,9 @@ namespace BackupEssentials{
|
||||
}
|
||||
|
||||
public void ShowPage(Type pageType, object data){
|
||||
IPageSwitchHandler switchHandler = ContentFrame.Content as IPageSwitchHandler;
|
||||
if (switchHandler != null && switchHandler.OnSwitch())return;
|
||||
|
||||
Page page = null;
|
||||
ContentFrame.Navigate(pageType == null ? null : page = AppPageManager.GetPage(pageType));
|
||||
if (ContentFrame.NavigationService.CanGoBack)ContentFrame.NavigationService.RemoveBackEntry();
|
||||
|
8
BackupEssentials/Pages/IPageSwitchHandler.cs
Normal file
8
BackupEssentials/Pages/IPageSwitchHandler.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace BackupEssentials.Pages{
|
||||
interface IPageSwitchHandler{
|
||||
/// <summary>
|
||||
/// Called when the display page is about to change, or when the window is closing. Return true to stop the switch (or closing) from happening.
|
||||
/// </summary>
|
||||
bool OnSwitch();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user