From ca8e01ffa0860101dcee85c225e4d238d86f217b Mon Sep 17 00:00:00 2001 From: rabbitism Date: Tue, 21 Mar 2023 12:02:36 +0800 Subject: [PATCH] feat: add resources --- demo/Ursa.Demo/Pages/DividerDemo.axaml | 30 +++++ demo/Ursa.Demo/Pages/DividerDemo.axaml.cs | 18 +++ demo/Ursa.Demo/Views/MainWindow.axaml | 3 + src/Ursa.Themes.Semi/Controls/Divider.axaml | 125 +++++++++++++++--- src/Ursa.Themes.Semi/Controls/_index.axaml | 1 + .../Themes/Dark/Divider.axaml | 4 + src/Ursa.Themes.Semi/Themes/Dark/_index.axaml | 7 +- .../Themes/Light/Divider.axaml | 4 + .../Themes/Light/_index.axaml | 7 +- .../Themes/Shared/Divider.axaml | 14 ++ .../Themes/Shared/_index.axaml | 7 +- src/Ursa/Controls/Divider.cs | 23 +++- 12 files changed, 212 insertions(+), 31 deletions(-) create mode 100644 demo/Ursa.Demo/Pages/DividerDemo.axaml create mode 100644 demo/Ursa.Demo/Pages/DividerDemo.axaml.cs create mode 100644 src/Ursa.Themes.Semi/Themes/Dark/Divider.axaml create mode 100644 src/Ursa.Themes.Semi/Themes/Light/Divider.axaml create mode 100644 src/Ursa.Themes.Semi/Themes/Shared/Divider.axaml diff --git a/demo/Ursa.Demo/Pages/DividerDemo.axaml b/demo/Ursa.Demo/Pages/DividerDemo.axaml new file mode 100644 index 0000000..bedde3d --- /dev/null +++ b/demo/Ursa.Demo/Pages/DividerDemo.axaml @@ -0,0 +1,30 @@ + + + Center + Left + Right + Center + Stretch + + + + + + + + + + + Stretch + + + diff --git a/demo/Ursa.Demo/Pages/DividerDemo.axaml.cs b/demo/Ursa.Demo/Pages/DividerDemo.axaml.cs new file mode 100644 index 0000000..bdd3bd4 --- /dev/null +++ b/demo/Ursa.Demo/Pages/DividerDemo.axaml.cs @@ -0,0 +1,18 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Markup.Xaml; + +namespace Ursa.Demo.Pages; + +public partial class DividerDemo : UserControl +{ + public DividerDemo() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } +} \ No newline at end of file diff --git a/demo/Ursa.Demo/Views/MainWindow.axaml b/demo/Ursa.Demo/Views/MainWindow.axaml index 613691a..de1f2dd 100644 --- a/demo/Ursa.Demo/Views/MainWindow.axaml +++ b/demo/Ursa.Demo/Views/MainWindow.axaml @@ -29,6 +29,9 @@ + + + diff --git a/src/Ursa.Themes.Semi/Controls/Divider.axaml b/src/Ursa.Themes.Semi/Controls/Divider.axaml index 1b36fb0..be677a7 100644 --- a/src/Ursa.Themes.Semi/Controls/Divider.axaml +++ b/src/Ursa.Themes.Semi/Controls/Divider.axaml @@ -2,22 +2,117 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:u="https://irihi.tech/ursa"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + diff --git a/src/Ursa.Themes.Semi/Controls/_index.axaml b/src/Ursa.Themes.Semi/Controls/_index.axaml index f0db1d0..4d15016 100644 --- a/src/Ursa.Themes.Semi/Controls/_index.axaml +++ b/src/Ursa.Themes.Semi/Controls/_index.axaml @@ -3,6 +3,7 @@ + diff --git a/src/Ursa.Themes.Semi/Themes/Dark/Divider.axaml b/src/Ursa.Themes.Semi/Themes/Dark/Divider.axaml new file mode 100644 index 0000000..1405352 --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Dark/Divider.axaml @@ -0,0 +1,4 @@ + + + + diff --git a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml index f0db1d0..7a530cc 100644 --- a/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Dark/_index.axaml @@ -1,8 +1,9 @@ - - - + + + + diff --git a/src/Ursa.Themes.Semi/Themes/Light/Divider.axaml b/src/Ursa.Themes.Semi/Themes/Light/Divider.axaml new file mode 100644 index 0000000..32b32e8 --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Light/Divider.axaml @@ -0,0 +1,4 @@ + + + + diff --git a/src/Ursa.Themes.Semi/Themes/Light/_index.axaml b/src/Ursa.Themes.Semi/Themes/Light/_index.axaml index f0db1d0..7a530cc 100644 --- a/src/Ursa.Themes.Semi/Themes/Light/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Light/_index.axaml @@ -1,8 +1,9 @@ - - - + + + + diff --git a/src/Ursa.Themes.Semi/Themes/Shared/Divider.axaml b/src/Ursa.Themes.Semi/Themes/Shared/Divider.axaml new file mode 100644 index 0000000..8664705 --- /dev/null +++ b/src/Ursa.Themes.Semi/Themes/Shared/Divider.axaml @@ -0,0 +1,14 @@ + + + 20 + 0 + 40 + 40 + 20 + 20 + 1 + + 1,0 + 0,1 + 8,0 + diff --git a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml index f0db1d0..7a530cc 100644 --- a/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml +++ b/src/Ursa.Themes.Semi/Themes/Shared/_index.axaml @@ -1,8 +1,9 @@ - - - + + + + diff --git a/src/Ursa/Controls/Divider.cs b/src/Ursa/Controls/Divider.cs index 04d457b..497a2de 100644 --- a/src/Ursa/Controls/Divider.cs +++ b/src/Ursa/Controls/Divider.cs @@ -1,17 +1,26 @@ using Avalonia; -using Avalonia.Collections; using Avalonia.Controls; -using Avalonia.Controls.Shapes; +using Avalonia.Layout; namespace Ursa.Controls; public class Divider : ContentControl { - public static readonly StyledProperty?> DashArrayProperty = Shape.StrokeDashArrayProperty.AddOwner(); - - public AvaloniaList? DashArray + static Divider() { - get => GetValue(DashArrayProperty); - set => SetValue(DashArrayProperty, value); + HorizontalContentAlignmentProperty.OverrideDefaultValue(HorizontalAlignment.Center); + } + + public Divider() + { + HorizontalContentAlignment = HorizontalAlignment.Center; + } + + public static readonly StyledProperty OrientationProperty = AvaloniaProperty.Register( + nameof(Orientation)); + public Orientation Orientation + { + get => GetValue(OrientationProperty); + set => SetValue(OrientationProperty, value); } } \ No newline at end of file