feat: more controls.

This commit is contained in:
rabbitism
2024-10-02 18:06:55 +08:00
parent f0b6c4ecf9
commit 3189968128
19 changed files with 66 additions and 128 deletions

View File

@@ -19,9 +19,7 @@
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.0" />
<!--
<PackageReference Include="Semi.Avalonia" Version="11.1.0.2" />
-->
<PackageReference Include="Semi.Avalonia" Version="11.1.0.5-beta1" />
</ItemGroup>
<ItemGroup>

View File

@@ -30,18 +30,19 @@
Header="Clear" />
</MenuFlyout>
<ControlTheme x:Key="{x:Type u:IPv4Box}" TargetType="{x:Type u:IPv4Box}">
<Setter Property="u:IPv4Box.Focusable" Value="True" />
<Setter Property="u:IPv4Box.ShowLeadingZero" Value="True" />
<Setter Property="u:IPv4Box.TextAlignment" Value="Center" />
<Setter Property="u:IPv4Box.HorizontalAlignment" Value="Left" />
<Setter Property="u:IPv4Box.CornerRadius" Value="{DynamicResource IPv4BoxCornerRadius}" />
<Setter Property="u:IPv4Box.Background" Value="{DynamicResource IPv4BoxBackground}" />
<Setter Property="u:IPv4Box.MinHeight" Value="{DynamicResource IPv4BoxDefaultMinHeight}" />
<Setter Property="u:IPv4Box.BorderThickness" Value="{DynamicResource IPv4BoxBorderThickness}" />
<Setter Property="u:IPv4Box.SelectionBrush" Value="{DynamicResource IPv4BoxSelectionBrush}" />
<Setter Property="u:IPv4Box.SelectionForegroundBrush" Value="{DynamicResource IPv4BoxSelectionForeground}" />
<Setter Property="u:IPv4Box.CaretBrush" Value="{DynamicResource IPv4BoxCaretBrush}" />
<Setter Property="u:IPv4Box.ContextFlyout" Value="{DynamicResource IPv4BoxMenuFlyout}" />
<Setter Property="Focusable" Value="True" />
<Setter Property="ShowLeadingZero" Value="True" />
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="CornerRadius" Value="{DynamicResource TextBoxDefaultCornerRadius}" />
<Setter Property="Background" Value="{DynamicResource TextBoxDefaultBackground}" />
<Setter Property="MinHeight" Value="{DynamicResource TextBoxDefaultHeight}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextBoxBorderThickness}" />
<Setter Property="SelectionBrush" Value="{DynamicResource TextBoxSelectionBackground}" />
<Setter Property="SelectionForegroundBrush" Value="{DynamicResource TextBoxSelectionForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxDefaultBorderBrush}" />
<Setter Property="CaretBrush" Value="{DynamicResource TextBoxTextCaretBrush}" />
<Setter Property="ContextFlyout" Value="{DynamicResource IPv4BoxMenuFlyout}" />
<Setter Property="FocusAdorner" Value="{x:Null}"></Setter>
<Setter Property="u:IPv4Box.Template">
<ControlTemplate TargetType="u:IPv4Box">
@@ -113,17 +114,20 @@
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource IPv4BoxPointeroverBackground}" />
<Setter Property="Background" Value="{DynamicResource TextBoxPointeroverBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxPointeroverBorderBrush}" />
</Style>
<Style Selector="^:pressed /template/ Border#PART_Border">
<Setter Property="Background" Value="{DynamicResource IPv4BoxPressedBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
</Style>
<Style Selector="^:focus-within">
<Setter Property="Border.BorderBrush" Value="{DynamicResource IPv4BoxFocusBorderBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
</Style>
<Style Selector="^:disabled">
<Setter Property="Background" Value="{DynamicResource IPv4BoxDisabledBackground}" />
<Setter Property="Foreground" Value="{DynamicResource SemiColorDisabledText}" />
<Setter Property="Background" Value="{DynamicResource TextBoxDisabledBackground}" />
<Setter Property="Foreground" Value="{DynamicResource TextBoxDisabledForeground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxDisabledBorderBrush}" />
</Style>
</ControlTheme>
</ResourceDictionary>

View File

