From 9a79d7213cf22bccdad74d160e13a93e82e95bb0 Mon Sep 17 00:00:00 2001 From: Zhang Dian <54255897+zdpcdt@users.noreply.github.com> Date: Fri, 7 Jun 2024 18:09:36 +0800 Subject: [PATCH] feat: add property Size. --- demo/Ursa.Demo/Pages/RatingDemo.axaml | 12 +++++++++++- demo/Ursa.Demo/ViewModels/RatingDemoViewModel.cs | 4 ++-- src/Ursa.Themes.Semi/Controls/Rating.axaml | 10 ++++++++-- src/Ursa.Themes.Semi/Themes/Shared/Rating.axaml | 3 +++ src/Ursa/Controls/Rating/Rating.cs | 15 +++++++++++++-- src/Ursa/Controls/Rating/RatingCharacter.cs | 9 +++++++++ 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/demo/Ursa.Demo/Pages/RatingDemo.axaml b/demo/Ursa.Demo/Pages/RatingDemo.axaml index 0344261..770b251 100644 --- a/demo/Ursa.Demo/Pages/RatingDemo.axaml +++ b/demo/Ursa.Demo/Pages/RatingDemo.axaml @@ -28,6 +28,16 @@ Count="{Binding Count}" DefaultValue="{Binding DefaultValue}" /> + - + + \ No newline at end of file diff --git a/src/Ursa.Themes.Semi/Themes/Shared/Rating.axaml b/src/Ursa.Themes.Semi/Themes/Shared/Rating.axaml index aab761e..5065bb6 100644 --- a/src/Ursa.Themes.Semi/Themes/Shared/Rating.axaml +++ b/src/Ursa.Themes.Semi/Themes/Shared/Rating.axaml @@ -1,3 +1,6 @@  + 24 + 16 + 3 4 M10.7525 1.90411C11.1451 0.698628 12.8549 0.698631 13.2475 1.90411L15.2395 8.01946H21.6858C22.9565 8.01946 23.4848 9.64143 22.4568 10.3865L17.2417 14.1659L19.2337 20.2813C19.6263 21.4868 18.2431 22.4892 17.2151 21.7442L12 17.9647L6.78489 21.7442C5.75687 22.4892 4.37368 21.4868 4.76635 20.2813L6.75834 14.1659L1.54323 10.3865C0.515206 9.64142 1.04354 8.01946 2.31425 8.01946H8.76048L10.7525 1.90411Z \ No newline at end of file diff --git a/src/Ursa/Controls/Rating/Rating.cs b/src/Ursa/Controls/Rating/Rating.cs index 08ece69..494ab10 100644 --- a/src/Ursa/Controls/Rating/Rating.cs +++ b/src/Ursa/Controls/Rating/Rating.cs @@ -38,6 +38,9 @@ public class Rating : TemplatedControl public static readonly StyledProperty DefaultValueProperty = AvaloniaProperty.Register(nameof(DefaultValue)); + public static readonly StyledProperty SizeProperty = + AvaloniaProperty.Register(nameof(Size)); + public static readonly StyledProperty ItemTemplateProperty = AvaloniaProperty.Register(nameof(ItemTemplate)); @@ -83,6 +86,12 @@ public class Rating : TemplatedControl set => SetValue(DefaultValueProperty, value); } + public double Size + { + get => GetValue(SizeProperty); + set => SetValue(SizeProperty, value); + } + public IDataTemplate? ItemTemplate { get => GetValue(ItemTemplateProperty); @@ -137,7 +146,8 @@ public class Rating : TemplatedControl Items.Add(new RatingCharacter { Character = Character, - AllowHalf = AllowHalf + AllowHalf = AllowHalf, + Size = Size, }); } } @@ -174,7 +184,8 @@ public class Rating : TemplatedControl Items.Add(new RatingCharacter { Character = Character, - AllowHalf = AllowHalf + AllowHalf = AllowHalf, + Size = Size, } ); } diff --git a/src/Ursa/Controls/Rating/RatingCharacter.cs b/src/Ursa/Controls/Rating/RatingCharacter.cs index 0bfaddc..08f5034 100644 --- a/src/Ursa/Controls/Rating/RatingCharacter.cs +++ b/src/Ursa/Controls/Rating/RatingCharacter.cs @@ -23,6 +23,9 @@ public class RatingCharacter : TemplatedControl public static readonly StyledProperty CharacterProperty = Rating.CharacterProperty.AddOwner(); + public static readonly StyledProperty SizeProperty = + Rating.SizeProperty.AddOwner(); + public bool AllowHalf { get => GetValue(AllowHalfProperty); @@ -35,6 +38,12 @@ public class RatingCharacter : TemplatedControl set => SetValue(CharacterProperty, value); } + public double Size + { + get => GetValue(SizeProperty); + set => SetValue(SizeProperty, value); + } + internal bool IsLast { get; set; } private bool _isHalf;