sunhonglei 5 months ago
commit ebf371a635
  1. 10
      Language/en_US.xaml
  2. 10
      Language/zh_CN.xaml
  3. 411
      ViewModel/Grading/GradingResultVM.cs
  4. 29
      Views/Grading/GradingResult.xaml

@ -199,4 +199,14 @@
<sys:String x:Key="MSVCRuntimeNoInstall">MSVC Runtime not installed, program may encounter errors during execution</sys:String>
<sys:String x:Key="FilePathNotExists">File path does not exist</sys:String>
<sys:String x:Key="LevelConfigFormatError">The file format is incorrect</sys:String>
<sys:String x:Key="DateOfIssue">DateOfIssue</sys:String>
<sys:String x:Key="Organization">Organization</sys:String>
<sys:String x:Key="Code">Code</sys:String>
<sys:String x:Key="Wight">Wight</sys:String>
<sys:String x:Key="Parameters">Parameters</sys:String>
<sys:String x:Key="Interval">Interval</sys:String>
<sys:String x:Key="YesOrNo">Whether to print labels</sys:String>
<sys:String x:Key="CuttingGrade">CuttingGrade</sys:String>
<sys:String x:Key="SymmetryLevel">SymmetryLevel</sys:String>
<sys:String x:Key="Print">Print</sys:String>
</ResourceDictionary>

@ -200,4 +200,14 @@
<sys:String x:Key="MSVCRuntimeNoInstall">MSVC Runtime未安装,程序执行中可能会出错</sys:String>
<sys:String x:Key="FilePathNotExists">文件路径不存在</sys:String>
<sys:String x:Key="LevelConfigFormatError">文件格式不正确</sys:String>
<sys:String x:Key="DateOfIssue">签发日期</sys:String>
<sys:String x:Key="Organization">机构</sys:String>
<sys:String x:Key="Code">编码</sys:String>
<sys:String x:Key="Wight">重量</sys:String>
<sys:String x:Key="Parameters">参数</sys:String>
<sys:String x:Key="Interval">区间</sys:String>
<sys:String x:Key="YesOrNo">是否打印标签</sys:String>
<sys:String x:Key="CuttingGrade">综合切工等级</sys:String>
<sys:String x:Key="SymmetryLevel">综合对称等级</sys:String>
<sys:String x:Key="Print">打印</sys:String>
</ResourceDictionary>

@ -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;
/// <summary>
/// 检测结果画面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()
{

@ -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"
>
<Border.Resources>
@ -66,6 +66,7 @@
<ColumnDefinition Width="Auto"/>
<!-- DS -->
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
<!-- 间隔 -->
<ColumnDefinition Width="*"/>
<!-- 标准 -->
@ -124,8 +125,8 @@
</Border>
</Button>
<!-- DS 下拉列表 -->
<Border Grid.Column="2" Background="#E0E2EE" Width="170" Height="40" CornerRadius="10" >
<Grid>
<Border Grid.Column="3" Background="#E0E2EE" Width="170" Height="40" CornerRadius="10" Margin="2,20,30,20" >
<Grid Margin="-2,0,2,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
@ -140,7 +141,7 @@
</Grid>
</Border>
<!-- 打印按钮 -->
<Button Grid.Column="3" Padding="0" Margin="20,0,0,0" Height="50" BorderThickness="0" IsEnabled="{Binding IsEnabled}"
<Button Grid.Column="2" Padding="0" Margin="0,0,10,0" Height="50" BorderThickness="0" IsEnabled="{Binding IsEnabled}"
Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding ThermalPrintCommand}" HorizontalAlignment="Left">
<Border
HorizontalAlignment="Center"
@ -152,16 +153,16 @@
CornerRadius="20">
<Border.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#3C9CE6" Offset="0"/>
<GradientStop Color="#FF557766" Offset="1"/>
<GradientStop Color="#C26989B7" Offset="0"/>
<GradientStop Color="#C26989B7" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<TextBlock FontSize="18" TextAlignment="Center" Foreground="#ffffff" Text="打印" />
<TextBlock FontSize="18" TextAlignment="Center" Foreground="#ffffff" Text="{StaticResource Print}" />
</Border>
</Button>
<!-- 卡片 -->
<!-- 标准 -->
<Border Grid.Column="4" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Border Grid.Column="5" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -176,7 +177,7 @@
</Grid>
</Border>
<!-- 形状 -->
<Border Grid.Column="5" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Border Grid.Column="6" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -191,7 +192,7 @@
</Grid>
</Border>
<!-- 冠部 -->
<Border Grid.Column="6" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Border Grid.Column="7" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -206,7 +207,7 @@
</Grid>
</Border>
<!-- 亭部 -->
<Border Grid.Column="7" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Border Grid.Column="8" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -221,7 +222,7 @@
</Grid>
</Border>
<!-- 重量 -->
<Border Grid.Column="8" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Border Grid.Column="9" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -236,7 +237,7 @@
</Grid>
</Border>
<!-- 切工等级 -->
<Border Grid.Column="9" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Border Grid.Column="10" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
@ -253,7 +254,7 @@
</Grid>
</Border>
<!-- 切工等级 -->
<Border Grid.Column="10" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Border Grid.Column="11" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>

Loading…
Cancel
Save