feat:add GB2017 and more bugs

master
Tongg 7 months ago
parent 3e8ebfc59b
commit cf819ee3a8
  1. 2
      LoginWindow.xaml.cs
  2. 14
      Model/Helper/Common.cs
  3. 4
      SparkClient.csproj
  4. 5
      ViewModel/Configuration/AlgorithmConfigVM.cs
  5. 724
      ViewModel/Grading/GradingResultVM.cs
  6. 2
      Views/Grading/GradingResult.xaml
  7. 6
      Views/UserControl/ViewportData/Helper/ViewportHelperPro.cs

@ -22,7 +22,7 @@ public partial class LoginWindow : Window
PasswordBox.Password = Settings.SelectValueById("SAVE_PASSWORD"); PasswordBox.Password = Settings.SelectValueById("SAVE_PASSWORD");
try try
{ {
string version = AESHelper.Decrypt(ConfigurationHelper.ReadConfigValue("AppVersion")); string version = Common.AssemblyFileVersion();
TBlockAppVersion.Text = $"Version {version}"; TBlockAppVersion.Text = $"Version {version}";
} }
catch catch

@ -26,6 +26,7 @@ public class Common
public static object LastParam = "ROUND P8 P8"; public static object LastParam = "ROUND P8 P8";
/// <summary> /// <summary>
/// 将 DataTable 转换为 JSON 字符串 /// 将 DataTable 转换为 JSON 字符串
/// </summary> /// </summary>
@ -104,4 +105,17 @@ public class Common
return string.Concat(hashBytes.Select(b => b.ToString("X2"))); return string.Concat(hashBytes.Select(b => b.ToString("X2")));
} }
} }
public static string AssemblyFileVersion()
{
object[] attributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), false);
if (attributes.Length == 0)
{
return "";
}
else
{
return ((AssemblyFileVersionAttribute)attributes[0]).Version;
}
}
} }

@ -12,8 +12,8 @@
<Description>SparkClient钻石检测工具</Description> <Description>SparkClient钻石检测工具</Description>
<Copyright>Copyright ©2025 北京跃洋新视科技有限公司</Copyright> <Copyright>Copyright ©2025 北京跃洋新视科技有限公司</Copyright>
<Company>北京跃洋新视科技有限公司</Company> <Company>北京跃洋新视科技有限公司</Company>
<AssemblyVersion>1.0.0</AssemblyVersion> <AssemblyVersion>1.0.2519</AssemblyVersion>
<FileVersion>1.0.0</FileVersion> <FileVersion>1.0.2519</FileVersion>
<RuntimeIdentifier>win-x64</RuntimeIdentifier> <RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup> </PropertyGroup>

@ -438,6 +438,11 @@ public class AlgorithmConfigVM : BaseViewModel
{ {
Value = "P8-P8-S8", Value = "P8-P8-S8",
Name = "P8-P8-S8" Name = "P8-P8-S8"
},
new Param()
{
Value = "P8-P8-S9",
Name = "P8-P8-S9"
} }
}; };
} }

@ -27,16 +27,11 @@ using HandyControl.Controls;
using RectangleF = System.Drawing.RectangleF; using RectangleF = System.Drawing.RectangleF;
using FontFamily = System.Drawing.FontFamily; using FontFamily = System.Drawing.FontFamily;
using FontStyle = System.Drawing.FontStyle; using FontStyle = System.Drawing.FontStyle;
using NPOI.SS.Formula.Functions;
using System.Windows.Media;
using HandyControl.Tools.Extension;
using NPOI.SS.Util; using NPOI.SS.Util;
using Brush = System.Drawing.Brush; using Brush = System.Drawing.Brush;
using Brushes = System.Drawing.Brushes; using Brushes = System.Drawing.Brushes;
using SparkClient.Model.Attributes; using SparkClient.Model.Attributes;
using SparkClient.Model.Common; using SparkClient.Model.Common;
using PaperSize = System.Drawing.Printing.PaperSize;
using SharpDX.Direct2D1.Effects;
using SparkDotNetCore.DiamondScanner.Entity.Child; using SparkDotNetCore.DiamondScanner.Entity.Child;
using Exception = System.Exception; using Exception = System.Exception;
@ -184,7 +179,7 @@ public class GradingResultVM : BaseViewModel
// 热敏标签打印 // 热敏标签打印
ThermalPrintCommand = new RelayCommand(ExecuteThermalPrint); ThermalPrintCommand = new RelayCommand(ExecuteThermalPrint);
// 初始化 SerialPort // 初始化 SerialPort
InitializeSerialPort(); // InitializeSerialPort();
if (result != null) if (result != null)
{ {
@ -193,15 +188,15 @@ public class GradingResultVM : BaseViewModel
machine = algorithmResult.DeviceId; machine = algorithmResult.DeviceId;
username = Settings.SelectValueById("PERMISSIONS"); username = Settings.SelectValueById("PERMISSIONS");
if (ruleId.StartsWith("IGI")) // if (ruleId.StartsWith("IGI"))
{ // {
IsEnabled = true; // IsEnabled = true;
} // }
else // else
{ // {
IsEnabled = false; // IsEnabled = false;
} // }
IsEnabled = true;
if (algorithmResult.Status.Equals(StatusCodes.Recheck)) IsEnabled = false; if (algorithmResult.Status.Equals(StatusCodes.Recheck)) IsEnabled = false;
} }
@ -890,50 +885,11 @@ public class GradingResultVM : BaseViewModel
info.Dev = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_DEV); info.Dev = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_DEV);
info.Min = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_MIN); info.Min = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_MIN);
info.Max = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_MAX); info.Max = FormatDouble_P(result.Measurements.GIRDLE_VALLEY_MAX);
info.CutLevel = calGrade_GIRDLE(result.Measurements.GIRDLE, result.Measurements.GIRDLE);
info.Dev = calDev(info.Max, info.Min);
var data = result.Measurements; var data = result.Measurements;
var girdleValleyDetail = data.GIRDLE_VALLEY_DETAIL; var girdleValleyDetail = data.GIRDLE_VALLEY_DETAIL;
// 变更 波谷评级计算方式
// List<double> gradeValues = new List<double>();
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_1);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_2);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_3);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_4);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_5);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_6);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_7);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_8);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_9);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_10);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_11);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_12);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_13);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_14);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_15);
// gradeValues.Add(data.GIRDLE_VALLEY_DETAIL.GIRDLE_VALLEY_16);
// gradeValues.Add(data.GIRDLE_BONE_DETAIL.GIRDLE_BONE_1);
// gradeValues.Add(data.GIRDLE_BONE_DETAIL.GIRDLE_BONE_2);
// gradeValues.Add(data.GIRDLE_BONE_DETAIL.GIRDLE_BONE_3);
// gradeValues.Add(data.GIRDLE_BONE_DETAIL.GIRDLE_BONE_4);
// gradeValues.Add(data.GIRDLE_BONE_DETAIL.GIRDLE_BONE_5);
// gradeValues.Add(data.GIRDLE_BONE_DETAIL.GIRDLE_BONE_6);
// gradeValues.Add(data.GIRDLE_BONE_DETAIL.GIRDLE_BONE_7);
// gradeValues.Add(data.GIRDLE_BONE_DETAIL.GIRDLE_BONE_8);
// gradeValues.Add(data.GIRDLE_BEZEL_DETAIL.GIRDLE_BEZEL_1);
// gradeValues.Add(data.GIRDLE_BEZEL_DETAIL.GIRDLE_BEZEL_2);
// gradeValues.Add(data.GIRDLE_BEZEL_DETAIL.GIRDLE_BEZEL_3);
// gradeValues.Add(data.GIRDLE_BEZEL_DETAIL.GIRDLE_BEZEL_4);
// gradeValues.Add(data.GIRDLE_BEZEL_DETAIL.GIRDLE_BEZEL_5);
// gradeValues.Add(data.GIRDLE_BEZEL_DETAIL.GIRDLE_BEZEL_6);
// gradeValues.Add(data.GIRDLE_BEZEL_DETAIL.GIRDLE_BEZEL_7);
// gradeValues.Add(data.GIRDLE_BEZEL_DETAIL.GIRDLE_BEZEL_8);
// double averageGrade = gradeValues.Average();
info.CutLevel = calGrade_GIRDLE(data.GIRDLE, data.GIRDLE);
// info.CutLevel = calGrade_GIRDLE(result.Measurements.GIRDLE_VALLEY_MIN, result.Measurements.GIRDLE_VALLEY_MAX);
info.Dev = calDev(info.Max, info.Min);
if (girdleValleyDetail != null) if (girdleValleyDetail != null)
{ {
@ -2370,217 +2326,233 @@ public class GradingResultVM : BaseViewModel
} }
// 自定义打印预览窗体类 // 自定义打印预览窗体类
public class CustomPrintPreviewForm : Form // public class CustomPrintPreviewForm : Form
{ // {
private PrintPreviewControl printPreviewControl; // private PrintPreviewControl printPreviewControl;
private Button confirmButton; // private Button confirmButton;
private Button systemPrintButton; // 新增的系统打印按钮 // private Button systemPrintButton; // 新增的系统打印按钮
private PrintDocument printDocument; // private PrintDocument printDocument;
//
public CustomPrintPreviewForm(PrintDocument document) // public CustomPrintPreviewForm(PrintDocument document)
{ // {
this.printDocument = document; // this.printDocument = document;
//
// 初始化打印预览控件 // // 初始化打印预览控件
printPreviewControl = new PrintPreviewControl(); // printPreviewControl = new PrintPreviewControl();
printPreviewControl.Dock = DockStyle.Fill; // printPreviewControl.Dock = DockStyle.Fill;
printPreviewControl.Document = printDocument; // printPreviewControl.Document = printDocument;
//
// 初始化确认按钮 // // 初始化确认按钮
confirmButton = new Button(); // confirmButton = new Button();
confirmButton.Text = "确认打印"; // confirmButton.Text = "确认打印";
confirmButton.Dock = DockStyle.Bottom; // confirmButton.Dock = DockStyle.Bottom;
confirmButton.Click += ConfirmButton_Click; // confirmButton.Click += ConfirmButton_Click;
//
// 初始化系统打印按钮 // // 初始化系统打印按钮
// systemPrintButton = new Button(); // // systemPrintButton = new Button();
// systemPrintButton.Text = "系统打印"; // // systemPrintButton.Text = "系统打印";
// systemPrintButton.Dock = DockStyle.Bottom; // // systemPrintButton.Dock = DockStyle.Bottom;
// systemPrintButton.Click += SystemPrintButton_Click; // // systemPrintButton.Click += SystemPrintButton_Click;
//
// 将控件添加到窗体 // // 将控件添加到窗体
this.Controls.Add(printPreviewControl); // this.Controls.Add(printPreviewControl);
this.Controls.Add(confirmButton); // this.Controls.Add(confirmButton);
this.Controls.Add(systemPrintButton); // this.Controls.Add(systemPrintButton);
//
// 设置窗体属性 // // 设置窗体属性
this.Size = new System.Drawing.Size(800, 600); // this.Size = new System.Drawing.Size(800, 600);
} // }
//
[Log] // [Log]
private void ConfirmButton_Click(object sender, EventArgs e) // private void ConfirmButton_Click(object sender, EventArgs e)
{ // {
this.DialogResult = DialogResult.OK; // this.DialogResult = DialogResult.OK;
this.Close(); // this.Close();
} // }
//
[Log] // [Log]
private void SystemPrintButton_Click(object sender, EventArgs e) // private void SystemPrintButton_Click(object sender, EventArgs e)
{ // {
// 创建一个打印对话框 // // 创建一个打印对话框
PrintDialog printDialog = new PrintDialog(); // PrintDialog printDialog = new PrintDialog();
// 将打印对话框关联到当前的 PrintDocument // // 将打印对话框关联到当前的 PrintDocument
printDialog.Document = printDocument; // printDialog.Document = printDocument;
//
// 显示打印对话框,如果用户点击了“确定”按钮 // // 显示打印对话框,如果用户点击了“确定”按钮
if (printDialog.ShowDialog() == DialogResult.OK) // if (printDialog.ShowDialog() == DialogResult.OK)
{ // {
// 使用用户在对话框中选择的打印机和设置进行打印 // // 使用用户在对话框中选择的打印机和设置进行打印
printDocument.Print(); // printDocument.Print();
} // }
} // }
} //
// /// <summary>
// /// Required method for Designer support - do not modify
// /// the contents of this method with the code editor.
// /// </summary>
// private void InitializeComponent()
// {
// SuspendLayout();
// //
// // CustomPrintPreviewForm
// //
// ClientSize = new System.Drawing.Size(479, 388);
// ResumeLayout(false);
// }
//
//
// }
[Log] // [Log]
private void PreparePrintData(object sender, PrintPageEventArgs e) // private void PreparePrintData(object sender, PrintPageEventArgs e)
{ // {
int width = e.PageSettings.PaperSize.Width; // int width = e.PageSettings.PaperSize.Width;
//
//
var result = algorithmResult.Measurements; // var result = algorithmResult.Measurements;
int startX = 3; // int startX = 3;
int startY = 3; // int startY = 3;
var col2X = startX + (width * 0.2f); // var col2X = startX + (width * 0.2f);
var col3X = col2X + (width * 0.2f); // var col3X = col2X + (width * 0.2f);
var col4X = col3X + (width * 0.2f); // var col4X = col3X + (width * 0.2f);
var col5X = col4X + (width * 0.2f); // var col5X = col4X + (width * 0.2f);
// 设置字体 // // 设置字体
Font font = new Font(FontFamily.GenericSerif, 6, FontStyle.Bold); // Font font = new Font(FontFamily.GenericSerif, 6, FontStyle.Bold);
//
// 设置颜色 // // 设置颜色
Brush brush = Brushes.Black; // Brush brush = Brushes.Black;
//
// 设置对齐方式 // // 设置对齐方式
StringFormat format = new StringFormat(); // StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center; // 水平居中 // format.Alignment = StringAlignment.Center; // 水平居中
format.LineAlignment = StringAlignment.Center; // 垂直居中 // format.LineAlignment = StringAlignment.Center; // 垂直居中
Brush backgroundBrush = new SolidBrush(System.Drawing.Color.Black); // 背景色为黑色 // Brush backgroundBrush = new SolidBrush(System.Drawing.Color.Black); // 背景色为黑色
//
// 绘制文本 // // 绘制文本
// 第一行 // // 第一行
float X = startX; // float X = startX;
float Y = startY; // float Y = startY;
e.Graphics.DrawString($"{MultilingualHelper.getString("Organization")}:{Standard}", font, brush, new PointF(X, Y)); // 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("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("Code")}:{DiamondCode}", font, brush, new PointF(col3X, Y));
e.Graphics.DrawString($"{MultilingualHelper.getString("Wight")}:{Wight}ct.", font, brush, new PointF(col5X, Y)); // e.Graphics.DrawString($"{MultilingualHelper.getString("Wight")}:{Wight}ct.", font, brush, new PointF(col5X, Y));
//
// 第二行 // // 第二行
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.DrawString($"{MultilingualHelper.getString("Parameters")}", font, brush, new PointF(X, Y)); // 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("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("Interval")}(Min~Max)", font, brush, new PointF(col3X, Y));
e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultGridCutLevel")}", font, brush, new PointF(col4X, Y)); // e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultGridCutLevel")}", font, brush, new PointF(col4X, Y));
e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultSymmetryGrade")}", font, brush, new PointF(col5X, Y)); // e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultSymmetryGrade")}", font, brush, new PointF(col5X, Y));
//
// 第三行 // // 第三行
// 直径 // // 直径
var d = getSelectData("DIAMETER"); // var d = getSelectData("DIAMETER");
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.DrawString($"{GetName("DIAMETER")}(mm)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{GetName("DIAMETER")}(mm)", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString(d.Avg, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(d.Avg, font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"({d.Min}-{d.Max})", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({d.Min}-{d.Max})", font, brush, new PointF(X, Y));
e.Graphics.DrawString($"-", font, brush, new PointF(col4X, Y)); // e.Graphics.DrawString($"-", font, brush, new PointF(col4X, Y));
e.Graphics.DrawString($"{d.SymLevel}", font, brush, new PointF(col5X, Y)); // e.Graphics.DrawString($"{d.SymLevel}", font, brush, new PointF(col5X, Y));
// 第四行 // // 第四行
// 全深比 // // 全深比
var o = getSelectData("TOTAL_DEPTH"); // var o = getSelectData("TOTAL_DEPTH");
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.DrawString($"{GetName("TOTAL_DEPTH")}(%)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{GetName("TOTAL_DEPTH")}(%)", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString(o.Avg, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(o.Avg, font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"-", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"-", font, brush, new PointF(X, Y));
e.Graphics.DrawString($"{o.CutLevel}", font, brush, new PointF(col4X, Y)); // e.Graphics.DrawString($"{o.CutLevel}", font, brush, new PointF(col4X, Y));
e.Graphics.FillRectangle(backgroundBrush, new RectangleF(col5X, Y, 150, font.Height)); // e.Graphics.FillRectangle(backgroundBrush, new RectangleF(col5X, Y, 150, font.Height));
// 第五行 // // 第五行
// 台宽比 // // 台宽比
var t = getSelectData("TABLE"); // var t = getSelectData("TABLE");
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.DrawString($"{GetName("TABLE")}(%)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{GetName("TABLE")}(%)", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString(t.Avg, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(t.Avg, font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"({t.Min}-{t.Max})", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({t.Min}-{t.Max})", font, brush, new PointF(X, Y));
e.Graphics.DrawString($"{t.CutLevel}", font, brush, new PointF(col4X, Y)); // e.Graphics.DrawString($"{t.CutLevel}", font, brush, new PointF(col4X, Y));
e.Graphics.FillRectangle(backgroundBrush, new RectangleF(col5X, Y, 150, font.Height)); // e.Graphics.FillRectangle(backgroundBrush, new RectangleF(col5X, Y, 150, font.Height));
// 第六行 // // 第六行
// 冠角 // // 冠角
var c = getSelectData("CROWN_ANGLE"); // var c = getSelectData("CROWN_ANGLE");
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.DrawString($"{GetName("CROWN_ANGLE")}(°)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{GetName("CROWN_ANGLE")}(°)", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString(c.Avg, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(c.Avg, font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"({c.Min}-{c.Max})", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({c.Min}-{c.Max})", font, brush, new PointF(X, Y));
X += 120; // X += 120;
e.Graphics.DrawString($"{c.CutLevel}", font, brush, new PointF(col4X, Y)); // e.Graphics.DrawString($"{c.CutLevel}", font, brush, new PointF(col4X, Y));
e.Graphics.DrawString($"{c.SymLevel}", font, brush, new PointF(col5X, Y)); // e.Graphics.DrawString($"{c.SymLevel}", font, brush, new PointF(col5X, Y));
// 第七行 // // 第七行
// 冠高比 // // 冠高比
var h = getSelectData("CROWN_HEIGHT"); // var h = getSelectData("CROWN_HEIGHT");
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.DrawString($"{GetName("CROWN_HEIGHT")}(%)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{GetName("CROWN_HEIGHT")}(%)", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString(h.Avg, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(h.Avg, font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"({h.Min}-{h.Max})", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({h.Min}-{h.Max})", font, brush, new PointF(X, Y));
X += 60; // X += 60;
e.Graphics.DrawString($"{h.CutLevel}", font, brush, new PointF(col4X, Y)); // e.Graphics.DrawString($"{h.CutLevel}", font, brush, new PointF(col4X, Y));
e.Graphics.DrawString($"{h.SymLevel}", font, brush, new PointF(col5X, Y)); // e.Graphics.DrawString($"{h.SymLevel}", font, brush, new PointF(col5X, Y));
// 第八行 // // 第八行
// 波谷腰厚 // // 波谷腰厚
var g = getSelectData("GIRDLE"); // var g = getSelectData("GIRDLE");
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.DrawString($"{GetName("GIRDLE")}(%)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{GetName("GIRDLE")}(%)", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString(g.Avg, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(g.Avg, font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"({g.Min}-{g.Max})", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({g.Min}-{g.Max})", font, brush, new PointF(X, Y));
e.Graphics.DrawString($"{g.CutLevel}", font, brush, new PointF(col4X, Y)); // e.Graphics.DrawString($"{g.CutLevel}", font, brush, new PointF(col4X, Y));
e.Graphics.DrawString($"{g.SymLevel}", font, brush, new PointF(col5X, Y)); // e.Graphics.DrawString($"{g.SymLevel}", font, brush, new PointF(col5X, Y));
// 第九行 // // 第九行
// 亭深比 // // 亭深比
var p = getSelectData("PAV_DEPTH"); // var p = getSelectData("PAV_DEPTH");
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.DrawString($"{GetName("PAV_DEPTH")}(%)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{GetName("PAV_DEPTH")}(%)", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString(p.Avg, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(p.Avg, font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"({p.Min}-{p.Max})", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({p.Min}-{p.Max})", font, brush, new PointF(X, Y));
e.Graphics.DrawString($"{p.CutLevel}", font, brush, new PointF(col4X, Y)); // e.Graphics.DrawString($"{p.CutLevel}", font, brush, new PointF(col4X, Y));
e.Graphics.DrawString($"{p.SymLevel}", font, brush, new PointF(col5X, Y)); // e.Graphics.DrawString($"{p.SymLevel}", font, brush, new PointF(col5X, Y));
// 第十行 // // 第十行
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, col2X - 5, font.Height)); // e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, col2X - 5, font.Height));
e.Graphics.DrawString($"{MultilingualHelper.getString("CuttingGrade")}", font, Brushes.White, new PointF(X, Y)); // e.Graphics.DrawString($"{MultilingualHelper.getString("CuttingGrade")}", font, Brushes.White, new PointF(X, Y));
//
X = col2X; // X = col2X;
e.Graphics.DrawString(CutLevelTotal, font, Brushes.Black, new PointF(X, Y)); // e.Graphics.DrawString(CutLevelTotal, font, Brushes.Black, new PointF(X, Y));
// 第十一行 // // 第十一行
X = startX; // X = startX;
Y += font.Height + 2; // Y += font.Height + 2;
e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, col2X - 5, font.Height)); // e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, col2X - 5, font.Height));
e.Graphics.DrawString($"{MultilingualHelper.getString("SymmetryLevel")}", font, Brushes.White, new PointF(X, Y)); // e.Graphics.DrawString($"{MultilingualHelper.getString("SymmetryLevel")}", font, Brushes.White, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString(SymLevelTotal, font, Brushes.Black, new PointF(X, Y)); // e.Graphics.DrawString(SymLevelTotal, font, Brushes.Black, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"{MultilingualHelper.getString("DateOfIssue")}: {DateTime.Now:yyyy/M/d}", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{MultilingualHelper.getString("DateOfIssue")}: {DateTime.Now:yyyy/M/d}", font, brush, new PointF(X, Y));
//
} // }
[Log] [Log]
private string GenerateTempExcelFile() private string GenerateTempExcelFile()
{ {
@ -2683,116 +2655,116 @@ public class GradingResultVM : BaseViewModel
ICell cell = row.GetCell(cellRef.Col) ?? row.CreateCell(cellRef.Col); ICell cell = row.GetCell(cellRef.Col) ?? row.CreateCell(cellRef.Col);
cell.SetCellValue(value?.ToString() ?? ""); cell.SetCellValue(value?.ToString() ?? "");
} }
[Log] // [Log]
private void PrintPageHandler(object sender, PrintPageEventArgs e) // private void PrintPageHandler(object sender, PrintPageEventArgs e)
{ // {
var result = algorithmResult.Measurements; // var result = algorithmResult.Measurements;
int startX = 10; // int startX = 10;
int startY = 10; // int startY = 10;
var col2X = startX + 90; // var col2X = startX + 90;
var col3X = col2X + 70; // var col3X = col2X + 70;
// 设置字体 // // 设置字体
Font font = new Font(FontFamily.GenericSerif, 12, FontStyle.Bold); // Font font = new Font(FontFamily.GenericSerif, 12, FontStyle.Bold);
//
// 设置颜色 // // 设置颜色
Brush brush = Brushes.Black; // Brush brush = Brushes.Black;
//
// 设置对齐方式 // // 设置对齐方式
StringFormat format = new StringFormat(); // StringFormat format = new StringFormat();
format.Alignment = StringAlignment.Center; // 水平居中 // format.Alignment = StringAlignment.Center; // 水平居中
format.LineAlignment = StringAlignment.Center; // 垂直居中 // format.LineAlignment = StringAlignment.Center; // 垂直居中
//
// 绘制文本 // // 绘制文本
// 第一行 // // 第一行
int X = startX; // int X = startX;
int Y = startY; // int Y = startY;
e.Graphics.DrawString(Standard, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(Standard, font, brush, new PointF(X, Y));
X += 70; // X += 70;
e.Graphics.DrawString(Shape, font, brush, new PointF(X, Y)); // e.Graphics.DrawString(Shape, font, brush, new PointF(X, Y));
X += 50; // X += 50;
e.Graphics.DrawString($"ID:{DiamondCode}", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"ID:{DiamondCode}", font, brush, new PointF(X, Y));
X += 100; // X += 100;
e.Graphics.DrawString($"Weight:{Wight}ct.", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"Weight:{Wight}ct.", font, brush, new PointF(X, Y));
X += 120; // X += 120;
Brush backgroundBrush = new SolidBrush(System.Drawing.Color.Black); // 背景色为黄色 // Brush backgroundBrush = new SolidBrush(System.Drawing.Color.Black); // 背景色为黄色
e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, 200, font.Height)); // e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, 200, font.Height));
e.Graphics.DrawString(CutLevelTotal, font, Brushes.White, new PointF(X, Y)); // e.Graphics.DrawString(CutLevelTotal, font, Brushes.White, new PointF(X, Y));
//
// 第二行 // // 第二行
X = startX; // X = startX;
Y += font.Height; // Y += font.Height;
e.Graphics.DrawString("Diameter", font, brush, new PointF(X, Y)); // 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.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($"({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.DrawString($"0.3%", font, brush, new PointF(310, Y));
e.Graphics.FillRectangle(backgroundBrush, new RectangleF(350, Y, 200, font.Height)); // e.Graphics.FillRectangle(backgroundBrush, new RectangleF(350, Y, 200, font.Height));
e.Graphics.DrawString(SymLevelTotal, font, Brushes.White, new PointF(X, Y)); // e.Graphics.DrawString(SymLevelTotal, font, Brushes.White, new PointF(X, Y));
//
// 第三行 // // 第三行
X = startX; // X = startX;
Y += font.Height; // Y += font.Height;
e.Graphics.DrawString("Total Dep.", font, brush, new PointF(X, Y)); // e.Graphics.DrawString("Total Dep.", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString($"{FormatDouble_D(result.DIAMETER * result.TOTAL_DEPTH)}mm", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{FormatDouble_D(result.DIAMETER * result.TOTAL_DEPTH)}mm", font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"{FormatDouble_P(result.TOTAL_DEPTH)}%", font, brush, new PointF(X, Y)); // 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)); // e.Graphics.DrawString($"{DtResults.Where(X=> "TOTAL_DEPTH".Equals(X.TestItemId)).Select(X=>X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y));
// 第四行 // // 第四行
X = startX; // X = startX;
Y += font.Height; // Y += font.Height;
e.Graphics.DrawString("Table", font, brush, new PointF(X, Y)); // e.Graphics.DrawString("Table", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString($"{FormatDouble_D(result.DIAMETER * result.TABLE)}mm", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{FormatDouble_D(result.DIAMETER * result.TABLE)}mm", font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"{FormatDouble_P(result.TABLE)}%", font, brush, new PointF(X, Y)); // 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)); // e.Graphics.DrawString($"{DtResults.Where(X => "TABLE".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y));
// 第五行 // // 第五行
X = startX; // X = startX;
Y += font.Height; // Y += font.Height;
e.Graphics.DrawString("Crown", font, brush, new PointF(X, Y)); // e.Graphics.DrawString("Crown", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString($"{FormatDouble_A(result.CROWN_ANGLE)}°", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{FormatDouble_A(result.CROWN_ANGLE)}°", font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"({FormatDouble_A(result.CROWN_ANGLE_MIN)}°-{FormatDouble_A(result.CROWN_ANGLE_MAX)}°)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({FormatDouble_A(result.CROWN_ANGLE_MIN)}°-{FormatDouble_A(result.CROWN_ANGLE_MAX)}°)", font, brush, new PointF(X, Y));
X += 120; // X += 120;
e.Graphics.DrawString($"({FormatDouble_A(result.CROWN_HEIGHT)}%)", font, brush, new PointF(X, Y)); // 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_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)); // e.Graphics.DrawString($"{DtResults.Where(X => "CROWN_HEIGHT".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y));
// 第六行 // // 第六行
X = startX; // X = startX;
Y += font.Height; // Y += font.Height;
e.Graphics.DrawString("Pavil.", font, brush, new PointF(X, Y)); // e.Graphics.DrawString("Pavil.", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString($"{FormatDouble_A(result.PAV_ANGLE)}°", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{FormatDouble_A(result.PAV_ANGLE)}°", font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"({FormatDouble_A(result.PAV_ANGLE_MIN)}°-{FormatDouble_A(result.PAV_ANGLE_MAX)}°)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({FormatDouble_A(result.PAV_ANGLE_MIN)}°-{FormatDouble_A(result.PAV_ANGLE_MAX)}°)", font, brush, new PointF(X, Y));
X += 120; // X += 120;
e.Graphics.DrawString($"({FormatDouble_A(result.PAV_DEPTH)}%)", font, brush, new PointF(X, Y)); // 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_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)); // e.Graphics.DrawString($"{DtResults.Where(X => "PAV_DEPTH".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y));
// 第七行 // // 第七行
X = startX; // X = startX;
Y += font.Height; // Y += font.Height;
e.Graphics.DrawString("Culet", font, brush, new PointF(X, Y)); // e.Graphics.DrawString("Culet", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString($"{FormatDouble_P(result.CULET)}%", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{FormatDouble_P(result.CULET)}%", font, brush, new PointF(X, Y));
X = col3X; // X = col3X;
e.Graphics.DrawString($"Twist", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"Twist", font, brush, new PointF(X, Y));
X += 60; // X += 60;
e.Graphics.DrawString($"({FormatDouble_A(result.TWIST_MIN)}°-{FormatDouble_A(result.TWIST_MAX)}°)", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"({FormatDouble_A(result.TWIST_MIN)}°-{FormatDouble_A(result.TWIST_MAX)}°)", font, brush, new PointF(X, Y));
// 第八行 // // 第八行
X = startX; // X = startX;
Y += font.Height; // Y += font.Height;
e.Graphics.DrawString("Girdle 16M", font, brush, new PointF(X, Y)); // e.Graphics.DrawString("Girdle 16M", font, brush, new PointF(X, Y));
X = col2X; // X = col2X;
e.Graphics.DrawString($"{FormatDouble_D(result.GIRDLE_VALLEY)}", font, brush, new PointF(X, Y)); // e.Graphics.DrawString($"{FormatDouble_D(result.GIRDLE_VALLEY)}", font, brush, new PointF(X, Y));
X = col3X; // 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($"({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)); // e.Graphics.DrawString($"{DtResults.Where(X => "GIRDLE".Equals(X.TestItemId)).Select(X => X.CutLevel).FirstOrDefault()}", font, brush, new PointF(480, Y));
//
} // }
[Log] [Log]
private void InitializeSerialPort() private void InitializeSerialPort()

@ -785,7 +785,7 @@
</DataGrid> </DataGrid>
</Border> </Border>
<GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="Transparent"></GridSplitter> <GridSplitter Grid.Column="1" Width="5" HorizontalAlignment="Stretch" IsEnabled="False" Background="Transparent"></GridSplitter>
<Border Grid.Column="2" Background="White" Style="{StaticResource BorderRowStyle}"> <Border Grid.Column="2" Background="White" Style="{StaticResource BorderRowStyle}">
<Grid> <Grid>
<Grid.RowDefinitions> <Grid.RowDefinitions>

@ -1107,6 +1107,12 @@ public class ViewportHelperPro
} }
catch (Exception ex) catch (Exception ex)
{ {
// S9暂不提示
if (step.ToLower().Equals("s9"))
{
return result;
}
new MessageBox().Show($"面取值错误:{ex.Message}"); new MessageBox().Show($"面取值错误:{ex.Message}");
return result; return result;
} }

Loading…
Cancel
Save