Prech谩dza钮 zdrojov茅 k贸dy

褰诲簳淇涓婚鍒囨崲 - ThemeHelper鐩存帴缂撳瓨鐢诲埛锛屽垏鎹㈡椂绔嬪嵆鐢熸晥

纾 鏇 6 dn铆 pred
rodi膷
commit
1083d73652

+ 2 - 2
src/YZWater.Avalonia/App.axaml.cs

@@ -51,7 +51,7 @@ public partial class App : Application
 
         resources[0] = ThemeService.Instance.IsDarkTheme ? _darkTheme : _lightTheme;
 
-        // 閫氱煡鎺т欢閲嶇粯
-        ThemeHelper.NotifyThemeChanged();
+        // 鏇存柊鐢诲埛缂撳瓨骞閫氱煡鎺т欢閲嶇粯
+        ThemeHelper.SetTheme(ThemeService.Instance.IsDarkTheme);
     }
 }

+ 3 - 3
src/YZWater.Avalonia/Controls/FanControl.cs

@@ -54,9 +54,9 @@ public class FanControl : Control
         var cx = bounds.Width / 2; var cy = bounds.Height / 2;
         var radius = Math.Min(bounds.Width, bounds.Height) / 2 - 5;
         var typeface = new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold);
-        var fanColor = IsRunning ? ThemeHelper.Success() : ThemeHelper.TextDisabled();
+        var fanColor = IsRunning ? ThemeHelper.Success : ThemeHelper.TextDisabled;
 
-        context.DrawRectangle(null, new Pen(ThemeHelper.Border(), 2), new Rect(cx - radius, cy - radius, radius * 2, radius * 2));
+        context.DrawRectangle(null, new Pen(ThemeHelper.Border, 2), new Rect(cx - radius, cy - radius, radius * 2, radius * 2));
 
         for (int i = 0; i < 4; i++)
         {
@@ -71,7 +71,7 @@ public class FanControl : Control
 
         if (!string.IsNullOrEmpty(Text))
         {
-            var t = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 10, ThemeHelper.TextPrimary());
+            var t = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 10, ThemeHelper.TextPrimary);
             context.DrawText(t, new Point(cx - t.Width / 2, bounds.Bottom - t.Height - 2));
         }
     }

+ 7 - 7
src/YZWater.Avalonia/Controls/GaugeControl.cs

@@ -36,12 +36,12 @@ public class GaugeControl : Control
         var radius = Math.Min(bounds.Width, bounds.Height) / 2 - 20;
         var typeface = new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold);
 
-        context.DrawEllipse(ThemeHelper.PanelBg(), null, new Rect(cx - radius - 5, cy - radius - 5, (radius + 5) * 2, (radius + 5) * 2));
-        DrawArc(context, new Pen(ThemeHelper.Border(), 8), cx, cy, radius, 135, 270);
+        context.DrawEllipse(ThemeHelper.PanelBg, null, new Rect(cx - radius - 5, cy - radius - 5, (radius + 5) * 2, (radius + 5) * 2));
+        DrawArc(context, new Pen(ThemeHelper.Border, 8), cx, cy, radius, 135, 270);
 
         var normalized = Math.Max(0, Math.Min(1, (Value - MinValue) / (MaxValue - MinValue)));
         var valueAngle = 135 + normalized * 270;
-        var valueColor = ValueColor ?? ThemeHelper.Success();
+        var valueColor = ValueColor ?? ThemeHelper.Success;
         DrawArc(context, new Pen(valueColor, 8), cx, cy, radius, 135, valueAngle - 135);
 
         for (int i = 0; i <= 10; i++)
@@ -50,7 +50,7 @@ public class GaugeControl : Control
             var rad = angle * Math.PI / 180;
             var isMajor = i % 5 == 0;
             var tickLen = isMajor ? 12 : 6;
-            context.DrawLine(new Pen(isMajor ? ThemeHelper.TextPrimary() : ThemeHelper.TextDisabled(), isMajor ? 2 : 1),
+            context.DrawLine(new Pen(isMajor ? ThemeHelper.TextPrimary : ThemeHelper.TextDisabled, isMajor ? 2 : 1),
                 new Point(cx + Math.Cos(rad) * (radius - tickLen), cy + Math.Sin(rad) * (radius - tickLen)),
                 new Point(cx + Math.Cos(rad) * radius, cy + Math.Sin(rad) * radius));
         }
