| | |
| | | |
| | | |
| | | 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)) |
| | |
| | | |
| | | 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 |
| | |
| | | Process141.PlcwritePrinter(1520, 0); |
| | | Process141.PlcwritePrinter(1510, 1); |
| | | } |
| | | catch(Exception ex) |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | } |
| | | public void StartPrint1(string str) |
| | | { |
| | | try |
| | | { |
| | | ttwith = 240; |
| | | ttheigh = 80; |
| | | message = str; |
| | | |
| | | if (string.IsNullOrEmpty(message)) |
| | | { |
| | | message = textBox1.Text; |
| | | } |
| | | |
| | | //this.printDocument1.DefaultPageSettings.PrinterSettings.PrinterName = "Honeywell PX240S (300 dpi)"; |
| | | //this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", ttwith, ttheigh); |
| | | |
| | | //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 |
| | | { |
| | | |
| | | } |
| | | |
| | | int statuscode = GetPrinterStatusCodeInt(); |
| | | string status = GetPrinterStatusMessage(statuscode); |
| | | |
| | | //Config141 |
| | | try |
| | | { |
| | | Process141.PlcwritePrinter(1520, 0); |
| | | Process141.PlcwritePrinter(1510, 1); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | MessageBox.Show(ex.Message); |
| | | } |
| | | } |
| | | |
| | | //C229M2508250500002 |
| | | private void printDocument_Print(object sender, PrintPageEventArgs e) |
| | |
| | | |
| | | 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)); |
| | | |
| | | |
| | | // 在二维码下方画内容文字 |
| | |
| | | // 让文字居中到二维码下方 |
| | | 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); |
| | | } |
| | |
| | | } |
| | | StartPrint(message); |
| | | } |
| | | |
| | | private void button4_Click(object sender, EventArgs e) |
| | | { |
| | | message = textBox1.Text; |
| | | if (string.IsNullOrEmpty(message)) |
| | | { |
| | | MessageBox.Show("打印内容不可为空"); |
| | | return; |
| | | } |
| | | StartPrint1(message); |
| | | } |
| | | |
| | | //预览 |
| | | private void button2_Click(object sender, EventArgs e) |
| | |
| | | |
| | | //bmp.SetResolution(320, 160); |
| | | |
| | | Graphics g = Graphics.FromImage(bmp);//利用该图片对象生成“画板” |
| | | Graphics g = Graphics.FromImage(bmp);//利用该图片对象生成“画板”mo |
| | | |
| | | Font font = new Font("Arial", 8 * Scale);//设置字体颜色 |
| | | Font font2 = new Font("Arial", 11 * Scale);//设置字体颜色 |
| | |
| | | int pronum = 0; |
| | | private void button6_Click(object sender, EventArgs e)//sn,result,zword,zno,entray |
| | | { |
| | | string Msg = Task.Run(() => Process141.mqtt.MESForProduceAsync(new ProductModel() { SN = textBox3.Text, Result = textBox4.Text ,Zword= textBox5.Text}, textBox8.Text, Convert.ToInt32(textBox6.Text), textBox7.Text)).Result; |
| | | string Msg = Task.Run(() => Process141.mqtt.MESForProduceAsync(new ProductModel() { SN = textBox3.Text, Result = textBox4.Text, Zword = textBox5.Text }, textBox8.Text, Convert.ToInt32(textBox6.Text), textBox7.Text)).Result; |
| | | if (Msg == null) |
| | | { |
| | | CommonLogger.LogAsync(DateTime.Now, EnumHelper.LogLevel.Exception, $"RabbitMQ 物料 返回数据为 null"); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | } |