From e3d71f94efa5d1fa494ad3c62c430e4fb2534c83 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 1 Mar 2026 14:23:57 +0800 Subject: [PATCH] Refactor window border style creation and copying Replaces GetNewWindowBorderStyle with direct instantiation of a new Style for Border and uses CopyStyle to transfer properties. Removes the old helper method and moves style copying logic inline for improved clarity and maintainability. --- Flow.Launcher.Core/Resource/Theme.cs | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 3a34b867a..a1fc93b31 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -530,7 +530,8 @@ namespace Flow.Launcher.Core.Resource if (windowBorderStyle == null) return; // Get a new unsealed style based on the old one, and copy Resources and Triggers - var newWindowBorderStyle = GetNewWindowBorderStyle(windowBorderStyle); + var newWindowBorderStyle = new Style(typeof(Border)); + CopyStyle(windowBorderStyle, newWindowBorderStyle); // Identify existing Margin to calculate new Margin, and copy other setters Setter existingMarginSetter = null; @@ -599,7 +600,8 @@ namespace Flow.Launcher.Core.Resource if (windowBorderStyle == null) return; // Get a new unsealed style based on the old one, and copy Resources and Triggers - var newWindowBorderStyle = GetNewWindowBorderStyle(windowBorderStyle); + var newWindowBorderStyle = new Style(typeof(Border)); + CopyStyle(windowBorderStyle, newWindowBorderStyle); // Copy Setters, excluding the Effect setter and updating the Margin setter foreach (var setterBase in windowBorderStyle.Setters) @@ -630,21 +632,6 @@ namespace Flow.Launcher.Core.Resource _oldResource["WindowBorderStyle"] = newWindowBorderStyle; } - private static Style GetNewWindowBorderStyle(Style windowBorderStyle) - { - // Create a new unsealed style based on the old one - var newWindowBorderStyle = new Style(windowBorderStyle.TargetType, windowBorderStyle.BasedOn); - - // Copy Resources and Triggers - foreach (var key in windowBorderStyle.Resources.Keys) - newWindowBorderStyle.Resources.Add(key, windowBorderStyle.Resources[key]); - - foreach (var trigger in windowBorderStyle.Triggers) - newWindowBorderStyle.Triggers.Add(trigger); - - return newWindowBorderStyle; - } - public void SetResizeBorderThickness(WindowChrome windowChrome, bool fixedWindowSize) { if (fixedWindowSize)