@@ -7,12 +7,11 @@
<converters:PlatformKeyGestureConverter x:Key="KeyGestureConverter" />
<ControlTheme x:Key="{x:Type u:KeyGestureInput}" TargetType="u:KeyGestureInput">
<Setter Property="MinWidth" Value="{DynamicResource KeyGestureInputWidth}" />
<Setter Property="MinHeight" Value="{DynamicResource KeyGestureInputHeight}" />
<Setter Property="Background" Value="{DynamicResource KeyGestureInputBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource KeyGestureInputBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource KeyGestureInputBorderThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource KeyGestureInputCornerRadius}" />
<Setter Property="MinHeight" Value="{DynamicResource TextBoxDefaultHeight}" />
<Setter Property="Background" Value="{DynamicResource TextBoxDefaultBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxDefaultBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextBoxBorderThickness}" />
<Setter Property="CornerRadius" Value="{DynamicResource TextBoxDefaultCornerRadius}" />
<Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
<Setter Property="Padding" Value="8 0" />
<Setter Property="Template">
@@ -67,18 +66,18 @@
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource KeyGestureInputPointeroverBackground}" />
<Setter Property="Background" Value="{DynamicResource TextBoxPointeroverBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxPointeroverBorderBrush}" />
</Style>
<Style Selector="^:pressed /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource KeyGestureInputPressedBackground}" />
<Setter Property="Background" Value="{DynamicResource TextBoxPressedBackground}" />
</Style>
<Style Selector="^:focus /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource KeyGestureInputPressedBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource KeyGestureInputFocusBorderBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
</Style>
<Style Selector="^:focus-within /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource KeyGestureInputPressedBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource KeyGestureInputFocusBorderBrush}" />
<Setter Property="Background" Value="{DynamicResource TextBoxPressedBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxFocusBorderBrush}" />
</Style>
<Style Selector="^:not(:empty).clearButton, ^:not(:empty).ClearButton">
<Style Selector="^:focus /template/ Button#PART_ClearButton">

View File

@@ -8,7 +8,7 @@
<Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" />
<Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderBrush}" />
<Setter Property="HorizontalAlignment" Value="Left" />
<Setter Property="MaxDropdownHeight" Value="300" />
<Setter Property="MaxSelectionBoxHeight" Value="270"></Setter>

View File

@@ -55,7 +55,8 @@
Grid.Row="0"
MinHeight="32"
HorizontalAlignment="Stretch"
Background="{TemplateBinding u:NavMenuItem.Background}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
CornerRadius="4"
Cursor="Hand">
<Grid
@@ -149,9 +150,11 @@
</Setter>
<Setter Property="Template" Value="{StaticResource DefaultNavMenuItemTemplate}" />
<Style Selector="^:selected">
<Setter Property="Background" Value="{DynamicResource NavigationMenuItemSelectedBackground}" />
<Setter Property="Foreground" Value="{DynamicResource ListBoxItemSelectedForeground}"></Setter>
<Setter Property="Background" Value="{DynamicResource ListBoxItemSelectedBackground}" />
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource NavigationMenuItemSelectedBackground}" />
<Setter Property="Foreground" Value="{DynamicResource ListBoxItemSelectedForeground}"></Setter>
<Setter Property="Background" Value="{DynamicResource ListBoxItemSelectedPointeroverBackground}" />
</Style>
</Style>
<Style Selector="^:vertical-collapsed /template/ ItemsPresenter#PART_ItemsPresenter">
@@ -165,7 +168,10 @@
<Setter Property="IsVisible" Value="False" />
</Style>
<Style Selector="^ /template/ Border#PART_Border:pointerover">
<Setter Property="Background" Value="{DynamicResource NavigationMenuItemPointeroverBackground}" />
<Setter Property="Background" Value="{DynamicResource ListBoxItemPointeroverBackground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#PART_HeaderPresenter:pointerover">
<Setter Property="Foreground" Value="{DynamicResource ListBoxItemPointeroverForeground}" />
</Style>
<Style Selector="^:horizontal-collapsed:first-level">
<Setter Property="HorizontalAlignment" Value="Stretch" />
@@ -179,7 +185,7 @@
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
<Style Selector="^ /template/ Border#PART_Border:pointerover">
<Setter Property="Background" Value="{DynamicResource NavigationMenuItemPointeroverBackground}" />
<Setter Property="Background" Value="{DynamicResource ListBoxItemPointeroverBackground}" />
</Style>
<Style Selector="^ /template/ ContentPresenter#PART_IconPresenter">
<Setter Property="Grid.ColumnSpan" Value="3" />

View File

@@ -11,6 +11,7 @@
<Setter Property="Width" Value="{DynamicResource TextBoxDefaultHeight}" />
<Setter Property="CornerRadius" Value="{DynamicResource TextBoxDefaultCornerRadius}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextBoxBorderThickness}" />
<Setter Property="BorderBrush" Value="{DynamicResource TextBoxDefaultBorderBrush}"></Setter>
<Setter Property="Background" Value="{DynamicResource TextBoxDefaultBackground}" />
<Setter Property="FocusAdorner" Value="{x:Null}" />
<Setter Property="Template">
@@ -20,6 +21,7 @@
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<TextPresenter

View File

@@ -18,6 +18,7 @@
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" />
<Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderBrush" Value="{DynamicResource ComboBoxSelectorBorderBrush}"></Setter>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="MinHeight" Value="{DynamicResource ComboBoxDefaultHeight}" />
<Setter Property="Cursor" Value="Hand" />