@@ -60,13 +60,13 @@ public class GaugeControl : Control
         context.DrawLine(new Pen(valueColor, 3), new Point(cx, cy), new Point(cx + Math.Cos(pAngle) * pLen, cy + Math.Sin(pAngle) * pLen));
         context.DrawEllipse(valueColor, null, new Rect(cx - 6, cy - 6, 12, 12));
 
-        var titleText = new FormattedText(Title, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 12, ThemeHelper.TextPrimary());
+        var titleText = new FormattedText(Title, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 12, ThemeHelper.TextPrimary);
         context.DrawText(titleText, new Point(cx - titleText.Width / 2, bounds.Y + 5));
 
-        var valText = new FormattedText($"{Value:F1}", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold), 20, ThemeHelper.TextPrimary());
+        var valText = new FormattedText($"{Value:F1}", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold), 20, ThemeHelper.TextPrimary);
         context.DrawText(valText, new Point(cx - valText.Width / 2, cy + radius * 0.3));
 
-        var unitText = new FormattedText(Unit, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), 10, ThemeHelper.TextDisabled());
+        var unitText = new FormattedText(Unit, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Microsoft YaHei"), 10, ThemeHelper.TextDisabled);
         context.DrawText(unitText, new Point(cx - unitText.Width / 2, cy + radius * 0.3 + valText.Height + 2));
     }
 

+ 2 - 2
src/YZWater.Avalonia/Controls/PipeLineControl.cs

@@ -57,8 +57,8 @@ public class PipeLineControl : Control
         base.Render(context);
         var bounds = new Rect(Bounds.Size);
         var pw = PipeWidth;
-        var pipeColor = PipeColor ?? ThemeHelper.Border();
-        var waterColor = WaterColor ?? ThemeHelper.Success();
+        var pipeColor = PipeColor ?? ThemeHelper.Border;
+        var waterColor = WaterColor ?? ThemeHelper.Success;
 
         if (IsHorizontal)
         {

+ 8 - 8
src/YZWater.Avalonia/Controls/PumpControl.cs

@@ -67,21 +67,21 @@ public class PumpControl : Control
         var radius = Math.Min(bounds.Width, bounds.Height) / 2 - 15;
         var typeface = new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold);
 
-        var statusColor = (IsRunning ? RunningColor : StoppedColor) ?? (IsRunning ? ThemeHelper.Success() : ThemeHelper.TextDisabled());
-        var statusBrush = statusColor as SolidColorBrush ?? (IsRunning ? ThemeHelper.Success() as SolidColorBrush : ThemeHelper.TextDisabled() as SolidColorBrush);
+        var statusColor = (IsRunning ? RunningColor : StoppedColor) ?? (IsRunning ? ThemeHelper.Success : ThemeHelper.TextDisabled);
+        var statusBrush = statusColor as SolidColorBrush ?? (IsRunning ? ThemeHelper.Success as SolidColorBrush : ThemeHelper.TextDisabled as SolidColorBrush);
         var statusColorValue = (statusBrush as SolidColorBrush)?.Color ?? Colors.Gray;
 
         if (IsRunning) context.DrawEllipse(new SolidColorBrush(statusColorValue, 0.2), null, new Rect(cx - radius - 8, cy - radius - 8, (radius + 8) * 2, (radius + 8) * 2));
 
