From c401a2f2fd1a509cdeb33e850bb5c2827074af48 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期一, 17 三月 2025 08:44:51 +0800
Subject: [PATCH] 完善框架,新增两个close方法;

---
 Plugin.TestResult/ViewControl.xaml.cs |   52 +++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/Plugin.TestResult/ViewControl.xaml.cs b/Plugin.TestResult/ViewControl.xaml.cs
index be38c85..ef1b83e 100644
--- a/Plugin.TestResult/ViewControl.xaml.cs
+++ b/Plugin.TestResult/ViewControl.xaml.cs
@@ -2,6 +2,7 @@
 using HMI.Core.Util;
 using HMI.ParameterManage.Entity;
 using HMI.ParameterManage.Util;
+using HMI.UI;
 using HMI.UI.Util;
 using log4net;
 using NationalInstruments.TestStand.Interop.API;
@@ -10,6 +11,8 @@
 using Plugin.TestResult_WPF.Util;
 using System;
 using System.Collections.Generic;
+using System.ComponentModel;
+using System.IO;
 using System.Linq;
 using System.Windows;
 using System.Windows.Controls;
@@ -70,6 +73,21 @@
             testResultView.testApp.ExecutionClosed += new _ApplicationMgrEvents_ExecutionClosedEventHandler(this.axApplicationMgr_ExecutionClosed);
         }
 
+        public override void InitFinish()
+        {
+            base.InitFinish();
+            string path = Path.Combine(BaseFolder, "Count.ini");
+            testResultView.SetCountIniPath(path);
+            testResultView.InitMainGrid();
+            LoadProduct();
+            testResultView.InitTestStandEngine();
+        }
+
+        public override void DoClose(object sender, EventArgs e)
+        {
+            testResultView.ReleaseResource();
+        }
+
         private void axApplicationMgr_ExitApplication(object sender, EventArgs e)
         {
         }
@@ -116,17 +134,31 @@
             { }
         }
 
+        private bool isLoaded;
         private void UserControl_Loaded(object sender, RoutedEventArgs e)
         {
-            LoadProduct();
-            testResultView.InitTestStandEngine();
-            Start_Click(null, null);
-            Loaded -= UserControl_Loaded;
+            new MaskWindow(Window.GetWindow(this),
+                (win) =>
+                {
+                    Dispatcher.Invoke(() =>
+                    {
+                        try
+                        {
+                            Start_Click(null, null);
+                            Loaded -= UserControl_Loaded;
+                        }
+                        finally
+                        {
+                            win.Close();
+                        }
+                    });
+                }).Info(LangUtil.Get("Ts.SequenceIsStarting"));
         }
 
         public void LoadProduct()
         {
-            List<ProductData> products = ParameterManager.GetProducts<List<ProductData>>();
+            List<ProductData> products = ParameterManager.GetProducts<List<ProductData>>()
+                ?? new List<ProductData>();
             this.modelSelect.Items.Clear();
             foreach (var prd in products)
             {
@@ -270,6 +302,16 @@
         {
         }
 
+        /// <summary>
+        /// 璁℃暟娓呴浂鎸夐挳浜嬩欢
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void BtnClear_Click(object sender, RoutedEventArgs e)
+        {
+            testResultView.ClearNumber();
+        }
+
 
     }
 }

--
Gitblit v1.9.1