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 作为历史根节点
---
Plugin.TestResult/ScannerSetting.xaml.cs | 149 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 149 insertions(+), 0 deletions(-)
diff --git a/Plugin.TestResult/ScannerSetting.xaml.cs b/Plugin.TestResult/ScannerSetting.xaml.cs
new file mode 100644
index 0000000..e6b1717
--- /dev/null
+++ b/Plugin.TestResult/ScannerSetting.xaml.cs
@@ -0,0 +1,149 @@
+锘縰sing HMI.Core.Util;
+using HMI.UI.DpUtil;
+using HMI.UI.Util;
+using HMI.Util;
+using Panuon.WPF.UI;
+using Plugin.TestResult.Model;
+using Plugin.TestResult_WPF;
+using System;
+using System.ComponentModel;
+using System.IO.Ports;
+
+namespace Plugin.TestResult
+{
+ /// <summary>
+ /// ScannerSetting.xaml 鐨勪氦浜掗�昏緫
+ /// </summary>
+ public partial class ScannerSetting : WindowX
+ {
+ public ScannerSetting()
+ {
+ DataContext = this;
+ InitializeComponent();
+ }
+
+ public ScannerConfig Data { get; set; }
+
+ private bool _isProcessing;
+
+ protected override void OnClosing(CancelEventArgs e)
+ {
+ //Press Continue Button
+ if (DialogResult == true)
+ {
+ if (_isProcessing)
+ {
+ e.Cancel = true;
+ return;
+ }
+ var okButton = WindowXModalDialog.GetOKButton(this);
+ try
+ {
+ _isProcessing = true;
+ ButtonHelper.SetIsPending(okButton, true);
+ if (!ValidateForm())
+ {
+ e.Cancel = true;
+ return;
+ }
+
+ SaveOrUpdateData();
+ }
+ catch (Exception ex)
+ {
+ ToastHelper.Error(this, $"Error锛亄ex.Message}");
+ e.Cancel = true;
+ return;
+ }
+ finally
+ {
+ _isProcessing = false;
+ ButtonHelper.SetIsPending(okButton, false);
+ }
+ }
+ base.OnClosing(e);
+ }
+
+
+ private bool ValidateForm()
+ {
+ bool flag = FormGroupHelper.ValidateForm(formPanel);
+ if (flag)
+ {
+ Data.PortName = CbPortName.SelectedItem?.ToString();
+ Data.BaudRate = (int)(NiBaudRate.Value??0);
+ Data.DataBits = (int)(NiDataBits.Value??0);
+ Data.StopBits = (StopBits)CbStopBits.SelectedItem;
+ Data.DtrEnable = CxDtrEnable.IsChecked ?? false;
+ Data.RtsEnable = CxRtsEnable.IsChecked ?? false;
+ }
+ return flag;
+ }
+
+ private bool _isEnabled;
+ public bool SbIsEnabled {
+ get => _isEnabled;
+ set {
+ Set(ref _isEnabled, value);
+ }
+ }
+
+ private string section;
+ public bool? Open(bool showPortName, string section)
+ {
+ string[] ports = SerialPort.GetPortNames();
+ CbPortName.ItemsSource = ports;
+
+ this.section = section;
+ this.Title = section == "Config" ? this.lang("Tr.CommonSetting") : (section + this.lang("Tr.ScannerSetting"));
+ if (showPortName)
+ {
+ FgPortName.Visibility = System.Windows.Visibility.Visible;
+ FormGroupHelper.SetIsRequired(FgPortName, true);
+ SbIsEnabled = false;
+ }
+ else
+ {
+ FgPortName.Visibility = System.Windows.Visibility.Collapsed;
+ FormGroupHelper.SetIsRequired(FgPortName, false);
+ SbIsEnabled = true;
+ }
+
+ var data = ScannerConfig.ReadFromIni(ViewControl.SannerIniFile, "Config");
+ string portName = IniFileHelper.ReadIniData(section, "PortName", "", ViewControl.SannerIniFile);
+ if (string.IsNullOrEmpty(portName)) {
+ if (section.StartsWith("A"))
+ {
+ portName = "COM1";
+ }
+ else {
+ portName = "COM2";
+ }
+ }
+ data.PortName = portName;
+
+ Data = data;
+ CbPortName.SelectedItem = Data.PortName;
+ NiBaudRate.Value = Data.BaudRate;
+ NiDataBits.Value = Data.DataBits;
+ CbStopBits.SelectedItem = Data.StopBits;
+ CxDtrEnable.IsChecked = Data.DtrEnable;
+ CxRtsEnable.IsChecked = Data.RtsEnable;
+ return this.ShowDialog();
+ }
+
+ private void SaveOrUpdateData()
+ {
+ string iniFile = ViewControl.SannerIniFile;
+ IniFileHelper.WriteIniData(section, "PortName", Data.PortName, iniFile);
+ if (section == "Config")
+ {
+ IniFileHelper.WriteIniData(section, "BaudRate", Data.BaudRate.ToString(), iniFile);
+ IniFileHelper.WriteIniData(section, "DataBits", Data.DataBits.ToString(), iniFile);
+ IniFileHelper.WriteIniData(section, "StopBits", Data.StopBits.ToString(), iniFile);
+ IniFileHelper.WriteIniData(section, "DtrEnable", Data.DtrEnable.ToString(), iniFile);
+ IniFileHelper.WriteIniData(section, "RtsEnable", Data.RtsEnable.ToString(), iniFile);
+ }
+ }
+ }
+}
--
Gitblit v1.9.1