quanzhou
2 天以前 86f899fa91e811415614dff1a699141144bfc802
src/Bro.M141.Process/UI/UIPrinter.cs
@@ -51,16 +51,16 @@
        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))
@@ -74,6 +74,14 @@
                this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
                this.printDocument1.Print();
                this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)1";
                this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh);
                this.printDocument1.PrintController = new System.Drawing.Printing.StandardPrintController();
                this.printDocument1.Print();
            }
            catch
            {
@@ -84,8 +92,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);
            }
        }
@@ -121,14 +136,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));
                // 在二维码下方画内容文字
@@ -138,7 +153,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);
                }
@@ -149,16 +164,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);