View File

@@ -1,12 +0,0 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="IPv4BoxBackground" Opacity="0.12" Color="White" />
<SolidColorBrush x:Key="IPv4BoxPointeroverBackground" Opacity="0.16" Color="White" />
<SolidColorBrush x:Key="IPv4BoxPressedBackground" Opacity="0.2" Color="White" />
<SolidColorBrush x:Key="IPv4BoxBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="IPv4BoxDisabledBackground" Opacity="0.04" Color="#E6E8EA" />
<SolidColorBrush x:Key="IPv4BoxFocusBorderBrush" Color="#FF54A9FF" />
<SolidColorBrush x:Key="IPv4BoxSelectionBrush" Color="#FF54A9FF" />
<SolidColorBrush x:Key="IPv4BoxSelectionForeground" Color="White" />
<SolidColorBrush x:Key="IPv4BoxCaretBrush" Color="White" />
</ResourceDictionary>

View File

@@ -1,9 +0,0 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="KeyGestureInputBackground" Opacity="0.12" Color="White" />
<SolidColorBrush x:Key="KeyGestureInputPointeroverBackground" Opacity="0.16" Color="White" />
<SolidColorBrush x:Key="KeyGestureInputPressedBackground" Opacity="0.2" Color="White" />
<SolidColorBrush x:Key="KeyGestureInputBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="KeyGestureInputDisabledBackground" Opacity="0.04" Color="#E6E8EA" />
<SolidColorBrush x:Key="KeyGestureInputFocusBorderBrush" Color="#FF54A9FF" />
</ResourceDictionary>

View File

@@ -1,9 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="NavigationMenuItemDefaultBackground" Color="Transparent" />
<SolidColorBrush x:Key="NavigationMenuItemPointeroverBackground" Opacity="0.12" Color="White" />
<SolidColorBrush x:Key="NavigationMenuItemPressedBackground" Opacity="0.16" Color="White" />
<SolidColorBrush x:Key="NavigationMenuItemSelectedBackground" Opacity="0.2" Color="#54A9FF" />
<SolidColorBrush x:Key="NavigationMenuItemHighlightForeground" Color="#54A9FF" />
<SolidColorBrush x:Key="NavigationMenuItemExpandIconForeground" Opacity="0.62" Color="#F9F9F9" />
</ResourceDictionary>

View File

@@ -8,8 +8,6 @@
<MergeResourceInclude Source="Dialog.axaml" />
<MergeResourceInclude Source="Divider.axaml" />
<MergeResourceInclude Source="DualBadge.axaml" />
<MergeResourceInclude Source="IPv4Box.axaml" />
<MergeResourceInclude Source="KeyGestureInput.axaml" />
<MergeResourceInclude Source="Loading.axaml" />
<MergeResourceInclude Source="NavigationMenu.axaml" />
<MergeResourceInclude Source="NotificationShared.axaml" />

View File

@@ -99,4 +99,5 @@
<!-- Divider -->
<SolidColorBrush x:Key="DividerBorderBrush" Color="{StaticResource WindowTextColor}" />
<SolidColorBrush x:Key="NavigationMenuItemExpandIconForeground" Color="{StaticResource WindowTextColor}" />
</ResourceDictionary>

View File

@@ -1,12 +0,0 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="IPv4BoxBackground" Opacity="0.05" Color="#FF2E3238" />
<SolidColorBrush x:Key="IPv4BoxPointeroverBackground" Opacity="0.09" Color="#FF2E3238" />
<SolidColorBrush x:Key="IPv4BoxPressedBackground" Opacity="0.13" Color="#FF2E3238" />
<SolidColorBrush x:Key="IPv4BoxBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="IPv4BoxDisabledBackground" Opacity="0.02" Color="#2E3238" />
<SolidColorBrush x:Key="IPv4BoxFocusBorderBrush" Color="#FF0077FA" />
<SolidColorBrush x:Key="IPv4BoxSelectionBrush" Color="#FF0077FA" />
<SolidColorBrush x:Key="IPv4BoxSelectionForeground" Color="White" />
<SolidColorBrush x:Key="IPv4BoxCaretBrush" Color="Black" />
</ResourceDictionary>

View File

@@ -1,9 +0,0 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="KeyGestureInputBackground" Opacity="0.05" Color="#FF2E3238" />
<SolidColorBrush x:Key="KeyGestureInputPointeroverBackground" Opacity="0.09" Color="#FF2E3238" />
<SolidColorBrush x:Key="KeyGestureInputPressedBackground" Opacity="0.13" Color="#FF2E3238" />
<SolidColorBrush x:Key="KeyGestureInputBorderBrush" Color="Transparent" />
<SolidColorBrush x:Key="KeyGestureInputDisabledBackground" Opacity="0.02" Color="#2E3238" />
<SolidColorBrush x:Key="KeyGestureInputFocusBorderBrush" Color="#FF0077FA" />
</ResourceDictionary>

