賮賴乇爻鬲 賲賳亘毓

淇鏍囬鏍忎富棰 - Loaded鏃剁珛鍗冲簲鐢ㄥ綋鍓嶄富棰+璁㈤槄鍚庣画鍙樻洿

纾 鏇 6 乇賵夭 倬蹖卮
賵丕賱丿
讴丕賲蹖鬲
997ac14a57

+ 16 - 13
src/YZWater.Avalonia/Views/ViewAView.axaml.cs

@@ -7,18 +7,21 @@ public partial class ViewAView : UserControl
     public ViewAView()
     {
         InitializeComponent();
-        Loaded += (_, _) =>
-        {
-            if (this.FindControl<Border>("TitleBar") is Border titleBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
-            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
-            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
-            if (this.FindControl<Border>("StatusBar") is Border statusBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
-            if (this.FindControl<Border>("RootBorder") is Border root)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
-        };
+        Loaded += (_, _) => ApplyCurrentTheme();
+        YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += ApplyCurrentTheme;
+    }
+
+    private void ApplyCurrentTheme()
+    {
+        if (this.FindControl<Border>("TitleBar") is Border titleBar)
+            titleBar.Background = YZWater.Avalonia.Controls.ThemeHelper.HeaderBg;
+        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+            t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+            s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+        if (this.FindControl<Border>("StatusBar") is Border statusBar)
+            statusBar.Background = YZWater.Avalonia.Controls.ThemeHelper.NavBg;
+        if (this.FindControl<Border>("RootBorder") is Border root)
+            root.Background = YZWater.Avalonia.Controls.ThemeHelper.AppBg;
     }
 }

+ 16 - 13
src/YZWater.Avalonia/Views/ViewBView.axaml.cs

@@ -7,18 +7,21 @@ public partial class ViewBView : UserControl
     public ViewBView()
     {
         InitializeComponent();
-        Loaded += (_, _) =>
-        {
-            if (this.FindControl<Border>("TitleBar") is Border titleBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
-            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
-            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
-            if (this.FindControl<Border>("StatusBar") is Border statusBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
-            if (this.FindControl<Border>("RootBorder") is Border root)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
-        };
+        Loaded += (_, _) => ApplyCurrentTheme();
+        YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += ApplyCurrentTheme;
+    }
+
+    private void ApplyCurrentTheme()
+    {
+        if (this.FindControl<Border>("TitleBar") is Border titleBar)
+            titleBar.Background = YZWater.Avalonia.Controls.ThemeHelper.HeaderBg;
+        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+            t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+            s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+        if (this.FindControl<Border>("StatusBar") is Border statusBar)
+            statusBar.Background = YZWater.Avalonia.Controls.ThemeHelper.NavBg;
+        if (this.FindControl<Border>("RootBorder") is Border root)
+            root.Background = YZWater.Avalonia.Controls.ThemeHelper.AppBg;
     }
 }

+ 16 - 13
src/YZWater.Avalonia/Views/ViewCView.axaml.cs

@@ -7,18 +7,21 @@ public partial class ViewCView : UserControl
     public ViewCView()
     {
         InitializeComponent();
-        Loaded += (_, _) =>
-        {
-            if (this.FindControl<Border>("TitleBar") is Border titleBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
-            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
-            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
-            if (this.FindControl<Border>("StatusBar") is Border statusBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
-            if (this.FindControl<Border>("RootBorder") is Border root)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
-        };
+        Loaded += (_, _) => ApplyCurrentTheme();
+        YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += ApplyCurrentTheme;
+    }
+
+    private void ApplyCurrentTheme()
+    {
+        if (this.FindControl<Border>("TitleBar") is Border titleBar)
+            titleBar.Background = YZWater.Avalonia.Controls.ThemeHelper.HeaderBg;
+        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+            t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+            s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+        if (this.FindControl<Border>("StatusBar") is Border statusBar)
+            statusBar.Background = YZWater.Avalonia.Controls.ThemeHelper.NavBg;
+        if (this.FindControl<Border>("RootBorder") is Border root)
+            root.Background = YZWater.Avalonia.Controls.ThemeHelper.AppBg;
     }
 }

+ 16 - 13
src/YZWater.Avalonia/Views/ViewDView.axaml.cs

@@ -7,18 +7,21 @@ public partial class ViewDView : UserControl
     public ViewDView()
     {
         InitializeComponent();
-        Loaded += (_, _) =>
-        {
-            if (this.FindControl<Border>("TitleBar") is Border titleBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
-            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
-            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
-            if (this.FindControl<Border>("StatusBar") is Border statusBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
-            if (this.FindControl<Border>("RootBorder") is Border root)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
-        };
+        Loaded += (_, _) => ApplyCurrentTheme();
+        YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += ApplyCurrentTheme;
+    }
+
+    private void ApplyCurrentTheme()
+    {
+        if (this.FindControl<Border>("TitleBar") is Border titleBar)
+            titleBar.Background = YZWater.Avalonia.Controls.ThemeHelper.HeaderBg;
+        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+            t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+            s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+        if (this.FindControl<Border>("StatusBar") is Border statusBar)
+            statusBar.Background = YZWater.Avalonia.Controls.ThemeHelper.NavBg;
+        if (this.FindControl<Border>("RootBorder") is Border root)
+            root.Background = YZWater.Avalonia.Controls.ThemeHelper.AppBg;
     }
 }

+ 16 - 13
src/YZWater.Avalonia/Views/ViewEView.axaml.cs

@@ -7,18 +7,21 @@ public partial class ViewEView : UserControl
     public ViewEView()
     {
         InitializeComponent();
-        Loaded += (_, _) =>
-        {
-            if (this.FindControl<Border>("TitleBar") is Border titleBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindTitleBar(titleBar);
-            if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
-            if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
-                YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += () => s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
-            if (this.FindControl<Border>("StatusBar") is Border statusBar)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindStatusBar(statusBar);
-            if (this.FindControl<Border>("RootBorder") is Border root)
-                YZWater.Avalonia.Controls.ThemeBrushBinding.BindContent(root);
-        };
+        Loaded += (_, _) => ApplyCurrentTheme();
+        YZWater.Avalonia.Controls.ThemeHelper.ThemeChanged += ApplyCurrentTheme;
+    }
+
+    private void ApplyCurrentTheme()
+    {
+        if (this.FindControl<Border>("TitleBar") is Border titleBar)
+            titleBar.Background = YZWater.Avalonia.Controls.ThemeHelper.HeaderBg;
+        if (this.FindControl<TextBlock>("TitleText") is TextBlock t)
+            t.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderText;
+        if (this.FindControl<TextBlock>("SubtitleText") is TextBlock s)
+            s.Foreground = YZWater.Avalonia.Controls.ThemeHelper.HeaderSubtext;
+        if (this.FindControl<Border>("StatusBar") is Border statusBar)
+            statusBar.Background = YZWater.Avalonia.Controls.ThemeHelper.NavBg;
+        if (this.FindControl<Border>("RootBorder") is Border root)
+            root.Background = YZWater.Avalonia.Controls.ThemeHelper.AppBg;
     }
 }