Flow.Launcher/Flow.Launcher.Core/Resource/ThemeHelper.cs
Jack251970 2bf6e2634c Simplify style copying by setting BasedOn directly
Refactored ThemeHelper.CopyStyle to assign the target style's BasedOn property directly from the original style, instead of recursively copying base style properties. This reduces complexity and ensures correct style inheritance.
2026-03-09 18:17:50 +08:00

30 lines
853 B
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 SolidColorBrush GetFrozenSolidColorBrush(Color color)
{
var brush = new SolidColorBrush(color);
brush.Freeze();
return brush;
}
}