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

---
 LB_VisionProcesses/BarcodeReaders/BarcodeReaderForm.cs |   50 +++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 45 insertions(+), 5 deletions(-)

diff --git a/LB_VisionProcesses/BarcodeReaders/BarcodeReaderForm.cs b/LB_VisionProcesses/BarcodeReaders/BarcodeReaderForm.cs
index 34a5867..911612c 100644
--- a/LB_VisionProcesses/BarcodeReaders/BarcodeReaderForm.cs
+++ b/LB_VisionProcesses/BarcodeReaders/BarcodeReaderForm.cs
@@ -22,6 +22,18 @@
             InitializeComponent();
         }
 
+        public BarcodeReaderForm(IBarcodeReader reader)
+        {
+            InitializeComponent();
+            _reader = reader;
+            _reader.BarcodeRead += Reader_BarcodeRead;
+            _currentSN = _reader.IsConnected ? "璁惧宸插湪绾�" : "";
+
+            // 鍚屾 UI 鐘舵��
+            cmbBrand.Text = _reader.Brand.ToString();
+            cmbSN.Text = _reader.IsConnected ? "鍦ㄧ嚎璁惧" : "";
+        }
+
         public BarcodeReaderForm(LB_VisionProcesses.Processes.BarcodeReaderProcess process, string processPath)
         {
             InitializeComponent();
@@ -192,11 +204,11 @@
             {
                 // 鏇存柊缁撴灉鍒楄〃
                 lstBarcodes.Items.Clear();
-                if (e.Barcodes != null && e.Barcodes.Count > 0)
+                if (e.BarcodeInfos != null && e.BarcodeInfos.Count > 0)
                 {
-                    foreach (var code in e.Barcodes)
+                    foreach (var info in e.BarcodeInfos)
                     {
-                        lstBarcodes.Items.Add($"{DateTime.Now:HH:mm:ss} - {code}");
+                        lstBarcodes.Items.Add($"{DateTime.Now:HH:mm:ss} - {info.Text}");
                     }
                 }
                 else
@@ -204,12 +216,40 @@
                     lstBarcodes.Items.Add($"{DateTime.Now:HH:mm:ss} - 鏈鍒版潯鐮�");
                 }
 
-                // 鏇存柊棰勮鍥惧儚
+                // 鏇存柊棰勮鍥惧儚骞剁粯鍒舵爣娉�
                 if (e.Image != null)
                 {
+                    // 鍒涘缓鏂颁綅鍥剧敤浜庣粯鍥撅紝涓嶇洿鎺ヤ慨鏀� SDK 浼犲叆鐨勫師鍥�
+                    Bitmap drawImg = new Bitmap(e.Image);
+                    using (Graphics g = Graphics.FromImage(drawImg))
+                    {
+                        // 璁剧疆缁樺浘璐ㄩ噺
+                        g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+                        
+                        using (Pen pen = new Pen(Color.LimeGreen, 3))
+                        using (SolidBrush brush = new SolidBrush(Color.LimeGreen))
+                        using (Font font = new Font("Arial", 16, FontStyle.Bold))
+                        {
+                            foreach (var info in e.BarcodeInfos)
+                            {
+                                if (info.Points != null && info.Points.Length >= 4)
+                                {
+                                    // 缁樺埗鍥涜竟褰㈡
+                                    g.DrawPolygon(pen, info.Points);
+
+                                    // 鍦ㄧ涓�涓偣涓婃柟缁樺埗鏉$爜鍐呭
+                                    // 璁$畻缁樺埗鏂囨湰鐨勪綅缃紙绋嶅井鍋忕Щ涓�鐐归槻姝㈣鐩栬竟妗嗭級
+                                    Point textPos = info.Points[0];
+                                    textPos.Y -= 25;
+                                    g.DrawString(info.Text, font, brush, textPos);
+                                }
+                            }
+                        }
+                    }
+
                     // 閲婃斁鏃у浘鍍忥紝闃叉鍐呭瓨娉勬紡
                     var oldImg = picPreview.Image;
-                    picPreview.Image = new Bitmap(e.Image); // 鎷疯礉涓�浠介槻姝㈣ SDK 鍐呴儴閲婃斁
+                    picPreview.Image = drawImg;
                     oldImg?.Dispose();
                 }
             }

--
Gitblit v1.9.3