|
|
@ -23,6 +23,15 @@ using SparkClient.Views.UserControl.ViewportData.Helper; |
|
|
|
using System.Diagnostics.Metrics; |
|
|
|
using System.Diagnostics.Metrics; |
|
|
|
using log4net; |
|
|
|
using log4net; |
|
|
|
using SparkClient.ViewModel.Configuration; |
|
|
|
using SparkClient.ViewModel.Configuration; |
|
|
|
|
|
|
|
using System.Drawing.Printing; |
|
|
|
|
|
|
|
using System.Drawing; |
|
|
|
|
|
|
|
using RectangleF = System.Drawing.RectangleF; |
|
|
|
|
|
|
|
using FontFamily = System.Drawing.FontFamily; |
|
|
|
|
|
|
|
using FontStyle = System.Drawing.FontStyle; |
|
|
|
|
|
|
|
using NPOI.SS.Formula.Functions; |
|
|
|
|
|
|
|
using System.Windows.Media; |
|
|
|
|
|
|
|
using Brush = System.Drawing.Brush; |
|
|
|
|
|
|
|
using Brushes = System.Drawing.Brushes; |
|
|
|
|
|
|
|
|
|
|
|
namespace SparkClient.ViewModel.Grading; |
|
|
|
namespace SparkClient.ViewModel.Grading; |
|
|
|
/// <summary> |
|
|
|
/// <summary> |
|
|
@ -828,6 +837,7 @@ public class GradingResultVM : BaseViewModel |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
SaveTestResult(SaveStatus.SaveAs); |
|
|
|
SaveTestResult(SaveStatus.SaveAs); |
|
|
|
|
|
|
|
//PrintLabel(); |
|
|
|
} |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -1644,6 +1654,130 @@ public class GradingResultVM : BaseViewModel |
|
|
|
} |
|
|
|
} |
|
|
|
#endregion |
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void PrintLabel() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
PrintDocument printDoc = new PrintDocument(); |
|
|
|
|
|
|
|
printDoc.PrintPage += new PrintPageEventHandler(PrintPageHandler); |
|
|
|
|
|
|
|
printDoc.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 550, 300); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PrintDialog printDialog = new PrintDialog(); |
|
|
|
|
|
|
|
printDialog.Document = printDoc; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (printDialog.ShowDialog() == DialogResult.OK) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
printDoc.Print(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void PrintPageHandler(object sender, PrintPageEventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var result = algorithmResult.measurements; |
|
|
|
|
|
|
|
int startX = 10; |
|
|
|
|
|
|
|
int startY = 10; |
|
|
|
|
|
|
|
var col2X = startX + 90; |
|
|
|
|
|
|
|
var col3X = col2X + 70; |
|
|
|
|
|
|
|
// 设置字体 |
|
|
|
|
|
|
|
Font font = new Font(FontFamily.GenericSerif, 12, FontStyle.Bold); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置颜色 |
|
|
|
|
|
|
|
Brush brush = Brushes.Black; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 设置对齐方式 |
|
|
|
|
|
|
|
StringFormat format = new StringFormat(); |
|
|
|
|
|
|
|
format.Alignment = StringAlignment.Center; // 水平居中 |
|
|
|
|
|
|
|
format.LineAlignment = StringAlignment.Center; // 垂直居中 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 绘制文本 |
|
|
|
|
|
|
|
// 第一行 |
|
|
|
|
|
|
|
int X = startX; |
|
|
|
|
|
|
|
int Y = startY; |
|
|
|
|
|
|
|
e.Graphics.DrawString(Standard, font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X += 70; |
|
|
|
|
|
|
|
e.Graphics.DrawString(Shape, font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X += 50; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"ID:{DiamondCode}", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X += 100; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"Weight:{Wight}ct.", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X += 120; |
|
|
|
|
|
|
|
Brush backgroundBrush = new SolidBrush(System.Drawing.Color.Black); // 背景色为黄色 |
|
|
|
|
|
|
|
e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, 200, font.Height)); |
|
|
|
|
|
|
|
e.Graphics.DrawString(CutLevelTotal, font, Brushes.White, new PointF(X, Y)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 第二行 |
|
|
|
|
|
|
|
X = startX; |
|
|
|
|
|
|
|
Y += font.Height; |
|
|
|
|
|
|
|
e.Graphics.DrawString("Diameter", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_D(result.DIAMETER)}mm", font, brush, new PointF(col2X, Y)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
e.Graphics.DrawString($"({FormatDouble_D(result.M1)}mm-{FormatDouble_D(result.M2)}mm)", font, brush, new PointF(col3X, Y)); |
|
|
|
|
|
|
|
e.Graphics.DrawString($"0.3%", font, brush, new PointF(310, Y)); |
|
|
|
|
|
|
|
e.Graphics.FillRectangle(backgroundBrush, new RectangleF(350, Y, 200, font.Height)); |
|
|
|
|
|
|
|
e.Graphics.DrawString(SymLevelTotal, font, Brushes.White, new PointF(X, Y)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 第三行 |
|
|
|
|
|
|
|
X = startX; |
|
|
|
|
|
|
|
Y += font.Height; |
|
|
|
|
|
|
|
e.Graphics.DrawString("Total Dep.", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col2X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_D(result.DIAMETER * result.TOTAL_DEPTH)}mm", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col3X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_P(result.TOTAL_DEPTH)}%", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{DtResults.Where(X=> "TOTAL_DEPTH".Equals(X.TestItemId)).Select(X=>X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y)); |
|
|
|
|
|
|
|
// 第四行 |
|
|
|
|
|
|
|
X = startX; |
|
|
|
|
|
|
|
Y += font.Height; |
|
|
|
|
|
|
|
e.Graphics.DrawString("Table", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col2X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_D(result.DIAMETER * result.TABLE)}mm", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col3X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_P(result.TABLE)}%", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{DtResults.Where(X => "TABLE".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y)); |
|
|
|
|
|
|
|
// 第五行 |
|
|
|
|
|
|
|
X = startX; |
|
|
|
|
|
|
|
Y += font.Height; |
|
|
|
|
|
|
|
e.Graphics.DrawString("Crown", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col2X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_A(result.CROWN_ANGLE)}°", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col3X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"({FormatDouble_A(result.CROWN_ANGLE_MIN)}°-{FormatDouble_A(result.CROWN_ANGLE_MAX)}°)", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X += 120; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"({FormatDouble_A(result.CROWN_HEIGHT)}%)", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{DtResults.Where(X => "CROWN_ANGLE".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(410, Y)); |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{DtResults.Where(X => "CROWN_HEIGHT".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y)); |
|
|
|
|
|
|
|
// 第六行 |
|
|
|
|
|
|
|
X = startX; |
|
|
|
|
|
|
|
Y += font.Height; |
|
|
|
|
|
|
|
e.Graphics.DrawString("Pavil.", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col2X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_A(result.PAV_ANGLE)}°", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col3X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"({FormatDouble_A(result.PAV_ANGLE_MIN)}°-{FormatDouble_A(result.PAV_ANGLE_MAX)}°)", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X += 120; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"({FormatDouble_A(result.PAV_DEPTH)}%)", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{DtResults.Where(X => "PAV_ANGLE".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(410, Y)); |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{DtResults.Where(X => "PAV_DEPTH".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y)); |
|
|
|
|
|
|
|
// 第七行 |
|
|
|
|
|
|
|
X = startX; |
|
|
|
|
|
|
|
Y += font.Height; |
|
|
|
|
|
|
|
e.Graphics.DrawString("Culet", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col2X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_P(result.CULET)}%", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col3X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"Twist", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X += 60; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"({FormatDouble_A(result.TWIST_MIN)}°-{FormatDouble_A(result.TWIST_MAX)}°)", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
// 第八行 |
|
|
|
|
|
|
|
X = startX; |
|
|
|
|
|
|
|
Y += font.Height; |
|
|
|
|
|
|
|
e.Graphics.DrawString("Girdle 16M", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col2X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{FormatDouble_D(result.GIRDLE_VALLEY)}", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
X = col3X; |
|
|
|
|
|
|
|
e.Graphics.DrawString($"({FormatDouble_P(result.GIRDLE_VALLEY_MIN)}%-{FormatDouble_P(result.GIRDLE_VALLEY_MAX)}%)", font, brush, new PointF(X, Y)); |
|
|
|
|
|
|
|
e.Graphics.DrawString($"{DtResults.Where(X => "GIRDLE".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
#region 钻石操作相关 |
|
|
|
#region 钻石操作相关 |
|
|
|
//暂略 |
|
|
|
//暂略 |
|
|
|
//部分代码(直接操作控件)需要在xaml.cs里边写 |
|
|
|
//部分代码(直接操作控件)需要在xaml.cs里边写 |
|
|
|