From 38577f9813ecf7988cd9b7d414a98b6f7f4b00e8 Mon Sep 17 00:00:00 2001 From: qhy040404 Date: Thu, 7 Mar 2024 13:37:22 +0800 Subject: [PATCH] apply suggestion --- .../Core/Windowing/WindowController.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/WindowController.cs b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/WindowController.cs index 46adc3f5..67949e07 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/WindowController.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/WindowController.cs @@ -122,20 +122,17 @@ internal sealed class WindowController private void OnOptionsPropertyChanged(object? sender, PropertyChangedEventArgs e) { - if (e.PropertyName is nameof(AppOptions.BackdropType)) + if (sender is not AppOptions options) { - if (sender is AppOptions options) - { - UpdateSystemBackdrop(options.BackdropType); - } + return; } - else if (e.PropertyName is nameof(AppOptions.ElementTheme)) + + _ = e.PropertyName switch { - if (sender is AppOptions options) - { - UpdateElementTheme(options.ElementTheme); - } - } + nameof(AppOptions.BackdropType) => UpdateSystemBackdrop(options.BackdropType), + nameof(AppOptions.ElementTheme) => UpdateElementTheme(options.ElementTheme), + _ => false, + }; } private void OnWindowClosed(object sender, WindowEventArgs args) @@ -165,7 +162,7 @@ internal sealed class WindowController } } - private void UpdateSystemBackdrop(BackdropType backdropType) + private bool UpdateSystemBackdrop(BackdropType backdropType) { window.SystemBackdrop = backdropType switch { @@ -175,11 +172,15 @@ internal sealed class WindowController BackdropType.Acrylic => new DesktopAcrylicBackdrop(), _ => null, }; + + return true; } - private void UpdateElementTheme(ElementTheme theme) + private bool UpdateElementTheme(ElementTheme theme) { ((FrameworkElement)window.Content).RequestedTheme = theme; + + return true; } private void UpdateTitleButtonColor()