|
@ -21,18 +21,85 @@ namespace BBWY.Client.Helpers |
|
|
//args.Graphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.Brushes.Black), 0, 0, sige.Width, sige.Height);//画出条码编辑区域
|
|
|
//args.Graphics.DrawRectangle(new System.Drawing.Pen(System.Drawing.Brushes.Black), 0, 0, sige.Width, sige.Height);//画出条码编辑区域
|
|
|
args.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; |
|
|
args.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; |
|
|
args.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; |
|
|
args.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; |
|
|
if (barCode.LabelModel == BarcodeLabelModel.barsimplify) |
|
|
|
|
|
|
|
|
switch (barCode.LabelModel) |
|
|
{ |
|
|
{ |
|
|
font = new Font("宋体", 10, System.Drawing.FontStyle.Regular); |
|
|
case BarcodeLabelModel.标准模板: |
|
|
SetBarSimplify(barCode, ref args, font); |
|
|
font = new Font("宋体", 8, System.Drawing.FontStyle.Regular); |
|
|
|
|
|
SetBar(barCode, ref args, font, 5); |
|
|
|
|
|
//SetBarStander(barCode, ref args, font);
|
|
|
|
|
|
break; |
|
|
|
|
|
case BarcodeLabelModel.精简模板: |
|
|
|
|
|
font = new Font("宋体", 10, System.Drawing.FontStyle.Regular); |
|
|
|
|
|
//SetBar(barCode, ref args, font, 15);
|
|
|
|
|
|
|
|
|
|
|
|
SetBarSimplify(barCode, ref args, font); |
|
|
|
|
|
break; |
|
|
|
|
|
case BarcodeLabelModel.无型号模板: |
|
|
|
|
|
font = new Font("宋体", 10, System.Drawing.FontStyle.Regular); |
|
|
|
|
|
SetBar(barCode, ref args, font,7); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
else |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void SetBar(BarCodeModel barCode, ref PrintPageEventArgs args, Font font, int heightSpace) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float topHeigth = 0;//与顶部的距离
|
|
|
|
|
|
string barcodeSku = $"POP{barCode.SkuId}"; |
|
|
|
|
|
Barcode barcode = new Barcode(); |
|
|
|
|
|
System.Drawing.Image img = barcode.Encode(TYPE.CODE128, barcodeSku, 500, 40); |
|
|
|
|
|
SizeF size = args.Graphics.MeasureString(barCode.BrandName, font); |
|
|
|
|
|
var sizeHeight = size.Height;//字体高度
|
|
|
|
|
|
topHeigth += 10; |
|
|
|
|
|
|
|
|
|
|
|
switch (barCode.LabelModel) |
|
|
{ |
|
|
{ |
|
|
font = new Font("宋体", 8, System.Drawing.FontStyle.Regular); |
|
|
case BarcodeLabelModel.无型号模板: |
|
|
SetBarStander(barCode, ref args, font); |
|
|
case BarcodeLabelModel.标准模板: |
|
|
|
|
|
args.Graphics.DrawString($"品牌: {barCode.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); |
|
|
|
|
|
topHeigth += (heightSpace + sizeHeight); |
|
|
|
|
|
break; |
|
|
|
|
|
case BarcodeLabelModel.精简模板: |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
args.Graphics.DrawString($"品名: {barCode.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); |
|
|
|
|
|
topHeigth += (heightSpace + sizeHeight); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (barCode.LabelModel) |
|
|
|
|
|
{ |
|
|
|
|
|
case BarcodeLabelModel.标准模板: |
|
|
|
|
|
args.Graphics.DrawString($"型号: {barCode.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); |
|
|
|
|
|
topHeigth += (heightSpace + sizeHeight); |
|
|
|
|
|
break; |
|
|
|
|
|
case BarcodeLabelModel.无型号模板: |
|
|
|
|
|
case BarcodeLabelModel.精简模板: |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
args.Graphics.DrawString($"规格: {barCode.SkuName}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); |
|
|
|
|
|
// g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
|
|
|
|
|
size = args.Graphics.MeasureString(barcodeSku, font); |
|
|
|
|
|
topHeigth += (heightSpace + sizeHeight); |
|
|
|
|
|
args.Graphics.DrawImage(img, 1, topHeigth, 234, 50); |
|
|
|
|
|
topHeigth += (50 + 5); |
|
|
|
|
|
args.Graphics.DrawString(barcodeSku, font, System.Drawing.Brushes.Black, new PointF((236 - size.Width) / 2, topHeigth)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 标准
|
|
|
/// 标准
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
@ -41,23 +108,28 @@ namespace BBWY.Client.Helpers |
|
|
/// <param name="font"></param>
|
|
|
/// <param name="font"></param>
|
|
|
private static void SetBarStander(BarCodeModel barCode, ref PrintPageEventArgs args, Font font) |
|
|
private static void SetBarStander(BarCodeModel barCode, ref PrintPageEventArgs args, Font font) |
|
|
{ |
|
|
{ |
|
|
|
|
|
float topHeigth = 0;//与顶部的距离
|
|
|
|
|
|
|
|
|
string barcodeSku = $"POP{barCode.SkuId}"; |
|
|
string barcodeSku = $"POP{barCode.SkuId}"; |
|
|
Barcode barcode = new Barcode(); |
|
|
Barcode barcode = new Barcode(); |
|
|
System.Drawing.Image img = barcode.Encode(TYPE.CODE128, barcodeSku, 500, 40); |
|
|
System.Drawing.Image img = barcode.Encode(TYPE.CODE128, barcodeSku, 500, 40); |
|
|
SizeF size = args.Graphics.MeasureString(barCode.BrandName, font); |
|
|
SizeF size = args.Graphics.MeasureString(barCode.BrandName, font); |
|
|
var sizeHeight = size.Height;//字体高度
|
|
|
var sizeHeight = size.Height;//字体高度
|
|
|
var heightSpace = 5;//间隔高度
|
|
|
var heightSpace = 5;//间隔高度
|
|
|
|
|
|
topHeigth += 10; |
|
|
args.Graphics.DrawString($"品牌: {barCode.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, 10)); |
|
|
args.Graphics.DrawString($"品牌: {barCode.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); |
|
|
args.Graphics.DrawString($"品名: {barCode.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, 10 + heightSpace + sizeHeight)); |
|
|
topHeigth += (heightSpace + sizeHeight); |
|
|
args.Graphics.DrawString($"型号: {barCode.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(10, 10 + 2 * (heightSpace + sizeHeight))); |
|
|
args.Graphics.DrawString($"品名: {barCode.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); |
|
|
args.Graphics.DrawString($"规格: {barCode.SkuName}", font, System.Drawing.Brushes.Black, new PointF(10, 10 + 3 * (heightSpace + sizeHeight))); |
|
|
topHeigth += (heightSpace + sizeHeight); |
|
|
|
|
|
args.Graphics.DrawString($"型号: {barCode.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); |
|
|
|
|
|
topHeigth += (heightSpace + sizeHeight); |
|
|
|
|
|
args.Graphics.DrawString($"规格: {barCode.SkuName}", font, System.Drawing.Brushes.Black, new PointF(10, topHeigth)); |
|
|
// g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
|
|
// g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
|
|
|
size = args.Graphics.MeasureString(barcodeSku, font); |
|
|
size = args.Graphics.MeasureString(barcodeSku, font); |
|
|
args.Graphics.DrawString(barcodeSku, font, System.Drawing.Brushes.Black, new PointF((236 - size.Width) / 2, 10 + 4 * (heightSpace + sizeHeight) + 50 + 5)); |
|
|
topHeigth += (heightSpace + sizeHeight); |
|
|
args.Graphics.DrawImage(img, 1, 10 + 4 * (heightSpace + sizeHeight), 234, 50); |
|
|
args.Graphics.DrawImage(img, 1, topHeigth, 234, 50); |
|
|
|
|
|
topHeigth += (50 + 5); |
|
|
|
|
|
args.Graphics.DrawString(barcodeSku, font, System.Drawing.Brushes.Black, new PointF((236 - size.Width) / 2, topHeigth)); |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 精简
|
|
|
/// 精简
|
|
@ -89,7 +161,20 @@ namespace BBWY.Client.Helpers |
|
|
args.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; |
|
|
args.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; |
|
|
|
|
|
|
|
|
font = new Font("宋体", 6, System.Drawing.FontStyle.Regular); |
|
|
font = new Font("宋体", 6, System.Drawing.FontStyle.Regular); |
|
|
SetCerStander(ref args, certificate, font); |
|
|
switch (certificate.LabelModel) |
|
|
|
|
|
{ |
|
|
|
|
|
case CertificateLabelModel.标准无3c: |
|
|
|
|
|
case CertificateLabelModel.标准有3c: |
|
|
|
|
|
SetCerStander(ref args, certificate, font); |
|
|
|
|
|
break; |
|
|
|
|
|
case CertificateLabelModel.无型号: |
|
|
|
|
|
SetCerNoXingHao(ref args, certificate, font); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static void SetCerStander(ref PrintPageEventArgs args, CertificateModel certificate, Font font) |
|
|
private static void SetCerStander(ref PrintPageEventArgs args, CertificateModel certificate, Font font) |
|
@ -112,14 +197,14 @@ namespace BBWY.Client.Helpers |
|
|
var fontBig = new Font("宋体", 14, System.Drawing.FontStyle.Regular); |
|
|
var fontBig = new Font("宋体", 14, System.Drawing.FontStyle.Regular); |
|
|
string cerName = "合格证"; |
|
|
string cerName = "合格证"; |
|
|
SizeF bigSize = args.Graphics.MeasureString(cerName, fontBig); |
|
|
SizeF bigSize = args.Graphics.MeasureString(cerName, fontBig); |
|
|
|
|
|
|
|
|
float verHeight = bigJiange + bigSize.Height; |
|
|
float verHeight = bigJiange + bigSize.Height; |
|
|
args.Graphics.DrawString(cerName, fontBig, System.Drawing.Brushes.Black, new PointF((236 - bigSize.Width) / 2, 10)); |
|
|
args.Graphics.DrawString(cerName, fontBig, System.Drawing.Brushes.Black, new PointF((236 - bigSize.Width) / 2, 10)); |
|
|
|
|
|
|
|
|
args.Graphics.DrawString($"品牌: {certificate.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); |
|
|
args.Graphics.DrawString($"品牌: {certificate.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); |
|
|
args.Graphics.DrawString($"型号: {certificate.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); |
|
|
args.Graphics.DrawString($"型号: {certificate.ProductNo}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); |
|
|
var smallSize = args.Graphics.MeasureString(certificate.Brand, font);//小字体高度
|
|
|
var smallSize = args.Graphics.MeasureString(certificate.Brand, font);//小字体高度
|
|
|
|
|
|
|
|
|
verHeight += (smallSize.Height + heightSpace); |
|
|
verHeight += (smallSize.Height + heightSpace); |
|
|
args.Graphics.DrawString($"品名: {certificate.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); |
|
|
args.Graphics.DrawString($"品名: {certificate.BrandName}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); |
|
|
|
|
|
|
|
@ -157,8 +242,95 @@ namespace BBWY.Client.Helpers |
|
|
var productStr = $"生产商: {certificate.ProductShop}"; |
|
|
var productStr = $"生产商: {certificate.ProductShop}"; |
|
|
if (args.Graphics.MeasureString(productStr, font).Width <= 220) |
|
|
if (args.Graphics.MeasureString(productStr, font).Width <= 220) |
|
|
{ |
|
|
{ |
|
|
args.Graphics.DrawString(productStr, font, System.Drawing.Brushes.Black,10,verHeight); |
|
|
args.Graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, 10, verHeight); |
|
|
verHeight += smallSize.Height + heightSpace; |
|
|
verHeight += smallSize.Height + heightSpace; |
|
|
|
|
|
} |
|
|
|
|
|
else |
|
|
|
|
|
{ |
|
|
|
|
|
args.Graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, rect); |
|
|
|
|
|
verHeight += 2 * smallSize.Height + heightSpace; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//var format = new StringFormat
|
|
|
|
|
|
//{
|
|
|
|
|
|
// LineAlignment = StringAlignment.Far,
|
|
|
|
|
|
// // Alignment = StringAlignment.Center
|
|
|
|
|
|
//};
|
|
|
|
|
|
|
|
|
|
|
|
var rect1 = new RectangleF(10, verHeight, 220, smallSize.Height * 3 + heightSpace); |
|
|
|
|
|
args.Graphics.DrawString($"地址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1); |
|
|
|
|
|
//certificate.ExcuteStander =;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//args.Graphics.DrawImage(img, 1, 68, 234, 60);
|
|
|
|
|
|
} |
|
|
|
|
|
private static void SetCerNoXingHao(ref PrintPageEventArgs args, CertificateModel certificate, Font font) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
int bigJiange = 20;//合格证与品牌的高度差
|
|
|
|
|
|
var heightSpace = 4;//所有行间隔高度
|
|
|
|
|
|
int standerSpace = 1;//执行标准之间的
|
|
|
|
|
|
//if (certificate.IsLogo == 1)//含图标
|
|
|
|
|
|
//{
|
|
|
|
|
|
// string appPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
|
|
|
|
|
|
|
|
|
|
|
|
// string path = appPath + $"/Resources/Images/3c.png";
|
|
|
|
|
|
// Image image = Image.FromFile(path);
|
|
|
|
|
|
// args.Graphics.DrawImage(image, 190, 7, 28, 21);
|
|
|
|
|
|
// args.Graphics.DrawString(certificate.FactoryNumber, font, System.Drawing.Brushes.Black, 188, 28);
|
|
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
|
|
var fontBig = new Font("宋体", 14, System.Drawing.FontStyle.Regular); |
|
|
|
|
|
string cerName = "合格证"; |
|
|
|
|
|
SizeF bigSize = args.Graphics.MeasureString(cerName, fontBig); |
|
|
|
|
|
|
|
|
|
|
|
float verHeight = bigJiange + bigSize.Height; |
|
|
|
|
|
args.Graphics.DrawString(cerName, fontBig, System.Drawing.Brushes.Black, new PointF((236 - bigSize.Width) / 2, 10)); |
|
|
|
|
|
|
|
|
|
|
|
args.Graphics.DrawString($"品牌: {certificate.Brand}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); |
|
|
|
|
|
args.Graphics.DrawString($"品名: {certificate.BrandName}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight)); |
|
|
|
|
|
var smallSize = args.Graphics.MeasureString(certificate.BrandName, font);//小字体高度
|
|
|
|
|
|
|
|
|
|
|
|
verHeight += (smallSize.Height + heightSpace); |
|
|
|
|
|
args.Graphics.DrawString($"材质: {certificate.Shader}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); |
|
|
|
|
|
|
|
|
|
|
|
//args.Graphics.DrawString($"材质: {certificate.Shader}", font, System.Drawing.Brushes.Black, new PointF(122, verHeight));
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
|
|
var excutes = certificate.ExcuteStander.Split(',', StringSplitOptions.RemoveEmptyEntries); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int hangCount = excutes.Count() / 2 + excutes.Count() % 2;//获取行数
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < excutes.Count(); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
if (i % 2 == 0 && i > 0)//间隔两个换行
|
|
|
|
|
|
{ |
|
|
|
|
|
sb.Append("\n"); |
|
|
|
|
|
} |
|
|
|
|
|
sb.Append(excutes[i]).Append(" "); |
|
|
|
|
|
} |
|
|
|
|
|
sb.Remove(sb.Length - 3, 3); |
|
|
|
|
|
var rows = sb.ToString().Split('\n'); |
|
|
|
|
|
string excuteStander = "执行标准: "; |
|
|
|
|
|
smallSize = args.Graphics.MeasureString(excuteStander, font); |
|
|
|
|
|
verHeight += (smallSize.Height + heightSpace); |
|
|
|
|
|
args.Graphics.DrawString($"执行标准: {rows[0]}", font, System.Drawing.Brushes.Black, new PointF(10, verHeight)); |
|
|
|
|
|
|
|
|
|
|
|
for (int i = 1; i < rows.Count(); i++) |
|
|
|
|
|
{ |
|
|
|
|
|
verHeight += (smallSize.Height + standerSpace); |
|
|
|
|
|
args.Graphics.DrawString($"{rows[i]}", font, System.Drawing.Brushes.Black, new PointF(10 + smallSize.Width, verHeight)); |
|
|
|
|
|
} |
|
|
|
|
|
verHeight += (smallSize.Height + heightSpace); |
|
|
|
|
|
|
|
|
|
|
|
RectangleF rect = new RectangleF(10, verHeight, 220, smallSize.Height * 2 + heightSpace); |
|
|
|
|
|
var productStr = $"生产商: {certificate.ProductShop}"; |
|
|
|
|
|
if (args.Graphics.MeasureString(productStr, font).Width <= 220) |
|
|
|
|
|
{ |
|
|
|
|
|
args.Graphics.DrawString(productStr, font, System.Drawing.Brushes.Black, 10, verHeight); |
|
|
|
|
|
verHeight += smallSize.Height + heightSpace; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
@ -173,7 +345,7 @@ namespace BBWY.Client.Helpers |
|
|
//};
|
|
|
//};
|
|
|
|
|
|
|
|
|
var rect1 = new RectangleF(10, verHeight, 220, smallSize.Height * 3 + heightSpace); |
|
|
var rect1 = new RectangleF(10, verHeight, 220, smallSize.Height * 3 + heightSpace); |
|
|
args.Graphics.DrawString($"地址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1 ); |
|
|
args.Graphics.DrawString($"地址: {certificate.ProductAdress}", font, System.Drawing.Brushes.Black, rect1); |
|
|
//certificate.ExcuteStander =;
|
|
|
//certificate.ExcuteStander =;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|