-        context.DrawEllipse(null, new Pen(ThemeHelper.Border(), 3), new Rect(cx - radius, cy - radius, radius * 2, radius * 2));
-        context.DrawEllipse(ThemeHelper.PanelBg(), null, new Rect(cx - radius + 3, cy - radius + 3, (radius - 3) * 2, (radius - 3) * 2));
+        context.DrawEllipse(null, new Pen(ThemeHelper.Border, 3), new Rect(cx - radius, cy - radius, radius * 2, radius * 2));
+        context.DrawEllipse(ThemeHelper.PanelBg, null, new Rect(cx - radius + 3, cy - radius + 3, (radius - 3) * 2, (radius - 3) * 2));
 
         for (int i = 0; i < 6; i++)
         {
             var angle = _rotationAngle + 60.0 * i;
             var bx = cx + Math.Cos(angle * Math.PI / 180) * radius * 0.65 * 0.5;
             var by = cy + Math.Sin(angle * Math.PI / 180) * radius * 0.65 * 0.5;
-            var bladeBrush = IsRunning ? new SolidColorBrush(statusColorValue, 200) : ThemeHelper.TextDisabled();
+            var bladeBrush = IsRunning ? new SolidColorBrush(statusColorValue, 200) : ThemeHelper.TextDisabled;
             var rad = angle * Math.PI / 180;
             var cos = Math.Cos(rad); var sin = Math.Sin(rad);
             var transform = new Matrix(cos, sin, -sin, cos, bx - bx * cos + by * sin, by - bx * sin - by * cos);
@@ -90,16 +90,16 @@ public class PumpControl : Control
         }
 
         var cr = radius * 0.25;
-        context.DrawEllipse(IsRunning ? statusColor : ThemeHelper.Border(), null, new Rect(cx - cr, cy - cr, cr * 2, cr * 2));
+        context.DrawEllipse(IsRunning ? statusColor : ThemeHelper.Border, null, new Rect(cx - cr, cy - cr, cr * 2, cr * 2));
         context.DrawEllipse(new SolidColorBrush(Colors.White, 0.3), null, new Rect(cx - cr * 0.5, cy - cr * 0.5, cr, cr));
 
-        var indColor = IsRunning ? ThemeHelper.Success() : ThemeHelper.TextDisabled();
+        var indColor = IsRunning ? ThemeHelper.Success : ThemeHelper.TextDisabled;
         if (IsRunning) context.DrawEllipse(new SolidColorBrush(statusColorValue, 0.3), null, new Rect(bounds.Width - 23, 7, 16, 16));
         context.DrawEllipse(indColor, null, new Rect(bounds.Width - 20, 10, 10, 10));
 
         if (!string.IsNullOrEmpty(Text))
         {
-            var t = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 11, ThemeHelper.TextPrimary());
+            var t = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 11, ThemeHelper.TextPrimary);
             context.DrawText(t, new Point(cx - t.Width / 2, bounds.Bottom - t.Height - 5));
         }
 

+ 4 - 4
src/YZWater.Avalonia/Controls/StatusCard.cs

