1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-05-16 01:34:08 +02:00

Added interface for passing data to pages

This commit is contained in:
chylex 2015-04-04 21:49:40 +02:00
parent fd48fc0356
commit cb2d15bc71
3 changed files with 33 additions and 3 deletions

View File

@ -88,6 +88,10 @@
<Compile Include="Pages\BackupLocations.xaml.cs">
<DependentUpon>BackupLocations.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\BackupLocationsEdit.xaml.cs">
<DependentUpon>BackupLocationsEdit.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\IPageShowData.cs" />
<Compile Include="TestingWindow.xaml.cs">
<DependentUpon>TestingWindow.xaml</DependentUpon>
</Compile>
@ -113,6 +117,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\BackupLocationsEdit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Simple Styles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

View File

@ -1,18 +1,22 @@
using BackupEssentials.Controls;
using BackupEssentials.Pages;
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
namespace BackupEssentials{
public partial class MainWindow : Window{
public static MainWindow Instance { get; private set; }
private new Rect RestoreBounds = new Rect();
private bool IsMaximized = false;
public MainWindow(){
InitializeComponent();
Instance = this;
}
private void ButtonWindowCloseClick(object sender, RoutedEventArgs e){
@ -68,9 +72,17 @@ namespace BackupEssentials{
}
btn.IsChecked = true;
ShowPage(GetType().Assembly.GetType("BackupEssentials."+btn.ClickPage,false));
}
Type pageType = GetType().Assembly.GetType("BackupEssentials."+btn.ClickPage,false);
ContentFrame.Navigate(pageType == null ? null : AppPageManager.GetPage(pageType));
public void ShowPage(Type pageType){
ShowPage(pageType,null);
}
public void ShowPage(Type pageType, object data){
Page page = null;
ContentFrame.Navigate(pageType == null ? null : page = AppPageManager.GetPage(pageType));
if (page is IPageShowData)((IPageShowData)page).OnShow(data);
}
}
}

View File

@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BackupEssentials.Pages{
interface IPageShowData{
void OnShow(object data);
}
}