From 36e15d3809664e54539bb4bc0fe0ba96922cb9f9 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 8 Mar 2026 23:48:10 +0800 Subject: [PATCH] Refactor: move CopyStyle to ThemeHelper class Moved the CopyStyle method from Theme to a new static ThemeHelper class for better code organization and reusability. Updated all references in Theme to use ThemeHelper.CopyStyle. Added ThemeHelper.cs and necessary using directives. --- Flow.Launcher.Core/Resource/Theme.cs | 17 +---------------- Flow.Launcher.Core/Resource/ThemeHelper.cs | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 5e0e2894a..8b678e0b9 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -798,7 +798,7 @@ namespace Flow.Launcher.Core.Resource Application.Current.Resources["WindowBorderStyle"] is Style originalStyle) { // Copy the original style, including the base style if it exists - CopyStyle(originalStyle, previewStyle); + ThemeHelper.CopyStyle(originalStyle, previewStyle); } // Apply background color (remove transparency in color) @@ -817,21 +817,6 @@ namespace Flow.Launcher.Core.Resource Application.Current.Resources["PreviewWindowBorderStyle"] = previewStyle; } - private void CopyStyle(Style originalStyle, Style targetStyle) - { - // If the style is based on another style, copy the base style first - if (originalStyle.BasedOn != null) - { - CopyStyle(originalStyle.BasedOn, targetStyle); - } - - // Copy the setters from the original style - foreach (var setter in originalStyle.Setters.OfType()) - { - targetStyle.Setters.Add(new Setter(setter.Property, setter.Value)); - } - } - private void ColorizeWindow(string theme, BackdropTypes backdropType) { var dict = GetThemeResourceDictionary(theme); diff --git a/Flow.Launcher.Core/Resource/ThemeHelper.cs b/Flow.Launcher.Core/Resource/ThemeHelper.cs index dd998e19a..ad7f1c957 100644 --- a/Flow.Launcher.Core/Resource/ThemeHelper.cs +++ b/Flow.Launcher.Core/Resource/ThemeHelper.cs @@ -1,9 +1,26 @@ -using System.Windows.Media; +using System.Linq; +using System.Windows; +using System.Windows.Media; namespace Flow.Launcher.Core.Resource; public static class ThemeHelper { + public static void CopyStyle(Style originalStyle, Style targetStyle) + { + // If the style is based on another style, copy the base style first + if (originalStyle.BasedOn != null) + { + CopyStyle(originalStyle.BasedOn, targetStyle); + } + + // Copy the setters from the original style + foreach (var setter in originalStyle.Setters.OfType()) + { + targetStyle.Setters.Add(new Setter(setter.Property, setter.Value)); + } + } + public static SolidColorBrush GetFreezeSolidColorBrush(Color color) { var brush = new SolidColorBrush(color);