Merge pull request #405 from irihitech/adorner

Update AdornerLayer
This commit is contained in:
Dong Bin 2024-08-08 16:17:14 +08:00 committed by GitHub
commit 1b5a5d5ea1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 110 additions and 104 deletions

View File

@ -5,11 +5,8 @@
<ControlTheme x:Key="{x:Type AdornerLayer}" TargetType="AdornerLayer">
<Setter Property="DefaultFocusAdorner">
<FocusAdornerTemplate>
<Rectangle
Margin="{DynamicResource AdornerLayerMargin}"
Stroke="{DynamicResource AdornerLayerBackground}"
StrokeDashArray="1,2"
StrokeThickness="{DynamicResource AdornerLayerThickness}" />
<Border BorderThickness="{DynamicResource AdornerLayerBorderThickness}"
BorderBrush="{DynamicResource AdornerLayerStroke}" />
</FocusAdornerTemplate>
</Setter>
</ControlTheme>

View File

@ -26,6 +26,7 @@
<Grid x:Name="RootGrid" ColumnDefinitions="Auto,*">
<Grid
Grid.Column="0"
TemplatedControl.IsTemplateFocusTarget="True"
Margin="0,0,0,0"
VerticalAlignment="Center">
<Border

View File

@ -39,7 +39,11 @@
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Grid ColumnDefinitions="Auto,*">
<Grid Margin="{DynamicResource RadioButtonIconMargin}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Grid
Grid.Column="0"
TemplatedControl.IsTemplateFocusTarget="True"
Margin="{DynamicResource RadioButtonIconMargin}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
<Ellipse
Name="OuterEllipse"
Width="{DynamicResource RadioButtonIconRadius}"

View File

@ -15,6 +15,13 @@
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="FocusAdorner">
<FocusAdornerTemplate>
<Border BorderThickness="{DynamicResource AdornerLayerBorderThickness}"
BorderBrush="{DynamicResource AdornerLayerStroke}"
CornerRadius="100"/>
</FocusAdornerTemplate>
</Setter>
<Setter Property="KnobTransitions">
<Transitions>
<DoubleTransition
@ -28,27 +35,23 @@
<Grid
Background="{TemplateBinding Background}"
Cursor="Hand"
RowDefinitions="Auto,*">
RowDefinitions="Auto,*"
ColumnDefinitions="Auto, *">
<ContentPresenter
x:Name="PART_ContentPresenter"
Grid.Row="0"
Grid.Row="0" Grid.Column="0"
Grid.ColumnSpan="2"
Margin="{DynamicResource ToggleSwitchHeaderMargin}"
VerticalAlignment="Top"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
IsVisible="{TemplateBinding Content, Converter={x:Static ObjectConverters.IsNotNull}}"
RecognizesAccessKey="True" />
<Grid
Grid.Row="1"
Background="Transparent"
ColumnDefinitions="Auto, *">
<Grid
Grid.Column="0"
Grid.ColumnSpan="2"
TemplatedControl.IsTemplateFocusTarget="True" />
<Border
x:Name="SwitchBackgroundBorder"
Grid.Column="0"
Grid.Row="1" Grid.Column="0"
TemplatedControl.IsTemplateFocusTarget="True"
Width="{DynamicResource ToggleSwitchDefaultWidth}"
Height="{DynamicResource ToggleSwitchDefaultHeight}"
CornerRadius="100">
@ -109,26 +112,22 @@
<ContentPresenter
x:Name="PART_OnContentPresenter"
Grid.Column="1"
Grid.Row="1" Grid.Column="1"
Margin="{DynamicResource ToggleSwitchOnContentMargin}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Content="{TemplateBinding OnContent}"
ContentTemplate="{TemplateBinding OnContentTemplate}"
IsVisible="True" />
ContentTemplate="{TemplateBinding OnContentTemplate}" />
<ContentPresenter
x:Name="PART_OffContentPresenter"
Grid.Column="1"
Grid.Row="1" Grid.Column="1"
Margin="{DynamicResource ToggleSwitchOnContentMargin}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
VerticalContentAlignment="Center"
Content="{TemplateBinding OffContent}"
ContentTemplate="{TemplateBinding OffContentTemplate}"
IsVisible="False" />
</Grid>
ContentTemplate="{TemplateBinding OffContentTemplate}" />
</Grid>
</ControlTemplate>
</Setter>
@ -241,6 +240,12 @@
<Setter Property="Padding" Value="8" />
<Setter Property="CornerRadius" Value="3" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="FocusAdorner">
<FocusAdornerTemplate>
<Border BorderThickness="{DynamicResource AdornerLayerBorderThickness}"
BorderBrush="{DynamicResource AdornerLayerStroke}" />
</FocusAdornerTemplate>
</Setter>
<Setter Property="Template">
<ControlTemplate TargetType="ToggleSwitch">
<Border
@ -249,9 +254,9 @@
Background="{TemplateBinding Background}"
CornerRadius="{TemplateBinding CornerRadius}"
Cursor="Hand">
<Grid ColumnDefinitions="Auto">
<Grid x:Name="PART_SwitchKnob" />
<Grid x:Name="PART_MovingKnobs" />
<Panel>
<Panel x:Name="PART_SwitchKnob" />
<Panel x:Name="PART_MovingKnobs" />
<ContentPresenter
x:Name="PART_OnContentPresenter"
Margin="{DynamicResource ToggleSwitchOnContentMargin}"
@ -262,7 +267,7 @@
Margin="{DynamicResource ToggleSwitchOnContentMargin}"
Content="{TemplateBinding OffContent}"
ContentTemplate="{TemplateBinding OffContentTemplate}" />
</Grid>
</Panel>
</Border>
</ControlTemplate>
</Setter>

View File

@ -1,3 +1,3 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="AdornerLayerBackground" Color="White" />
<SolidColorBrush x:Key="AdornerLayerStroke" Opacity="0.4" Color="#54A9FF" />
</ResourceDictionary>

View File

@ -1,3 +1,3 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="AdornerLayerBackground" Color="#1C1F23" />
<SolidColorBrush x:Key="AdornerLayerStroke" Color="#98CDFD" />
</ResourceDictionary>

View File

@ -1,4 +1,3 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Thickness x:Key="AdornerLayerMargin">1</Thickness>
<x:Double x:Key="AdornerLayerThickness">1</x:Double>
<Thickness x:Key="AdornerLayerBorderThickness">2</Thickness>
</ResourceDictionary>