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