Files
Shrlalgo.RvKits/Melskin/Controls/Anchor.xaml

211 lines
11 KiB
Plaintext
Raw Normal View History

2025-08-12 23:08:54 +08:00
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
2026-02-20 15:31:44 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
2026-01-02 17:30:41 +08:00
xmlns:controls="clr-namespace:Melskin.Controls"
2026-02-20 15:31:44 +08:00
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations">
2025-12-23 21:35:54 +08:00
<ResourceDictionary.MergedDictionaries>
2026-01-02 17:30:41 +08:00
<ResourceDictionary Source="/Melskin;Component/Themes/Animations.xaml" />
2025-12-23 21:35:54 +08:00
</ResourceDictionary.MergedDictionaries>
2025-08-12 23:08:54 +08:00
<!-- ListBoxItem 的样式保持不变,因为我们内部还是用 ListBox 来显示锚点 -->
2026-02-20 15:31:44 +08:00
<Style x:Key="SlotAnchorItemStyle" TargetType="{x:Type ListBoxItem}">
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
2025-08-12 23:08:54 +08:00
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Height" Value="40" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<!-- <Setter Property="Margin" Value="15" /> -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
2025-09-04 22:39:00 +08:00
<decorations:SlotBorder
2026-02-20 15:31:44 +08:00
x:Name="slot"
Margin="-4"
2026-01-02 17:30:30 +08:00
HorizontalAlignment="Stretch"
2026-02-20 15:31:44 +08:00
ClipToBounds="True"
2025-08-12 23:08:54 +08:00
Intensity="0"
2026-02-20 15:31:44 +08:00
ShaderEnabled="False">
2025-08-12 23:08:54 +08:00
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="content"
2025-08-12 23:08:54 +08:00
HorizontalAlignment="Center"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Center"
2026-02-20 15:31:44 +08:00
TextElement.FontWeight="Normal"
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
2025-09-04 22:39:00 +08:00
</decorations:SlotBorder>
2025-08-12 23:08:54 +08:00
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="content" Property="TextElement.Foreground" Value="{DynamicResource PrimaryFocusedBrush}" />
<Setter TargetName="slot" Property="Intensity" Value="0.15" />
<Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
2025-08-12 23:08:54 +08:00
</Trigger>
<Trigger Property="IsSelected" Value="True">
<!-- <Setter TargetName="ConvexShadow" Property="Background" Value="Transparent" /> -->
2026-02-20 15:31:44 +08:00
<Setter TargetName="slot" Property="Intensity" Value="0.6" />
<Setter TargetName="slot" Property="ShaderEnabled" Value="True" />
<Setter TargetName="content" Property="TextElement.FontWeight" Value="Bold" />
<Setter TargetName="content" Property="TextElement.Foreground" Value="{DynamicResource PrimaryGradientBrush}" />
2025-08-12 23:08:54 +08:00
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Anchor样式和模板 -->
2026-02-20 15:31:44 +08:00
<Style x:Key="EmbossAnchorStyle" TargetType="{x:Type controls:Anchor}">
2025-08-12 23:08:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Anchor}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- 左侧: 锚点列表 -->
2025-09-04 22:39:00 +08:00
<decorations:EmbossBorder
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Stretch"
2025-08-12 23:08:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
ClipToBounds="True"
Intensity="0">
<ListBox
2026-02-20 15:31:44 +08:00
x:Name="PART_AnchorList"
2025-08-12 23:08:54 +08:00
Background="Transparent"
BorderThickness="0"
2025-12-23 21:35:54 +08:00
ItemContainerStyle="{StaticResource EmbossAnchorStyle}"
2026-02-20 15:31:44 +08:00
ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
2025-09-04 22:39:00 +08:00
</decorations:EmbossBorder>
2025-08-12 23:08:54 +08:00
<!-- 右侧: 内容滚动区 -->
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentScroller"
2025-12-23 21:35:54 +08:00
Grid.Column="1"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="Auto">
2025-12-23 21:35:54 +08:00
<!-- ContentPresenter 会将 Anchor 的 Content 放置在这里 -->
<ContentPresenter />
</ScrollViewer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
2026-02-20 15:31:44 +08:00
<Style x:Key="FlatAnchorItemStyle" TargetType="{x:Type ListBoxItem}">
2025-12-23 21:35:54 +08:00
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource ControlBackgroundNormalBrush}" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Height" Value="40" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<!-- <Setter Property="Margin" Value="15" /> -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="12" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Border
2026-02-20 15:31:44 +08:00
x:Name="Indicator"
Width="4"
Margin="2,4"
HorizontalAlignment="Left"
2025-12-23 21:35:54 +08:00
Background="{DynamicResource PrimaryNormalBrush}"
CornerRadius="2"
2026-02-20 15:31:44 +08:00
RenderTransformOrigin="0.5, 0.5">
2025-12-23 21:35:54 +08:00
<Border.RenderTransform>
<ScaleTransform ScaleY="0" />
</Border.RenderTransform>
</Border>
<Border
Grid.Column="1"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Stretch"
ClipToBounds="True">
2025-12-23 21:35:54 +08:00
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="ContentPresenter"
2025-12-23 21:35:54 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Center"
2026-02-20 15:31:44 +08:00
TextElement.FontWeight="Normal"
TextElement.Foreground="{DynamicResource TextPrimaryBrush}" />
2025-12-23 21:35:54 +08:00
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource PrimaryFocusedBrush}" />
2025-12-23 21:35:54 +08:00
<!--<Setter Property="Background" Value="{DynamicResource }" />-->
</Trigger>
<Trigger Property="IsSelected" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Indicator" Property="Visibility" Value="Visible" />
<Setter TargetName="ContentPresenter" Property="TextElement.FontWeight" Value="Bold" />
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
2025-12-23 21:35:54 +08:00
<Trigger.EnterActions>
<BeginStoryboard Storyboard="{StaticResource ExtendYAnimation}" />
</Trigger.EnterActions>
<Trigger.ExitActions>
<BeginStoryboard Storyboard="{StaticResource ShrinkYAnimation}" />
</Trigger.ExitActions>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- Anchor样式和模板 -->
<Style TargetType="{x:Type controls:Anchor}">
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Anchor}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- 左侧: 锚点列表 -->
<Border
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Stretch"
2025-12-23 21:35:54 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
2026-02-20 15:31:44 +08:00
ClipToBounds="True">
2025-12-23 21:35:54 +08:00
<ListBox
2026-02-20 15:31:44 +08:00
x:Name="PART_AnchorList"
2025-12-23 21:35:54 +08:00
Background="Transparent"
BorderThickness="0"
ItemContainerStyle="{StaticResource FlatAnchorItemStyle}"
2026-02-20 15:31:44 +08:00
ScrollViewer.HorizontalScrollBarVisibility="Disabled" />
2025-12-23 21:35:54 +08:00
</Border>
<Rectangle
2026-02-20 15:31:44 +08:00
x:Name="Separator"
2025-08-12 23:08:54 +08:00
Grid.Column="1"
2026-02-20 15:31:44 +08:00
Width="2"
2025-12-23 21:35:54 +08:00
Margin="4,0"
VerticalAlignment="Stretch"
2026-02-20 15:31:44 +08:00
Fill="{TemplateBinding BorderBrush}" />
2025-12-23 21:35:54 +08:00
<!-- 右侧: 内容滚动区 -->
<ScrollViewer
2026-02-20 15:31:44 +08:00
x:Name="PART_ContentScroller"
2025-12-23 21:35:54 +08:00
Grid.Column="2"
2026-02-20 15:31:44 +08:00
VerticalScrollBarVisibility="Auto">
2025-08-12 23:08:54 +08:00
<!-- ContentPresenter 会将 Anchor 的 Content 放置在这里 -->
<ContentPresenter />
</ScrollViewer>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>