From 5eff797d5cb5d036bad2958e3497a8821474c8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=AC=E9=87=8C=E5=B0=94=E5=90=89=E5=B4=BD?= Date: Mon, 17 Jun 2024 14:01:01 +0800 Subject: [PATCH 1/3] Add Icon for dialogwindow Add ShowInTaskBar for DialogOptions --- demo/Ursa.Demo/Pages/DialogDemo.axaml | 12 +++++++++ .../ViewModels/DialogDemoViewModel.cs | 17 ++++++++++--- src/Ursa/Controls/Dialog/Dialog.cs | 25 ++++++++++++++++--- .../Controls/Dialog/Options/DialogOptions.cs | 2 ++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/demo/Ursa.Demo/Pages/DialogDemo.axaml b/demo/Ursa.Demo/Pages/DialogDemo.axaml index 7981a93..8ff3534 100644 --- a/demo/Ursa.Demo/Pages/DialogDemo.axaml +++ b/demo/Ursa.Demo/Pages/DialogDemo.axaml @@ -34,6 +34,12 @@ IsVisible="{Binding !#overlay.IsChecked}" OffContent="Regular" OnContent="Modal" /> + + ( - vm); + vm, + options: new DialogOptions + { + ShowInTaskBar = ShowInTaskBar + }); Date = vm.Date; } else { Dialog.ShowCustom( - vm); + vm, + options: new DialogOptions + { + ShowInTaskBar = ShowInTaskBar + }); } } else diff --git a/src/Ursa/Controls/Dialog/Dialog.cs b/src/Ursa/Controls/Dialog/Dialog.cs index aa459d8..655259d 100644 --- a/src/Ursa/Controls/Dialog/Dialog.cs +++ b/src/Ursa/Controls/Dialog/Dialog.cs @@ -1,9 +1,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Controls.Shapes; -using Avalonia.Media; -using Ursa.Common; namespace Ursa.Controls; @@ -34,6 +31,7 @@ public static class Dialog } else { + window.Icon = owner.Icon; window.Show(owner); } } @@ -60,6 +58,7 @@ public static class Dialog } else { + window.Icon = owner.Icon; window.Show(owner); } } @@ -84,11 +83,16 @@ public static class Dialog }; ConfigureDefaultDialogWindow(window, options); owner ??= GetMainWindow(); + window.Icon = owner!.Icon; if (owner is null) { window.Show(); return Task.FromResult(DialogResult.None); } + else + { + window.Icon = owner.Icon; + } return window.ShowDialog(owner); } @@ -114,6 +118,10 @@ public static class Dialog window.Show(); return Task.FromResult(DialogResult.None); } + else + { + window.Icon = owner.Icon; + } return window.ShowDialog(owner); } @@ -143,6 +151,10 @@ public static class Dialog window.Show(); return Task.FromResult(default(TResult)); } + else + { + window.Icon = owner.Icon; + } return window.ShowDialog(owner); } @@ -170,6 +182,11 @@ public static class Dialog window.Show(); return Task.FromResult(default(TResult)); } + else + { + + window.Icon = owner.Icon; + } return window.ShowDialog(owner); } @@ -197,6 +214,7 @@ public static class Dialog window.WindowStartupLocation = options.StartupLocation; window.Title = options.Title; window.IsCloseButtonVisible = options.IsCloseButtonVisible; + window.ShowInTaskbar = options.ShowInTaskBar; if (options.StartupLocation == WindowStartupLocation.Manual) { if (options.Position is not null) @@ -222,6 +240,7 @@ public static class Dialog window.Title = options.Title; window.Buttons = options.Button; window.Mode = options.Mode; + window.ShowInTaskbar = options.ShowInTaskBar; if (options.StartupLocation == WindowStartupLocation.Manual) { if (options.Position is not null) diff --git a/src/Ursa/Controls/Dialog/Options/DialogOptions.cs b/src/Ursa/Controls/Dialog/Options/DialogOptions.cs index f7c3408..e743077 100644 --- a/src/Ursa/Controls/Dialog/Options/DialogOptions.cs +++ b/src/Ursa/Controls/Dialog/Options/DialogOptions.cs @@ -26,4 +26,6 @@ public class DialogOptions public DialogButton Button { get; set; } = DialogButton.OKCancel; public bool IsCloseButtonVisible { get; set; } = true; + + public bool ShowInTaskBar { get; set; } = true; } \ No newline at end of file From fa6899e43229449cc5b5f181b20bb76d727bbbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=AC=E9=87=8C=E5=B0=94=E5=90=89=E5=B4=BD?= Date: Mon, 17 Jun 2024 14:05:11 +0800 Subject: [PATCH 2/3] remove duplicate code --- src/Ursa/Controls/Dialog/Dialog.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Ursa/Controls/Dialog/Dialog.cs b/src/Ursa/Controls/Dialog/Dialog.cs index 655259d..d2d0974 100644 --- a/src/Ursa/Controls/Dialog/Dialog.cs +++ b/src/Ursa/Controls/Dialog/Dialog.cs @@ -83,7 +83,6 @@ public static class Dialog }; ConfigureDefaultDialogWindow(window, options); owner ??= GetMainWindow(); - window.Icon = owner!.Icon; if (owner is null) { window.Show(); From 6f7ca5b36ee19b5d2bcb97d91461bec3742095f9 Mon Sep 17 00:00:00 2001 From: Easley wang Date: Mon, 17 Jun 2024 17:40:26 +0800 Subject: [PATCH 3/3] remove test string --- demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs b/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs index feb199d..b1058c1 100644 --- a/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs +++ b/demo/Ursa.Demo/Dialogs/PlainDialogViewModel.cs @@ -22,7 +22,6 @@ public class PlainDialogViewModel: ObservableObject public PlainDialogViewModel() { - Text = - "千古悠悠 有多少冤魂嗟叹 空怅望人寰无限 丛生哀怨 泣血蝇虫笑苍天 孤帆叠影锁白链 残月升骤起烈烈风 尽吹散 尽吹散 尽吹散 滂沱雨无底涧 涉激流登彼岸 奋力拨云间消得雾患 社稷安抚臣子心 长驱鬼魅不休战 看斜阳照大地阡陌 从头转"; + Text = "I am PlainDialogViewModel!"; } -} \ No newline at end of file +}