feat: start to build button, prepare for renaming.

This commit is contained in:
rabbitism 2022-11-04 23:58:38 +08:00
parent b58a38f22e
commit c55e64a3d8
7 changed files with 69 additions and 2 deletions

View File

@ -0,0 +1,52 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<ControlTheme x:Key="{x:Type Button}" TargetType="Button">
<Setter Property="Button.Background" Value="{DynamicResource ColorButtonOutlineBackground}"/>
<Setter Property="Button.Foreground" Value="{DynamicResource ColorButtonOutlinePrimaryForeground}"/>
<Setter Property="Button.BorderBrush" Value="{DynamicResource ColorButtonOutlinePrimaryBorderBrush}"/>
<Setter Property="Button.CornerRadius" Value="{DynamicResource SizeButtonCornerRadius}"/>
<Setter Property="Button.BorderThickness" Value="1"/>
<Setter Property="Button.Padding" Value="{DynamicResource ThicknessButtonContentDefault}"/>
<Setter Property="Button.RenderTransform" Value="none"/>
<Setter Property="Button.FontSize" Value="{DynamicResource FontRegularSize}"></Setter>
<Setter Property="Button.FontWeight" Value="{DynamicResource FontButtonFontWeight}"></Setter>
<Setter Property="Button.Template">
<ControlTemplate TargetType="Button">
<ContentPresenter
x:Name="PART_ContentPresenter"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
Padding="{TemplateBinding Padding}"
RecognizesAccessKey="True"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
TextElement.FontWeight="{TemplateBinding FontWeight}"
TextElement.FontSize="{TemplateBinding FontSize}"
UseLayoutRounding="False"
>
</ContentPresenter>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Button.BorderBrush" Value="{DynamicResource ColorButtonOutlinePrimaryPointeroverForeground}" />
<Setter Property="Button.Foreground" Value="{DynamicResource ColorButtonOutlinePrimaryPointeroverBorderBrush}" />
</Style>
<Style Selector="^:pressed /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Button.BorderBrush" Value="{DynamicResource ColorButtonOutlinePrimaryPressedForeground}" />
<Setter Property="Button.Foreground" Value="{DynamicResource ColorButtonOutlinePrimaryPressedBorderBrush}" />
</Style>
<Style Selector="^:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Button.BorderBrush" Value="{DynamicResource ColorButtonOutlineDisabledBorderBrush}" />
<Setter Property="Button.Foreground" Value="{DynamicResource ColorButtonOutlineDisabledForeground}" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here --> <!-- Add Resources Here -->
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Controls/Button.axaml"/>
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Controls/UserControl.axaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Semi/Controls/UserControl.axaml"/>
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Controls/Window.axaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Semi/Controls/Window.axaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>

View File

@ -0,0 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
</ResourceDictionary>

View File

@ -3,6 +3,8 @@
<!-- Add Resources Here --> <!-- Add Resources Here -->
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Dark/Palette.axaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Dark/Palette.axaml"/>
<!-- Controls -->
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Dark/Button.axaml"/>
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Dark/Window.axaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Dark/Window.axaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

View File

@ -0,0 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
</ResourceDictionary>

View File

@ -1,8 +1,9 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" <ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Light/Palette.axaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Light/Palette.axaml"/>
<!-- Controls -->
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Light/Button.axaml"/>
<ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Light/Window.axaml"/> <ResourceInclude Source="avares://Avalonia.Themes.Semi/Themes/Light/Window.axaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

View File

@ -5,5 +5,8 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Semi.Demo.MainWindow" x:Class="Semi.Demo.MainWindow"
Title="Semi.Demo"> Title="Semi.Demo">
Welcome to Avalonia! <StackPanel>
<Button>Primary</Button>
<Button>Secondary</Button>
</StackPanel>
</Window> </Window>