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

Added page frame and page manager

This commit is contained in:
chylex 2015-04-03 14:20:34 +02:00
parent 6d3b333351
commit 02c3d7910f
5 changed files with 49 additions and 6 deletions

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Windows.Controls;
namespace BackupEssentials{
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;
}
}
}

View File

@ -61,10 +61,19 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="AppPageManager.cs" />
<Compile Include="Pages\About.xaml.cs">
<DependentUpon>About.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ButtonMainMenu.cs" />
<Compile Include="TestingWindow.xaml.cs">
<DependentUpon>TestingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Utils\WindowsVersion.cs" />
<Page Include="Pages\About.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
@ -111,9 +120,7 @@
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Fonts\" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Expression\Blend\.NETFramework\v4.5\Microsoft.Expression.Blend.WPF.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -4,6 +4,13 @@ using System.Windows.Controls;
namespace BackupEssentials.Controls{
public class ButtonMainMenu:Button{
public static DependencyProperty ClickPageProperty = DependencyProperty.Register("ClickPage",typeof(string),typeof(ButtonMainMenu));
public string ClickPage {
get { return (string)base.GetValue(ClickPageProperty); }
set { base.SetValue(ClickPageProperty,(string)value); }
}
private bool IsCheckedVar;
public bool IsChecked {

View File

@ -7,7 +7,7 @@
xmlns:custom="clr-namespace:BackupEssentials.Controls"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
mc:Ignorable="d" x:Class="BackupEssentials.MainWindow"
Title="Backup" Height="600" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="CanResizeWithGrip" Background="#FF000000" AllowsTransparency="True" MinWidth="540" MinHeight="240">
Title="Backup" Height="600" Width="800" WindowStartupLocation="CenterScreen" WindowStyle="None" ResizeMode="CanResizeWithGrip" Background="#FF000000" AllowsTransparency="True" MinWidth="800" MinHeight="600">
<Window.Resources>
<sys:String x:Key="PathButtonClose">M7,0 L9,0 9,7 16,7 16,9 9,9 9,16 7,16 7,9 0,9 0,7 7,7 z</sys:String>
<sys:String x:Key="PathButtonMaximized">M1,2 L1,9 13,9 13,2 z M0,0 L14,0 14,10 0,10 z</sys:String>
@ -21,7 +21,6 @@
<RowDefinition Height="60"/>
<RowDefinition Height="2"/>
<RowDefinition Height="*"/>
<RowDefinition Height="2"/>
<RowDefinition Height="16"/>
</Grid.RowDefinitions>
<DockPanel x:Name="TitleBar" LastChildFill="False" VerticalAlignment="Top" Width="Auto" Height="36" MouseLeftButtonDown="TitleBarLeftButtonDown">
@ -242,5 +241,6 @@
<custom:ButtonMainMenu Content="Settings" Click="ButtonMainMenuClick" Grid.Column="6" Style="{DynamicResource ButtonStyleMainMenu}"/>
<custom:ButtonMainMenu Content="About" Click="ButtonMainMenuClick" Grid.Column="8" Style="{DynamicResource ButtonStyleMainMenu}"/>
</Grid>
</Grid>
<Frame x:Name="ContentFrame" Content="" Margin="0" Grid.Row="4" NavigationUIVisibility="Hidden"/>
</Grid>
</Window>

View File

@ -1,5 +1,6 @@
using BackupEssentials.Controls;
using System;
using System.Reflection;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
@ -67,6 +68,9 @@ namespace BackupEssentials{
}
btn.IsChecked = true;
Type pageType = GetType().Assembly.GetType("BackupEssentials."+btn.ClickPage,false);
ContentFrame.Navigate(pageType == null ? null : AppPageManager.GetPage(pageType));
}
}
}