From 19bf97fd8ec4f435e9111d72969c4ebf00d97991 Mon Sep 17 00:00:00 2001
From: C3032 <1057644574@qq.com>
Date: 星期五, 20 三月 2026 11:10:02 +0800
Subject: [PATCH] 读码器功能集成完成

---
 LB_SmartVision/Forms/Pages/BarcodeReaderPage/CreateBarcodeReaderForm.cs |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 117 insertions(+), 0 deletions(-)

diff --git a/LB_SmartVision/Forms/Pages/BarcodeReaderPage/CreateBarcodeReaderForm.cs b/LB_SmartVision/Forms/Pages/BarcodeReaderPage/CreateBarcodeReaderForm.cs
new file mode 100644
index 0000000..363e9df
--- /dev/null
+++ b/LB_SmartVision/Forms/Pages/BarcodeReaderPage/CreateBarcodeReaderForm.cs
@@ -0,0 +1,117 @@
+using LB_VisionProcesses.BarcodeReaders;
+using LB_VisionProcesses.BarcodeReaders.Huayray;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace LB_SmartVision.Forms.Pages.BarcodeReaderPage
+{
+    public partial class CreateBarcodeReaderForm : Form
+    {
+        public BarcodeReaderBase barcodeReader { get; set; }
+        public bool bCreate = false;
+
+        public CreateBarcodeReaderForm(BarcodeReaderBase reader = null)
+        {
+            InitializeComponent();
+            // 绂佹淇敼绐楀彛澶у皬
+            this.FormBorderStyle = FormBorderStyle.FixedDialog;
+            if (reader == null)
+                this.barcodeReader = new HRBarcodeReader();
+            else
+                this.barcodeReader = reader;
+
+            uiButtonCreate.Enabled = false;
+        }
+
+        private void uiButtonTest_Click(object sender, EventArgs e)
+        {
+            uiButtonCreate.Enabled = false;
+
+            if (string.IsNullOrEmpty(uiComboBoxSN.Text))
+                MessageBox.Show($"鍒濆鍖栬鐮佸櫒[{uiComboBoxSN.Text}]涓虹┖!", "寮傚父");
+
+            if (barcodeReader == null)
+            {
+                MessageBox.Show("璇峰厛閫夋嫨璇荤爜鍣ㄥ搧鐗�!", "寮傚父");
+                return;
+            }
+
+            barcodeReader.Close();
+            if (barcodeReader.Open(uiComboBoxSN.Text))
+            {
+                uiButtonCreate.Enabled = true;
+                barcodeReader.Close();
+            }
+            else
+                MessageBox.Show($"鍒濆鍖栬鐮佸櫒[{uiComboBoxSN.Text}]澶辫触!", "寮傚父");
+        }
+
+        private void uiButtonCreate_Click(object sender, EventArgs e)
+        {
+            if (barcodeReader.Open(uiComboBoxSN.Text))
+            {
+                barcodeReader.SN = uiComboBoxSN.Text;
+                bCreate = true;
+                this.Close();
+            }
+            else
+                MessageBox.Show($"鍒濆鍖栬鐮佸櫒[{uiComboBoxSN.Text}]澶辫触!", "寮傚父");
+        }
+
+        private void uiButtonCancel_Click(object sender, EventArgs e)
+        {
+            if (barcodeReader != null)
+                barcodeReader.Close();
+            bCreate = false;
+            this.Close();
+        }
+
+        private void uiComboBoxBrand_MouseClick(object sender, MouseEventArgs e)
+        {
+            uiComboBoxBrand.Items.Clear();
+            foreach (BarcodeReaderBrand brand in Enum.GetValues(typeof(BarcodeReaderBrand)))
+            {
+                if (brand != BarcodeReaderBrand.Unsupported)
+                    uiComboBoxBrand.Items.Add(brand.ToString());
+            }
+        }
+
+        private void uiComboBoxBrand_SelectedIndexChanged(object sender, EventArgs e)
+        {
+            uiButtonCreate.Enabled = false;
+            uiComboBoxSN.Text = string.Empty;
+
+            if (barcodeReader != null)
+                barcodeReader.Close();
+
+            Enum.TryParse<BarcodeReaderBrand>(uiComboBoxBrand.Text, out BarcodeReaderBrand brand);
+            switch (brand)
+            {
+                case BarcodeReaderBrand.Huayray:
+                    barcodeReader = new HRBarcodeReader();
+                    break;
+                default:
+                    return;
+            }
+        }
+
+        private void uiComboBoxSN_MouseClick(object sender, MouseEventArgs e)
+        {
+            uiButtonCreate.Enabled = false;
+            uiComboBoxSN.Text = string.Empty;
+
+            uiComboBoxSN.Items.Clear();
+            var list = barcodeReader.GetDeviceList();
+
+            foreach (string sn in list)
+                uiComboBoxSN.Items.Add(sn);
+        }
+    }
+}

--
Gitblit v1.9.3