@@ -31,23 +31,23 @@ public class StatusCard : Control
     {
         base.Render(context);
         var bounds = new Rect(Bounds.Size);
-        var statusColor = IsActive ? (ActiveColor ?? ThemeHelper.Success()) : (InactiveColor ?? ThemeHelper.TextDisabled());
+        var statusColor = IsActive ? (ActiveColor ?? ThemeHelper.Success) : (InactiveColor ?? ThemeHelper.TextDisabled);
         var statusBrush = statusColor as SolidColorBrush;
         var statusColorValue = statusBrush?.Color ?? Colors.Gray;
         var monoTypeface = new Typeface("Consolas, monospace");
         var labelTypeface = new Typeface("Microsoft YaHei");
 
-        context.DrawRectangle(ThemeHelper.PanelBg(), null, bounds);
+        context.DrawRectangle(ThemeHelper.PanelBg, null, bounds);
         context.DrawRectangle(statusColor, null, new Rect(0, 0, 3, bounds.Height));
 
         var ledX = 12.0; var ledY = bounds.Height / 2 - 5;
         if (IsActive) context.DrawEllipse(new SolidColorBrush(statusColorValue, 0.3), null, new Rect(ledX - 3, ledY - 3, 16, 16));
         context.DrawEllipse(statusColor, null, new Rect(ledX, ledY, 10, 10));
 
-        var iconText = new FormattedText(Icon, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, monoTypeface, 11, ThemeHelper.TextPrimary());
+        var iconText = new FormattedText(Icon, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, monoTypeface, 11, ThemeHelper.TextPrimary);
         context.DrawText(iconText, new Point(28, 6));
 
-        var titleText = new FormattedText(Title, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, labelTypeface, 10, ThemeHelper.TextSecondary());
+        var titleText = new FormattedText(Title, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, labelTypeface, 10, ThemeHelper.TextSecondary);
         context.DrawText(titleText, new Point(28, 22));
 
         var statusText = new FormattedText(Status, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, monoTypeface, 9, statusColor);

+ 59 - 48
src/YZWater.Avalonia/Controls/ThemeHelper.cs

@@ -1,66 +1,77 @@
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Controls.ApplicationLifetimes;
 using Avalonia.Media;
 
 namespace YZWater.Avalonia.Controls;
 
 /// <summary>
-/// 涓婚璧勬簮杈呭姪鏂规硶
+/// 涓婚璧勬簮杈呭姪鏂规硶 - 鐩存帴缂撳瓨褰撳墠涓婚鐢诲埛
 /// </summary>
 internal static class ThemeHelper
 {
-    /// <summary>
-    /// 涓婚鍙樻洿浜嬩欢
-    /// </summary>
     public static event Action? ThemeChanged;
+    public static void NotifyThemeChanged() => ThemeChanged?.Invoke();
 
-    /// <summary>
-    /// 瑙﹀彂涓婚鍙樻洿锛堢敱 App.axaml.cs 璋冪敤锛
-    /// </summary>
-    public static void NotifyThemeChanged()
-    {
-        ThemeChanged?.Invoke();
-    }
+    // 鈹鈹鈹 褰撳墠涓婚鐢诲埛缂撳瓨 鈹鈹鈹
+    public static IBrush AppBg { get; private set; } = new SolidColorBrush(Color.Parse("#0A0E14"));
+    public static IBrush SurfaceBg { get; private set; } = new SolidColorBrush(Color.Parse("#111820"));
+    public static IBrush PanelBg { get; private set; } = new SolidColorBrush(Color.Parse("#0D1117"));
+    public static IBrush Border { get; private set; } = new SolidColorBrush(Color.Parse("#1C2333"));
+    public static IBrush TextPrimary { get; private set; } = new SolidColorBrush(Color.Parse("#E6EDF3"));
+    public static IBrush TextSecondary { get; private set; } = new SolidColorBrush(Color.Parse("#9CA3AF"));
+    public static IBrush TextTertiary { get; private set; } = new SolidColorBrush(Color.Parse("#6B7280"));
+    public static IBrush TextDisabled { get; private set; } = new SolidColorBrush(Color.Parse("#4B5563"));
+    public static IBrush Success { get; private set; } = new SolidColorBrush(Color.Parse("#00897B"));
+    public static IBrush Warning { get; private set; } = new SolidColorBrush(Color.Parse("#F59E0B"));
+    public static IBrush Danger { get; private set; } = new SolidColorBrush(Color.Parse("#EF4444"));
+    public static IBrush Info { get; private set; } = new SolidColorBrush(Color.Parse("#3B82F6"));
+    public static IBrush HeaderBg { get; private set; } = new SolidColorBrush(Color.Parse("#111820"));
+    public static IBrush HeaderText { get; private set; } = new SolidColorBrush(Color.Parse("#E6EDF3"));
+    public static IBrush HeaderSubtext { get; private set; } = new SolidColorBrush(Color.Parse("#9CA3AF"));
+    public static IBrush NavBg { get; private set; } = new SolidColorBrush(Color.Parse("#111820"));
 
     /// <summary>
-    /// 浠庡簲鐢ㄨ祫婧愯幏鍙栫敾鍒凤紝鎵句笉鍒板垯杩斿洖榛樿鍊
+    /// 璁剧疆褰撳墠涓婚锛堢敱 App.axaml.cs 璋冪敤锛
     /// </summary>
-    public static IBrush GetBrush(string key, string fallbackHex)
+    public static void SetTheme(bool isDark)
     {
-        try
+        if (isDark)
         {
-            var app = Application.Current;
-            if (app?.Resources?.MergedDictionaries != null)
-            {
-                foreach (var dict in app.Resources.MergedDictionaries)
-                {
-                    if (dict.TryGetResource(key, null, out var value) && value is IBrush brush)
-                        return brush;
-                }
-            }
-            if (app != null && app.Resources.TryGetResource(key, null, out var rootValue) && rootValue is IBrush rootBrush)
-                return rootBrush;
+            AppBg = new SolidColorBrush(Color.Parse("#0A0E14"));
+            SurfaceBg = new SolidColorBrush(Color.Parse("#111820"));
+            PanelBg = new SolidColorBrush(Color.Parse("#0D1117"));
+            Border = new SolidColorBrush(Color.Parse("#1C2333"));
+            TextPrimary = new SolidColorBrush(Color.Parse("#E6EDF3"));
+            TextSecondary = new SolidColorBrush(Color.Parse("#9CA3AF"));
+            TextTertiary = new SolidColorBrush(Color.Parse("#6B7280"));
+            TextDisabled = new SolidColorBrush(Color.Parse("#4B5563"));
+            Success = new SolidColorBrush(Color.Parse("#00897B"));
+            Warning = new SolidColorBrush(Color.Parse("#F59E0B"));
+            Danger = new SolidColorBrush(Color.Parse("#EF4444"));
+            Info = new SolidColorBrush(Color.Parse("#3B82F6"));
+            HeaderBg = new SolidColorBrush(Color.Parse("#111820"));
+            HeaderText = new SolidColorBrush(Color.Parse("#E6EDF3"));
+            HeaderSubtext = new SolidColorBrush(Color.Parse("#9CA3AF"));
+            NavBg = new SolidColorBrush(Color.Parse("#111820"));
+        }
+        else
+        {
+            AppBg = new SolidColorBrush(Color.Parse("#E5E7EB"));
+            SurfaceBg = new SolidColorBrush(Color.Parse("#F3F4F6"));
+            PanelBg = new SolidColorBrush(Color.Parse("#FFFFFF"));
+            Border = new SolidColorBrush(Color.Parse("#9CA3AF"));
+            TextPrimary = new SolidColorBrush(Color.Parse("#111827"));
+            TextSecondary = new SolidColorBrush(Color.Parse("#4B5563"));
+            TextTertiary = new SolidColorBrush(Color.Parse("#6B7280"));
+            TextDisabled = new SolidColorBrush(Color.Parse("#9CA3AF"));
+            Success = new SolidColorBrush(Color.Parse("#047857"));
+            Warning = new SolidColorBrush(Color.Parse("#B45309"));
+            Danger = new SolidColorBrush(Color.Parse("#B91C1C"));
+            Info = new SolidColorBrush(Color.Parse("#1D4ED8"));
+            HeaderBg = new SolidColorBrush(Color.Parse("#1F2937"));
+            HeaderText = new SolidColorBrush(Color.Parse("#F9FAFB"));
+            HeaderSubtext = new SolidColorBrush(Color.Parse("#9CA3AF"));
+            NavBg = new SolidColorBrush(Color.Parse("#F9FAFB"));
         }
-        catch { }
-        return new SolidColorBrush(Color.Parse(fallbackHex));
-    }
 
-    // 甯哥敤蹇嵎鏂规硶
-    public static IBrush AppBg() => GetBrush("AppBgBrush", "#0A0E14");
-    public static IBrush SurfaceBg() => GetBrush("SurfaceBgBrush", "#111820");
-    public static IBrush PanelBg() => GetBrush("PanelBgBrush", "#0D1117");
-    public static IBrush Border() => GetBrush("BorderBrush", "#1C2333");
-    public static IBrush TextPrimary() => GetBrush("TextPrimaryBrush", "#E6EDF3");
-    public static IBrush TextSecondary() => GetBrush("TextSecondaryBrush", "#9CA3AF");
-    public static IBrush TextTertiary() => GetBrush("TextTertiaryBrush", "#6B7280");
-    public static IBrush TextDisabled() => GetBrush("TextDisabledBrush", "#4B5563");
-    public static IBrush Success() => GetBrush("SuccessBrush", "#00897B");
-    public static IBrush Warning() => GetBrush("WarningBrush", "#F59E0B");
-    public static IBrush Danger() => GetBrush("DangerBrush", "#EF4444");
-    public static IBrush Info() => GetBrush("InfoBrush", "#3B82F6");
-    public static IBrush HeaderBg() => GetBrush("HeaderBgBrush", "#111820");
-    public static IBrush HeaderText() => GetBrush("HeaderTextBrush", "#E6EDF3");
-    public static IBrush HeaderSubtext() => GetBrush("HeaderSubtextBrush", "#9CA3AF");
-    public static IBrush NavBg() => GetBrush("NavBgBrush", "#111820");
+        ThemeChanged?.Invoke();
+    }
 }

