From 421d3eef3b72efb18f9a9ecde62bc1a2701e3deb Mon Sep 17 00:00:00 2001 From: chylex <info@chylex.com> Date: Mon, 6 Apr 2015 17:27:48 +0200 Subject: [PATCH] Moved most of the title bar into App.xml --- BackupEssentials/App.xaml | 116 +++++++++++++++++++++++++++++++ BackupEssentials/MainWindow.xaml | 107 ++-------------------------- 2 files changed, 120 insertions(+), 103 deletions(-) diff --git a/BackupEssentials/App.xaml b/BackupEssentials/App.xaml index 333a359..9c6690c 100644 --- a/BackupEssentials/App.xaml +++ b/BackupEssentials/App.xaml @@ -11,10 +11,126 @@ <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Simple Styles.xaml"/> </ResourceDictionary.MergedDictionaries> + + <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> + <sys:String x:Key="PathButtonWindowed">M2.5,3.75 L2.5,8.75 10.5,8.75 10.5,3.75 z M1.5,1.75 L11.5,1.75 11.5,9.75 1.5,9.75 z M0,0 L10,0 10,1.25 1,1.25 1,2 1,7 1,8 0,8 z</sys:String> + <sys:String x:Key="PathButtonMinimize">M0,0 L20,0 L20,3 L0,3 z</sys:String> <sys:Double x:Key="PageWidth">796</sys:Double> <sys:Double x:Key="PageHeight">482</sys:Double> <SolidColorBrush x:Key="PageBackground">#FF2E2E2E</SolidColorBrush> + + <Style x:Key="DockPanelStyleTitleBar" TargetType="{x:Type DockPanel}"> + <Setter Property="LastChildFill" Value="False"/> + <Setter Property="VerticalAlignment" Value="Top"/> + <Setter Property="Width" Value="Auto"/> + <Setter Property="Height" Value="36"/> + <Setter Property="Background"> + <Setter.Value> + <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> + <GradientStop Color="#FF171717" Offset="0"/> + <GradientStop Color="#FF1D1D1D" Offset="1"/> + </LinearGradientBrush> + </Setter.Value> + </Setter> + </Style> + + <Style x:Key="WrapPanelStyleTitleBar" TargetType="{x:Type WrapPanel}"> + <Setter Property="Height" Value="36"/> + <Setter Property="Orientation" Value="Horizontal"/> + <Setter Property="VerticalAlignment" Value="Top"/> + <Setter Property="HorizontalAlignment" Value="Right"/> + <Setter Property="FlowDirection" Value="RightToLeft"/> + </Style> + + <Style x:Key="ButtonStyleTitleBar" TargetType="{x:Type Button}"> + <Setter Property="HorizontalContentAlignment" Value="Center"/> + <Setter Property="VerticalContentAlignment" Value="Center"/> + <Setter Property="Width" Value="36"/> + <Setter Property="Height" Value="36"/> + <Setter Property="Padding" Value="3"/> + <Setter Property="RenderOptions.EdgeMode" Value="Aliased"/> + <Setter Property="Template"> + <Setter.Value> + <ControlTemplate TargetType="{x:Type Button}"> + <Grid HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="36"> + <VisualStateManager.VisualStateGroups> + <VisualStateGroup x:Name="CommonStates"> + <VisualStateGroup.Transitions> + <VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver"> + <Storyboard> + <PointAnimation Duration="0:0:0.12" To="36,0" Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(LineSegment.Point)" Storyboard.TargetName="GridHover"/> + <PointAnimation Duration="0:0:0.12" To="0,36" Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.StartPoint)" Storyboard.TargetName="GridHover"/> + <PointAnimation Duration="0:0:0.12" To="36,36" Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(LineSegment.Point)" Storyboard.TargetName="GridHover"/> + <PointAnimation Duration="0:0:0.12" To="0,0" Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[2].(LineSegment.Point)" Storyboard.TargetName="GridHover"/> + </Storyboard> + </VisualTransition> + </VisualStateGroup.Transitions> + <VisualState x:Name="Normal"/> + <VisualState x:Name="MouseOver"> + <Storyboard> + <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.StartPoint)" Storyboard.TargetName="GridHover"> + <EasingPointKeyFrame KeyTime="0" Value="0,36"/> + </PointAnimationUsingKeyFrames> + <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(LineSegment.Point)" Storyboard.TargetName="GridHover"> + <EasingPointKeyFrame KeyTime="0" Value="36,36"/> + </PointAnimationUsingKeyFrames> + <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(LineSegment.Point)" Storyboard.TargetName="GridHover"> + <EasingPointKeyFrame KeyTime="0" Value="36,0"/> + </PointAnimationUsingKeyFrames> + <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[2].(LineSegment.Point)" Storyboard.TargetName="GridHover"> + <EasingPointKeyFrame KeyTime="0" Value="0,0"/> + </PointAnimationUsingKeyFrames> + </Storyboard> + </VisualState> + <VisualState x:Name="Pressed"/> + <VisualState x:Name="Disabled"/> + </VisualStateGroup> + </VisualStateManager.VisualStateGroups> + <Rectangle x:Name="CollisionBackground" Fill="#FFFFFFFF" HorizontalAlignment="Stretch" Height="36" VerticalAlignment="Stretch" Width="36" Visibility="Visible" Opacity="0"/> + <Grid x:Name="GridDefault"> + <Rectangle x:Name="ButtonBackground" Fill="#FFC3C3C3" HorizontalAlignment="Stretch" Height="0" VerticalAlignment="Bottom" Width="36" Visibility="Visible" StrokeThickness="0"/> + <Path x:Name="ButtonForeground" Fill="#FFC3C3C3" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{Binding CXPathWidth, RelativeSource={RelativeSource TemplatedParent}}" Height="{Binding CXPathHeight, RelativeSource={RelativeSource TemplatedParent}}" Margin="{Binding CXPathMargin, RelativeSource={RelativeSource TemplatedParent}}" StrokeThickness="0" Data="{Binding CXPathData, RelativeSource={RelativeSource TemplatedParent}}" RenderTransformOrigin="0.5,0.5" Stretch="Fill"> + <Path.RenderTransform> + <TransformGroup> + <RotateTransform Angle="{Binding CXPathRotation, RelativeSource={RelativeSource TemplatedParent}}"/> + </TransformGroup> + </Path.RenderTransform> + </Path> + </Grid> + <Grid x:Name="GridHover"> + <Grid.Clip> + <PathGeometry> + <PathFigure IsClosed="True" StartPoint="0,36"> + <LineSegment Point="36,36"/> + <LineSegment Point="36,36"/> + <LineSegment Point="0,36"/> + </PathFigure> + </PathGeometry> + </Grid.Clip> + <Rectangle x:Name="ButtonBackgroundHover" HorizontalAlignment="Stretch" Height="36" VerticalAlignment="Bottom" Width="36" Visibility="Visible" StrokeThickness="0"> + <Rectangle.Fill> + <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> + <GradientStop Color="#FF2C2C2C" Offset="0"/> + <GradientStop Color="#FF252525" Offset="1"/> + </LinearGradientBrush> + </Rectangle.Fill> + </Rectangle> + <Path x:Name="ButtonForegroundHover" Fill="#FF38B6FD" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{Binding CXPathWidth, RelativeSource={RelativeSource TemplatedParent}}" Height="{Binding CXPathHeight, RelativeSource={RelativeSource TemplatedParent}}" Margin="{Binding CXPathMargin, RelativeSource={RelativeSource TemplatedParent}}" StrokeThickness="0" Data="{Binding CXPathData, RelativeSource={RelativeSource TemplatedParent}}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Stroke="{x:Null}"> + <Path.RenderTransform> + <TransformGroup> + <RotateTransform Angle="{Binding CXPathRotation, RelativeSource={RelativeSource TemplatedParent}}"/> + </TransformGroup> + </Path.RenderTransform> + </Path> + </Grid> + </Grid> + <ControlTemplate.Triggers/> + </ControlTemplate> + </Setter.Value> + </Setter> + </Style> <Storyboard x:Key="StoryboardButtonDisabled"> <ColorAnimationUsingKeyFrames Storyboard.TargetProperty="(TextElement.Foreground).(SolidColorBrush.Color)" Storyboard.TargetName="label"> diff --git a/BackupEssentials/MainWindow.xaml b/BackupEssentials/MainWindow.xaml index a017638..23cfc2c 100644 --- a/BackupEssentials/MainWindow.xaml +++ b/BackupEssentials/MainWindow.xaml @@ -9,10 +9,6 @@ mc:Ignorable="d" x:Class="BackupEssentials.MainWindow" 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> - <sys:String x:Key="PathButtonWindowed">M2.5,3.75 L2.5,8.75 10.5,8.75 10.5,3.75 z M1.5,1.75 L11.5,1.75 11.5,9.75 1.5,9.75 z M0,0 L10,0 10,1.25 1,1.25 1,2 1,7 1,8 0,8 z</sys:String> - <sys:String x:Key="PathButtonMinimize">M0,0 L20,0 L20,3 L0,3 z</sys:String> <Style TargetType="ResizeGrip"> <Setter Property="Margin" Value="2"/> </Style> @@ -23,105 +19,10 @@ <RowDefinition Height="36"/> <RowDefinition Height="*"/> </Grid.RowDefinitions> - - <DockPanel x:Name="TitleBar" LastChildFill="False" VerticalAlignment="Top" Width="Auto" Height="36" MouseLeftButtonDown="TitleBarLeftButtonDown"> - <DockPanel.Background> - <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> - <GradientStop Color="#FF171717" Offset="0"/> - <GradientStop Color="#FF1D1D1D" Offset="1"/> - </LinearGradientBrush> - </DockPanel.Background> - <WrapPanel Height="36" VerticalAlignment="Top" Width="120" Orientation="Horizontal" DockPanel.Dock="Top" HorizontalAlignment="Right" FlowDirection="RightToLeft"> - <WrapPanel.Resources> - <Style x:Key="ButtonStyleTitleBar" TargetType="{x:Type Button}"> - <Setter Property="HorizontalContentAlignment" Value="Center"/> - <Setter Property="VerticalContentAlignment" Value="Center"/> - <Setter Property="Width" Value="36"/> - <Setter Property="Height" Value="36"/> - <Setter Property="Padding" Value="3"/> - <Setter Property="RenderOptions.EdgeMode" Value="Aliased"/> - <Setter Property="Template"> - <Setter.Value> - <ControlTemplate TargetType="{x:Type Button}"> - <Grid HorizontalAlignment="Left" Height="36" VerticalAlignment="Top" Width="36"> - <VisualStateManager.VisualStateGroups> - <VisualStateGroup x:Name="CommonStates"> - <VisualStateGroup.Transitions> - <VisualTransition GeneratedDuration="0:0:0.1" To="MouseOver"> - <Storyboard> - <PointAnimation Duration="0:0:0.12" To="36,0" Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(LineSegment.Point)" Storyboard.TargetName="GridHover"/> - <PointAnimation Duration="0:0:0.12" To="0,36" Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.StartPoint)" Storyboard.TargetName="GridHover"/> - <PointAnimation Duration="0:0:0.12" To="36,36" Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(LineSegment.Point)" Storyboard.TargetName="GridHover"/> - <PointAnimation Duration="0:0:0.12" To="0,0" Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[2].(LineSegment.Point)" Storyboard.TargetName="GridHover"/> - </Storyboard> - </VisualTransition> - </VisualStateGroup.Transitions> - <VisualState x:Name="Normal"/> - <VisualState x:Name="MouseOver"> - <Storyboard> - <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.StartPoint)" Storyboard.TargetName="GridHover"> - <EasingPointKeyFrame KeyTime="0" Value="0,36"/> - </PointAnimationUsingKeyFrames> - <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[0].(LineSegment.Point)" Storyboard.TargetName="GridHover"> - <EasingPointKeyFrame KeyTime="0" Value="36,36"/> - </PointAnimationUsingKeyFrames> - <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[1].(LineSegment.Point)" Storyboard.TargetName="GridHover"> - <EasingPointKeyFrame KeyTime="0" Value="36,0"/> - </PointAnimationUsingKeyFrames> - <PointAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Clip).(PathGeometry.Figures)[0].(PathFigure.Segments)[2].(LineSegment.Point)" Storyboard.TargetName="GridHover"> - <EasingPointKeyFrame KeyTime="0" Value="0,0"/> - </PointAnimationUsingKeyFrames> - </Storyboard> - </VisualState> - <VisualState x:Name="Pressed"/> - <VisualState x:Name="Disabled"/> - </VisualStateGroup> - </VisualStateManager.VisualStateGroups> - <Rectangle x:Name="CollisionBackground" Fill="#FFFFFFFF" HorizontalAlignment="Stretch" Height="36" VerticalAlignment="Stretch" Width="36" Visibility="Visible" Opacity="0"/> - <Grid x:Name="GridDefault"> - <Rectangle x:Name="ButtonBackground" Fill="#FFC3C3C3" HorizontalAlignment="Stretch" Height="0" VerticalAlignment="Bottom" Width="36" Visibility="Visible" StrokeThickness="0"/> - <Path x:Name="ButtonForeground" Fill="#FFC3C3C3" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{Binding CXPathWidth, RelativeSource={RelativeSource TemplatedParent}}" Height="{Binding CXPathHeight, RelativeSource={RelativeSource TemplatedParent}}" Margin="{Binding CXPathMargin, RelativeSource={RelativeSource TemplatedParent}}" StrokeThickness="0" Data="{Binding CXPathData, RelativeSource={RelativeSource TemplatedParent}}" RenderTransformOrigin="0.5,0.5" Stretch="Fill"> - <Path.RenderTransform> - <TransformGroup> - <RotateTransform Angle="{Binding CXPathRotation, RelativeSource={RelativeSource TemplatedParent}}"/> - </TransformGroup> - </Path.RenderTransform> - </Path> - </Grid> - <Grid x:Name="GridHover"> - <Grid.Clip> - <PathGeometry> - <PathFigure IsClosed="True" StartPoint="0,36"> - <LineSegment Point="36,36"/> - <LineSegment Point="36,36"/> - <LineSegment Point="0,36"/> - </PathFigure> - </PathGeometry> - </Grid.Clip> - <Rectangle x:Name="ButtonBackgroundHover" HorizontalAlignment="Stretch" Height="36" VerticalAlignment="Bottom" Width="36" Visibility="Visible" StrokeThickness="0"> - <Rectangle.Fill> - <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> - <GradientStop Color="#FF2C2C2C" Offset="0"/> - <GradientStop Color="#FF252525" Offset="1"/> - </LinearGradientBrush> - </Rectangle.Fill> - </Rectangle> - <Path x:Name="ButtonForegroundHover" Fill="#FF38B6FD" HorizontalAlignment="Center" VerticalAlignment="Center" Width="{Binding CXPathWidth, RelativeSource={RelativeSource TemplatedParent}}" Height="{Binding CXPathHeight, RelativeSource={RelativeSource TemplatedParent}}" Margin="{Binding CXPathMargin, RelativeSource={RelativeSource TemplatedParent}}" StrokeThickness="0" Data="{Binding CXPathData, RelativeSource={RelativeSource TemplatedParent}}" RenderTransformOrigin="0.5,0.5" Stretch="Fill" Stroke="{x:Null}"> - <Path.RenderTransform> - <TransformGroup> - <RotateTransform Angle="{Binding CXPathRotation, RelativeSource={RelativeSource TemplatedParent}}"/> - </TransformGroup> - </Path.RenderTransform> - </Path> - </Grid> - </Grid> - <ControlTemplate.Triggers/> - </ControlTemplate> - </Setter.Value> - </Setter> - </Style> - </WrapPanel.Resources> - <custom:ButtonTitleBar x:Name="ButtonWindowClose" CXPathData="{StaticResource PathButtonClose}" CXPathWidth="16" CXPathHeight="16" CXPathMargin="0,2,0,0" CXPathRotation="-45" HorizontalContentAlignment="Center" Style="{DynamicResource ButtonStyleTitleBar}" Click="ButtonWindowCloseClick"/> + + <DockPanel x:Name="TitleBar" Style="{StaticResource DockPanelStyleTitleBar}" MouseLeftButtonDown="TitleBarLeftButtonDown"> + <WrapPanel Style="{StaticResource WrapPanelStyleTitleBar}" Width="120" DockPanel.Dock="Top"> + <custom:ButtonTitleBar x:Name="ButtonWindowClose" CXPathData="{StaticResource PathButtonClose}" CXPathWidth="16" CXPathHeight="16" CXPathMargin="0,2,0,0" CXPathRotation="-45" HorizontalContentAlignment="Center" Style="{DynamicResource ButtonStyleTitleBar}" Click="ButtonWindowCloseClick"/> <custom:ButtonTitleBar x:Name="ButtonWindowToggle" CXPathData="{StaticResource PathButtonMaximized}" CXPathWidth="14" CXPathHeight="14" CXPathMargin="0,3,0,0" HorizontalContentAlignment="Center" Style="{DynamicResource ButtonStyleTitleBar}" Click="ButtonWindowToggleClick"/> <custom:ButtonTitleBar x:Name="ButtonWindowMinimize" CXPathData="{StaticResource PathButtonMinimize}" CXPathWidth="12" CXPathHeight="2" CXPathMargin="0,12,0,0" HorizontalContentAlignment="Center" Style="{DynamicResource ButtonStyleTitleBar}" Click="ButtonWindowMinimizeClick"/> </WrapPanel>