From 43be266ad4f6064053f99fd9516c66c754aacc9d Mon Sep 17 00:00:00 2001 From: Mahdi Hosseini Date: Tue, 14 Jan 2025 16:43:52 +0330 Subject: [PATCH] Improve Growl --- dev/DevWinUI.Controls/Controls/Growl/Growl.cs | 18 ++---------------- .../Controls/Growl/GrowlWindow.cs | 14 ++++---------- dev/DevWinUI.Controls/Themes/Generic.xaml | 9 ++++++--- .../Themes/Styles/Controls/Growl.xaml | 11 ++++++++--- 4 files changed, 20 insertions(+), 32 deletions(-) diff --git a/dev/DevWinUI.Controls/Controls/Growl/Growl.cs b/dev/DevWinUI.Controls/Controls/Growl/Growl.cs index 19ea03a7..e7f55f0c 100644 --- a/dev/DevWinUI.Controls/Controls/Growl/Growl.cs +++ b/dev/DevWinUI.Controls/Controls/Growl/Growl.cs @@ -261,24 +261,10 @@ private static void InitGrowlGlobal(GrowlInfo growlInfo, bool isForceSeverity = if (GrowlWindow == null || GrowlWindow.WindowClosed) { GrowlWindow = new GrowlWindow(); - GrowlWindow.Init(); + GrowlWindow.MoveAndResizeWindow(); } - switch (growlInfo.Severity) - { - case InfoBarSeverity.Informational: - ctl.Background = Application.Current.Resources["InfoBarInformationalSeverityBackgroundBrush"] as Brush; - break; - case InfoBarSeverity.Success: - ctl.Background = Application.Current.Resources["InfoBarSuccessSeverityBackgroundBrush"] as Brush; - break; - case InfoBarSeverity.Warning: - ctl.Background = Application.Current.Resources["InfoBarWarningSeverityBackgroundBrush"] as Brush; - break; - case InfoBarSeverity.Error: - ctl.Background = Application.Current.Resources["InfoBarErrorSeverityBackgroundBrush"] as Brush; - break; - } + VisualStateManager.GoToState(ctl, growlInfo.Severity.ToString(), true); SetPanelTransition(GrowlTransition.AddDeleteThemeTransition, GrowlWindow.GrowlPanel); diff --git a/dev/DevWinUI.Controls/Controls/Growl/GrowlWindow.cs b/dev/DevWinUI.Controls/Controls/Growl/GrowlWindow.cs index c4af34db..30994182 100644 --- a/dev/DevWinUI.Controls/Controls/Growl/GrowlWindow.cs +++ b/dev/DevWinUI.Controls/Controls/Growl/GrowlWindow.cs @@ -9,13 +9,12 @@ public partial class GrowlWindow : Window public GrowlWindow() { SystemBackdrop = new TransparentBackdrop(); - - ((OverlappedPresenter)AppWindow.Presenter).SetBorderAndTitleBar(false, false); - ((OverlappedPresenter)AppWindow.Presenter).IsMinimizable = false; - ((OverlappedPresenter)AppWindow.Presenter).IsMaximizable = false; - ((OverlappedPresenter)AppWindow.Presenter).IsResizable = false; + ExtendsContentIntoTitleBar = true; + AppWindow.TitleBar.PreferredHeightOption = Microsoft.UI.Windowing.TitleBarHeightOption.Collapsed; AppWindow.IsShownInSwitchers = false; + WindowHelper.RemoveWindowBorderAndTitleBar(this); + GrowlPanel = new StackPanel { VerticalAlignment = VerticalAlignment.Top, @@ -89,9 +88,4 @@ internal void MoveAndResizeWindow(bool isRightSide = true) AppWindow?.MoveAndResize(position); } } - internal void Init() - { - WindowHelper.SetWindowCornerRadius(this, NativeValues.DWM_WINDOW_CORNER_PREFERENCE.DWMWCP_DONOTROUND); - MoveAndResizeWindow(); - } } diff --git a/dev/DevWinUI.Controls/Themes/Generic.xaml b/dev/DevWinUI.Controls/Themes/Generic.xaml index 9c8a2560..4e14b41e 100644 --- a/dev/DevWinUI.Controls/Themes/Generic.xaml +++ b/dev/DevWinUI.Controls/Themes/Generic.xaml @@ -4405,7 +4405,10 @@ Themes\Styles\Win2D\Watermark.xaml +