mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
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.
30 lines
853 B
C#
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;
|
|
}
|
|
}
|