From 2e54b439c64e0adbb7e010243c1f33aa5fc5f503 Mon Sep 17 00:00:00 2001
From: alielie <alielie@git.com>
Date: 星期二, 11 三月 2025 14:08:57 +0800
Subject: [PATCH] 完善程序; Merge branch 'master' of http://58.211.88.246:3600/r/WPF/WPFProject

---
 Plugin.TestResult/Scanner.xaml.cs |   43 ++++++++++++-------------------------------
 1 files changed, 12 insertions(+), 31 deletions(-)

diff --git a/Plugin.TestResult/Scanner.xaml.cs b/Plugin.TestResult/Scanner.xaml.cs
index 7e80db7..929b47a 100644
--- a/Plugin.TestResult/Scanner.xaml.cs
+++ b/Plugin.TestResult/Scanner.xaml.cs
@@ -1,19 +1,9 @@
-锘縰sing System;
-using System.Collections.Generic;
+锘縰sing HMI.UI.Util;
+using Panuon.WPF.UI;
+using System;
 using System.ComponentModel;
 using System.IO.Ports;
-using System.Linq;
-using System.Runtime.CompilerServices;
-using System.Text;
-using System.Threading.Tasks;
 using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
 
 namespace Plugin.TestResult_WPF
 {
@@ -34,29 +24,14 @@
     /// <summary>
     /// Scanner.xaml 鐨勪氦浜掗�昏緫
     /// </summary>
-    public partial class Scanner : Window, INotifyPropertyChanged
+    public partial class Scanner : 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 { return _title; }
-            set => RaiseAndSetIfchanged(ref _title, value);
+            set => Set(ref _title, value);
         }
 
         public event EventHandler<BarcodeEventArg> FinishBarcode;
@@ -68,7 +43,13 @@
             this.title = title;
             this.DataContext = this;
             InitializeComponent();
+            Loaded += Scanner_Loaded;
+        }
+
+        private void Scanner_Loaded(object sender, RoutedEventArgs e)
+        {
             InitScanner();
+            Loaded -= Scanner_Loaded;
         }
 
         /// <summary>
@@ -112,7 +93,7 @@
             }
             catch (Exception ex)
             {
-                MessageBox.Show($"鍒濆鍖栨壂鐮佹灙澶辫触锛亄ex.StackTrace}");
+                MsgBoxHelper.Error(this, $"鍒濆鍖栨壂鐮佹灙澶辫触锛亄ex.StackTrace}");
             }
         }
 

--
Gitblit v1.9.1