+ 7 - 7
src/YZWater.Avalonia/Controls/ValveControl.cs

@@ -47,27 +47,27 @@ public class ValveControl : Control
         var size = Math.Min(bounds.Width, bounds.Height) * 0.8;
         var typeface = new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold);
 
-        var bg = BackgroundColor ?? ThemeHelper.Border();
+        var bg = BackgroundColor ?? ThemeHelper.Border;
         context.DrawEllipse(bg, null, new Rect(cx - size / 2, cy - size / 2, size, size));
 
         var handleLen = size * 0.35;
         var handleW = size * 0.15;
-        var vc = ValveColor ?? ThemeHelper.Warning();
+        var vc = ValveColor ?? ThemeHelper.Warning;
         context.DrawRectangle(vc, null, new Rect(cx - handleW / 2, cy - handleLen, handleW, handleLen * 2));
 
         var indSize = size * 0.15;
         var indColor = Status switch
         {
-            ValveStatus.Open => ThemeHelper.Success(),
-            ValveStatus.Middle => ThemeHelper.Warning(),
-            ValveStatus.Closed => ThemeHelper.Danger(),
-            _ => ThemeHelper.TextDisabled()
+            ValveStatus.Open => ThemeHelper.Success,
+            ValveStatus.Middle => ThemeHelper.Warning,
+            ValveStatus.Closed => ThemeHelper.Danger,
+            _ => ThemeHelper.TextDisabled
         };
         context.DrawEllipse(indColor, null, new Rect(cx - indSize / 2, cy - size / 2 - indSize - 5, indSize, indSize));
 
         if (!string.IsNullOrEmpty(Text))
         {
-            var t = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 10, ThemeHelper.TextPrimary());
+            var t = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 10, ThemeHelper.TextPrimary);
             context.DrawText(t, new Point(cx - t.Width / 2, bounds.Bottom - t.Height - 2));
         }
     }

