-
-
Notifications
You must be signed in to change notification settings - Fork 587
Expand file tree
/
Copy pathThemeHelper.cs
More file actions
39 lines (33 loc) · 1.14 KB
/
ThemeHelper.cs
File metadata and controls
39 lines (33 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
}
}