From 1ca4a5a10afc833713b94f8e6cf6648f418bd30a Mon Sep 17 00:00:00 2001 From: rabbitism Date: Fri, 1 Nov 2024 12:01:38 +0800 Subject: [PATCH 01/26] fix: fix breadcrumb insertion issue. --- src/Ursa/Controls/Breadcrumb/Breadcrumb.cs | 21 ++++++----- .../Controls/Breadcrumb/BreadcrumbItem.cs | 7 ++++ .../BreadcrumbTests/BreadcrumbTests.cs | 35 +++++++++++++++---- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/src/Ursa/Controls/Breadcrumb/Breadcrumb.cs b/src/Ursa/Controls/Breadcrumb/Breadcrumb.cs index a95369c8..9ad968cc 100644 --- a/src/Ursa/Controls/Breadcrumb/Breadcrumb.cs +++ b/src/Ursa/Controls/Breadcrumb/Breadcrumb.cs @@ -5,6 +5,7 @@ using Avalonia.Data; using Avalonia.Layout; using Avalonia.Metadata; +using Avalonia.VisualTree; namespace Ursa.Controls; @@ -84,17 +85,6 @@ protected override Control CreateContainerForItemOverride(object? item, int inde return new BreadcrumbItem(); } - protected override void LogicalChildrenCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e) - { - base.LogicalChildrenCollectionChanged(sender, e); - var breadcrumbItems = LogicalChildren.OfType().ToList(); - for (var i = 0; i < breadcrumbItems.Count; i++) - { - var breadcrumbItem = breadcrumbItems[i]; - breadcrumbItem.SetPseudoClassLast(i == breadcrumbItems.Count - 1); - } - } - protected override void PrepareContainerForItemOverride(Control container, object? item, int index) { if (container is not BreadcrumbItem breadcrumbItem) return; @@ -149,4 +139,13 @@ protected override void PrepareContainerForItemOverride(Control container, objec ITemplate t => t.Build(), _ => separator.ToString() }; + + internal void InvalidateContainers() + { + var breadcrumbItems = this.GetVisualDescendants().OfType().ToList(); + for (var i = 0; i < breadcrumbItems.Count; i++) + { + breadcrumbItems[i].SetPseudoClassLast(i == breadcrumbItems.Count - 1); + } + } } \ No newline at end of file diff --git a/src/Ursa/Controls/Breadcrumb/BreadcrumbItem.cs b/src/Ursa/Controls/Breadcrumb/BreadcrumbItem.cs index 4e93a354..3bb0e5e2 100644 --- a/src/Ursa/Controls/Breadcrumb/BreadcrumbItem.cs +++ b/src/Ursa/Controls/Breadcrumb/BreadcrumbItem.cs @@ -79,4 +79,11 @@ internal void SetPseudoClassLast(bool isLast) { PseudoClasses.Set(PC_Last, isLast); } + + protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) + { + base.OnAttachedToVisualTree(e); + var parent = this.Parent as Breadcrumb; + parent?.InvalidateContainers(); + } } \ No newline at end of file diff --git a/tests/HeadlessTest.Ursa/Controls/BreadcrumbTests/BreadcrumbTests.cs b/tests/HeadlessTest.Ursa/Controls/BreadcrumbTests/BreadcrumbTests.cs index d7d7ed11..9761faef 100644 --- a/tests/HeadlessTest.Ursa/Controls/BreadcrumbTests/BreadcrumbTests.cs +++ b/tests/HeadlessTest.Ursa/Controls/BreadcrumbTests/BreadcrumbTests.cs @@ -2,6 +2,7 @@ using Avalonia.Controls; using Avalonia.Headless.XUnit; using Avalonia.LogicalTree; +using Avalonia.VisualTree; using Ursa.Controls; namespace HeadlessTest.Ursa.Controls; @@ -34,11 +35,11 @@ public void Generated_BreadcrumbItem_Should_Have_Correct_PseudoClasses() var item1 = new TextBlock(); var item2 = new TextBlock(); breadcrumb.Items.Add(item1); - var firstItem = breadcrumb.GetLogicalChildren().OfType().FirstOrDefault(); + var firstItem = breadcrumb.GetVisualDescendants().OfType().FirstOrDefault(); Assert.NotNull(firstItem); Assert.Contains(":last", firstItem.Classes); breadcrumb.Items.Add(item2); - var lastItem = breadcrumb.GetLogicalChildren().OfType().LastOrDefault(); + var lastItem = breadcrumb.GetVisualDescendants().OfType().LastOrDefault(); Assert.NotNull(lastItem); Assert.Contains(":last", lastItem.Classes); Assert.DoesNotContain(":last", firstItem.Classes); @@ -54,16 +55,38 @@ public void BreadcrumbItem_FromItemsSource_Should_Have_Correct_PseudoClasses() var items = new ObservableCollection(); breadcrumb.ItemsSource = items; items.Add("Item 1"); - var item1 = breadcrumb.GetLogicalChildren().OfType().FirstOrDefault(); + var item1 = breadcrumb.GetVisualDescendants().OfType().FirstOrDefault(); Assert.NotNull(item1); Assert.Contains(":last", item1.Classes); items.Add("Item 2"); - var item2 = breadcrumb.GetLogicalChildren().OfType().LastOrDefault(); + var item2 = breadcrumb.GetVisualDescendants().OfType().LastOrDefault(); Assert.NotNull(item2); Assert.Contains(":last", item2.Classes); Assert.DoesNotContain(":last", item1.Classes); } + [AvaloniaFact] + public void BreadcrumbItem_FromItemsSource_Should_Have_Correct_PseudoClasses_When_Insert() + { + var window = new Window(); + var breadcrumb = new Breadcrumb(); + window.Content = breadcrumb; + window.Show(); + var items = new ObservableCollection(); + breadcrumb.ItemsSource = items; + items.Add("Item 1"); + var item1 = breadcrumb.GetVisualDescendants().OfType().FirstOrDefault(); + Assert.NotNull(item1); + Assert.Contains(":last", item1.Classes); + items.Insert(0, "Item 2"); + var item2 = breadcrumb.GetVisualDescendants().OfType().LastOrDefault(); + Assert.NotNull(item2); + Assert.Contains(":last", item2.Classes); + var newItem1 = breadcrumb.GetVisualDescendants().OfType().FirstOrDefault(); + Assert.NotNull(newItem1); + Assert.DoesNotContain(":last", newItem1.Classes); + } + [AvaloniaFact] public void Bulk_Added_BreadcrumbItem_Should_Have_Correct_PseudoClasses() { @@ -77,8 +100,8 @@ public void Bulk_Added_BreadcrumbItem_Should_Have_Correct_PseudoClasses() "Item 2" }; breadcrumb.ItemsSource = items; - var item1 = breadcrumb.GetLogicalChildren().OfType().FirstOrDefault(); - var item2 = breadcrumb.GetLogicalChildren().OfType().LastOrDefault(); + var item1 = breadcrumb.GetVisualDescendants().OfType().FirstOrDefault(); + var item2 = breadcrumb.GetVisualDescendants().OfType().LastOrDefault(); Assert.NotNull(item1); Assert.NotNull(item2); Assert.Contains(":last", item2.Classes); From 6297258e5a03eb236dd1795f34232c7243b87952 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Fri, 1 Nov 2024 12:05:55 +0800 Subject: [PATCH 02/26] feat: add more tests. --- .../BreadcrumbTests/BreadcrumbTests.cs | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tests/HeadlessTest.Ursa/Controls/BreadcrumbTests/BreadcrumbTests.cs b/tests/HeadlessTest.Ursa/Controls/BreadcrumbTests/BreadcrumbTests.cs index 9761faef..1733a316 100644 --- a/tests/HeadlessTest.Ursa/Controls/BreadcrumbTests/BreadcrumbTests.cs +++ b/tests/HeadlessTest.Ursa/Controls/BreadcrumbTests/BreadcrumbTests.cs @@ -25,6 +25,22 @@ public void BreadcrumbItem_Should_Have_Correct_PseudoClasses() Assert.DoesNotContain(":last", item1.Classes); } + [AvaloniaFact] + public void BreadcrumbItem_Should_Have_Correct_PseudoClasses_When_Insert() + { + var window = new Window(); + var breadcrumb = new Breadcrumb(); + window.Content = breadcrumb; + window.Show(); + var item1 = new BreadcrumbItem(); + var item2 = new BreadcrumbItem(); + breadcrumb.Items.Add(item1); + Assert.Contains(":last", item1.Classes); + breadcrumb.Items.Insert(0, item2); + Assert.Contains(":last", item1.Classes); + Assert.DoesNotContain(":last", item2.Classes); + } + [AvaloniaFact] public void Generated_BreadcrumbItem_Should_Have_Correct_PseudoClasses() { @@ -45,6 +61,28 @@ public void Generated_BreadcrumbItem_Should_Have_Correct_PseudoClasses() Assert.DoesNotContain(":last", firstItem.Classes); } + [AvaloniaFact] + public void Generated_BreadcrumbItem_Should_Have_Correct_PseudoClasses_When_Insert() + { + var window = new Window(); + var breadcrumb = new Breadcrumb(); + window.Content = breadcrumb; + window.Show(); + var item1 = new TextBlock(); + var item2 = new TextBlock(); + breadcrumb.Items.Add(item1); + var firstItem = breadcrumb.GetVisualDescendants().OfType().FirstOrDefault(); + Assert.NotNull(firstItem); + Assert.Contains(":last", firstItem.Classes); + breadcrumb.Items.Insert(0, item2); + var lastItem = breadcrumb.GetVisualDescendants().OfType().LastOrDefault(); + Assert.NotNull(lastItem); + Assert.Contains(":last", lastItem.Classes); + firstItem = breadcrumb.GetVisualDescendants().OfType().FirstOrDefault(); + Assert.NotNull(firstItem); + Assert.DoesNotContain(":last", firstItem.Classes); + } + [AvaloniaFact] public void BreadcrumbItem_FromItemsSource_Should_Have_Correct_PseudoClasses() { From ee707cd9779c79f1b00c52a477eb85aa3056b785 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sun, 3 Nov 2024 01:19:42 +0800 Subject: [PATCH 03/26] feat: add styleClass as an option to Dialogs. --- .../ViewModels/DialogDemoViewModel.cs | 1 + src/Ursa/Controls/Dialog/Dialog.cs | 8 +++++++ .../Controls/Dialog/Options/DialogOptions.cs | 1 + .../Dialog/Options/OverlayDialogOptions.cs | 2 ++ src/Ursa/Controls/Dialog/OverlayDialog.cs | 8 +++++++ src/Ursa/Controls/Drawer/Drawer.cs | 9 ++++++++ .../Controls/Drawer/Options/DrawerOptions.cs | 2 ++ src/Ursa/Controls/MessageBox/MessageBox.cs | 21 ++++++++++++++++--- 8 files changed, 49 insertions(+), 3 deletions(-) diff --git a/demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs b/demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs index 59d5da6b..fae0f229 100644 --- a/demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs +++ b/demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs @@ -163,6 +163,7 @@ private async Task ShowDialog() CanDragMove = CanDragMove, IsCloseButtonVisible = IsCloseButtonVisible, CanResize = CanResize, + StyleClass = "Alert", }; string? dialogHostId = IsLocal ? DialogDemoViewModel.LocalHost : null; if (IsModal) diff --git a/src/Ursa/Controls/Dialog/Dialog.cs b/src/Ursa/Controls/Dialog/Dialog.cs index be9d5165..15d7ed54 100644 --- a/src/Ursa/Controls/Dialog/Dialog.cs +++ b/src/Ursa/Controls/Dialog/Dialog.cs @@ -214,6 +214,10 @@ private static void ConfigureDialogWindow(DialogWindow window, DialogOptions? op else window.WindowStartupLocation = WindowStartupLocation.CenterOwner; } + if (!string.IsNullOrWhiteSpace(options.StyleClass)) + { + window.Classes.Add(options.StyleClass); + } } /// @@ -240,5 +244,9 @@ private static void ConfigureDefaultDialogWindow(DefaultDialogWindow window, Dia else window.WindowStartupLocation = WindowStartupLocation.CenterOwner; } + if (!string.IsNullOrWhiteSpace(options.StyleClass)) + { + window.Classes.Add(options.StyleClass); + } } } \ No newline at end of file diff --git a/src/Ursa/Controls/Dialog/Options/DialogOptions.cs b/src/Ursa/Controls/Dialog/Options/DialogOptions.cs index 63645c46..37dce87a 100644 --- a/src/Ursa/Controls/Dialog/Options/DialogOptions.cs +++ b/src/Ursa/Controls/Dialog/Options/DialogOptions.cs @@ -32,4 +32,5 @@ public class DialogOptions public bool CanDragMove { get; set; } = true; public bool CanResize { get; set; } + public string? StyleClass { get; set; } } \ No newline at end of file diff --git a/src/Ursa/Controls/Dialog/Options/OverlayDialogOptions.cs b/src/Ursa/Controls/Dialog/Options/OverlayDialogOptions.cs index 5d99014e..086fc324 100644 --- a/src/Ursa/Controls/Dialog/Options/OverlayDialogOptions.cs +++ b/src/Ursa/Controls/Dialog/Options/OverlayDialogOptions.cs @@ -64,4 +64,6 @@ public class OverlayDialogOptions public int? TopLevelHashCode { get; set; } public bool CanResize { get; set; } + + public string? StyleClass { get; set; } } \ No newline at end of file diff --git a/src/Ursa/Controls/Dialog/OverlayDialog.cs b/src/Ursa/Controls/Dialog/OverlayDialog.cs index 2b4fe52b..15bd7ebf 100644 --- a/src/Ursa/Controls/Dialog/OverlayDialog.cs +++ b/src/Ursa/Controls/Dialog/OverlayDialog.cs @@ -205,6 +205,10 @@ private static void ConfigureCustomDialogControl(CustomDialogControl control, Ov control.IsCloseButtonVisible = options.IsCloseButtonVisible; control.CanLightDismiss = options.CanLightDismiss; control.CanResize = options.CanResize; + if (!string.IsNullOrWhiteSpace(options.StyleClass)) + { + control.Classes.Add(options.StyleClass); + } DialogControlBase.SetCanDragMove(control, options.CanDragMove); } @@ -231,6 +235,10 @@ private static void ConfigureDefaultDialogControl(DefaultDialogControl control, control.CanLightDismiss = options.CanLightDismiss; control.IsCloseButtonVisible = options.IsCloseButtonVisible; control.CanResize = options.CanResize; + if (!string.IsNullOrWhiteSpace(options.StyleClass)) + { + control.Classes.Add(options.StyleClass); + } DialogControlBase.SetCanDragMove(control, options.CanDragMove); } diff --git a/src/Ursa/Controls/Drawer/Drawer.cs b/src/Ursa/Controls/Drawer/Drawer.cs index 1c38fcd8..4deaeaa6 100644 --- a/src/Ursa/Controls/Drawer/Drawer.cs +++ b/src/Ursa/Controls/Drawer/Drawer.cs @@ -217,6 +217,11 @@ private static void ConfigureCustomDrawer(CustomDrawerControl drawer, DrawerOpti if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value; if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value; } + + if (!string.IsNullOrWhiteSpace(options.StyleClass)) + { + drawer.Classes.Add(options.StyleClass!); + } } private static void ConfigureDefaultDrawer(DefaultDrawerControl drawer, DrawerOptions? options) @@ -239,5 +244,9 @@ private static void ConfigureDefaultDrawer(DefaultDrawerControl drawer, DrawerOp if(options.MinHeight is not null) drawer.MinHeight = options.MinHeight.Value; if(options.MaxHeight is not null) drawer.MaxHeight = options.MaxHeight.Value; } + if (!string.IsNullOrWhiteSpace(options.StyleClass)) + { + drawer.Classes.Add(options.StyleClass!); + } } } \ No newline at end of file diff --git a/src/Ursa/Controls/Drawer/Options/DrawerOptions.cs b/src/Ursa/Controls/Drawer/Options/DrawerOptions.cs index 34bdcb48..ec80da7e 100644 --- a/src/Ursa/Controls/Drawer/Options/DrawerOptions.cs +++ b/src/Ursa/Controls/Drawer/Options/DrawerOptions.cs @@ -22,4 +22,6 @@ public class DrawerOptions public int? TopLevelHashCode { get; set; } public bool CanResize { get; set; } + + public string? StyleClass { get; set; } } \ No newline at end of file diff --git a/src/Ursa/Controls/MessageBox/MessageBox.cs b/src/Ursa/Controls/MessageBox/MessageBox.cs index 0e976658..86c059b8 100644 --- a/src/Ursa/Controls/MessageBox/MessageBox.cs +++ b/src/Ursa/Controls/MessageBox/MessageBox.cs @@ -11,7 +11,8 @@ public static async Task ShowAsync( string message, string? title = null, MessageBoxIcon icon = MessageBoxIcon.None, - MessageBoxButton button = MessageBoxButton.OK) + MessageBoxButton button = MessageBoxButton.OK, + string? styleClass = null) { var messageWindow = new MessageBoxWindow(button) { @@ -19,6 +20,10 @@ public static async Task ShowAsync( Title = title, MessageIcon = icon }; + if (!string.IsNullOrWhiteSpace(styleClass)) + { + messageWindow.Classes.Add(styleClass!); + } var lifetime = Application.Current?.ApplicationLifetime; if (lifetime is not IClassicDesktopStyleApplicationLifetime classLifetime) return MessageBoxResult.None; var main = classLifetime.MainWindow; @@ -37,7 +42,8 @@ public static async Task ShowAsync( string message, string title, MessageBoxIcon icon = MessageBoxIcon.None, - MessageBoxButton button = MessageBoxButton.OK) + MessageBoxButton button = MessageBoxButton.OK, + string? styleClass = null) { var messageWindow = new MessageBoxWindow(button) { @@ -45,6 +51,10 @@ public static async Task ShowAsync( Title = title, MessageIcon = icon }; + if (!string.IsNullOrWhiteSpace(styleClass)) + { + messageWindow.Classes.Add(styleClass!); + } var result = await messageWindow.ShowDialog(owner); return result; } @@ -55,7 +65,8 @@ public static async Task ShowOverlayAsync( string? hostId = null, MessageBoxIcon icon = MessageBoxIcon.None, MessageBoxButton button = MessageBoxButton.OK, - int? toplevelHashCode = null) + int? toplevelHashCode = null, + string? styleClass = null) { var host = OverlayDialogManager.GetHost(hostId, toplevelHashCode); if (host is null) return MessageBoxResult.None; @@ -67,6 +78,10 @@ public static async Task ShowOverlayAsync( MessageIcon = icon, [KeyboardNavigation.TabNavigationProperty] = KeyboardNavigationMode.Cycle }; + if (!string.IsNullOrWhiteSpace(styleClass)) + { + messageControl.Classes.Add(styleClass!); + } host.AddModalDialog(messageControl); var result = await messageControl.ShowAsync(); return result; From bad4c90a9d67b2d3361f0386e98374bcbbc81361 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sun, 3 Nov 2024 16:21:10 +0800 Subject: [PATCH 04/26] test: add failing test case for issue 460. --- .../UrsaWindowTests/UrsaWindowTest.cs | 44 +++++++++++++++++++ .../UrsaWindowWithCloseInference.axaml | 11 +++++ .../UrsaWindowWithCloseInference.axaml.cs | 40 +++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowTest.cs create mode 100644 tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowWithCloseInference.axaml create mode 100644 tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowWithCloseInference.axaml.cs diff --git a/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowTest.cs b/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowTest.cs new file mode 100644 index 00000000..101e2d65 --- /dev/null +++ b/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowTest.cs @@ -0,0 +1,44 @@ +using Avalonia.Headless.XUnit; +using Ursa.Controls; + +namespace HeadlessTest.Ursa.Controls.UrsaWindowTests; + +public class UrsaWindowTest +{ + [AvaloniaFact] + public void Default_UrsaWindow_Closing_Is_Called_Once() + { + var ursaWindow = new UrsaWindow(); + ursaWindow.Show(); + int count = 0; + ursaWindow.Closing += (_, _) => count++; + ursaWindow.Close(); + Assert.Equal(1, count); + } + + [AvaloniaFact] + public async void Inferenced_Window_Closing_Called_Once_When_Yes() + { + var window = new UrsaWindowWithCloseInference(); + window.Show(); + int count = 0; + window.Closing += (_, _) => count++; + window.Close(); + window.DialogViewModel.CloseYes(); + Assert.Equal(1, count); + } + + [AvaloniaFact] + public async void Inferenced_Window_Closing_Called_Once_When_No() + { + var window = new UrsaWindowWithCloseInference(); + window.Show(); + int count = 0; + window.Closing += (_, _) => count++; + window.Close(); + window.DialogViewModel.Close(); + Assert.Equal(1, count); + } + + +} \ No newline at end of file diff --git a/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowWithCloseInference.axaml b/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowWithCloseInference.axaml new file mode 100644 index 00000000..2d76a2eb --- /dev/null +++ b/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowWithCloseInference.axaml @@ -0,0 +1,11 @@ + + Hello World + diff --git a/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowWithCloseInference.axaml.cs b/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowWithCloseInference.axaml.cs new file mode 100644 index 00000000..cdbaaaf4 --- /dev/null +++ b/tests/HeadlessTest.Ursa/Controls/UrsaWindowTests/UrsaWindowWithCloseInference.axaml.cs @@ -0,0 +1,40 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Interactivity; +using Avalonia.Markup.Xaml; +using Irihi.Avalonia.Shared.Contracts; +using Ursa.Controls; + +namespace HeadlessTest.Ursa.Controls.UrsaWindowTests; + +public partial class UrsaWindowWithCloseInference : UrsaWindow +{ + public UrsaWindowWithCloseInference() + { + InitializeComponent(); + } + + internal TextBox TextBox = new TextBox(); + internal DialogViewModel DialogViewModel = new DialogViewModel(); + + protected override async Task CanClose() + { + var result = await OverlayDialog.ShowModal(TextBox, DialogViewModel); + return result == DialogResult.Yes; + } +} + +class DialogViewModel : IDialogContext +{ + public void Close() + { + RequestClose?.Invoke(this, DialogResult.No); + } + + public void CloseYes() + { + RequestClose?.Invoke(this, DialogResult.Yes); + } + + public event EventHandler? RequestClose; +} \ No newline at end of file From 0b0db32bfe3737faabc72f17dca2db07dd46652e Mon Sep 17 00:00:00 2001 From: Dameng <313880747@qq.com> Date: Sun, 3 Nov 2024 20:18:56 +0800 Subject: [PATCH 05/26] UrsaWindow Only trigger OnClosing event once when click Close Button --- src/Ursa/Windows/UrsaWindow.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Ursa/Windows/UrsaWindow.cs b/src/Ursa/Windows/UrsaWindow.cs index 17194933..92fd303d 100644 --- a/src/Ursa/Windows/UrsaWindow.cs +++ b/src/Ursa/Windows/UrsaWindow.cs @@ -117,6 +117,7 @@ protected override async void OnClosing(WindowClosingEventArgs e) if (_canClose) { Close(); + return; } } base.OnClosing(e); From 9d394753d7c208678cd7331f07e6060771f34af6 Mon Sep 17 00:00:00 2001 From: rabbitism Date: Sun, 3 Nov 2024 22:26:14 +0800 Subject: [PATCH 06/26] feat: 1. Update dependency. 2. Provide sample for Dialog StyleClass option. --- demo/Ursa.Demo/App.axaml | 11 +- demo/Ursa.Demo/Pages/DialogDemo.axaml | 30 +++ .../ViewModels/DialogDemoViewModel.cs | 5 +- demo/Ursa.Demo/Views/MainWindow.axaml | 18 +- src/Ursa.Themes.Semi/Behaviors/ClassHelper.cs | 69 ------- .../Controls/AutoCompleteBox.axaml | 4 +- src/Ursa.Themes.Semi/Controls/Dialog.axaml | 190 ++++++++++-------- .../Controls/EnumSelector.axaml | 4 +- src/Ursa.Themes.Semi/Styles/PinCode.axaml | 7 +- src/Ursa/Ursa.csproj | 3 +- 10 files changed, 175 insertions(+), 166 deletions(-) delete mode 100644 src/Ursa.Themes.Semi/Behaviors/ClassHelper.cs diff --git a/demo/Ursa.Demo/App.axaml b/demo/Ursa.Demo/App.axaml index ed454560..ccab5426 100644 --- a/demo/Ursa.Demo/App.axaml +++ b/demo/Ursa.Demo/App.axaml @@ -3,9 +3,18 @@ xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:semi="https://irihi.tech/semi" - xmlns:u-semi="https://irihi.tech/ursa/themes/semi"> + xmlns:u-semi="https://irihi.tech/ursa/themes/semi" + xmlns:u="https://irihi.tech/ursa" + xmlns:helpers="clr-namespace:Irihi.Avalonia.Shared.Helpers;assembly=Irihi.Avalonia.Shared"> + + + \ No newline at end of file diff --git a/demo/Ursa.Demo/Pages/DialogDemo.axaml b/demo/Ursa.Demo/Pages/DialogDemo.axaml index 2b4fe183..b50c1ecc 100644 --- a/demo/Ursa.Demo/Pages/DialogDemo.axaml +++ b/demo/Ursa.Demo/Pages/DialogDemo.axaml @@ -51,6 +51,21 @@ IsThreeState="True" /> + + + + + + + + +