整理代码

This commit is contained in:
GG Z
2026-02-20 15:31:44 +08:00
parent 94cf3f3266
commit 9f121cfc7f
149 changed files with 4063 additions and 6964 deletions

View File

@@ -1,25 +1,25 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:Melskin.Assists"
xmlns:markup="clr-namespace:Melskin.Markup"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:markup="clr-namespace:Melskin.Markup">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="RepeatButtonTransparent.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- 显示两端按钮 -->
<Storyboard x:Key="ShowScrollItem">
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetName="border"
Storyboard.TargetProperty="Opacity"
To="1" />
To="1"
Duration="0:0:0.2" />
</Storyboard>
<!-- 隐藏两端按钮 -->
<Storyboard x:Key="HideScrollItem">
<DoubleAnimationUsingKeyFrames
Duration="0:0:1.2"
Storyboard.TargetName="border"
Storyboard.TargetProperty="Opacity">
Storyboard.TargetProperty="Opacity"
Duration="0:0:1.2">
<LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="1" />
<LinearDoubleKeyFrame KeyTime="0:0:1" Value="1" />
<LinearDoubleKeyFrame KeyTime="0:0:1.2" Value="0" />
@@ -28,43 +28,43 @@
<!-- 展开滚动条 -->
<Storyboard x:Key="ExpandBar">
<ThicknessAnimation
Duration="0:0:0.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="Margin"
To="1" />
To="1"
Duration="0:0:0.2" />
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="RadiusX"
To="4" />
To="4"
Duration="0:0:0.2" />
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="RadiusY"
To="4" />
To="4"
Duration="0:0:0.2" />
</Storyboard>
<!-- 收缩垂直滚动条 -->
<Storyboard x:Key="ShrinkVerticalBar">
<ThicknessAnimationUsingKeyFrames
Duration="0:0:1.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="Margin">
Storyboard.TargetProperty="Margin"
Duration="0:0:1.2">
<LinearThicknessKeyFrame KeyTime="0:0:0.2" Value="1" />
<LinearThicknessKeyFrame KeyTime="0:0:1" Value="1" />
<LinearThicknessKeyFrame KeyTime="0:0:1.2" Value="6,1,1,1" />
</ThicknessAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Duration="0:0:1.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="RadiusX">
Storyboard.TargetProperty="RadiusX"
Duration="0:0:1.2">
<LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="4" />
<LinearDoubleKeyFrame KeyTime="0:0:1" Value="4" />
<LinearDoubleKeyFrame KeyTime="0:0:1.2" Value="1.5" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Duration="0:0:1.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="RadiusY">
Storyboard.TargetProperty="RadiusY"
Duration="0:0:1.2">
<LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="4" />
<LinearDoubleKeyFrame KeyTime="0:0:1" Value="4" />
<LinearDoubleKeyFrame KeyTime="0:0:1.2" Value="1.5" />
@@ -73,25 +73,25 @@
<!-- 收缩水平滚动条 -->
<Storyboard x:Key="ShrinkHorizontalBar">
<ThicknessAnimationUsingKeyFrames
Duration="0:0:1.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="Margin">
Storyboard.TargetProperty="Margin"
Duration="0:0:1.2">
<LinearThicknessKeyFrame KeyTime="0:0:0.2" Value="1" />
<LinearThicknessKeyFrame KeyTime="0:0:1" Value="1" />
<LinearThicknessKeyFrame KeyTime="0:0:1.2" Value="1,6,1,1" />
</ThicknessAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Duration="0:0:1.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="RadiusX">
Storyboard.TargetProperty="RadiusX"
Duration="0:0:1.2">
<LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="4" />
<LinearDoubleKeyFrame KeyTime="0:0:1" Value="4" />
<LinearDoubleKeyFrame KeyTime="0:0:1.2" Value="1.5" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
Duration="0:0:1.2"
Storyboard.TargetName="rectangle"
Storyboard.TargetProperty="RadiusY">
Storyboard.TargetProperty="RadiusY"
Duration="0:0:1.2">
<LinearDoubleKeyFrame KeyTime="0:0:0.2" Value="4" />
<LinearDoubleKeyFrame KeyTime="0:0:1" Value="4" />
<LinearDoubleKeyFrame KeyTime="0:0:1.2" Value="1.5" />
@@ -99,7 +99,7 @@
</Storyboard>
<!-- 滚动条两端按钮 -->
<Style TargetType="{x:Type RepeatButton}" x:Key="ScrollBarButtonStyle">
<Style x:Key="ScrollBarButtonStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="VerticalContentAlignment" Value="Center" />
@@ -110,20 +110,20 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border
x:Name="border"
Opacity="0"
SnapsToDevicePixels="true"
x:Name="border">
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="Icon"
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}"
x:Name="Icon" />
TextElement.Foreground="{DynamicResource TextSecondaryBrush}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter Property="TextElement.Foreground" TargetName="Icon" Value="{DynamicResource TextPrimaryBrush}" />
<Setter TargetName="Icon" Property="TextElement.Foreground" Value="{DynamicResource TextPrimaryBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter Property="Margin" TargetName="border" Value="1.5" />
<Setter TargetName="border" Property="Margin" Value="1.5" />
</Trigger>
<Trigger Property="IsEnabled" Value="True">
<!-- TODO:不知道是不是要移除原有动画,原有动画是否会被自动释放 -->
@@ -140,7 +140,7 @@
</Setter>
</Style>
<!-- 垂直滑块 -->
<Style TargetType="{x:Type Thumb}" x:Key="ScrollBarThumbVerticalStyle">
<Style x:Key="ScrollBarThumbVerticalStyle" TargetType="{x:Type Thumb}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
@@ -148,14 +148,14 @@
<ControlTemplate TargetType="{x:Type Thumb}">
<Rectangle
Fill="{DynamicResource TextSecondaryBrush}"
x:Name="rectangle"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Margin="6,1,1,1"
Fill="{DynamicResource TextSecondaryBrush}"
RadiusX="1.5"
RadiusY="1.5"
SnapsToDevicePixels="True"
Width="{TemplateBinding Width}"
x:Name="rectangle" />
SnapsToDevicePixels="True" />
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Trigger.EnterActions>
@@ -166,7 +166,7 @@
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsDragging" Value="true">
<Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource TextPrimaryBrush}" />
<Setter TargetName="rectangle" Property="Fill" Value="{DynamicResource TextPrimaryBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -174,21 +174,21 @@
</Setter>
</Style>
<!-- 水平滑块 -->
<Style TargetType="{x:Type Thumb}" x:Key="ScrollBarHorizontalThumbStyle">
<Style x:Key="ScrollBarHorizontalThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Rectangle
Fill="{DynamicResource TextSecondaryBrush}"
x:Name="rectangle"
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Margin="1,6,1,1"
Fill="{DynamicResource TextSecondaryBrush}"
RadiusX="1.5"
RadiusY="1.5"
SnapsToDevicePixels="True"
Width="{TemplateBinding Width}"
x:Name="rectangle" />
SnapsToDevicePixels="True" />
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Trigger.EnterActions>
@@ -199,7 +199,7 @@
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsDragging" Value="true">
<Setter Property="Fill" TargetName="rectangle" Value="{DynamicResource TextPrimaryBrush}" />
<Setter TargetName="rectangle" Property="Fill" Value="{DynamicResource TextPrimaryBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -207,32 +207,32 @@
</Setter>
</Style>
<ControlTemplate TargetType="{x:Type ScrollBar}" x:Key="ScrollBarVerticalTemplate">
<Grid SnapsToDevicePixels="true" x:Name="Bg">
<ControlTemplate x:Key="ScrollBarVerticalTemplate" TargetType="{x:Type ScrollBar}">
<Grid x:Name="Bg" SnapsToDevicePixels="true">
<Grid.RowDefinitions>
<RowDefinition MaxHeight="10" />
<RowDefinition Height="*" />
<RowDefinition MaxHeight="10" />
</Grid.RowDefinitions>
<Rectangle
Fill="{TemplateBinding Background}"
x:Name="border"
Grid.RowSpan="3"
Fill="{TemplateBinding Background}"
Opacity="0"
RadiusX="4"
RadiusY="4"
x:Name="border" />
RadiusY="4" />
<RepeatButton
Command="{x:Static ScrollBar.LineUpCommand}"
x:Name="PART_LineUpButton"
Grid.Row="0"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource ScrollBarButtonStyle}"
assists:ControlAssist.Icon="{markup:Icon SymbolValue=ArrowDropUp}"
x:Name="PART_LineUpButton" />
Command="{x:Static ScrollBar.LineUpCommand}"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource ScrollBarButtonStyle}" />
<Track
x:Name="PART_Track"
Grid.Row="1"
IsDirectionReversed="true"
IsEnabled="{TemplateBinding IsMouseOver}"
x:Name="PART_Track">
IsEnabled="{TemplateBinding IsMouseOver}">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static ScrollBar.PageUpCommand}" Style="{StaticResource RepeatButtonTransparentStyle}" />
</Track.DecreaseRepeatButton>
@@ -241,22 +241,22 @@
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb
x:Name="ThumbPart"
IsEnabled="False"
Style="{StaticResource ScrollBarThumbVerticalStyle}"
x:Name="ThumbPart" />
Style="{StaticResource ScrollBarThumbVerticalStyle}" />
</Track.Thumb>
</Track>
<RepeatButton
Command="{x:Static ScrollBar.LineDownCommand}"
x:Name="PART_LineDownButton"
Grid.Row="2"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource ScrollBarButtonStyle}"
assists:ControlAssist.Icon="{markup:Icon SymbolValue=ArrowDropDown}"
x:Name="PART_LineDownButton" />
Command="{x:Static ScrollBar.LineDownCommand}"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource ScrollBarButtonStyle}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="IsEnabled" TargetName="ThumbPart" Value="True" />
<Setter TargetName="ThumbPart" Property="IsEnabled" Value="True" />
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ShowScrollItem}" />
</Trigger.EnterActions>
@@ -265,37 +265,37 @@
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Visibility" TargetName="PART_LineUpButton" Value="Hidden" />
<Setter Property="Visibility" TargetName="PART_LineDownButton" Value="Hidden" />
<Setter TargetName="PART_LineUpButton" Property="Visibility" Value="Hidden" />
<Setter TargetName="PART_LineDownButton" Property="Visibility" Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<ControlTemplate TargetType="{x:Type ScrollBar}" x:Key="ScrollBarHorizontalTemplate">
<Grid SnapsToDevicePixels="true" x:Name="Bg">
<ControlTemplate x:Key="ScrollBarHorizontalTemplate" TargetType="{x:Type ScrollBar}">
<Grid x:Name="Bg" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="10" />
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="10" />
</Grid.ColumnDefinitions>
<Rectangle
Fill="{TemplateBinding Background}"
x:Name="border"
Grid.ColumnSpan="3"
Fill="{TemplateBinding Background}"
Opacity="0"
RadiusX="4"
RadiusY="4"
x:Name="border" />
RadiusY="4" />
<RepeatButton
Command="{x:Static ScrollBar.LineLeftCommand}"
x:Name="PART_LineLeftButton"
Grid.Column="0"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource ScrollBarButtonStyle}"
assists:ControlAssist.Icon="{markup:Icon SymbolValue=ArrowLeft}"
x:Name="PART_LineLeftButton" />
<Track
Grid.Column="1"
Command="{x:Static ScrollBar.LineLeftCommand}"
IsEnabled="{TemplateBinding IsMouseOver}"
x:Name="PART_Track">
Style="{StaticResource ScrollBarButtonStyle}" />
<Track
x:Name="PART_Track"
Grid.Column="1"
IsEnabled="{TemplateBinding IsMouseOver}">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static ScrollBar.PageLeftCommand}" Style="{StaticResource RepeatButtonTransparentStyle}" />
</Track.DecreaseRepeatButton>
@@ -304,22 +304,22 @@
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb
x:Name="ThumbPart"
IsEnabled="False"
Style="{StaticResource ScrollBarHorizontalThumbStyle}"
x:Name="ThumbPart" />
Style="{StaticResource ScrollBarHorizontalThumbStyle}" />
</Track.Thumb>
</Track>
<RepeatButton
Command="{x:Static ScrollBar.LineRightCommand}"
x:Name="PART_LineRightButton"
Grid.Column="2"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource ScrollBarButtonStyle}"
assists:ControlAssist.Icon="{markup:Icon SymbolValue=ArrowRight}"
x:Name="PART_LineRightButton" />
Command="{x:Static ScrollBar.LineRightCommand}"
IsEnabled="{TemplateBinding IsMouseOver}"
Style="{StaticResource ScrollBarButtonStyle}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="IsEnabled" TargetName="ThumbPart" Value="True" />
<Setter TargetName="ThumbPart" Property="IsEnabled" Value="True" />
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ShowScrollItem}" />
</Trigger.EnterActions>
@@ -328,8 +328,8 @@
</Trigger.ExitActions>
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Visibility" TargetName="PART_LineLeftButton" Value="Hidden" />
<Setter Property="Visibility" TargetName="PART_LineRightButton" Value="Hidden" />
<Setter TargetName="PART_LineLeftButton" Property="Visibility" Value="Hidden" />
<Setter TargetName="PART_LineRightButton" Property="Visibility" Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -359,7 +359,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid Background="{TemplateBinding Background}" x:Name="Grid">
<Grid x:Name="Grid" Background="{TemplateBinding Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
@@ -369,38 +369,38 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ScrollContentPresenter
x:Name="PART_ScrollContentPresenter"
Grid.Row="0"
Grid.Column="0"
Margin="{TemplateBinding Padding}"
CanContentScroll="{TemplateBinding CanContentScroll}"
CanHorizontallyScroll="False"
CanVerticallyScroll="False"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Grid.Column="0"
Grid.Row="0"
Margin="{TemplateBinding Padding}"
x:Name="PART_ScrollContentPresenter" />
ContentTemplate="{TemplateBinding ContentTemplate}" />
<ScrollBar
x:Name="PART_VerticalScrollBar"
Grid.Row="0"
Grid.Column="1"
AutomationProperties.AutomationId="VerticalScrollBar"
Cursor="Arrow"
Grid.Column="1"
Grid.Row="0"
Maximum="{TemplateBinding ScrollableHeight}"
Minimum="0"
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
ViewportSize="{TemplateBinding ViewportHeight}"
Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
x:Name="PART_VerticalScrollBar" />
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
<ScrollBar
x:Name="PART_HorizontalScrollBar"
Grid.Row="1"
Grid.Column="0"
AutomationProperties.AutomationId="HorizontalScrollBar"
Cursor="Arrow"
Grid.Column="0"
Grid.Row="1"
Maximum="{TemplateBinding ScrollableWidth}"
Minimum="0"
Orientation="Horizontal"
Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
ViewportSize="{TemplateBinding ViewportWidth}"
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
x:Name="PART_HorizontalScrollBar" />
Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" />
</Grid>
</ControlTemplate>
</Setter.Value>