Files
ShrlAlgoToolkit/Melskin/Controls/Spin.xaml

215 lines
13 KiB
Plaintext
Raw Normal View History

2025-07-31 20:12:01 +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:converters="clr-namespace:Melskin.Converters">
2025-07-31 20:12:01 +08:00
2025-08-12 23:08:54 +08:00
<Style TargetType="{x:Type controls:Spin}">
2025-07-31 20:12:01 +08:00
<Setter Property="IsTabStop" Value="False" />
2025-08-12 23:08:54 +08:00
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Setter Property="Foreground" Value="{DynamicResource PrimaryNormalBrush}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:Spin}">
<Grid>
<!-- Content -->
<Border
2026-02-20 15:31:44 +08:00
x:Name="Content"
Padding="{TemplateBinding Padding}"
2025-07-31 20:12:01 +08:00
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2026-02-20 15:31:44 +08:00
BorderThickness="{TemplateBinding BorderThickness}">
2025-07-31 20:12:01 +08:00
<ContentPresenter
2026-02-20 15:31:44 +08:00
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
2025-07-31 20:12:01 +08:00
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
2026-02-20 15:31:44 +08:00
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" />
2025-07-31 20:12:01 +08:00
</Border>
<!-- IndicatorPanel -->
<Grid
2026-02-20 15:31:44 +08:00
x:Name="IndicatorPanel"
2025-07-31 20:12:01 +08:00
VerticalAlignment="Center"
2026-02-20 15:31:44 +08:00
Visibility="{Binding Spinning, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}">
2025-07-31 20:12:01 +08:00
<Grid.RowDefinitions>
<!-- Icon -->
<RowDefinition />
<!-- Text -->
<RowDefinition />
</Grid.RowDefinitions>
<!-- Indicator -->
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="Indicator"
2026-01-02 17:30:30 +08:00
Grid.RowSpan="2"
2026-02-20 15:31:44 +08:00
Content="{TemplateBinding Indicator}"
Visibility="Hidden" />
2025-07-31 20:12:01 +08:00
<!-- Dot -->
<Grid
2026-02-20 15:31:44 +08:00
x:Name="Dot"
2025-07-31 20:12:01 +08:00
Grid.RowSpan="2"
2026-01-02 17:30:30 +08:00
Width="20"
2026-02-20 15:31:44 +08:00
Height="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self}}"
RenderTransformOrigin="0.5,0.5">
2025-07-31 20:12:01 +08:00
<Grid.RenderTransform>
<RotateTransform />
</Grid.RenderTransform>
<Grid.Resources>
<Style TargetType="{x:Type Ellipse}">
<Setter Property="Opacity" Value="0.3" />
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
2025-08-12 23:08:54 +08:00
<Setter Property="Fill" Value="{DynamicResource PrimaryNormalBrush}" />
2025-07-31 20:12:01 +08:00
<Setter Property="Height" Value="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.75" ScaleY="0.75" />
</Setter.Value>
</Setter>
</Style>
</Grid.Resources>
<Ellipse
2026-02-20 15:31:44 +08:00
x:Name="Dot1"
2026-01-02 17:30:30 +08:00
Width="9"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Left"
VerticalAlignment="Top" />
2025-07-31 20:12:01 +08:00
<Ellipse
2026-02-20 15:31:44 +08:00
x:Name="Dot2"
2025-07-31 20:12:01 +08:00
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Right"
VerticalAlignment="Top" />
2025-07-31 20:12:01 +08:00
<Ellipse
2026-02-20 15:31:44 +08:00
x:Name="Dot3"
2025-07-31 20:12:01 +08:00
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Left"
VerticalAlignment="Bottom" />
2026-01-02 17:30:30 +08:00
<Ellipse
2026-02-20 15:31:44 +08:00
x:Name="Dot4"
2026-01-02 17:30:30 +08:00
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}"
2026-02-20 15:31:44 +08:00
HorizontalAlignment="Right"
VerticalAlignment="Bottom" />
2025-07-31 20:12:01 +08:00
</Grid>
<ContentPresenter
2026-02-20 15:31:44 +08:00
x:Name="LoadingText"
2025-07-31 20:12:01 +08:00
Grid.Row="1"
2026-02-20 15:31:44 +08:00
Content="{TemplateBinding Tip}" />
2025-07-31 20:12:01 +08:00
</Grid>
<!-- Mask -->
<Rectangle
2026-02-20 15:31:44 +08:00
x:Name="Mask"
2025-07-31 20:12:01 +08:00
Fill="Transparent"
2026-02-20 15:31:44 +08:00
Visibility="Collapsed" />
2025-07-31 20:12:01 +08:00
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SpinStates">
<VisualStateGroup.Transitions>
2026-02-20 15:31:44 +08:00
<VisualTransition GeneratedDuration="0:0:0.2" From="Spun">
2025-07-31 20:12:01 +08:00
<Storyboard>
<!-- Content -->
<DoubleAnimation Storyboard.TargetName="Content" Storyboard.TargetProperty="Opacity" />
</Storyboard>
</VisualTransition>
</VisualStateGroup.Transitions>
<VisualState x:Name="Spun">
<Storyboard>
<!-- Content -->
<DoubleAnimation
Storyboard.TargetName="Content"
Storyboard.TargetProperty="Opacity"
2026-02-20 15:31:44 +08:00
To="0.5"
Duration="0:0:0.2" />
2025-07-31 20:12:01 +08:00
<!-- Dot -->
<DoubleAnimation
RepeatBehavior="Forever"
Storyboard.TargetName="Dot"
Storyboard.TargetProperty="RenderTransform.Angle"
2026-02-20 15:31:44 +08:00
From="45"
To="405"
Duration="0:0:1.2" />
2025-07-31 20:12:01 +08:00
<DoubleAnimation
AutoReverse="True"
RepeatBehavior="Forever"
Storyboard.TargetName="Dot1"
Storyboard.TargetProperty="Opacity"
2026-02-20 15:31:44 +08:00
From="0.3"
To="1"
Duration="0:0:1" />
2025-07-31 20:12:01 +08:00
<DoubleAnimation
AutoReverse="True"
BeginTime="0:0:0.4"
RepeatBehavior="Forever"
Storyboard.TargetName="Dot2"
Storyboard.TargetProperty="Opacity"
2026-02-20 15:31:44 +08:00
From="0.3"
To="1"
Duration="0:0:1" />
2025-07-31 20:12:01 +08:00
<DoubleAnimation
AutoReverse="True"
BeginTime="0:0:0.8"
RepeatBehavior="Forever"
Storyboard.TargetName="Dot3"
Storyboard.TargetProperty="Opacity"
2026-02-20 15:31:44 +08:00
From="0.3"
To="1"
Duration="0:0:1" />
2025-07-31 20:12:01 +08:00
<DoubleAnimation
AutoReverse="True"
BeginTime="0:0:1.2"
RepeatBehavior="Forever"
Storyboard.TargetName="Dot4"
Storyboard.TargetProperty="Opacity"
2026-02-20 15:31:44 +08:00
From="0.3"
To="1"
Duration="0:0:1" />
2025-07-31 20:12:01 +08:00
</Storyboard>
</VisualState>
<VisualState x:Name="Unspun" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
<ControlTemplate.Triggers>
2025-08-12 23:08:54 +08:00
<!--<Trigger Property="Size" Value="Small">
2025-07-31 20:12:01 +08:00
<Setter Property="Width" TargetName="Dot1" Value="6" />
<Setter Property="Width" TargetName="Dot" Value="{DynamicResource SpinDotSizeSmall}" />
</Trigger>
<Trigger Property="Size" Value="Large">
<Setter Property="Width" TargetName="Dot1" Value="14" />
<Setter Property="Width" TargetName="Dot" Value="{DynamicResource SpinDotSizeLarge}" />
2025-08-12 23:08:54 +08:00
</Trigger>-->
2025-07-31 20:12:01 +08:00
<!-- Spun State -->
<Trigger Property="Spinning" Value="True">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Mask" Property="Visibility" Value="Visible" />
<Setter TargetName="Content" Property="Effect">
2025-07-31 20:12:01 +08:00
<Setter.Value>
<BlurEffect Radius="2" />
</Setter.Value>
</Setter>
</Trigger>
<!-- With Loading Text -->
2025-09-04 22:39:00 +08:00
<DataTrigger Binding="{Binding Tip, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.Instance}}" Value="False">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Dot" Property="Grid.RowSpan" Value="1" />
<Setter TargetName="Indicator" Property="Grid.RowSpan" Value="1" />
<Setter TargetName="LoadingText" Property="Margin" Value="0,8,0,0" />
2025-07-31 20:12:01 +08:00
</DataTrigger>
<!-- Nested Loading -->
2025-09-04 22:39:00 +08:00
<DataTrigger Binding="{Binding Content, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.Instance}}" Value="False">
2026-02-20 15:31:44 +08:00
<Setter TargetName="IndicatorPanel" Property="HorizontalAlignment" Value="Center" />
2025-07-31 20:12:01 +08:00
</DataTrigger>
<!-- With Indicator -->
2025-09-04 22:39:00 +08:00
<DataTrigger Binding="{Binding Indicator, Mode=OneWay, RelativeSource={RelativeSource Self}, Converter={x:Static converters:NullOrEmptyConverter.Instance}}" Value="False">
2026-02-20 15:31:44 +08:00
<Setter TargetName="Dot" Property="Visibility" Value="Collapsed" />
<Setter TargetName="Indicator" Property="Visibility" Value="Visible" />
2025-07-31 20:12:01 +08:00
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<!-- Spun State -->
<Trigger Property="Spinning" Value="True">
<Setter Property="KeyboardNavigation.TabNavigation" Value="None" />
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="None" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>