From 745d1ce73a3b27d2a3507843c8060755a0c95765 Mon Sep 17 00:00:00 2001
From: quanzhou <quan.zhou@broconcentric.com>
Date: 星期二, 21 十月 2025 19:06:36 +0800
Subject: [PATCH] 打印机条码格式修改,增添一个点检功能方法

---
 src/Bro.M141.Process/UI/UIPrinter.cs |   59 +++++++++++++++++++++++++++--------------------------------
 1 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/src/Bro.M141.Process/UI/UIPrinter.cs b/src/Bro.M141.Process/UI/UIPrinter.cs
index 1e933c1..59b576c 100644
--- a/src/Bro.M141.Process/UI/UIPrinter.cs
+++ b/src/Bro.M141.Process/UI/UIPrinter.cs
@@ -45,24 +45,22 @@
         {
             base.OnProcessUpdated();
             printDocument1.PrintPage += new PrintPageEventHandler(printDocument_Print);
-
-            Process141.StartPrinter += StartPrint;
             textBox1.Text = "C229M2508250500002";
         }
 
 
 
         PrintDocument printDocument1 = new PrintDocument();
-        int ttwith = (int)(80 * 4);
-        int ttheigh = (int)(40 * 4);
+        int ttwith = (int)(60 * 4);
+        int ttheigh = (int)(20 * 4);
         string message = "";
 
         public void StartPrint(string str)
         {
             try
             {
-                ttwith = 320;
-                ttheigh = 160;
+                ttwith = 240;
+                ttheigh = 80;
                 message = str;
 
                 if (string.IsNullOrEmpty(message))
@@ -86,8 +84,15 @@
             string status = GetPrinterStatusMessage(statuscode);
 
             //Config141
-            Process141.PlcwritePrinter(1520, 0);
-            Process141.PlcwritePrinter(1510, 1);
+            try
+            {
+                Process141.PlcwritePrinter(1520, 0);
+                Process141.PlcwritePrinter(1510, 1);
+            }
+            catch(Exception ex)
+            {
+                MessageBox.Show(ex.Message);
+            }  
         }
 
 
@@ -123,14 +128,14 @@
                 {
                     DisableECI = true,//璁剧疆鍐呭缂栫爜
                     CharacterSet = "UTF-8",  //璁剧疆浜岀淮鐮佺殑瀹藉害鍜岄珮搴�
-                    Width = 123,
-                    Height = 123,
+                    Width = 60,
+                    Height = 60,
                     Margin = 1//璁剧疆浜岀淮鐮佺殑杈硅窛,鍗曚綅涓嶆槸鍥哄畾鍍忕礌
                 };
 
                 writer.Options = options;
                 Bitmap map = writer.Write(numvalue);
-                e.Graphics.DrawImage(map, new System.Drawing.Point(90,10));
+                e.Graphics.DrawImage(map, new System.Drawing.Point(90,4));
 
 
                 // 鍦ㄤ簩缁寸爜涓嬫柟鐢诲唴瀹规枃瀛�
@@ -140,7 +145,7 @@
                     // 璁╂枃瀛楀眳涓埌浜岀淮鐮佷笅鏂�
                     SizeF textSize = e.Graphics.MeasureString(numvalue, font);
                     float textX = 90 + (map.Width - textSize.Width) / 2;
-                    float textY = 10 + map.Height;
+                    float textY = 1 + map.Height;
 
                     e.Graphics.DrawString(numvalue, font, brush3, textX, textY);
                 }
@@ -151,16 +156,16 @@
                 //g.DrawString("鍘傚晢", font, brush, (startX + 20) * Scale, (startY + 5) * Scale);//
                 //g.DrawString("鍢夊桨绉戞妧", font2, brush, (startX + 140) * Scale, (startY + 4) * Scale);
 
-                BarcodeWriter writer = new BarcodeWriter();
-                writer.Format = BarcodeFormat.QR_CODE;
-                QrCodeEncodingOptions options = new QrCodeEncodingOptions()
-                {
-                    DisableECI = true,//璁剧疆鍐呭缂栫爜
-                    CharacterSet = "UTF-8",  //璁剧疆浜岀淮鐮佺殑瀹藉害鍜岄珮搴�
-                    Width = 123,
-                    Height = 123,
-                    Margin = 1//璁剧疆浜岀淮鐮佺殑杈硅窛,鍗曚綅涓嶆槸鍥哄畾鍍忕礌
-                };
+                //BarcodeWriter writer = new BarcodeWriter();
+                //writer.Format = BarcodeFormat.QR_CODE;
+                //QrCodeEncodingOptions options = new QrCodeEncodingOptions()
+                //{
+                //    DisableECI = true,//璁剧疆鍐呭缂栫爜
+                //    CharacterSet = "UTF-8",  //璁剧疆浜岀淮鐮佺殑瀹藉害鍜岄珮搴�
+                //    Width = 123,
+                //    Height = 123,
+                //    Margin = 1//璁剧疆浜岀淮鐮佺殑杈硅窛,鍗曚綅涓嶆槸鍥哄畾鍍忕礌
+                //};
 
                 ////绗簩琛屾暟鎹�
                 //g.DrawRectangle(p, startX * Scale, (startY + 20) * Scale, 70 * Scale, 20 * Scale);
@@ -520,16 +525,6 @@
 
             return bmp;
         }
-
-
-
-
-
-
-
-
-
-
 
 
         #region 

--
Gitblit v1.8.0