From c1c3772a11b1f3fbad8846cc714120771d85fa53 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期四, 12 六月 2025 20:10:59 +0800
Subject: [PATCH] 新增SeqEditor

---
 Plugin.TestResult/SingleCell.xaml.cs |  115 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 104 insertions(+), 11 deletions(-)

diff --git a/Plugin.TestResult/SingleCell.xaml.cs b/Plugin.TestResult/SingleCell.xaml.cs
index 981c6c9..b8b62a7 100644
--- a/Plugin.TestResult/SingleCell.xaml.cs
+++ b/Plugin.TestResult/SingleCell.xaml.cs
@@ -1,10 +1,12 @@
-锘縰sing Plugin.TestResult_WPF.Constant;
+锘縰sing HMI.Util;
+using Plugin.TestResult_WPF.Constant;
 using Plugin.TestResult_WPF.Model;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.ComponentModel;
+using System.IO;
 using System.Runtime.CompilerServices;
 using System.Windows;
 using System.Windows.Controls;
@@ -42,13 +44,15 @@
             InitializeComponent();
         }
 
-        public SingleCell(string parentName, int index, int maxSize)
+        public SingleCell(string parentName, int index, int maxSize, string iniFile)
         {
             this.parentName = parentName;
             this.index = index;
             this.maxSize = maxSize;
+            this.countIniPath = iniFile;
             DataContext = this;
             InitializeComponent();
+            LoadProbeCount();
         }
 
         private string _parentName;
@@ -74,7 +78,19 @@
             }
         }
 
-        public string title => $"{parentName}{index + 1}";
+        private bool cellIsDisabled;
+
+        public bool CellIsDisabled
+        {
+            get { return cellIsDisabled; }
+            set
+            {
+                RaiseAndSetIfchanged(ref cellIsDisabled, value);
+            }
+        }
+
+
+        public string title => $"{parentName}-{index + 1}";
 
         private string _status = CommonStatus.WAITING;
 
@@ -102,7 +118,7 @@
 
         private ConcurrentQueue<Info> queue = new ConcurrentQueue<Info>();
 
-        private ObservableCollection<Info> _infos;
+        private ObservableCollection<Info> _infos = new ObservableCollection<Info>();
 
         public ObservableCollection<Info> infos
         {
@@ -114,12 +130,44 @@
             }
         }
 
+        private string countIniPath;
+        /// <summary>
+        /// 鎺㈤拡瀵垮懡
+        /// </summary>
+        private int probeCount;
+        public int ProbeCount
+        {
+            get => probeCount;
+            set
+            {
+                RaiseAndSetIfchanged(ref probeCount, value);
+            }
+        }
+
+        public void LoadProbeCount()
+        {
+            string temp = IniFileHelper.ReadIniData($"{title}", "ProbeCount", "", countIniPath);
+            if (!string.IsNullOrEmpty(temp))
+            {
+                int count = Convert.ToInt32(temp);
+                ProbeCount = count;
+            }
+        }
+
+        private void UpdateProbeCount(int count)
+        {
+            ProbeCount = count;
+            IniFileHelper.WriteIniData($"{title}", "ProbeCount", ProbeCount.ToString(), countIniPath);
+            if (window != null) window.UpdateProbeCount(ProbeCount);
+        }
+
         private void UserControl_MouseDoubleClick(object sender, MouseButtonEventArgs e)
         {
             if (window == null)
             {
-                window = new InfoWindow(title, infos);
+                window = new InfoWindow(title, infos, electricChart, ProbeCount);
                 window.Closed += Window_Closed;
+                window.ClearProbeCountEvent += Window_ClearProbeCountEvent;
                 window.Owner = Window.GetWindow(this);
                 window.Show();
             }
@@ -127,6 +175,11 @@
             {
                 window.Activate();
             }
+        }
+
+        private void Window_ClearProbeCountEvent(object sender, EventArgs e)
+        {
+            UpdateProbeCount(0);
         }
 
         private void Window_Closed(object sender, EventArgs e)
@@ -137,12 +190,10 @@
         public void SetStatus(string status)
         {
             this.status = status;
-        }
-
-        public void SetInfos(List<Info> infos)
-        {
-            this.infos = new ObservableCollection<Info>(infos);
-            if (window != null) window.UpdateSource(this.infos);
+            if (status == "testing")
+            {
+                UpdateProbeCount(ProbeCount + 1);
+            }
         }
 
         public void SetInfos(Info info)
@@ -183,5 +234,47 @@
             if (window != null) window.UpdateSource(this.infos);
         }
 
+        private Chart electricChart = new Chart("鐢垫祦鏇茬嚎(A)", false, 20);
+        public void AddElectricData(double data)
+        {
+            electricChart.AddData(data);
+        }
+
+        public void ClearElectricData()
+        {
+            electricChart.Clear();
+        }
+
+        public void SaveElectricDataToCSV(string filePath)
+        {
+            try
+            {
+                List<double> datas = electricChart?.GetSingleData();
+
+                FileInfo fi = new FileInfo(filePath);
+                if (!fi.Directory.Exists)
+                {
+                    fi.Directory.Create();  //鏂囦欢涓嶅瓨鍦紝鍒涘缓鏂囦欢
+                }
+
+                using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write))
+                using (StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8))
+                {
+                    string title = "鐢垫祦鏁版嵁(A)";
+                    sw.WriteLine(title);
+                    if (datas != null)
+                    {
+                        for (int i = 0; i < datas.Count; i++)
+                        {
+                            sw.WriteLine(datas[i].ToString());
+                        }
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.ToString());
+            }
+        }
     }
 }

--
Gitblit v1.9.1