From 9d1660270272180cd71147d6ddd53d1382643d2e Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 18:00:14 +0800
Subject: [PATCH] merge: 并入远程 Initial commit 作为历史根节点

---
 WPFProject/UI/ResourceUI.xaml.cs |   91 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 91 insertions(+), 0 deletions(-)

diff --git a/WPFProject/UI/ResourceUI.xaml.cs b/WPFProject/UI/ResourceUI.xaml.cs
new file mode 100644
index 0000000..7efd5f2
--- /dev/null
+++ b/WPFProject/UI/ResourceUI.xaml.cs
@@ -0,0 +1,91 @@
+锘縰sing HMI.Base;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace WPFProject
+{
+    /// <summary>
+    /// ResourceListener.xaml 鐨勪氦浜掗�昏緫
+    /// </summary>
+    public partial class ResourceUI : NotifyControl
+    {
+        private string cpuRate;
+        public string CpuRate
+        {
+            get => cpuRate;
+            set
+            {
+                Set(ref cpuRate, value);
+            }
+        }
+
+        private string remRate;
+        public string RemRate
+        {
+            get => remRate;
+            set
+            {
+                Set(ref remRate, value);
+            }
+        }
+
+        private string totalCpuRate;
+        public string TotalCpuRate
+        {
+            get => totalCpuRate;
+            set
+            {
+                Set(ref totalCpuRate, value);
+            }
+        }
+
+        private string totalRemRate;
+        public string TotalRemRate
+        {
+            get => totalRemRate;
+            set
+            {
+                Set(ref totalRemRate, value);
+            }
+        }
+
+        public ResourceUI()
+        {
+            DataContext = this;
+            InitializeComponent();
+        }
+
+        public void Refresh(object sender, RunTimeState state)
+        {
+            Dispatcher.BeginInvoke(() =>
+            {
+                CpuRate = $"{state.cpuRate:F1}%";
+                SetColor(state.cpuRate, l1);
+                RemRate = $"{state.remRate:F1}%";
+                SetColor(state.remRate, l2);
+
+                TotalCpuRate = $"{state.totalCpuRate:F1}%";
+                SetColor(state.totalCpuRate, l3);
+                TotalRemRate = $"{state.totalRemRate:F1}%";
+                SetColor(state.totalRemRate, l4);
+            }, System.Windows.Threading.DispatcherPriority.Normal);
+        }
+
+        private void SetColor(double val, Label label)
+        {
+            if (val > 80)
+            {
+                label.Background = Brushes.Red;
+            }
+            else if (val > 60)
+            {
+                label.Background = Brushes.Orange;
+            }
+            else
+            {
+                label.Background = Application.Current.FindResource("SecondPrimaryColor") as Brush;
+            }
+        }
+    }
+}

--
Gitblit v1.9.1