1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-06-06 18:34:03 +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"> <Compile Include="Pages\BackupLocations.xaml.cs">
<DependentUpon>BackupLocations.xaml</DependentUpon> <DependentUpon>BackupLocations.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Pages\BackupLocationsEdit.xaml.cs">
<DependentUpon>BackupLocationsEdit.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\IPageShowData.cs" />
<Compile Include="TestingWindow.xaml.cs"> <Compile Include="TestingWindow.xaml.cs">
<DependentUpon>TestingWindow.xaml</DependentUpon> <DependentUpon>TestingWindow.xaml</DependentUpon>
</Compile> </Compile>
@ -113,6 +117,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Pages\BackupLocationsEdit.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Simple Styles.xaml"> <Page Include="Simple Styles.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>

View File

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