Skip to content

Commit

Permalink
chore: modify Slider template.
Browse files Browse the repository at this point in the history
  • Loading branch information
NaBian committed Dec 15, 2024
1 parent b4734cd commit 1d181c8
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 152 deletions.
43 changes: 33 additions & 10 deletions src/Avalonia/HandyControl_Avalonia/Themes/Styles/Slider.axaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="clr-namespace:HandyControl.Controls">
<ControlTheme x:Key="SliderRepeatButtonStyle"
<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="{TemplateBinding Background}" />
<Border Background="Transparent"
Height="{TemplateBinding Height}"
Width="{TemplateBinding Width}">
<Rectangle Fill="{TemplateBinding Background}"
Width="2" />
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
Expand Down Expand Up @@ -322,13 +349,11 @@
<Track.DecreaseButton>
<RepeatButton Name="PART_DecreaseButton"
Background="{DynamicResource PrimaryBrush}"
Theme="{StaticResource SliderRepeatButtonStyle}"
Height="2" />
Theme="{StaticResource SliderRepeatButtonHorizontalStyle}" />
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_IncreaseButton"
Theme="{StaticResource SliderRepeatButtonStyle}"
Height="2" />
Theme="{StaticResource SliderRepeatButtonHorizontalStyle}" />
</Track.IncreaseButton>
<Thumb Margin="-9,0"
Theme="{StaticResource SliderThumb}" />
Expand Down Expand Up @@ -386,13 +411,11 @@
<Track.DecreaseButton>
<RepeatButton Name="PART_DecreaseButton"
Background="{DynamicResource PrimaryBrush}"
Theme="{StaticResource SliderRepeatButtonStyle}"
Width="2" />
Theme="{StaticResource SliderRepeatButtonVerticalStyle}" />
</Track.DecreaseButton>
<Track.IncreaseButton>
<RepeatButton Name="PART_IncreaseButton"
Theme="{StaticResource SliderRepeatButtonStyle}"
Width="2" />
Theme="{StaticResource SliderRepeatButtonVerticalStyle}" />
</Track.IncreaseButton>
<Thumb Margin="0,-9"
Theme="{StaticResource SliderThumb}" />
Expand Down
62 changes: 16 additions & 46 deletions src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -418,36 +418,6 @@
</Setter.Value>
</Setter>
</Style>
<Style x:Key="PreviewSliderRepeatButtonHorizontalStyle" TargetType="RepeatButton">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border Background="Transparent" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<Rectangle Fill="{TemplateBinding Background}" Height="2" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="PreviewSliderRepeatButtonVerticalStyle" TargetType="RepeatButton">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Focusable" Value="false" />
<Setter Property="IsTabStop" Value="false" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<Border Background="Transparent" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
<Rectangle Fill="{TemplateBinding Background}" Width="2" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollBarBaseRepeatButton" TargetType="RepeatButton">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="Background" Value="Transparent" />
Expand Down Expand Up @@ -1667,10 +1637,10 @@
<Border x:Name="TrackBackground" Background="{TemplateBinding Background}" Height="2" VerticalAlignment="center" Margin="9,0" />
<Track VerticalAlignment="center" Margin="9,0" x:Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Background="{DynamicResource PrimaryBrush}" Style="{StaticResource PreviewSliderRepeatButtonHorizontalStyle}" />
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Background="{DynamicResource PrimaryBrush}" Style="{StaticResource SliderRepeatButtonHorizontalStyle}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource PreviewSliderRepeatButtonHorizontalStyle}" />
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource SliderRepeatButtonHorizontalStyle}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Margin="-9,0" x:Name="PART_Thumb" Focusable="False" Height="18" OverridesDefaultStyle="True" Template="{StaticResource PreviewSliderThumb}" VerticalAlignment="Center" Width="18" />
Expand All @@ -1683,10 +1653,10 @@
<Border x:Name="TrackBackground" Background="{TemplateBinding Background}" Width="2" HorizontalAlignment="center" Margin="0,9" />
<Track HorizontalAlignment="center" Margin="0,9" x:Name="PART_Track">
<Track.DecreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Background="{DynamicResource PrimaryBrush}" Style="{StaticResource PreviewSliderRepeatButtonVerticalStyle}" />
<RepeatButton Command="{x:Static Slider.DecreaseLarge}" Background="{DynamicResource PrimaryBrush}" Style="{StaticResource SliderRepeatButtonVerticalStyle}" />
</Track.DecreaseRepeatButton>
<Track.IncreaseRepeatButton>
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource PreviewSliderRepeatButtonVerticalStyle}" />
<RepeatButton Command="{x:Static Slider.IncreaseLarge}" Style="{StaticResource SliderRepeatButtonVerticalStyle}" />
</Track.IncreaseRepeatButton>
<Track.Thumb>
<Thumb Margin="0,-9" x:Name="PART_Thumb" Focusable="False" Height="18" OverridesDefaultStyle="True" Template="{StaticResource PreviewSliderThumb}" HorizontalAlignment="Center" Width="18" />
Expand Down Expand Up @@ -14037,8 +14007,8 @@
<ColumnDefinition MinWidth="{TemplateBinding MinWidth}" Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TickBar x:Name="TopTick" Grid.Column="0" Fill="{TemplateBinding Foreground}" Margin="0,0,2,0" Placement="Left" Visibility="Collapsed" Width="4" />
<TickBar x:Name="BottomTick" Grid.Column="2" Fill="{TemplateBinding Foreground}" Margin="2,0,0,0" Placement="Right" Visibility="Collapsed" Width="4" />
<TickBar x:Name="LeftTick" Grid.Column="0" Fill="{TemplateBinding Foreground}" Margin="0,0,2,0" Placement="Left" Visibility="Collapsed" Width="4" />
<TickBar x:Name="RightTick" Grid.Column="2" Fill="{TemplateBinding Foreground}" Margin="2,0,0,0" Placement="Right" Visibility="Collapsed" Width="4" />
<Border x:Name="TrackBackground" Background="{TemplateBinding Background}" Grid.Column="1" HorizontalAlignment="center" Margin="0,9" Width="2">
<Canvas x:Name="Canvas_SelectionRange" Visibility="Hidden">
<Rectangle x:Name="PART_SelectionRange" Fill="{DynamicResource AccentBrush}" Width="2" />
Expand Down Expand Up @@ -14072,14 +14042,14 @@
<Setter Property="Template" TargetName="Thumb" Value="{StaticResource TipSliderThumbVerticalRight}" />
</MultiTrigger>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Visibility" TargetName="LeftTick" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
<Setter Property="Visibility" TargetName="RightTick" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
<Setter Property="Visibility" TargetName="LeftTick" Value="Visible" />
<Setter Property="Visibility" TargetName="RightTick" Value="Visible" />
</Trigger>
<Trigger Property="IsSelectionRangeEnabled" Value="true">
<Setter Property="Visibility" TargetName="Canvas_SelectionRange" Value="Visible" />
Expand Down Expand Up @@ -14285,8 +14255,8 @@
<ColumnDefinition MinWidth="{TemplateBinding MinWidth}" Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<TickBar x:Name="TopTick" Height="{Binding ActualHeight,ElementName=TrackBackground}" Ticks="{TemplateBinding Ticks}" TickFrequency="{TemplateBinding TickFrequency}" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Grid.Column="0" Fill="{TemplateBinding Foreground}" Margin="0,0,2,0" Placement="Left" Visibility="Collapsed" Width="4" />
<TickBar x:Name="BottomTick" Height="{Binding ActualHeight,ElementName=TrackBackground}" Ticks="{TemplateBinding Ticks}" TickFrequency="{TemplateBinding TickFrequency}" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Grid.Column="2" Fill="{TemplateBinding Foreground}" Margin="2,0,0,0" Placement="Right" Visibility="Collapsed" Width="4" />
<TickBar x:Name="LeftTick" Height="{Binding ActualHeight,ElementName=TrackBackground}" Ticks="{TemplateBinding Ticks}" TickFrequency="{TemplateBinding TickFrequency}" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Grid.Column="0" Fill="{TemplateBinding Foreground}" Margin="0,0,2,0" Placement="Left" Visibility="Collapsed" Width="4" />
<TickBar x:Name="RightTick" Height="{Binding ActualHeight,ElementName=TrackBackground}" Ticks="{TemplateBinding Ticks}" TickFrequency="{TemplateBinding TickFrequency}" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Grid.Column="2" Fill="{TemplateBinding Foreground}" Margin="2,0,0,0" Placement="Right" Visibility="Collapsed" Width="4" />
<Border x:Name="TrackBackground" Background="{TemplateBinding Background}" Margin="0,9" Grid.Column="1" HorizontalAlignment="center" Width="2" />
<hc:RangeTrack IsDirectionReversed="{TemplateBinding IsDirectionReversed}" Orientation="{TemplateBinding Orientation}" ValueStart="{TemplateBinding ValueStart}" ValueEnd="{TemplateBinding ValueEnd}" Minimum="{TemplateBinding Minimum}" Maximum="{TemplateBinding Maximum}" Margin="0,9" x:Name="PART_Track" Grid.Column="1">
<hc:RangeTrack.DecreaseRepeatButton>
Expand Down Expand Up @@ -14324,14 +14294,14 @@
<Setter Property="Template" TargetName="ThumbEnd" Value="{StaticResource TipRangeSliderThumbVerticalRight}" />
</MultiTrigger>
<Trigger Property="TickPlacement" Value="TopLeft">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Visibility" TargetName="LeftTick" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="BottomRight">
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
<Setter Property="Visibility" TargetName="RightTick" Value="Visible" />
</Trigger>
<Trigger Property="TickPlacement" Value="Both">
<Setter Property="Visibility" TargetName="TopTick" Value="Visible" />
<Setter Property="Visibility" TargetName="BottomTick" Value="Visible" />
<Setter Property="Visibility" TargetName="LeftTick" Value="Visible" />
<Setter Property="Visibility" TargetName="RightTick" Value="Visible" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
Expand Down
Loading

0 comments on commit 1d181c8

Please sign in to comment.