整理代码

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,13 +1,13 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:Melskin.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Melskin.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Melskin;component/Themes/Animations.xaml" />
<ResourceDictionary Source="/Melskin;component/Controls/IconElement.xaml" />
</ResourceDictionary.MergedDictionaries>
<!-- 只显示当前选项 -->
<Style TargetType="{x:Type ComboBox}" x:Key="ComboBoxPreviewStyle">
<Style x:Key="ComboBoxPreviewStyle" TargetType="{x:Type ComboBox}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
@@ -24,20 +24,20 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type ComboBox}">
<Grid
x:Name="templateRoot"
Background="{TemplateBinding Background}"
IsHitTestVisible="False"
SnapsToDevicePixels="true"
x:Name="templateRoot">
SnapsToDevicePixels="true">
<ContentPresenter
x:Name="contentPresenter"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding SelectionBoxItem}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ControlTemplate>
</Setter.Value>
@@ -45,7 +45,7 @@
</Style>
<Style TargetType="{x:Type ToggleButton}" x:Key="FlattenComboBoxToggleButtonStyle">
<Style x:Key="FlattenComboBoxToggleButtonStyle" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Focusable" Value="false" />
@@ -54,27 +54,27 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Border
x:Name="border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="0"
SnapsToDevicePixels="true"
x:Name="border">
SnapsToDevicePixels="true">
<!-- 下拉箭头 -->
<Border
x:Name="splitBorder"
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
Margin="0"
HorizontalAlignment="Right"
BorderBrush="Transparent"
BorderThickness="1"
HorizontalAlignment="Right"
Margin="0"
SnapsToDevicePixels="true"
Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}"
x:Name="splitBorder">
SnapsToDevicePixels="true">
<controls:IconElement
x:Name="arrow"
Foreground="{DynamicResource TextPrimaryBrush}"
RenderTransformOrigin="0.5,0.5"
SnapsToDevicePixels="false"
Symbol="KeyboardArrowDown"
x:Name="arrow">
Symbol="KeyboardArrowDown">
<controls:IconElement.RenderTransform>
<RotateTransform Angle="0" />
</controls:IconElement.RenderTransform>
@@ -86,7 +86,7 @@
<!-- 缩减阴影,下压效果 -->
<Trigger Property="IsPressed" Value="true" />
<Trigger Property="IsChecked" Value="True">
<Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource BorderGradientBrush}" />
<Setter TargetName="border" Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ExpandRotateStoryboard}" />
</Trigger.EnterActions>
@@ -96,8 +96,8 @@
</Trigger>
<!-- 按钮禁用效果 -->
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" TargetName="arrow" Value="{DynamicResource TextDisabledBrush}" />
<Setter Property="Background" TargetName="border" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter TargetName="arrow" Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter TargetName="border" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@@ -105,81 +105,81 @@
</Setter>
</Style>
<!-- 默认样式 -->
<ControlTemplate TargetType="{x:Type ComboBox}" x:Key="FlattenComboBoxTemplate">
<Grid SnapsToDevicePixels="true" x:Name="templateRoot">
<ControlTemplate x:Key="FlattenComboBoxTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="templateRoot" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0" />
<ColumnDefinition Width="0" MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" />
</Grid.ColumnDefinitions>
<Popup
AllowsTransparency="true"
x:Name="PART_Popup"
Grid.ColumnSpan="2"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Margin="-8"
AllowsTransparency="true"
IsOpen="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PopupAnimation="Slide"
VerticalOffset="4"
x:Name="PART_Popup">
VerticalOffset="4">
<Border
x:Name="dropDownBorder"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
Margin="8"
Background="{DynamicResource BackgroundLayoutBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1"
CornerRadius="4"
Margin="8"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
MinWidth="{Binding ActualWidth, ElementName=templateRoot}"
x:Name="dropDownBorder">
<ScrollViewer Margin="4,3" x:Name="DropDownScrollViewer">
<Grid RenderOptions.ClearTypeHint="Enabled" x:Name="grid">
CornerRadius="4">
<ScrollViewer x:Name="DropDownScrollViewer" Margin="4,3">
<Grid x:Name="grid" RenderOptions.ClearTypeHint="Enabled">
<Canvas
x:Name="canvas"
Width="0"
Height="0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Width="0"
x:Name="canvas">
VerticalAlignment="Top">
<Rectangle
Fill="{Binding Background, ElementName=dropDownBorder}"
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
x:Name="opaqueRect"
Width="{Binding ActualWidth, ElementName=dropDownBorder}"
x:Name="opaqueRect" />
Height="{Binding ActualHeight, ElementName=dropDownBorder}"
Fill="{Binding Background, ElementName=dropDownBorder}" />
</Canvas>
<ItemsPresenter
x:Name="ItemsPresenter"
KeyboardNavigation.DirectionalNavigation="Contained"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
x:Name="ItemsPresenter" />
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ScrollViewer>
</Border>
</Popup>
<ToggleButton
x:Name="toggleButton"
Grid.Column="0"
Grid.ColumnSpan="2"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Grid.Column="0"
Grid.ColumnSpan="2"
IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
Style="{StaticResource FlattenComboBoxToggleButtonStyle}"
x:Name="toggleButton" />
Style="{StaticResource FlattenComboBoxToggleButtonStyle}" />
<ContentPresenter
x:Name="contentPresenter"
Grid.Column="0"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding SelectionBoxItem}"
ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}"
ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}"
ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
Grid.Column="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
IsHitTestVisible="false"
Margin="{TemplateBinding Padding}"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
x:Name="contentPresenter" />
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
<Setter Property="Effect" TargetName="dropDownBorder" Value="{DynamicResource PopupShadow}" />
<Trigger SourceName="PART_Popup" Property="HasDropShadow" Value="true">
<Setter TargetName="dropDownBorder" Property="Effect" Value="{DynamicResource PopupShadow}" />
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="Height" TargetName="dropDownBorder" Value="95" />
<Setter TargetName="dropDownBorder" Property="Height" Value="95" />
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
@@ -188,14 +188,14 @@
</MultiTrigger.Conditions>
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
</MultiTrigger>
<Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
<Setter Property="Canvas.Top" TargetName="opaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
<Setter Property="Canvas.Left" TargetName="opaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
<Trigger SourceName="DropDownScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false">
<Setter TargetName="opaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}" />
<Setter TargetName="opaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type ComboBox}" x:Key="FlattenComboBoxStyle">
<Style x:Key="FlattenComboBoxStyle" TargetType="{x:Type ComboBox}">
<Setter Property="FocusVisualStyle" Value="{DynamicResource FocusVisual}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />