mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Refactor: move CopyStyle to ThemeHelper class
Moved the CopyStyle method from Theme to a new static ThemeHelper class for better code organization and reusability. Updated all references in Theme to use ThemeHelper.CopyStyle. Added ThemeHelper.cs and necessary using directives.
This commit is contained in:
parent
ed14c45fd2
commit
36e15d3809
2 changed files with 19 additions and 17 deletions
|
|
@ -798,7 +798,7 @@ namespace Flow.Launcher.Core.Resource
|
||||||
Application.Current.Resources["WindowBorderStyle"] is Style originalStyle)
|
Application.Current.Resources["WindowBorderStyle"] is Style originalStyle)
|
||||||
{
|
{
|
||||||
// Copy the original style, including the base style if it exists
|
// Copy the original style, including the base style if it exists
|
||||||
CopyStyle(originalStyle, previewStyle);
|
ThemeHelper.CopyStyle(originalStyle, previewStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply background color (remove transparency in color)
|
// Apply background color (remove transparency in color)
|
||||||
|
|
@ -817,21 +817,6 @@ namespace Flow.Launcher.Core.Resource
|
||||||
Application.Current.Resources["PreviewWindowBorderStyle"] = previewStyle;
|
Application.Current.Resources["PreviewWindowBorderStyle"] = previewStyle;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CopyStyle(Style originalStyle, Style targetStyle)
|
|
||||||
{
|
|
||||||
// If the style is based on another style, copy the base style first
|
|
||||||
if (originalStyle.BasedOn != null)
|
|
||||||
{
|
|
||||||
CopyStyle(originalStyle.BasedOn, targetStyle);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the setters from the original style
|
|
||||||
foreach (var setter in originalStyle.Setters.OfType<Setter>())
|
|
||||||
{
|
|
||||||
targetStyle.Setters.Add(new Setter(setter.Property, setter.Value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ColorizeWindow(string theme, BackdropTypes backdropType)
|
private void ColorizeWindow(string theme, BackdropTypes backdropType)
|
||||||
{
|
{
|
||||||
var dict = GetThemeResourceDictionary(theme);
|
var dict = GetThemeResourceDictionary(theme);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,26 @@
|
||||||
using System.Windows.Media;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
namespace Flow.Launcher.Core.Resource;
|
namespace Flow.Launcher.Core.Resource;
|
||||||
|
|
||||||
public static class ThemeHelper
|
public static class ThemeHelper
|
||||||
{
|
{
|
||||||
|
public static void CopyStyle(Style originalStyle, Style targetStyle)
|
||||||
|
{
|
||||||
|
// If the style is based on another style, copy the base style first
|
||||||
|
if (originalStyle.BasedOn != null)
|
||||||
|
{
|
||||||
|
CopyStyle(originalStyle.BasedOn, targetStyle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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 GetFreezeSolidColorBrush(Color color)
|
public static SolidColorBrush GetFreezeSolidColorBrush(Color color)
|
||||||
{
|
{
|
||||||
var brush = new SolidColorBrush(color);
|
var brush = new SolidColorBrush(color);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue