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-01-02 17:30:41 +08:00
xmlns:controls="clr-namespace:Melskin.Controls"
xmlns:converters="clr-namespace:Melskin.Converters"
2026-01-02 17:30:30 +08:00
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
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
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
2026-01-02 17:30:30 +08:00
BorderThickness="{TemplateBinding BorderThickness}"
Padding="{TemplateBinding Padding}"
x:Name="Content">
2025-07-31 20:12:01 +08:00
<ContentPresenter
Content="{TemplateBinding Content}"
ContentStringFormat="{TemplateBinding ContentStringFormat}"
ContentTemplate="{TemplateBinding ContentTemplate}"
2026-01-02 17:30:30 +08:00
ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
2025-07-31 20:12:01 +08:00
</Border>
<!-- IndicatorPanel -->
<Grid
VerticalAlignment="Center"
2026-01-02 17:30:30 +08:00
Visibility="{Binding Spinning, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static converters:BooleanToVisibilityConverter.CollapsedInstance}}"
x:Name="IndicatorPanel">
2025-07-31 20:12:01 +08:00
<Grid.RowDefinitions>
<!-- Icon -->
<RowDefinition />
<!-- Text -->
<RowDefinition />
</Grid.RowDefinitions>
<!-- Indicator -->
<ContentPresenter
2025-12-23 21:35:54 +08:00
Content="{TemplateBinding Indicator}"
2026-01-02 17:30:30 +08:00
Grid.RowSpan="2"
Visibility="Hidden"
x:Name="Indicator" />
2025-07-31 20:12:01 +08:00
<!-- Dot -->
<Grid
Grid.RowSpan="2"
2025-12-23 21:35:54 +08:00
Height="{Binding Width, Mode=OneWay, RelativeSource={RelativeSource Self}}"
2026-01-02 17:30:30 +08:00
RenderTransformOrigin="0.5,0.5"
Width="20"
x:Name="Dot">
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
2025-12-23 21:35:54 +08:00
HorizontalAlignment="Left"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Top"
Width="9"
x:Name="Dot1" />
2025-07-31 20:12:01 +08:00
<Ellipse
2025-12-23 21:35:54 +08:00
HorizontalAlignment="Right"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Top"
2025-07-31 20:12:01 +08:00
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}"
2026-01-02 17:30:30 +08:00
x:Name="Dot2" />
2025-07-31 20:12:01 +08:00
<Ellipse
2026-01-02 17:30:30 +08:00
HorizontalAlignment="Left"
VerticalAlignment="Bottom"
2025-07-31 20:12:01 +08:00
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}"
2026-01-02 17:30:30 +08:00
x:Name="Dot3" />
<Ellipse
2025-12-23 21:35:54 +08:00
HorizontalAlignment="Right"
2026-01-02 17:30:30 +08:00
VerticalAlignment="Bottom"
Width="{Binding Width, Mode=OneWay, ElementName=Dot1}"
x:Name="Dot4" />
2025-07-31 20:12:01 +08:00
</Grid>
<ContentPresenter
2026-01-02 17:30:30 +08:00
Content="{TemplateBinding Tip}"
2025-07-31 20:12:01 +08:00
Grid.Row="1"
2026-01-02 17:30:30 +08:00
x:Name="LoadingText" />
2025-07-31 20:12:01 +08:00
</Grid>
<!-- Mask -->
<Rectangle
Fill="Transparent"
2026-01-02 17:30:30 +08:00
Visibility="Collapsed"
x:Name="Mask" />
2025-07-31 20:12:01 +08:00
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SpinStates">
<VisualStateGroup.Transitions>
2026-01-02 17:30:30 +08:00
<VisualTransition From="Spun" GeneratedDuration="0:0:0.2">
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
2026-01-02 17:30:30 +08:00
Duration="0:0:0.2"
2025-07-31 20:12:01 +08:00
Storyboard.TargetName="Content"
Storyboard.TargetProperty="Opacity"
2026-01-02 17:30:30 +08:00
To="0.5" />
2025-07-31 20:12:01 +08:00
<!-- Dot -->
<DoubleAnimation
2026-01-02 17:30:30 +08:00
Duration="0:0:1.2"
From="45"
2025-07-31 20:12:01 +08:00
RepeatBehavior="Forever"
Storyboard.TargetName="Dot"
Storyboard.TargetProperty="RenderTransform.Angle"
2026-01-02 17:30:30 +08:00
To="405" />
2025-07-31 20:12:01 +08:00
<DoubleAnimation
AutoReverse="True"
2026-01-02 17:30:30 +08:00
Duration="0:0:1"
From="0.3"
2025-07-31 20:12:01 +08:00
RepeatBehavior="Forever"
Storyboard.TargetName="Dot1"
Storyboard.TargetProperty="Opacity"
2026-01-02 17:30:30 +08:00
To="1" />
2025-07-31 20:12:01 +08:00
<DoubleAnimation
AutoReverse="True"
BeginTime="0:0:0.4"
2026-01-02 17:30:30 +08:00
Duration="0:0:1"
From="0.3"
2025-07-31 20:12:01 +08:00
RepeatBehavior="Forever"
Storyboard.TargetName="Dot2"
Storyboard.TargetProperty="Opacity"
2026-01-02 17:30:30 +08:00
To="1" />
2025-07-31 20:12:01 +08:00
<DoubleAnimation
AutoReverse="True"
BeginTime="0:0:0.8"
2026-01-02 17:30:30 +08:00
Duration="0:0:1"
From="0.3"
2025-07-31 20:12:01 +08:00
RepeatBehavior="Forever"
Storyboard.TargetName="Dot3"
Storyboard.TargetProperty="Opacity"
2026-01-02 17:30:30 +08:00
To="1" />
2025-07-31 20:12:01 +08:00
<DoubleAnimation
AutoReverse="True"
BeginTime="0:0:1.2"
2026-01-02 17:30:30 +08:00
Duration="0:0:1"
From="0.3"
2025-07-31 20:12:01 +08:00
RepeatBehavior="Forever"
Storyboard.TargetName="Dot4"
Storyboard.TargetProperty="Opacity"
2026-01-02 17:30:30 +08:00
To="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-01-02 17:30:30 +08:00
<Setter Property="Visibility" TargetName="Mask" Value="Visible" />
<Setter Property="Effect" TargetName="Content">
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-01-02 17:30:30 +08:00
<Setter Property="Grid.RowSpan" TargetName="Dot" Value="1" />
<Setter Property="Grid.RowSpan" TargetName="Indicator" Value="1" />
<Setter Property="Margin" TargetName="LoadingText" 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-01-02 17:30:30 +08:00
<Setter Property="HorizontalAlignment" TargetName="IndicatorPanel" 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-01-02 17:30:30 +08:00
<Setter Property="Visibility" TargetName="Dot" Value="Collapsed" />
<Setter Property="Visibility" TargetName="Indicator" 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>