Files
HandyControl/src/Avalonia/HandyControl_Avalonia/Themes/Styles/Slider.axaml
T

474 lines
22 KiB
XML

<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:ClassModifier="internal"
xmlns:hc="clr-namespace:HandyControl.Controls">
<ControlTheme x:Key="SliderRepeatButtonHorizontalStyle"
TargetType="RepeatButton">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Focusable"
Value="False" />
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="Template">
<ControlTemplate>
<Border Background="Transparent"
Height="{TemplateBinding Height}"
Width="{TemplateBinding Width}">
<Rectangle Fill="{TemplateBinding Background}"
Height="2" />
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="SliderRepeatButtonVerticalStyle"
TargetType="RepeatButton">
<Setter Property="Background"
Value="Transparent" />
<Setter Property="Focusable"
Value="False" />
<Setter Property="IsTabStop"
Value="False" />
<Setter Property="Template">
<ControlTemplate>
<Border Background="Transparent"
Height="{TemplateBinding Height}"
Width="{TemplateBinding Width}">
<Rectangle Fill="{TemplateBinding Background}"
Width="2" />
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
<ControlTheme x:Key="SliderThumb"
TargetType="Thumb">
<Setter Property="Height"
Value="18" />
<Setter Property="Width"
Value="18" />
<Setter Property="ClipToBounds"
Value="False" />
<Setter Property="Template">
<ControlTemplate>
<hc:AxleCanvas>
<Ellipse Width="18"
Height="18"
Fill="White"
Effect="{StaticResource EffectShadow1}"
StrokeThickness="0"
Stroke="{DynamicResource PrimaryBrush}">
<Ellipse.Transitions>
<Transitions>
<DoubleTransition Property="StrokeThickness"
Duration="0:0:0.1" />
</Transitions>
</Ellipse.Transitions>
</Ellipse>
</hc:AxleCanvas>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Style Selector="^ /template/ Ellipse">
<Setter Property="Effect"
Value="{StaticResource EffectShadow2}" />
</Style>
</Style>
<Style Selector="^:pressed /template/ Ellipse">
<Setter Property="StrokeThickness"
Value="2" />
</Style>
</ControlTheme>
<ControlTheme x:Key="TipSliderThumbHorizontalTop"
TargetType="Thumb">
<Setter Property="Height"
Value="18" />
<Setter Property="Width"
Value="18" />
<Setter Property="ClipToBounds"
Value="False" />
<Setter Property="Template">
<ControlTemplate>
<hc:AxleCanvas>
<Label Name="LabelValue"
IsHitTestVisible="False"
IsVisible="False"
Canvas.Bottom="28"
Theme="{StaticResource LabelPrimary}"
hc:ContentControlAttach.Content="{Binding Value,RelativeSource={RelativeSource AncestorType=Slider}}"
hc:ContentControlAttach.ContentStringFormat="{Binding Path=(hc:TipElement.StringFormat),RelativeSource={RelativeSource AncestorType=Slider}}" />
<Ellipse Width="18"
Height="18"
Fill="White"
Effect="{StaticResource EffectShadow1}"
StrokeThickness="0"
Stroke="{DynamicResource PrimaryBrush}">
<Ellipse.Transitions>
<Transitions>
<DoubleTransition Property="StrokeThickness"
Duration="0:0:0.1" />
</Transitions>
</Ellipse.Transitions>
</Ellipse>
</hc:AxleCanvas>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Style Selector="^ /template/ Ellipse">
<Setter Property="Effect"
Value="{StaticResource EffectShadow2}" />
</Style>
<Style Selector="^ /template/ Label#LabelValue">
<Setter Property="IsVisible"
Value="True" />
</Style>
</Style>
<Style Selector="^:pressed /template/ Ellipse">
<Setter Property="StrokeThickness"
Value="2" />
</Style>
</ControlTheme>
<ControlTheme x:Key="TipSliderThumbHorizontalBottom"
TargetType="Thumb">
<Setter Property="Height"
Value="18" />
<Setter Property="Width"
Value="18" />
<Setter Property="ClipToBounds"
Value="False" />
<Setter Property="Template">
<ControlTemplate>
<hc:AxleCanvas>
<Label Name="LabelValue"
IsHitTestVisible="False"
IsVisible="False"
Canvas.Top="28"
Theme="{StaticResource LabelPrimary}"
hc:ContentControlAttach.Content="{Binding Value,RelativeSource={RelativeSource AncestorType=Slider}}"
hc:ContentControlAttach.ContentStringFormat="{Binding Path=(hc:TipElement.StringFormat),RelativeSource={RelativeSource AncestorType=Slider}}" />
<Ellipse Width="18"
Height="18"
Fill="White"
Effect="{StaticResource EffectShadow1}"
StrokeThickness="0"
Stroke="{DynamicResource PrimaryBrush}">
<Ellipse.Transitions>
<Transitions>
<DoubleTransition Property="StrokeThickness"
Duration="0:0:0.1" />
</Transitions>
</Ellipse.Transitions>
</Ellipse>
</hc:AxleCanvas>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Style Selector="^ /template/ Ellipse">
<Setter Property="Effect"
Value="{StaticResource EffectShadow2}" />
</Style>
<Style Selector="^ /template/ Label#LabelValue">
<Setter Property="IsVisible"
Value="True" />
</Style>
</Style>
<Style Selector="^:pressed /template/ Ellipse">
<Setter Property="StrokeThickness"
Value="2" />
</Style>
</ControlTheme>
<ControlTheme x:Key="TipSliderThumbVerticalLeft"
TargetType="Thumb">
<Setter Property="Height"
Value="18" />
<Setter Property="Width"
Value="18" />
<Setter Property="ClipToBounds"
Value="False" />
<Setter Property="Template">
<ControlTemplate>
<hc:AxleCanvas Orientation="Vertical">
<Label Name="LabelValue"
IsHitTestVisible="False"
IsVisible="False"
Canvas.Right="28"
Theme="{StaticResource LabelPrimary}"
hc:ContentControlAttach.Content="{Binding Value,RelativeSource={RelativeSource AncestorType=Slider}}"
hc:ContentControlAttach.ContentStringFormat="{Binding Path=(hc:TipElement.StringFormat),RelativeSource={RelativeSource AncestorType=Slider}}" />
<Ellipse Width="18"
Height="18"
Fill="White"
Effect="{StaticResource EffectShadow1}"
StrokeThickness="0"
Stroke="{DynamicResource PrimaryBrush}">
<Ellipse.Transitions>
<Transitions>
<DoubleTransition Property="StrokeThickness"
Duration="0:0:0.1" />
</Transitions>
</Ellipse.Transitions>
</Ellipse>
</hc:AxleCanvas>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Style Selector="^ /template/ Ellipse">
<Setter Property="Effect"
Value="{StaticResource EffectShadow2}" />
</Style>
<Style Selector="^ /template/ Label#LabelValue">
<Setter Property="IsVisible"
Value="True" />
</Style>
</Style>
<Style Selector="^:pressed /template/ Ellipse">
<Setter Property="StrokeThickness"
Value="2" />
</Style>
</ControlTheme>
<ControlTheme x:Key="TipSliderThumbVerticalRight"
TargetType="Thumb">
<Setter Property="Height"
Value="18" />
<Setter Property="Width"
Value="18" />
<Setter Property="ClipToBounds"
Value="False" />
<Setter Property="Template">
<ControlTemplate>
<hc:AxleCanvas Orientation="Vertical">
<Label Name="LabelValue"
IsHitTestVisible="False"
IsVisible="False"
Canvas.Left="28"
Theme="{StaticResource LabelPrimary}"
hc:ContentControlAttach.Content="{Binding Value,RelativeSource={RelativeSource AncestorType=Slider}}"
hc:ContentControlAttach.ContentStringFormat="{Binding Path=(hc:TipElement.StringFormat),RelativeSource={RelativeSource AncestorType=Slider}}" />
<Ellipse Width="18"
Height="18"
Fill="White"
Effect="{StaticResource EffectShadow1}"
StrokeThickness="0"
Stroke="{DynamicResource PrimaryBrush}">
<Ellipse.Transitions>
<Transitions>
<DoubleTransition Property="StrokeThickness"
Duration="0:0:0.1" />
</Transitions>
</Ellipse.Transitions>
</Ellipse>
</hc:AxleCanvas>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Style Selector="^ /template/ Ellipse">
<Setter Property="Effect"
Value="{StaticResource EffectShadow2}" />
</Style>
<Style Selector="^ /template/ Label#LabelValue">
<Setter Property="IsVisible"
Value="True" />
</Style>
</Style>
<Style Selector="^:pressed /template/ Ellipse">
<Setter Property="StrokeThickness"
Value="2" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type Slider}"
TargetType="Slider">
<Setter Property="Background"
Value="{DynamicResource SecondaryRegionBrush}" />
<Setter Property="BorderBrush"
Value="{DynamicResource BorderBrush}" />
<Setter Property="Foreground"
Value="{DynamicResource DarkPrimaryBrush}" />
<Setter Property="ClipToBounds"
Value="False" />
<Style Selector="^:horizontal">
<Setter Property="Template">
<ControlTemplate>
<Grid x:Name="rootGrid"
Margin="9,0"
RenderOptions.RequiresFullOpacityHandling="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto"
MinHeight="{TemplateBinding MinHeight}" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TickBar x:Name="TopTickBar"
Fill="{TemplateBinding Foreground}"
Ticks="{TemplateBinding Ticks}"
TickFrequency="{TemplateBinding TickFrequency}"
Minimum="{TemplateBinding Slider.Minimum}"
Maximum="{TemplateBinding Slider.Maximum}"
Height="4"
Margin="0,0,0,2"
Placement="Top"
Grid.Row="0"
IsVisible="False" />
<TickBar x:Name="BottomTickBar"
Fill="{TemplateBinding Foreground}"
Ticks="{TemplateBinding Ticks}"
TickFrequency="{TemplateBinding TickFrequency}"
Minimum="{TemplateBinding Slider.Minimum}"
Maximum="{TemplateBinding Slider.Maximum}"
Height="4"
Margin="0,2,0,0"
Placement="Bottom"
Grid.Row="2"
IsVisible="False" />
<Border Grid.Row="1"
Height="2"
Background="{TemplateBinding Background}"
VerticalAlignment="Center" />
<Track Name="PART_Track"
Grid.Row="1"
Minimum="{TemplateBinding Minimum}"
Maximum="{TemplateBinding Maximum}"
Value="{TemplateBinding Value}"
IsDirectionReversed="{TemplateBinding IsDirectionReversed}"
Orientation="Horizontal">
<Track.DecreaseButton>
<RepeatButton Name="PART_DecreaseButton"
Background="{DynamicResource PrimaryBrush}"
Theme="{StaticResource SliderRepeatButtonHorizontalStyle}" />
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_IncreaseButton"
Theme="{StaticResource SliderRepeatButtonHorizontalStyle}" />
</Track.IncreaseButton>
<Thumb Margin="-9,0"
Theme="{StaticResource SliderThumb}" />
</Track>
</Grid>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="^:vertical">
<Setter Property="Template">
<ControlTemplate>
<Grid x:Name="rootGrid"
Margin="0,9"
RenderOptions.RequiresFullOpacityHandling="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition MinWidth="{TemplateBinding MinWidth}"
Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TickBar x:Name="LeftTickBar"
Grid.Column="0"
Fill="{TemplateBinding Foreground}"
Ticks="{TemplateBinding Ticks}"
TickFrequency="{TemplateBinding TickFrequency}"
Minimum="{TemplateBinding Slider.Minimum}"
Maximum="{TemplateBinding Slider.Maximum}"
Margin="0,0,2,0"
Placement="Left"
IsVisible="False"
Width="4" />
<TickBar x:Name="RightTickBar"
Grid.Column="2"
Fill="{TemplateBinding Foreground}"
Ticks="{TemplateBinding Ticks}"
TickFrequency="{TemplateBinding TickFrequency}"
Minimum="{TemplateBinding Slider.Minimum}"
Maximum="{TemplateBinding Slider.Maximum}"
Margin="2,0,0,0"
Placement="Right"
IsVisible="False"
Width="4" />
<Border Grid.Column="1"
Width="2"
Background="{TemplateBinding Background}"
HorizontalAlignment="Center" />
<Track Name="PART_Track"
Grid.Column="1"
Minimum="{TemplateBinding Minimum}"
Maximum="{TemplateBinding Maximum}"
Value="{TemplateBinding Value}"
IsDirectionReversed="{TemplateBinding IsDirectionReversed}"
Orientation="Vertical">
<Track.DecreaseButton>
<RepeatButton Name="PART_DecreaseButton"
Background="{DynamicResource PrimaryBrush}"
Theme="{StaticResource SliderRepeatButtonVerticalStyle}" />
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_IncreaseButton"
Theme="{StaticResource SliderRepeatButtonVerticalStyle}" />
</Track.IncreaseButton>
<Thumb Margin="0,-9"
Theme="{StaticResource SliderThumb}" />
</Track>
</Grid>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="^[TickPlacement=TopLeft] /template/ TickBar#LeftTickBar, ^[TickPlacement=Outside] /template/ TickBar#LeftTickBar">
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style Selector="^[TickPlacement=TopLeft] /template/ TickBar#TopTickBar, ^[TickPlacement=Outside] /template/ TickBar#TopTickBar">
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style Selector="^[TickPlacement=BottomRight] /template/ TickBar#BottomTickBar, ^[TickPlacement=Outside] /template/ TickBar#BottomTickBar">
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style Selector="^[TickPlacement=BottomRight] /template/ TickBar#RightTickBar, ^[TickPlacement=Outside] /template/ TickBar#RightTickBar">
<Setter Property="IsVisible"
Value="True" />
</Style>
<Style Selector="^[(hc|TipElement.IsVisible)=True]">
<Style Selector="^[(hc|TipElement.Placement)=Top] /template/ Thumb">
<Setter Property="Theme"
Value="{StaticResource TipSliderThumbHorizontalTop}" />
</Style>
<Style Selector="^[(hc|TipElement.Placement)=Bottom] /template/ Thumb">
<Setter Property="Theme"
Value="{StaticResource TipSliderThumbHorizontalBottom}" />
</Style>
<Style Selector="^[(hc|TipElement.Placement)=Left] /template/ Thumb">
<Setter Property="Theme"
Value="{StaticResource TipSliderThumbVerticalLeft}" />
</Style>
<Style Selector="^[(hc|TipElement.Placement)=Right] /template/ Thumb">
<Setter Property="Theme"
Value="{StaticResource TipSliderThumbVerticalRight}" />
</Style>
</Style>
<Style Selector="^:disabled /template/ Grid#rootGrid">
<Setter Property="Opacity"
Value="0.2" />
</Style>
</ControlTheme>
</ResourceDictionary>