+ 5 - 5
src/YZWater.Avalonia/Controls/WaterTankControl.cs

@@ -45,25 +45,25 @@ public class WaterTankControl : Control
         var typeface = new Typeface("Microsoft YaHei", FontStyle.Normal, FontWeight.Bold);
         var edgeWidth = 3.0;
 
-        context.DrawRectangle(ThemeHelper.PanelBg(), null, bounds);
-        var borderColor = BorderColor ?? ThemeHelper.Border();
+        context.DrawRectangle(ThemeHelper.PanelBg, null, bounds);
+        var borderColor = BorderColor ?? ThemeHelper.Border;
         context.DrawRectangle(null, new Pen(borderColor, edgeWidth), bounds);
 
         var waterHeight = (bounds.Height - edgeWidth * 2) * Math.Max(0, Math.Min(100, WaterLevel)) / 100.0;
         if (waterHeight > 0)
         {
-            var waterColor = WaterColor ?? ThemeHelper.Success();
+            var waterColor = WaterColor ?? ThemeHelper.Success;
             var waterBrush = waterColor is SolidColorBrush sc ? new SolidColorBrush(sc.Color, 0.8) : waterColor;
             context.DrawRectangle(waterBrush, null, new Rect(bounds.X + edgeWidth, bounds.Y + bounds.Height - edgeWidth - waterHeight, bounds.Width - edgeWidth * 2, waterHeight));
         }
 
         if (!string.IsNullOrEmpty(Text))
         {
-            var t = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 12, ThemeHelper.TextPrimary());
+            var t = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 12, ThemeHelper.TextPrimary);
             context.DrawText(t, new Point(bounds.X + (bounds.Width - t.Width) / 2, bounds.Y + edgeWidth + 5));
         }
 
-        var lt = new FormattedText($"{WaterLevel:F1}%", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 14, ThemeHelper.TextPrimary());
+        var lt = new FormattedText($"{WaterLevel:F1}%", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 14, ThemeHelper.TextPrimary);
         var bg = new Rect(bounds.X + (bounds.Width - lt.Width - 10) / 2, bounds.Y + bounds.Height - edgeWidth - lt.Height - 10, lt.Width + 10, lt.Height + 6);
         context.DrawRectangle(new SolidColorBrush(Colors.Black, 0.5), null, bg);
         context.DrawText(lt, new Point(bg.X + 5, bg.Y + 3));