From d63a0f6bea65cef745d916f7d42d283b680c997a Mon Sep 17 00:00:00 2001 From: Dong Bin Date: Sat, 18 Jan 2025 02:02:42 +0800 Subject: [PATCH 1/6] update style. --- demo/Ursa.Demo/Pages/PathPickerDemo.axaml | 32 +++--- .../Controls/PathPicker.axaml | 108 +++++++++++------- src/Ursa/Controls/PathPicker/PathPicker.cs | 18 +-- 3 files changed, 90 insertions(+), 68 deletions(-) diff --git a/demo/Ursa.Demo/Pages/PathPickerDemo.axaml b/demo/Ursa.Demo/Pages/PathPickerDemo.axaml index 50fa8c13..fc6fc0f9 100644 --- a/demo/Ursa.Demo/Pages/PathPickerDemo.axaml +++ b/demo/Ursa.Demo/Pages/PathPickerDemo.axaml @@ -16,7 +16,7 @@ Content="PathPicker aggregates a file selector and provides a Command property. The Command is triggered solely after opening the file selector and selecting a file, whereupon the Command receives an IReadOnlyList<string> parameter."> - + @@ -29,18 +29,19 @@ - - - - - - + + + + + + + @@ -48,11 +49,12 @@ - - + - + + + + + + + + - - - - + + + - + diff --git a/src/Ursa/Controls/PathPicker/PathPicker.cs b/src/Ursa/Controls/PathPicker/PathPicker.cs index e4e69d2e..6cb2b2e7 100644 --- a/src/Ursa/Controls/PathPicker/PathPicker.cs +++ b/src/Ursa/Controls/PathPicker/PathPicker.cs @@ -5,19 +5,17 @@ using Avalonia.Controls.Metadata; using Avalonia.Controls.Primitives; using Avalonia.Data; -using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Logging; using Avalonia.Platform.Storage; -using Avalonia.Threading; -using Irihi.Avalonia.Shared.Common; using Irihi.Avalonia.Shared.Helpers; namespace Ursa.Controls; -[TemplatePart(Name = "PART_Button", Type = typeof(Button))] +[TemplatePart(Name = PART_Button, Type = typeof(Button))] public class PathPicker : TemplatedControl { + public const string PART_Button = "PART_Button"; public static readonly StyledProperty SuggestedStartPathProperty = AvaloniaProperty.Register( nameof(SuggestedStartPath), string.Empty); @@ -185,7 +183,7 @@ protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); Button.ClickEvent.RemoveHandler(LaunchPicker, _button); - _button = e.NameScope.Find + Content="{TemplateBinding Title}" + CornerRadius="{TemplateBinding CornerRadius, + Converter={x:Static converters:CornerRadiusTakeConverter.Left}}" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 68c4cfc36b8754dec1028d3d79f7d14163dc068c Mon Sep 17 00:00:00 2001 From: Dong Bin Date: Sat, 18 Jan 2025 17:00:38 +0800 Subject: [PATCH 3/6] feat: remove comment, add pseudo class. --- src/Ursa/Controls/PathPicker/PathPicker.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Ursa/Controls/PathPicker/PathPicker.cs b/src/Ursa/Controls/PathPicker/PathPicker.cs index 6cb2b2e7..d21b981b 100644 --- a/src/Ursa/Controls/PathPicker/PathPicker.cs +++ b/src/Ursa/Controls/PathPicker/PathPicker.cs @@ -8,11 +8,13 @@ using Avalonia.Interactivity; using Avalonia.Logging; using Avalonia.Platform.Storage; +using Irihi.Avalonia.Shared.Common; using Irihi.Avalonia.Shared.Helpers; namespace Ursa.Controls; [TemplatePart(Name = PART_Button, Type = typeof(Button))] +[PseudoClasses(PseudoClassName.PC_Empty)] public class PathPicker : TemplatedControl { public const string PART_Button = "PART_Button"; @@ -164,14 +166,6 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang { _twoConvertLock = true; string[] separatedStrings = ["\r", "\n", "\r\n"]; - // var list = SelectedPathsText?.Split(separatedStrings, StringSplitOptions.RemoveEmptyEntries) - // .Select(RemoveNewLine).ToArray() - // ?? []; - // if (list.Length == SelectedPaths.Count) - // { - // if (SelectedPaths.Select(x => list.Any(y => x == y)).All(x => x is false)) - // } - SelectedPaths = SelectedPathsText?.Split(separatedStrings, StringSplitOptions.RemoveEmptyEntries) .Select(RemoveNewLine).ToArray() ?? []; @@ -288,9 +282,11 @@ await storageProvider.TryGetFolderFromPathAsync(SuggestedStartPath), default: throw new ArgumentOutOfRangeException(); } - + this.PseudoClasses.Set(PseudoClassName.PC_Empty, SelectedPaths.Count == 0); if (SelectedPaths.Count != 0 || IsOmitCommandOnCancel is false) + { Command?.Execute(SelectedPaths); + } } catch (Exception exception) { From 56c1bbb948720fe342bcf189c75ae4f0f3f2e49a Mon Sep 17 00:00:00 2001 From: Dong Bin Date: Sat, 18 Jan 2025 17:04:08 +0800 Subject: [PATCH 4/6] feat: adjust menu order. --- demo/Ursa.Demo/ViewModels/MenuViewModel.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demo/Ursa.Demo/ViewModels/MenuViewModel.cs b/demo/Ursa.Demo/ViewModels/MenuViewModel.cs index b0afd2a6..ebb38673 100644 --- a/demo/Ursa.Demo/ViewModels/MenuViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/MenuViewModel.cs @@ -12,6 +12,7 @@ public MenuViewModel() { new() { MenuHeader = "Introduction", Key = MenuKeys.MenuKeyIntroduction, IsSeparator = false }, new() { MenuHeader = "Controls", IsSeparator = true }, + new() { MenuHeader = "AspectRatioLayout", Key = MenuKeys.AspectRatioLayout, Status = "New" }, new() { MenuHeader = "AutoCompleteBox", Key = MenuKeys.MenuKeyAutoCompleteBox, Status = "WIP" }, new() { MenuHeader = "Avatar", Key = MenuKeys.MenuKeyAvatar, Status = "WIP" }, new() { MenuHeader = "Badge", Key = MenuKeys.MenuKeyBadge }, @@ -44,6 +45,7 @@ public MenuViewModel() new() { MenuHeader = "Numeric UpDown", Key = MenuKeys.MenuKeyNumericUpDown }, new() { MenuHeader = "NumPad", Key = MenuKeys.MenuKeyNumPad }, new() { MenuHeader = "Pagination", Key = MenuKeys.MenuKeyPagination }, + new() { MenuHeader = "PathPicker", Key = MenuKeys.PathPicker, Status = "WIP" }, new() { MenuHeader = "PinCode", Key = MenuKeys.MenuKeyPinCode }, new() { MenuHeader = "RangeSlider", Key = MenuKeys.MenuKeyRangeSlider }, new() { MenuHeader = "Rating", Key = MenuKeys.MenuKeyRating }, @@ -59,8 +61,7 @@ public MenuViewModel() new() { MenuHeader = "ToolBar", Key = MenuKeys.MenuKeyToolBar }, new() { MenuHeader = "TreeComboBox", Key = MenuKeys.MenuKeyTreeComboBox }, new() { MenuHeader = "TwoTonePathIcon", Key = MenuKeys.MenuKeyTwoTonePathIcon }, - new() { MenuHeader = "AspectRatioLayout", Key = MenuKeys.AspectRatioLayout, Status = "New" }, - new() { MenuHeader = "PathPicker", Key = MenuKeys.PathPicker, Status = "WIP" }, + }; } } From 8ff9aeb1235cd0c4e661f7d0ef8a7a3bc98ee415 Mon Sep 17 00:00:00 2001 From: Dong Bin Date: Sat, 18 Jan 2025 17:26:17 +0800 Subject: [PATCH 5/6] feat: update cursor. --- src/Ursa.Themes.Semi/Controls/PathPicker.axaml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Ursa.Themes.Semi/Controls/PathPicker.axaml b/src/Ursa.Themes.Semi/Controls/PathPicker.axaml index 391e4ca8..b793e407 100644 --- a/src/Ursa.Themes.Semi/Controls/PathPicker.axaml +++ b/src/Ursa.Themes.Semi/Controls/PathPicker.axaml @@ -148,6 +148,7 @@ + Date: Mon, 20 Jan 2025 17:10:04 +0800 Subject: [PATCH 6/6] feat: add watermark. --- demo/Ursa.Demo/Pages/PathPickerDemo.axaml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/demo/Ursa.Demo/Pages/PathPickerDemo.axaml b/demo/Ursa.Demo/Pages/PathPickerDemo.axaml index 599bf082..b28612c3 100644 --- a/demo/Ursa.Demo/Pages/PathPickerDemo.axaml +++ b/demo/Ursa.Demo/Pages/PathPickerDemo.axaml @@ -61,7 +61,14 @@ + u:FormItem.Label="Style Class" > + + + + +