Flow.Launcher/Flow.Launcher.Core/Resource/ThemeHelper.cs
Jack251970 3c82661262 Remove duplicate Margin and Effect setters in theme code
Ensure existing Margin and Effect setters are removed from
newWindowBorderStyle before adding new ones. This prevents
duplicate property setters and ensures only the latest values
are applied.
2026-03-09 18:54:10 +08:00

39 lines
1.1 KiB
C#

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, use the same base style for the target style
if (originalStyle.BasedOn != null)
{
targetStyle.BasedOn = originalStyle.BasedOn;
}
// Copy the setters from the original style
foreach (var setter in originalStyle.Setters.OfType<Setter>())
{
targetStyle.Setters.Add(new Setter(setter.Property, setter.Value));
}
}
public static void ReplaceSetter(Style style, Setter setter)
{
var existingSetter = style.Setters.OfType<Setter>().FirstOrDefault(s => s.Property == setter.Property);
if (existingSetter != null)
style.Setters.Remove(existingSetter);
style.Setters.Add(setter);
}
public static SolidColorBrush GetFrozenSolidColorBrush(Color color)
{
var brush = new SolidColorBrush(color);
brush.Freeze();
return brush;
}
}