112 lines
5.2 KiB
XML
112 lines
5.2 KiB
XML
<UserControl x:Class="Ramitta.winTitleBar"
|
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
|
xmlns:local="clr-namespace:Ramitta"
|
|
mc:Ignorable="d"
|
|
d:DesignHeight="30" d:DesignWidth="800"
|
|
x:Name="root">
|
|
|
|
<UserControl.Resources>
|
|
<!-- 自定义命令 -->
|
|
<RoutedUICommand x:Key="MinimizeCommand" Text="Minimize"/>
|
|
<RoutedUICommand x:Key="MaximizeCommand" Text="Maximize"/>
|
|
<RoutedUICommand x:Key="CloseCommand" Text="Close"/>
|
|
|
|
<Style x:Key="EllipseButtonStyle" TargetType="Button">
|
|
<Setter Property="BorderBrush" Value="#424242"/>
|
|
<Setter Property="BorderThickness" Value="2"/>
|
|
<Setter Property="Width" Value="20"/>
|
|
<Setter Property="Height" Value="20"/>
|
|
<Setter Property="Margin" Value="2,2,5,5"/>
|
|
<Setter Property="Template">
|
|
<Setter.Value>
|
|
<ControlTemplate TargetType="Button">
|
|
<Grid>
|
|
<Ellipse x:Name="ellipse"
|
|
Fill="{TemplateBinding Background}"
|
|
Stroke="{TemplateBinding BorderBrush}"
|
|
StrokeThickness="{TemplateBinding BorderThickness}"/>
|
|
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
|
|
</Grid>
|
|
<ControlTemplate.Triggers>
|
|
<Trigger Property="IsMouseOver" Value="True">
|
|
<Trigger.EnterActions>
|
|
<BeginStoryboard>
|
|
<Storyboard>
|
|
<DoubleAnimation
|
|
Storyboard.TargetName="ellipse"
|
|
Storyboard.TargetProperty="Opacity"
|
|
To="0.5"
|
|
Duration="0:0:0.2" />
|
|
</Storyboard>
|
|
</BeginStoryboard>
|
|
</Trigger.EnterActions>
|
|
<Trigger.ExitActions>
|
|
<BeginStoryboard>
|
|
<Storyboard>
|
|
<DoubleAnimation
|
|
Storyboard.TargetName="ellipse"
|
|
Storyboard.TargetProperty="Opacity"
|
|
To="1"
|
|
Duration="0:0:0.2" />
|
|
</Storyboard>
|
|
</BeginStoryboard>
|
|
</Trigger.ExitActions>
|
|
</Trigger>
|
|
</ControlTemplate.Triggers>
|
|
</ControlTemplate>
|
|
</Setter.Value>
|
|
</Setter>
|
|
</Style>
|
|
</UserControl.Resources>
|
|
|
|
<UserControl.CommandBindings>
|
|
<CommandBinding Command="{StaticResource MinimizeCommand}" Executed="MinimizeCommand_Executed"/>
|
|
<CommandBinding Command="{StaticResource MaximizeCommand}" Executed="MaximizeCommand_Executed"/>
|
|
<CommandBinding Command="{StaticResource CloseCommand}" Executed="CloseCommand_Executed"/>
|
|
</UserControl.CommandBindings>
|
|
|
|
<Grid Background="#FF1A1A1D" MouseLeftButtonDown="Grid_MouseLeftButtonDown">
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition Width="Auto"/>
|
|
<ColumnDefinition Width="*"/>
|
|
<ColumnDefinition Width="Auto"/>
|
|
</Grid.ColumnDefinitions>
|
|
|
|
<!-- 图标 -->
|
|
<Image Source="{Binding Icon, ElementName=root}"
|
|
HorizontalAlignment="Left"
|
|
VerticalAlignment="Center"
|
|
Width="20" Height="20"
|
|
Margin="2,0,0,0"/>
|
|
|
|
<!-- 标题 -->
|
|
<Label Content="{Binding Title, ElementName=root}"
|
|
VerticalContentAlignment="Center"
|
|
Grid.Column="1"
|
|
Foreground="White"/>
|
|
|
|
<!-- 窗口控制按钮 -->
|
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Grid.Column="2">
|
|
<!-- 最小化按钮 -->
|
|
<Button Command="{StaticResource MinimizeCommand}"
|
|
Background="#efb64e"
|
|
Style="{StaticResource EllipseButtonStyle}"
|
|
ToolTip="最小化"/>
|
|
|
|
<!-- 最大化按钮 -->
|
|
<Button Command="{StaticResource MaximizeCommand}"
|
|
Background="#6bc155"
|
|
Style="{StaticResource EllipseButtonStyle}"
|
|
ToolTip="最大化/还原"/>
|
|
|
|
<!-- 关闭按钮 -->
|
|
<Button Command="{StaticResource CloseCommand}"
|
|
Background="#e66c5f"
|
|
Style="{StaticResource EllipseButtonStyle}"
|
|
ToolTip="关闭"/>
|
|
</StackPanel>
|
|
</Grid>
|
|
</UserControl> |