diff --git a/Language/en_US.xaml b/Language/en_US.xaml index 85a0859..ea90373 100644 --- a/Language/en_US.xaml +++ b/Language/en_US.xaml @@ -199,4 +199,14 @@ MSVC Runtime not installed, program may encounter errors during execution File path does not exist The file format is incorrect + DateOfIssue + Organization + Code + Wight + Parameters + Interval + Whether to print labels + CuttingGrade + SymmetryLevel + Print diff --git a/Language/zh_CN.xaml b/Language/zh_CN.xaml index b024cf1..67c1936 100644 --- a/Language/zh_CN.xaml +++ b/Language/zh_CN.xaml @@ -200,4 +200,14 @@ MSVC Runtime未安装,程序执行中可能会出错 文件路径不存在 文件格式不正确 + 签发日期 + 机构 + 编码 + 重量 + 参数 + 区间 + 是否打印标签 + 综合切工等级 + 综合对称等级 + 打印 \ No newline at end of file diff --git a/ViewModel/Grading/GradingResultVM.cs b/ViewModel/Grading/GradingResultVM.cs index 00401b3..83cf6ba 100644 --- a/ViewModel/Grading/GradingResultVM.cs +++ b/ViewModel/Grading/GradingResultVM.cs @@ -23,6 +23,14 @@ using log4net; using System.Drawing.Printing; using System.Drawing; using HandyControl.Controls; +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; /// /// 检测结果画面VM @@ -1295,7 +1303,7 @@ public class GradingResultVM : BaseViewModel #region 各类名称取得 private string GetName(string id) { - return Name.getNameById(id); + return Name.getNameById(id).Trim(); } private string GetGradeName(decimal order) { @@ -1683,50 +1691,25 @@ public class GradingResultVM : BaseViewModel } #endregion - // 执行热敏打印的方法 private void ExecuteThermalPrint(object parameter) { try { - // 准备要打印的数据 - string printData = PreparePrintData(); - // 创建打印文档 PrintDocument printDocument = new PrintDocument(); - - // 确保 PrintPage 事件处理程序正确实现 - printDocument.PrintPage += (sender, e) => - { - // 设置打印字体和格式 - Font printFont = new Font("Courier", 10); - SolidBrush drawBrush = new SolidBrush(System.Drawing.Color.Black); - float yPos = 0f; - int linesPerPage = 0; - - // 逐行打印数据 - using (StringReader sr = new StringReader(printData)) - { - string line; - while ((line = sr.ReadLine()) != null) - { - yPos = e.MarginBounds.Top + (linesPerPage * printFont.GetHeight(e.Graphics)); - e.Graphics.DrawString(line, printFont, drawBrush, e.MarginBounds.Left, yPos); - linesPerPage++; - } - } - - // 表示已完成打印,不需要额外的页面 - e.HasMorePages = false; - }; + //printDocument.PrintPage += PrintPageHandler; + // 订阅 PrintPage 事件 + printDocument.PrintPage += PreparePrintData; // 创建自定义打印预览窗体 CustomPrintPreviewForm customPreviewForm = new CustomPrintPreviewForm(printDocument); // 显示自定义打印预览窗体 - DialogResult result = customPreviewForm.ShowDialog(); - - if (result == DialogResult.OK) + // DialogResult result = customPreviewForm.ShowDialog(); + MessageBox messageBox = new MessageBox(); + MessageBoxResult boxResult = messageBox.ShowAsk(MultilingualHelper.getString("YesOrNo")); + if (boxResult == MessageBoxResult.OK) { // 打开串口 if (!_serialPort.IsOpen) @@ -1734,8 +1717,26 @@ public class GradingResultVM : BaseViewModel _serialPort.Open(); } - // 将数据转换为字节数组 - byte[] dataToSend = System.Text.Encoding.UTF8.GetBytes(printData); + // 将绘制内容转换为字节数组 + MemoryStream memoryStream = new MemoryStream(); + using (Bitmap bitmap = new Bitmap((int)printDocument.DefaultPageSettings.PrintableArea.Width, (int)printDocument.DefaultPageSettings.PrintableArea.Height)) + { + using (var graphics = Graphics.FromImage(bitmap)) + { + // 计算可打印区域的 Rectangle + var margins = new Margins(0, 0, 0, 0); + var printableArea = new System.Drawing.Rectangle(margins.Left, margins.Top, + (int)printDocument.DefaultPageSettings.PrintableArea.Width - margins.Left - margins.Right, + (int)printDocument.DefaultPageSettings.PrintableArea.Height - margins.Top - margins.Bottom); + + // 调用 PreparePrintData 方法绘制内容到 Graphics 对象 + // 注意这里的第三个参数应该是 Rectangle 类型 + PreparePrintData(printDocument, new PrintPageEventArgs(graphics, printableArea, printableArea, new PageSettings())); + } + // 将 Bitmap 保存到 MemoryStream 中 + bitmap.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png); + } + byte[] dataToSend = memoryStream.ToArray(); // 发送数据到串口 _serialPort.Write(dataToSend, 0, dataToSend.Length); @@ -1782,10 +1783,10 @@ public class GradingResultVM : BaseViewModel confirmButton.Click += ConfirmButton_Click; // 初始化系统打印按钮 - systemPrintButton = new Button(); - systemPrintButton.Text = "系统打印"; - systemPrintButton.Dock = DockStyle.Bottom; - systemPrintButton.Click += SystemPrintButton_Click; + // systemPrintButton = new Button(); + // systemPrintButton.Text = "系统打印"; + // systemPrintButton.Dock = DockStyle.Bottom; + // systemPrintButton.Click += SystemPrintButton_Click; // 将控件添加到窗体 this.Controls.Add(printPreviewControl); @@ -1817,83 +1818,261 @@ public class GradingResultVM : BaseViewModel } } } - // 准备要打印的数据 - - private string PreparePrintData() - { - var result = algorithmResult.measurements; - - // 定义每个字段的目标宽度,确保每个字段有足够的空间 - int paramWidth = 20; // 参数列宽度 - int avgWidth = 15; // 平均值列宽度 - int rangeWidth = 50; // 区间列宽度 - int cutGradeWidth = 15; // 切工等级列宽度 - int symGradeWidth = 15; // 对称性等级列宽度 - - // 格式化数值,确保数值位数一致 - string formatNumber = "{0,8:F2}"; // 数值占8个字符宽度,保留两位小数 - - // 使用固定宽度填充每个字段,确保整齐 - string data = $"{string.Format(formatNumber, "机构:IGI").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, "形状:圆形").PadRight(avgWidth)}" + - $"{string.Format(formatNumber, $"编码:{DiamondCode}").PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, $"重量: {Wight}ct.").PadRight(paramWidth)}" + "\n"; - - data += $"{string.Format(formatNumber, "参数").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, "平均值").PadRight(avgWidth)}" + - $"{string.Format(formatNumber, "区间(Min/Max)").PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, "切工等级").PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, "对称性等级").PadRight(symGradeWidth)}" + "\n"; - - // 使用 PadRight 对齐每列,确保每一列内容在宽度内对齐 - data += $"{string.Format(formatNumber, "直径(mm)").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, result.DIAMETER).PadRight(avgWidth)}" + - $"{string.Format($"({formatNumber}-{formatNumber})", result.M1, result.M2).PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, "完美").PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, "很好").PadRight(symGradeWidth)}" + "\n"; - - data += $"{string.Format(formatNumber, "全深比(%)").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, result.TOTAL_DEPTH * 100).PadRight(avgWidth)}" + - $"{string.Format(formatNumber, "-").PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, CutLevelTotal).PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, "-").PadRight(symGradeWidth)}" + "\n"; - - data += $"{string.Format(formatNumber, "台宽比(%)").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, result.TABLE * 100).PadRight(avgWidth)}" + - $"{string.Format($"({formatNumber}-{formatNumber})", result.TABLE * 100 - 0.7, result.TABLE * 100 + 0.3).PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, "极好").PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, "-").PadRight(symGradeWidth)}" + "\n"; - - data += $"{string.Format(formatNumber, "冠角(°)").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, result.CROWN_ANGLE).PadRight(avgWidth)}" + - $"{string.Format($"({formatNumber}-{formatNumber})", result.CROWN_ANGLE_MIN, result.CROWN_ANGLE_MAX).PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, "一般 - 差").PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, "好").PadRight(symGradeWidth)}" + "\n"; - - data += $"{string.Format(formatNumber, "冠高比(%)").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, result.CROWN_HEIGHT).PadRight(avgWidth)}" + - $"{string.Format(formatNumber, "-").PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, "完美").PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, "很好").PadRight(symGradeWidth)}" + "\n"; - - data += $"{string.Format(formatNumber, "波谷腰厚(%)").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, result.GIRDLE_VALLEY).PadRight(avgWidth)}" + - $"{string.Format($"({formatNumber}-{formatNumber})", result.GIRDLE_VALLEY_MIN, result.GIRDLE_VALLEY_MAX).PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, "极好").PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, "-").PadRight(symGradeWidth)}" + "\n"; - - data += $"{string.Format(formatNumber, "亭深比(%)").PadRight(paramWidth)}" + - $"{string.Format(formatNumber, result.PAV_DEPTH).PadRight(avgWidth)}" + - $"{string.Format($"({formatNumber}-{formatNumber})", result.PAV_DEPTH - 0.3, result.PAV_DEPTH + 0.3).PadRight(rangeWidth)}" + - $"{string.Format(formatNumber, "极好").PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, "极好").PadRight(symGradeWidth)}" + "\n"; - - data += $"{string.Format(formatNumber, "综合切工等级: 一般 - 差").PadRight(paramWidth + avgWidth + rangeWidth)}" + - $"{string.Format(formatNumber, "综合对称等级: 好").PadRight(cutGradeWidth)}" + - $"{string.Format(formatNumber, $"签发日期: {DateTime.Now:yyyy/M/d}").PadRight(symGradeWidth)}" + "\n"; - - return data; - } + + private void PreparePrintData(object sender, PrintPageEventArgs e) + { + var result = algorithmResult.measurements; + int startX = 10; + int startY = 10; + var col2X = startX + 160; + var col3X = col2X + 100; + // 设置字体 + 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; // 垂直居中 + Brush backgroundBrush = new SolidBrush(System.Drawing.Color.Black); // 背景色为黑色 + + // 绘制文本 + // 第一行 + int X = startX; + int Y = startY; + e.Graphics.DrawString($"{MultilingualHelper.getString("Organization")}:{Standard}", font, brush, new PointF(X, Y)); + e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultShape")}:{Shape}", font, brush, new PointF(col2X, Y)); + e.Graphics.DrawString($"{MultilingualHelper.getString("Code")}:{DiamondCode}", font, brush, new PointF(col3X, Y)); + e.Graphics.DrawString($"{MultilingualHelper.getString("Wight")}:{Wight}ct.", font, brush, new PointF(540, Y)); + + // 第二行 + X = startX; + Y += font.Height; + e.Graphics.DrawString($"{MultilingualHelper.getString("Parameters")}", font, brush, new PointF(X, Y)); + + e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultGridAvgValue")}", font, brush, new PointF(col2X, Y)); + + e.Graphics.DrawString($"{MultilingualHelper.getString("Interval")}(Min~Max)", font, brush, new PointF(col3X, Y)); + e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultGridCutLevel")}", font, brush, new PointF(420, Y)); + e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultSymmetryGrade")}", font, brush, new PointF(540, Y)); + + // 第三行 + // 直径 + var d = getSelectData("DIAMETER"); + X = startX; + Y += font.Height; + e.Graphics.DrawString($"{GetName("DIAMETER")}(mm)", font, brush, new PointF(X, Y)); + X = col2X; + e.Graphics.DrawString(d.Avg, font, brush, new PointF(X, Y)); + X = col3X; + e.Graphics.DrawString($"({d.Min}-{d.Max})", font, brush, new PointF(X, Y)); + e.Graphics.DrawString($"-", font, brush, new PointF(420, Y)); + e.Graphics.DrawString($"{d.SymLevel}", font, brush, new PointF(540, Y)); + // 第四行 + // 全深比 + var o = getSelectData("TOTAL_DEPTH"); + X = startX; + Y += font.Height; + e.Graphics.DrawString($"{GetName("TOTAL_DEPTH")}(%)", font, brush, new PointF(X, Y)); + X = col2X; + e.Graphics.DrawString(o.Avg, font, brush, new PointF(X, Y)); + X = col3X; + e.Graphics.DrawString($"-", font, brush, new PointF(X, Y)); + e.Graphics.DrawString($"{o.CutLevel}", font, brush, new PointF(420, Y)); + e.Graphics.FillRectangle(backgroundBrush, new RectangleF(540, Y, 100, font.Height)); + // 第五行 + // 台宽比 + var t = getSelectData("TABLE"); + X = startX; + Y += font.Height; + e.Graphics.DrawString($"{GetName("TABLE")}(%)", font, brush, new PointF(X, Y)); + X = col2X; + e.Graphics.DrawString(t.Avg, font, brush, new PointF(X, Y)); + X = col3X; + e.Graphics.DrawString($"({t.Min}-{t.Max})", font, brush, new PointF(X, Y)); + e.Graphics.DrawString($"{t.CutLevel}", font, brush, new PointF(420, Y)); + e.Graphics.FillRectangle(backgroundBrush, new RectangleF(540, Y, 100, font.Height)); + // 第六行 + // 冠角 + var c = getSelectData("CROWN_ANGLE"); + X = startX; + Y += font.Height; + e.Graphics.DrawString($"{GetName("CROWN_ANGLE")}(°)", font, brush, new PointF(X, Y)); + X = col2X; + e.Graphics.DrawString(c.Avg, font, brush, new PointF(X, Y)); + X = col3X; + e.Graphics.DrawString($"({c.Min}-{c.Max})", font, brush, new PointF(X, Y)); + X += 120; + e.Graphics.DrawString($"{c.CutLevel}", font, brush, new PointF(420, Y)); + e.Graphics.DrawString($"{c.SymLevel}", font, brush, new PointF(540, Y)); + // 第七行 + // 冠高比 + var h = getSelectData("CROWN_HEIGHT"); + X = startX; + Y += font.Height; + e.Graphics.DrawString($"{GetName("CROWN_HEIGHT")}(%)", font, brush, new PointF(X, Y)); + X = col2X; + e.Graphics.DrawString(h.Avg, font, brush, new PointF(X, Y)); + X = col3X; + e.Graphics.DrawString($"({h.Min}-{h.Max})", font, brush, new PointF(X, Y)); + X += 60; + e.Graphics.DrawString($"{h.CutLevel}", font, brush, new PointF(420, Y)); + e.Graphics.DrawString($"{h.SymLevel}", font, brush, new PointF(540, Y)); + // 第八行 + // 波谷腰厚 + var g = getSelectData("GIRDLE"); + X = startX; + Y += font.Height; + e.Graphics.DrawString($"{GetName("GIRDLE")}(%)", font, brush, new PointF(X, Y)); + X = col2X; + e.Graphics.DrawString(g.Avg, font, brush, new PointF(X, Y)); + X = col3X; + e.Graphics.DrawString($"({g.Min}-{g.Max})", font, brush, new PointF(X, Y)); + e.Graphics.DrawString($"{g.CutLevel}", font, brush, new PointF(420, Y)); + e.Graphics.DrawString($"{g.SymLevel}", font, brush, new PointF(540, Y)); + // 第九行 + // 亭深比 + var p = getSelectData("PAV_DEPTH"); + X = startX; + Y += font.Height; + e.Graphics.DrawString($"{GetName("PAV_DEPTH")}(%)", font, brush, new PointF(X, Y)); + X = col2X; + e.Graphics.DrawString(p.Avg, font, brush, new PointF(X, Y)); + X = col3X; + e.Graphics.DrawString($"({p.Min}-{p.Max})", font, brush, new PointF(X, Y)); + e.Graphics.DrawString($"{p.CutLevel}", font, brush, new PointF(420, Y)); + e.Graphics.DrawString($"{p.SymLevel}", font, brush, new PointF(540, Y)); + // 第十行 + X = startX; + Y += font.Height; + e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, 130, font.Height)); + e.Graphics.DrawString($"{MultilingualHelper.getString("CuttingGrade")}", font, Brushes.White, new PointF(X, Y)); + + X = col2X; + e.Graphics.DrawString(CutLevelTotal, font, Brushes.Red, new PointF(X, Y)); + // 第十一行 + X = startX; + Y += font.Height; + e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, 130, font.Height)); + e.Graphics.DrawString($"{MultilingualHelper.getString("SymmetryLevel")}", font, Brushes.White, new PointF(X, Y)); + X = col2X; + e.Graphics.DrawString(SymLevelTotal, font, Brushes.Red, new PointF(X, Y)); + X = col3X; + e.Graphics.DrawString($"{MultilingualHelper.getString("DateOfIssue")}: {DateTime.Now:yyyy/M/d}", font, brush, new PointF(X, Y)); + + } + + 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)); + + } private void InitializeSerialPort() { diff --git a/Views/Grading/GradingResult.xaml b/Views/Grading/GradingResult.xaml index cd66d0c..7d8b42e 100644 --- a/Views/Grading/GradingResult.xaml +++ b/Views/Grading/GradingResult.xaml @@ -8,7 +8,7 @@ xmlns:hx="http://helix-toolkit.org/wpf/SharpDX" xmlns:userControl="clr-namespace:SparkClient.Views.UserControl" mc:Ignorable="d" - d:DesignWidth="2000" + d:DesignWidth="1920" d:DesignHeight="600" > @@ -66,6 +66,7 @@ + @@ -124,8 +125,8 @@ - - + + @@ -140,7 +141,7 @@ - - + @@ -176,7 +177,7 @@ - + @@ -191,7 +192,7 @@ - + @@ -206,7 +207,7 @@ - + @@ -221,7 +222,7 @@ - + @@ -236,7 +237,7 @@ - + @@ -253,7 +254,7 @@ - +