Files
HandyControl/HandyControl/Themes/Styles/Window.xaml
T
Mahdi Hosseini a301d415e2 fix CanMinimize
when we set CanMinimize, Maximize must be collapsed
2018-11-23 22:14:25 +03:30

249 lines
19 KiB
XML

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:langs="clr-namespace:HandyControl.Properties.Langs"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Button.xaml"/>
<ResourceDictionary Source="TextBlock.xaml"/>
<ResourceDictionary Source="Border.xaml"/>
<ResourceDictionary Source="ToggleButton.xaml"/>
<ResourceDictionary Source="../Basic/Converters.xaml"/>
<ResourceDictionary Source="../Basic/Paths.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="WindowDefaultStyle" BasedOn="{x:Null}" TargetType="Window">
<Setter Property="Background" Value="{DynamicResource BackgroundBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
</Style>
<Style x:Key="CustomWindowStyle" BasedOn="{x:Null}" TargetType="controls:WindowBorderless">
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource PrimaryTextBrush}"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="NonClientAreaBackground" Value="{DynamicResource TitleBrush}"/>
<Setter Property="NonClientAreaForeground" Value="White"/>
<Setter Property="CloseButtonHoverBrush" Value="Red"/>
<Setter Property="CloseButtonHoverForeground" Value="White"/>
<Setter Property="OtherButtonHoverBrush" Value="{DynamicResource DarkPrimaryBrush}"/>
<Setter Property="OtherButtonHoverForeground" Value="White"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:WindowBorderless">
<Border BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}">
<Grid Margin="{TemplateBinding Padding}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid Visibility="{TemplateBinding IsFullScreen,Converter={StaticResource Boolean2VisibilityReConverter}}" Background="{TemplateBinding NonClientAreaBackground}" Name="GridMenu" TextElement.Foreground="{TemplateBinding NonClientAreaForeground}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<StackPanel WindowChrome.IsHitTestVisibleInChrome="True" UseLayoutRounding="True" VerticalAlignment="Top" Grid.Column="1" HorizontalAlignment="Right" Orientation="Horizontal">
<Button Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MinimizeWindowCommand" IsTabStop="False" WindowChrome.IsHitTestVisibleInChrome="True" Name="ButtonMin" Height="28" Style="{StaticResource ButtonIcon}" Width="44" controls:IconElement.Geometry="{StaticResource WindowMinGeometry}" Padding="17,0"/>
<Button Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.MaximizeWindowCommand" IsTabStop="False" WindowChrome.IsHitTestVisibleInChrome="True" Name="ButtonMax" Height="28" Style="{StaticResource ButtonIcon}" Width="44" controls:IconElement.Geometry="{StaticResource WindowMaxGeometry}" Padding="17,0"/>
<Button Foreground="{TemplateBinding OtherButtonForeground}" Command="SystemCommands.RestoreWindowCommand" IsTabStop="False" WindowChrome.IsHitTestVisibleInChrome="True" Name="ButtonRestore" Height="28" Style="{StaticResource ButtonIcon}" Width="44" controls:IconElement.Geometry="{StaticResource WindowRestoreGeometry}" Padding="17,0"/>
<Button Foreground="{TemplateBinding CloseButtonForeground}" Command="SystemCommands.CloseWindowCommand" IsTabStop="False" WindowChrome.IsHitTestVisibleInChrome="True" Name="ButtonClose" Height="28" Style="{StaticResource ButtonIcon}" Width="44" controls:IconElement.Geometry="{StaticResource CloseGeometry}" Padding="9"/>
</StackPanel>
<Grid Grid.Column="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<ContentPresenter Content="{TemplateBinding Icon}" VerticalAlignment="Center"/>
<TextBlock Name="Title" Grid.Column="1" Text="{TemplateBinding Title}" Padding="10,0,0,0" VerticalAlignment="Center"/>
<ContentPresenter WindowChrome.IsHitTestVisibleInChrome="True" Grid.Column="2" x:Name="ContentPresenterMain" Content="{TemplateBinding NonClientAreaContent}"/>
</Grid>
</Grid>
<ContentPresenter Grid.Row="1" Content="{TemplateBinding Content}"/>
<ResizeGrip Width="10" Height="10" x:Name="ResizeGrip" HorizontalAlignment="Right" VerticalAlignment="Bottom" Grid.Row="1" IsTabStop="False" Visibility="Collapsed" WindowChrome.ResizeGripDirection="BottomRight" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsActive" Value="False">
<Setter Property="Opacity" Value=".8" TargetName="ContentPresenterMain"/>
</Trigger>
<Trigger Property="WindowState" Value="Maximized">
<Setter Property="Padding" Value="8"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Visible" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="WindowState" Value="Normal">
<Setter Property="Visibility" Value="Visible" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="NoResize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMin"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="ResizeMode" Value="CanMinimize">
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonMax"/>
<Setter Property="Visibility" Value="Collapsed" TargetName="ButtonRestore"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonClose">
<Setter Property="Background" TargetName="ButtonClose" Value="{Binding CloseButtonHoverBrush,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonClose" Value="{Binding CloseButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMax">
<Setter Property="Background" TargetName="ButtonMax" Value="{Binding OtherButtonHoverBrush,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMax" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonRestore">
<Setter Property="Background" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverBrush,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonRestore" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="IsMouseOver" Value="True" SourceName="ButtonMin">
<Setter Property="Background" TargetName="ButtonMin" Value="{Binding OtherButtonHoverBrush,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
<Setter Property="Foreground" TargetName="ButtonMin" Value="{Binding OtherButtonHoverForeground,RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</Trigger>
<Trigger Property="ShowNonClientArea" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="GridMenu"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="Title"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="ResizeMode" Value="CanResizeWithGrip"/>
<Condition Property="WindowState" Value="Normal" />
</MultiTrigger.Conditions>
<Setter TargetName="ResizeGrip" Property="Visibility" Value="Visible" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsFullScreen" Value="True">
<Setter Property="WindowChrome.WindowChrome">
<Setter.Value>
<WindowChrome CornerRadius="0" GlassFrameThickness="1" CaptionHeight="0"/>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="controls:PopupWindow">
<Setter Property="WindowStyle" Value="None"/>
<Setter Property="MinHeight" Value="220"/>
<Setter Property="UseLayoutRounding" Value="True"/>
<Setter Property="BorderThickness" Value="20"/>
<Setter Property="ShowInTaskbar" Value="False"/>
<Setter Property="MinWidth" Value="300"/>
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="Background" Value="{DynamicResource RegionBrush}"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect Opacity=".6" ShadowDepth="0" BlurRadius="15"/>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:PopupWindow">
<Border Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Name="TitleGrid" Height="30" Background="{DynamicResource TitleBrush}">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Name="PART_TitleBlock" Background="Transparent" Padding="10,6" Foreground="White" Text="{TemplateBinding Title}" VerticalAlignment="Center" TextWrapping="Wrap" TextTrimming="WordEllipsis"/>
<Button Margin="0,0,1,0" Background="Transparent" Name="CloseButton" Foreground="White" Grid.Column="1" controls:BackgroundSwitchElement.MouseHoverBackground="Red" controls:BackgroundSwitchElement.MouseDownBackground="Red" Command="interactivity:ControlCommands.Close" IsCancel="True" Height="28" Style="{StaticResource ButtonCustom}" Width="44" controls:IconElement.Geometry="{StaticResource CloseGeometry}" Padding="9">
<Path Fill="{Binding ElementName=CloseButton,Path=Foreground}" Style="{StaticResource ClosePathStyle}"/>
</Button>
</Grid>
<Border BorderBrush="{DynamicResource TitleBrush}" Name="PART_MainBorder" Grid.Row="1">
<StackPanel>
<TextBlock Text="{TemplateBinding ContentStr}" MinHeight="110" Name="MyTextBlock" TextAlignment="Center" Padding="32" Foreground="{DynamicResource PrimaryTextBrush}" MaxWidth="300" TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Background="{TemplateBinding Background}"/>
<StackPanel Margin="0,0,0,32" Orientation="Horizontal" Background="{DynamicResource RegionBrush}" HorizontalAlignment="Center">
<Button IsCancel="True" MinWidth="80" Command="interactivity:ControlCommands.Cancel" Content="{x:Static langs:Lang.Cancel}" Visibility="{TemplateBinding ShowCancel,Converter={StaticResource Boolean2VisibilityConverter}}" Margin="0,0,16,0"/>
<Button IsDefault="True" MinWidth="80" Command="interactivity:ControlCommands.Confirm" Content="{x:Static langs:Lang.Confirm}" Style="{StaticResource ButtonPrimary}"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="ShowBorder" Value="True">
<Setter Property="BorderThickness" Value="1,0,1,1" TargetName="PART_MainBorder"/>
</Trigger>
<Trigger Property="ShowTitle" Value="False">
<Setter Property="Visibility" Value="Collapsed" TargetName="TitleGrid"/>
<Setter Property="Background" Value="Transparent"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="controls:ImageBrowser">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="MinWidth" Value="400"/>
<Setter Property="MinHeight" Value="250"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="ResizeMode" Value="NoResize"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:ImageBrowser">
<ControlTemplate.Resources>
<Storyboard x:Key="Storyboard1">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_GridTop">
<EasingDoubleKeyFrame KeyTime="0:0:.1" Value="1"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard x:Key="Storyboard2">
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_GridTop">
<EasingDoubleKeyFrame KeyTime="0:0:.4" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</ControlTemplate.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<controls:ImageViewer x:Name="PART_ImageViewer" ShowImgMap="True" BorderThickness="0" Background="#dd000000"/>
<Grid Name="PART_GridTop" Opacity="0" Background="{DynamicResource DarkOpacityBrush}" VerticalAlignment="Top" Grid.Row="0">
<StackPanel HorizontalAlignment="Left" VerticalAlignment="Center" Orientation="Horizontal">
<TextBlock Text="{Binding ImgPath,ElementName=PART_ImageViewer}" Foreground="White" Margin="10,0,0,0"/>
<TextBlock Text="{Binding ImgSize,ElementName=PART_ImageViewer,Converter={StaticResource Long2FileSizeConverter}}" Foreground="White" Margin="30,0,0,0"/>
</StackPanel>
<Button Command="interactivity:ControlCommands.Close" WindowChrome.IsHitTestVisibleInChrome="True" Background="Red" Grid.Row="0" Padding="14" controls:IconElement.Geometry="{StaticResource DeleteGeometry}" Style="{StaticResource ButtonIcon}" HorizontalAlignment="Right" VerticalAlignment="Top" Width="40" Height="40"/>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger SourceName="PART_ImageViewer" Property="ShowCloseButton" Value="True">
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource Storyboard2}"/>
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsFullScreen" Value="True">
<Setter Property="WindowState" Value="Maximized"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>