-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
239 additions
and
82 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/CheckBoxDemoCtl.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
x:Class="HandyControlDemo.UserControl.CheckBoxDemoCtl"> | ||
<StackPanel Margin="32" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center"> | ||
<CheckBox Content="CheckBox" | ||
IsChecked="True" /> | ||
<CheckBox Margin="0,16,0,0" | ||
Content="CheckBox" | ||
IsChecked="True" | ||
IsEnabled="False" /> | ||
<CheckBox Margin="0,16,0,0" | ||
Content="CheckBox" /> | ||
<CheckBox Margin="0,16,0,0" | ||
Content="CheckBox" | ||
IsEnabled="False" /> | ||
<CheckBox Margin="0,16,0,0" | ||
Content="CheckBox" | ||
IsChecked="{x:Null}" /> | ||
<CheckBox Margin="0,16,0,0" | ||
Content="CheckBox" | ||
IsChecked="{x:Null}" | ||
IsEnabled="False" /> | ||
</StackPanel> | ||
</UserControl> |
9 changes: 9 additions & 0 deletions
9
src/Avalonia/HandyControlDemo_Avalonia/UserControl/Styles/CheckBoxDemoCtl.axaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace HandyControlDemo.UserControl; | ||
|
||
public partial class CheckBoxDemoCtl : Avalonia.Controls.UserControl | ||
{ | ||
public CheckBoxDemoCtl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
121 changes: 121 additions & 0 deletions
121
src/Avalonia/HandyControl_Avalonia/Themes/Styles/CheckBox.axaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
<ResourceDictionary xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> | ||
<ControlTheme x:Key="CheckBoxBaseStyle" | ||
TargetType="CheckBox"> | ||
<Setter Property="Foreground" | ||
Value="{DynamicResource PrimaryTextBrush}" /> | ||
<Setter Property="Background" | ||
Value="White" /> | ||
<Setter Property="BorderBrush" | ||
Value="{DynamicResource BorderBrush}" /> | ||
<Setter Property="BorderThickness" | ||
Value="1" /> | ||
<Setter Property="HorizontalAlignment" | ||
Value="Stretch" /> | ||
<Setter Property="VerticalAlignment" | ||
Value="Center" /> | ||
<Setter Property="VerticalContentAlignment" | ||
Value="Center" /> | ||
<Setter Property="Padding" | ||
Value="6,0,0,0" /> | ||
<Setter Property="Template"> | ||
<ControlTemplate> | ||
<Grid Background="Transparent" | ||
ColumnDefinitions="Auto, *"> | ||
<Border Height="16" | ||
Width="16" | ||
Background="{TemplateBinding Background}" | ||
BorderBrush="{TemplateBinding BorderBrush}" | ||
BorderThickness="{TemplateBinding BorderThickness}" | ||
CornerRadius="2" /> | ||
<Panel Grid.Column="0" | ||
Height="16" | ||
Width="16"> | ||
<Path FlowDirection="LeftToRight" | ||
StrokeDashOffset="8" | ||
StrokeDashArray="8,8" | ||
Width="10" | ||
Height="8" | ||
Data="{StaticResource CheckedGeometry}" | ||
StrokeThickness="2" | ||
Stretch="Uniform" | ||
Stroke="{DynamicResource TextIconBrush}" | ||
VerticalAlignment="Center" | ||
HorizontalAlignment="Center" | ||
x:Name="path"> | ||
<Path.Transitions> | ||
<Transitions> | ||
<DoubleTransition Property="StrokeDashOffset" | ||
Duration="0:0:0.2" /> | ||
</Transitions> | ||
</Path.Transitions> | ||
</Path> | ||
<Rectangle RadiusX="2" | ||
RadiusY="2" | ||
Width="12" | ||
Height="12" | ||
Fill="{DynamicResource PrimaryBrush}" | ||
IsVisible="{Binding IsChecked, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNull}}" | ||
Margin="2" | ||
Opacity="1" | ||
x:Name="indeterminateMark" /> | ||
</Panel> | ||
<ContentPresenter x:Name="contentPresenter" | ||
IsVisible="{Binding $self.Content, Converter={x:Static ObjectConverters.IsNotNull}}" | ||
Grid.Column="1" | ||
Focusable="False" | ||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" | ||
Margin="{TemplateBinding Padding}" | ||
RecognizesAccessKey="True" | ||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" /> | ||
</Grid> | ||
</ControlTemplate> | ||
</Setter> | ||
|
||
<Style Selector="^:pointerover"> | ||
<Setter Property="BorderBrush" | ||
Value="{DynamicResource SecondaryBorderBrush}" /> | ||
</Style> | ||
|
||
<Style Selector="^:checked"> | ||
<Setter Property="Background" | ||
Value="{DynamicResource PrimaryBrush}" /> | ||
<Setter Property="BorderBrush" | ||
Value="{DynamicResource DarkPrimaryBrush}" /> | ||
|
||
<Style Selector="^ /template/ Path#path"> | ||
<Setter Property="StrokeDashOffset" | ||
Value="0" /> | ||
</Style> | ||
</Style> | ||
|
||
<Style Selector="^:unchecked"> | ||
<Style Selector="^ /template/ Path#path"> | ||
<Setter Property="Stroke" | ||
Value="{DynamicResource BorderBrush}" /> | ||
<Setter Property="StrokeDashOffset" | ||
Value="8" /> | ||
</Style> | ||
</Style> | ||
|
||
<Style Selector="^:pressed"> | ||
<Style Selector="^:checked"> | ||
<Setter Property="Opacity" | ||
Value=".8" /> | ||
</Style> | ||
<Style Selector="^:unchecked"> | ||
<Setter Property="BorderBrush" | ||
Value="{DynamicResource PrimaryBrush}" /> | ||
</Style> | ||
</Style> | ||
|
||
<Style Selector="^:disabled"> | ||
<Setter Property="Opacity" | ||
Value="0.4" /> | ||
</Style> | ||
</ControlTheme> | ||
|
||
<ControlTheme x:Key="{x:Type CheckBox}" | ||
BasedOn="{StaticResource CheckBoxBaseStyle}" | ||
TargetType="CheckBox" /> | ||
</ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.