View File

@@ -1,9 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<SolidColorBrush x:Key="NavigationMenuItemDefaultBackground" Color="Transparent" />
<SolidColorBrush x:Key="NavigationMenuItemPointeroverBackground" Opacity="0.05" Color="#2E3238" />
<SolidColorBrush x:Key="NavigationMenuItemPressedBackground" Opacity="0.09" Color="#2E3238" />
<SolidColorBrush x:Key="NavigationMenuItemSelectedBackground" Color="#EAF5FF" />
<SolidColorBrush x:Key="NavigationMenuItemHighlightForeground" Color="#0077FA" />
<SolidColorBrush x:Key="NavigationMenuItemExpandIconForeground" Opacity="0.62" Color="#1C1F23" />
</ResourceDictionary>

View File

@@ -1,24 +1,22 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary.MergedDictionaries>
<MergeResourceInclude Source="Avatar.axaml" />
<MergeResourceInclude Source="Badge.axaml" />
<MergeResourceInclude Source="Banner.axaml" />
<MergeResourceInclude Source="ButtonGroup.axaml" />
<MergeResourceInclude Source="DatePicker.axaml" />
<MergeResourceInclude Source="Dialog.axaml" />
<MergeResourceInclude Source="Divider.axaml" />
<MergeResourceInclude Source="DualBadge.axaml" />
<MergeResourceInclude Source="IPv4Box.axaml" />
<MergeResourceInclude Source="KeyGestureInput.axaml" />
<MergeResourceInclude Source="Loading.axaml" />
<MergeResourceInclude Source="NavigationMenu.axaml" />
<MergeResourceInclude Source="NotificationShared.axaml" />
<MergeResourceInclude Source="Pagination.axaml" />
<MergeResourceInclude Source="Rating.axaml" />
<MergeResourceInclude Source="TagInput.axaml" />
<MergeResourceInclude Source="Timeline.axaml" />
<MergeResourceInclude Source="Toast.axaml" />
<MergeResourceInclude Source="Skeleton.axaml" />
<MergeResourceInclude Source="TimeBox.axaml" />
<ResourceInclude Source="Avatar.axaml" />
<ResourceInclude Source="Badge.axaml" />
<ResourceInclude Source="Banner.axaml" />
<ResourceInclude Source="ButtonGroup.axaml" />
<ResourceInclude Source="DatePicker.axaml" />
<ResourceInclude Source="Dialog.axaml" />
<ResourceInclude Source="Divider.axaml" />
<ResourceInclude Source="DualBadge.axaml" />
<ResourceInclude Source="Loading.axaml" />
<ResourceInclude Source="NavigationMenu.axaml" />
<ResourceInclude Source="NotificationShared.axaml" />
<ResourceInclude Source="Pagination.axaml" />
<ResourceInclude Source="Rating.axaml" />
<ResourceInclude Source="TagInput.axaml" />
<ResourceInclude Source="Timeline.axaml" />
<ResourceInclude Source="Toast.axaml" />
<ResourceInclude Source="Skeleton.axaml" />
<ResourceInclude Source="TimeBox.axaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

View File

@@ -1,8 +0,0 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<x:Double x:Key="IPv4BoxDefaultMinHeight">32</x:Double>
<x:Double x:Key="IPv4BoxSmallMinHeight">24</x:Double>
<x:Double x:Key="IPv4BoxLargeMinHeight">40</x:Double>
<Thickness x:Key="IPv4BoxBorderThickness">1</Thickness>
<CornerRadius x:Key="IPv4BoxCornerRadius">3</CornerRadius>
</ResourceDictionary>

View File

@@ -1,7 +0,0 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Add Resources Here -->
<x:Double x:Key="KeyGestureInputWidth">80</x:Double>
<x:Double x:Key="KeyGestureInputHeight">32</x:Double>
<CornerRadius x:Key="KeyGestureInputCornerRadius">3</CornerRadius>
<Thickness x:Key="KeyGestureInputBorderThickness">1</Thickness>
</ResourceDictionary>

View File

@@ -11,8 +11,6 @@
<ResourceInclude Source="Divider.axaml" />
<ResourceInclude Source="Drawer.axaml" />
<ResourceInclude Source="DualBadge.axaml" />
<ResourceInclude Source="IPv4Box.axaml" />
<ResourceInclude Source="KeyGestureInput.axaml" />
<ResourceInclude Source="MessageBox.axaml" />
<ResourceInclude Source="NavigationMenu.axaml" />
<ResourceInclude Source="Notification.axaml" />