/// <summary> /// 绘制一张标签 /// </summary> /// <param name="topx"></param> /// <param name="topy"></param> /// <param name="grap"></param> /// <param name="detail"></param> private void Tag_Draw(int topx, int topy, Graphics grap, OrderLabelDetail detail) { OrderLabelInfo currLable = DictLabel[detail.Sphh]; //Form1.log.InfoFormat("货号:{0} 品名:{1} QRCOE:{2} Spid:{3}", // detail.Sphh, currLable.Pm, detail.Qrcode, detail.Spid); string tm = "http://tm.lilanz.com/tm.aspx?id=" + detail.Qrcode; QRCodeEncoder qrcode = new QRCodeEncoder(); qrcode.QRCodeScale = 1; qrcode.QRCodeVersion = 4; Bitmap bitQR = qrcode.Encode(tm); Image ImgCode128 = Code128Rendering.MakeBarcodeImage(detail.Spid, 1, false); Bitmap bitCode128 = new Bitmap(ImgCode128); /*ean 13*/ Ean13 _ean13 = new Ean13(detail.Tm); _ean13.Scale = 1f; /* * grap.DrawEllipse(pen, topx + 22, topy + 6, 1, 1); * grap.DrawEllipse(penWhite, topx + 22, topy - 8, 1, 1); */ grap.DrawString("合 格 证", FontTitle, brush, new Point(topx + 18, topy + 10)); DrawItem(grap, "品名:", currLable.Pm, topx + 5, topy + 15); DrawItem2(grap, "货号:", detail.Sphh, topx + 5, topy + 18); DrawItem2(grap, "号型:", detail.Hx, topx + 5, topy + 21); DrawMaterial(grap, currLable.Material, topx + 5, topy + 24);//纤维含量 currY += 3; DrawLevel(grap, currLable.Dj, detail.Sn, topx + 5, currY); //等级 currY += 3; DrawStandard(grap, currLable.Zxbz, topx + 5, currY); currY += 3; DrawSecurity(grap, currLable.Aqlb, topx + 5, currY); DrawItemPrice(grap, String.Format("¥{0}", currLable.Lsdj), topx, topy + 63); _ean13.DrawEan13Barcode(grap, new Point(topx + 5, topy + 70));//ean 13 grap.DrawImage(bitCode128, new Rectangle(topx + 4, topy + 80, 38, 6), 0, 0, bitCode128.Width, bitCode128.Height, GraphicsUnit.Pixel); grap.DrawString(detail.Spid, FontCode128, brush, new Point(topx + 8, topy + 86)); grap.DrawString("(仅供内部使用)", font5, brush, new Point(topx + 16, topy + 89)); grap.DrawImage(bitQR, new Rectangle(topx + 16, topy + 92, 13, 13), 0, 0, bitQR.Width, bitQR.Height, GraphicsUnit.Pixel); }
/// <summary> /// 绘制一张标签 /// </summary> /// <param name="topx"></param> /// <param name="topy"></param> /// <param name="grap"></param> /// <param name="detail"></param> private void Tag_Draw(int topx, int topy, Graphics grap, OrderLabelDetail detail) { OrderLabelInfo currLable = DictLabel[detail.Sphh]; CurrentTemp = currLable.Template; string tm = "http://tm.lilanz.com/tm.aspx?id=" + detail.Qrcode; QRCodeEncoder qrcode = new QRCodeEncoder(); qrcode.QRCodeScale = 1; qrcode.QRCodeVersion = 4; Bitmap bitQR = qrcode.Encode(tm); Image ImgCode128 = Code128Rendering.MakeBarcodeImage(detail.Spid, 1, false); Bitmap bitCode128 = new Bitmap(ImgCode128); /*ean 13*/ Ean13 _ean13 = new Ean13(detail.Tm); _ean13.Scale = 1f; /* * grap.DrawEllipse(pen, topx + 22, topy + 6, 1, 1); * grap.DrawEllipse(penWhite, topx + 22, topy - 8, 1, 1); */ //grap.DrawRectangle(pen, topx, topy, LabelWidth, LabelHeigth); grap.DrawString("合 格 证", FontTitle, brush, new Point(topx + (LabelWidth - 8) / 2, topy + 10)); DrawItem(grap, "品名:", currLable.Pm, topx + 5, topy + 15); DrawItem2(grap, "货号:", detail.Sphh, topx + 5, topy + 18); currY = topy + 21; if (detail.Gg == null) { detail.Gg = ""; } if (detail.Hx == null) { detail.Hx = ""; } if (detail.Hx.TrimEnd().Length > 0 || detail.Gg.TrimEnd().Length > 0) { if (detail.Hx.TrimEnd().Length > 0) { DrawItem2(grap, "号型:", detail.Hx, topx + 5, currY); } else { DrawItem2(grap, "规格:", detail.Gg, topx + 5, currY); } currY = currY + 3; } /* * 40mm促销品 */ if (LabelWidth == 40) { DrawItem(grap, "颜色:", currLable.Iname.Split('-')[1], topx + 5, currY); currY = currY + 3; } if (currLable.Template.TrimEnd().ToUpper() != "K") { DrawMaterial(grap, "纤维含量:", currLable.Material, topx + 5, currY);//纤维含量 } else { DrawMaterial(grap, "材质:", currLable.Material, topx + 5, currY);//纤维含量 currY += 3; DrawItem(grap, "生产日期:", currLable.ProDate.ToString("yyyy-MM-dd"), topx + 5, currY); /* * J版需要打生产日期、商标 */ } currY += 3; DrawLevel(grap, currLable.Dj, detail.Sn, topx + 5, currY); //等级 currY += 3; DrawStandard(grap, currLable.Zxbz, topx + 5, currY); currY += 3; DrawSecurity(grap, currLable.Aqlb, topx + 5, currY); currY = topy + (LabelHeigth - 43); DrawItemPrice(grap, String.Format("¥{0}", currLable.Lsdj), topx, currY); _ean13.DrawEan13Barcode(grap, new Point(topx + (LabelWidth - 36) / 2, currY));//ean 13 currY += 10; grap.DrawImage(bitCode128, new Rectangle(topx + 3, currY, (LabelWidth - 6), 6), 0, 0, bitCode128.Width, bitCode128.Height, GraphicsUnit.Pixel); //左右各留3mm currY += 6; float FontWidth = grap.MeasureString(detail.Spid, FontCode128).Width; grap.DrawString(detail.Spid, FontCode128, brush, new Point(topx + (LabelWidth - (int)FontWidth) / 2, currY)); currY += 3; grap.DrawString("(仅供内部使用)", font5, brush, new Point(topx + (LabelWidth - 12) / 2, currY)); currY += 3; grap.DrawImage(bitQR, new Rectangle(topx + (LabelWidth - 13) / 2, currY, 13, 13), 0, 0, bitQR.Width, bitQR.Height, GraphicsUnit.Pixel); }