From fe2aa4880d5c9fd88088ad0ed81ebaca05629f5f Mon Sep 17 00:00:00 2001
From: wenxiangchao <wenxiangchao@ihengxin.com.cn>
Date: 星期一, 02 十一月 2026 17:59:45 +0800
Subject: [PATCH] feat: 集成CAN驱动/模拟器 + 仪器仪表注册/硬件调试模块

---
 Plugin.TestResult/InfoWindow.xaml.cs |  165 +++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 142 insertions(+), 23 deletions(-)

diff --git a/Plugin.TestResult/InfoWindow.xaml.cs b/Plugin.TestResult/InfoWindow.xaml.cs
index bb085f8..1cb75b9 100644
--- a/Plugin.TestResult/InfoWindow.xaml.cs
+++ b/Plugin.TestResult/InfoWindow.xaml.cs
@@ -1,37 +1,25 @@
-锘縰sing Plugin.TestResult_WPF.Model;
+锘縰sing HMI.Core.Util;
+using HMI.UI.Util;
+using Panuon.WPF.UI;
+using Plugin.TestResult_WPF.Model;
+using System;
 using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Runtime.CompilerServices;
 using System.Windows;
+using System.Windows.Controls;
 
 namespace Plugin.TestResult_WPF
 {
     /// <summary>
     /// InfoWindow.xaml 鐨勪氦浜掗�昏緫
     /// </summary>
-    public partial class InfoWindow : Window, INotifyPropertyChanged
+    public partial class InfoWindow : WindowX
     {
-
-        #region ...
-        public event PropertyChangedEventHandler PropertyChanged;
-
-        public virtual void RaisePropertyChanged(string name)
-        {
-            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
-        }
-
-        public void RaiseAndSetIfchanged<T>(ref T old, T @new, [CallerMemberName] string propertyName = null)
-        {
-            old = @new;
-            if (propertyName != null) RaisePropertyChanged(propertyName);
-        }
-        #endregion
 
         private string _title;
         public string title
         {
             get => _title;
-            set => RaiseAndSetIfchanged(ref _title, value);
+            set => Set(ref _title, value);
         }
 
         private ObservableCollection<Info> _dataSource;
@@ -39,20 +27,151 @@
         public ObservableCollection<Info> dataSource
         {
             get => _dataSource == null ? new ObservableCollection<Info>() : _dataSource;
-            set => RaiseAndSetIfchanged(ref _dataSource, value);
+            set => Set(ref _dataSource, value);
         }
+        private LiveChart waterChart;
+        private LiveChart electricChart;
+        private LiveChart vChart;
 
-        public InfoWindow(string title, ObservableCollection<Info> infos)
+        //public InfoWindow(string title, ObservableCollection<Info> infos, Chart waterChart, Chart electricChart, Chart vChart, int probeCount, int probeWarn)
+        //{
+        //    this.title = title;
+        //    this.dataSource = infos;
+        //    DataContext = this;
+        //    Topmost = false;
+        //    this.ProbeWarn = probeWarn;
+        //    InitializeComponent();
+
+
+        //    UpdateProbeCount(probeCount,probeWarn);
+
+        //    if (waterChart != null)
+        //    {
+        //        this.waterChart = waterChart;
+        //        mainGrid.Children.Add(waterChart);
+        //        Grid.SetRow(waterChart, 1);
+        //    }
+
+        //    this.electricChart = electricChart;
+        //    mainGrid.Children.Add(electricChart);
+        //    Grid.SetRow(electricChart, 2);
+
+
+        //    this.vChart = vChart;
+        //    mainGrid.Children.Add(vChart);
+        //    Grid.SetRow(vChart, 3);
+        //}
+
+        public InfoWindow(string title, ObservableCollection<Info> infos, LiveChart[] charts, int probeCount, int probeWarn)
         {
             this.title = title;
             this.dataSource = infos;
-            this.DataContext = this;
+            DataContext = this;
+            Topmost = false;
+            this.ProbeWarn = probeWarn;
             InitializeComponent();
+
+
+            UpdateProbeCount(probeCount, probeWarn);
+            int row = 1;
+            foreach (var chart in charts)
+            {
+                if (chart == null) return;
+                mainGrid.Children.Add(chart);
+                Grid.SetRow(chart, row++);
+            }
+
+            //if (waterChart != null)
+            //{
+            //    this.waterChart = waterChart;
+            //    mainGrid.Children.Add(waterChart);
+            //    Grid.SetRow(waterChart, 1);
+            //}
+
+            //this.electricChart = electricChart;
+            //mainGrid.Children.Add(electricChart);
+            //Grid.SetRow(electricChart, 2);
+
+            //this.vChart = vChart;
+            //mainGrid.Children.Add(vChart);
+            //Grid.SetRow(vChart, 3);
+        }
+
+        public event EventHandler ClearProbeCountEvent;
+
+        private int probeCount;
+        public int ProbeCount
+        {
+            get => probeCount;
+            set
+            {
+                Set(ref probeCount, value);
+            }
+        }
+
+        public int ProbeWarn
+        {
+            get;
+            set;
+        }
+
+        public void UpdateProbeCount(int count, int warn)
+        {
+            Dispatcher.Invoke(() =>
+            {
+                ProbeCount = count;
+                ProbeWarn = warn;
+
+                if (ProbeWarn < 0)
+                {
+                    alarmLabel.Visibility = Visibility.Collapsed;
+                    alarmValue.Visibility = Visibility.Collapsed;
+                }
+                else
+                {
+                    probeCountAlarm.Visibility = (ProbeCount >= ProbeWarn) ? Visibility.Visible : Visibility.Collapsed;
+                }
+            });
         }
 
         public void UpdateSource(ObservableCollection<Info> infos)
         {
             this.dataSource = infos;
         }
+
+        private void Window_Loaded(object sender, RoutedEventArgs e)
+        {
+            DataContext = this;
+        }
+
+        private void Window_Unloaded(object sender, RoutedEventArgs e)
+        {
+            DataContext = null;
+        }
+
+        protected override void OnClosed(EventArgs e)
+        {
+            waterChart = null;
+            electricChart = null;
+            vChart = null;
+            mainGrid.Children.Clear();
+            base.OnClosed(e);
+        }
+
+        private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
+        {
+            //if (electricChart != null)
+            //{
+            //    electricChart.Height = this.ActualHeight * 0.3;
+            //}
+        }
+
+        private void Button_Click(object sender, RoutedEventArgs e)
+        {
+            if (MsgBoxHelper.WarnMessage(this, this.lang("Ts.MakeSureToClearProbeCount")) == MessageBoxResult.OK)
+            {
+                ClearProbeCountEvent?.Invoke(this, null);
+            }
+        }
     }
 }

--
Gitblit v1.9.1