master
tongg 7 months ago
parent 3987afe481
commit f27be31c17
  1. 2
      Model/Helper/Common.cs
  2. 50
      Model/Services/SOCClientService.cs
  3. 6
      ViewModel/BaseWindow/BaseControlVM.cs
  4. 1
      ViewModel/Grading/DiamondSelectVM.cs
  5. 2
      ViewModel/Grading/GradingLoadingVM.cs
  6. 463
      ViewModel/Grading/GradingResultVM.cs
  7. 2
      Views/HelperPage.xaml.cs

@ -22,7 +22,7 @@ public class Common
public const string DataBaseName = "SparkDB";
public static int RunMode = 0;
public static int RunMode { get; set; } = 0;
public static object LastParam = "ROUND P8 P8";

@ -251,6 +251,7 @@ namespace BrilliantSightClient.Model.Services
/// <returns>图片的字节数组</returns>
public async Task<List<string>> RetrieveImageAsync(string? savePath, CancellationToken token = default)
{
List<string> imageNames = new List<string>();
// 读取图片接口
int imageIndex = 0;
@ -266,9 +267,9 @@ namespace BrilliantSightClient.Model.Services
string sendCode = url.GenerateSign();
try
{
var response = await SendGetRequestImageAsync(url,sendCode);
var response = await SendGetRequestImageAsync(url, sendCode);
int status = (int)response.StatusCode;
token.ThrowIfCancellationRequested();
switch (status)
{
@ -299,7 +300,7 @@ namespace BrilliantSightClient.Model.Services
// 资源未找到,结束循环
Logger.Info($"[SendCode={sendCode}] Image Not Found.");
break;
//return imageNames;
//return imageNames;
default:
// 其他状态码,记录警告并继续
Logger.Warn($"[SendCode={sendCode}]Unexpected status code: {status} for URL: {url}");
@ -316,7 +317,8 @@ namespace BrilliantSightClient.Model.Services
catch (Exception ex)
{
// 捕获其他异常并记录错误信息,结束循环
Logger.Error($"[SendCode={sendCode}]An unexpected error occurred for URL: {url}, Exception: {ex.Message}");
Logger.Error(
$"[SendCode={sendCode}]An unexpected error occurred for URL: {url}, Exception: {ex.Message}");
return imageNames;
}
}
@ -366,6 +368,7 @@ namespace BrilliantSightClient.Model.Services
{
try
{
await OpenPump(true);
// SOC接口
string? savePath = ConfigurationManager.AppSettings["ImageFileBasePath"];
// 清理 savePath 文件夹
@ -387,40 +390,7 @@ namespace BrilliantSightClient.Model.Services
}
// 读取图片接口
List<string> imageNames = await RetrieveImageAsync(savePath);
// var cts = new CancellationTokenSource();
// Task<HttpSendResult> startImage = CollectImagesAsyncNotAwait();
// Task<List<string>> downloadImage = RetrieveImageAsync(savePath, cts.Token);
// await startImage;
// var entity = startImage.Result;
// if (entity.StatusCode != 200 || entity.Content == null)
// {
// //downloadImage怎么取消并终止
// cts.Cancel();
// return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List<string>() };
// }
//
// List<string> imageNames = new List<string>();
// try
// {
// await downloadImage;
// imageNames = downloadImage.Result;
// }
// catch (OperationCanceledException e)
// {
// Logger.Error($"Error in Await downloadImage: {e.Message}");
// }
// // 采集状态接口
// string acquisitionStatus = await CollectStatusAsync();
// // 成功
// if (acquisitionStatus != StatusCodes.Success)
// {
// Logger.Debug($"acquisitionStatus != StatusCodes.Success : {acquisitionStatus}");
// // 采集状态失败
// return new SocResultEntity { Status = acquisitionStatus, Images = new List<string>() };
// }
if (imageNames.Count == 0)
{
Logger.Debug("imageNames.Count == 0");
@ -437,6 +407,10 @@ namespace BrilliantSightClient.Model.Services
Logger.Error(logMessage);
return new SocResultEntity { Status = StatusCodes.DeviceNotFound, Images = new List<string>() };
}
finally
{
await OpenPump(false);
}
}
/// <summary>

@ -2,6 +2,7 @@
using System.Windows.Input;
using GlobalHotKey;
using BrilliantSightClient.Model.Attributes;
using BrilliantSightClient.Model.Extension;
using BrilliantSightClient.Model.Helper;
using BrilliantSightClient.Model.Services;
using BrilliantSightClient.ViewModel.Grading;
@ -135,7 +136,7 @@ public class BaseControlVM : BaseViewModel
public void NextDiamond(object parameter)
{
CloseVM(parameter);
CloseVM("FromNextDiamond");
DiamondSelectVM selectVm = new DiamondSelectVM();
ViewControl = selectVm;
WindowTitle = MultilingualHelper.getString("DiamondSelect");
@ -154,7 +155,8 @@ public class BaseControlVM : BaseViewModel
{
WindowManager.PreviousVM();
WindowManager.mainViewModel.Content = WindowManager.PreviousVM();
await SOCClientService.Service.OpenPump(false);
if(Common.RunMode == 0 || !parameter.ToSafeString().Equals("FromNextDiamond"))
await SOCClientService.Service.OpenPump(false);
if(resultVM._isSaveCsv == false)
resultVM.SaveToCsv();
try

@ -269,6 +269,7 @@ public class DiamondSelectVM : BaseViewModel
);
if (result == MessageBoxResult.None)
{
await SOCClientService.Service.OpenPump(false);
return;
}
if (result == MessageBoxResult.OK)

@ -231,7 +231,7 @@ public class GradingLoadingVM : BaseViewModel,IDisposable
if(type == 0)
{
await SOCClientService.Service.OpenPump(true);
// await SOCClientService.Service.OpenPump(true);
// if (!StatusCodes.Success.Equals(openpupmStatus))
// {
// new MessageBox().Show("气泵开启失败!");

@ -333,7 +333,7 @@ public class GradingResultVM : BaseViewModel
{
File.Create(filePath).Close();
string header = string.Empty;
if ("zh-cn".Equals(MultilingualHelper.getLangType()))
if ("en".Equals(MultilingualHelper.getLangType()))
{
header = "Diamond Code,Wight(ct),Measurement1(mm), Measurement2(mm), Measurement3(mm), Table(%), Crown Height(%),Pavilion Depth(%), Total Depth(%),Crown Angle(°), Pavilion Angle(°),Culet Size(mm), Girdle Percent(%),Girdle Name, POL or Pol/ Sym,SYM,CUT - PROP";
}
@ -2275,319 +2275,8 @@ public class GradingResultVM : BaseViewModel
File.Delete(tempFilePath);
}
}
// try
// {
// // 创建打印文档
// PrintDocument printDocument = new PrintDocument();
// //printDocument.PrintPage += PrintPageHandler;
// // 订阅 PrintPage 事件
// printDocument.PrintPage += PreparePrintData;
//
// // 创建自定义打印预览窗体
// CustomPrintPreviewForm customPreviewForm = new CustomPrintPreviewForm(printDocument);
//
// // 显示自定义打印预览窗体
//
// MessageBox messageBox = new MessageBox();
// MessageBoxResult boxResult = messageBox.ShowAsk(MultilingualHelper.getString("YesOrNo"));
// if (boxResult == MessageBoxResult.OK)
// {
// // 打开串口
// // if (!_serialPort.IsOpen)
// // {
// // _serialPort.Open();
// // }
//
// // 将绘制内容转换为字节数组
// // 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();
// string? printName = ConfigurationManager.AppSettings["PrintName"];
// string? printWidth = ConfigurationManager.AppSettings["PrintWidth"];
// string? printHeight = ConfigurationManager.AppSettings["PrintHeight"];
//
// int pageWidth = 400;
// int pageHeight = 300;
// if (string.IsNullOrWhiteSpace(printName) || string.IsNullOrWhiteSpace(printWidth) ||
// string.IsNullOrWhiteSpace(printHeight) )
// {
// Logger.Info("缺少打印配置。");
// throw new Exception("The printer parameter is invalid");
// }
// int.TryParse(printWidth, out pageWidth);
// int.TryParse(printHeight, out pageHeight);
//
// printDocument.PrinterSettings.PrinterName = printName;
// printDocument.DefaultPageSettings.PaperSize = new PaperSize("mm", pageWidth, pageHeight);
// printDocument.PrintController = new System.Drawing.Printing.StandardPrintController();
//
// // DialogResult result = customPreviewForm.ShowDialog();
// printDocument.Print();
// // 发送数据到串口
// //_serialPort.Write(dataToSend, 0, dataToSend.Length);
//
// Logger.Info("数据已发送到热敏打印机。");
// }
// }
// catch (Exception ex)
// {
// Logger.Error($"热敏打印发生错误: {ex.Message}");
// Growl.Error(MultilingualHelper.getString("DiamodResultPrintError"));
// }
// finally
// {
// // 关闭串口
// // if (_serialPort.IsOpen)
// // {
// // _serialPort.Close();
// // }
// }
}
// 自定义打印预览窗体类
// public class CustomPrintPreviewForm : Form
// {
// private PrintPreviewControl printPreviewControl;
// private Button confirmButton;
// private Button systemPrintButton; // 新增的系统打印按钮
// private PrintDocument printDocument;
//
// public CustomPrintPreviewForm(PrintDocument document)
// {
// this.printDocument = document;
//
// // 初始化打印预览控件
// printPreviewControl = new PrintPreviewControl();
// printPreviewControl.Dock = DockStyle.Fill;
// printPreviewControl.Document = printDocument;
//
// // 初始化确认按钮
// confirmButton = new Button();
// confirmButton.Text = "确认打印";
// confirmButton.Dock = DockStyle.Bottom;
// confirmButton.Click += ConfirmButton_Click;
//
// // 初始化系统打印按钮
// // systemPrintButton = new Button();
// // systemPrintButton.Text = "系统打印";
// // systemPrintButton.Dock = DockStyle.Bottom;
// // systemPrintButton.Click += SystemPrintButton_Click;
//
// // 将控件添加到窗体
// this.Controls.Add(printPreviewControl);
// this.Controls.Add(confirmButton);
// this.Controls.Add(systemPrintButton);
//
// // 设置窗体属性
// this.Size = new System.Drawing.Size(800, 600);
// }
//
// [Log]
// private void ConfirmButton_Click(object sender, EventArgs e)
// {
// this.DialogResult = DialogResult.OK;
// this.Close();
// }
//
// [Log]
// private void SystemPrintButton_Click(object sender, EventArgs e)
// {
// // 创建一个打印对话框
// PrintDialog printDialog = new PrintDialog();
// // 将打印对话框关联到当前的 PrintDocument
// printDialog.Document = printDocument;
//
// // 显示打印对话框,如果用户点击了“确定”按钮
// if (printDialog.ShowDialog() == DialogResult.OK)
// {
// // 使用用户在对话框中选择的打印机和设置进行打印
// 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]
// private void PreparePrintData(object sender, PrintPageEventArgs e)
// {
// int width = e.PageSettings.PaperSize.Width;
//
//
// var result = algorithmResult.Measurements;
// int startX = 3;
// int startY = 3;
// var col2X = startX + (width * 0.2f);
// var col3X = col2X + (width * 0.2f);
// var col4X = col3X + (width * 0.2f);
// var col5X = col4X + (width * 0.2f);
// // 设置字体
// Font font = new Font(FontFamily.GenericSerif, 6, 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); // 背景色为黑色
//
// // 绘制文本
// // 第一行
// float X = startX;
// float 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(col5X, Y));
//
// // 第二行
// X = startX;
// Y += font.Height + 2;
// 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(col4X, Y));
// e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultSymmetryGrade")}", font, brush, new PointF(col5X, Y));
//
// // 第三行
// // 直径
// var d = getSelectData("DIAMETER");
// X = startX;
// Y += font.Height + 2;
// 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(col4X, Y));
// e.Graphics.DrawString($"{d.SymLevel}", font, brush, new PointF(col5X, Y));
// // 第四行
// // 全深比
// var o = getSelectData("TOTAL_DEPTH");
// X = startX;
// Y += font.Height + 2;
// 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(col4X, Y));
// e.Graphics.FillRectangle(backgroundBrush, new RectangleF(col5X, Y, 150, font.Height));
// // 第五行
// // 台宽比
// var t = getSelectData("TABLE");
// X = startX;
// Y += font.Height + 2;
// 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(col4X, Y));
// e.Graphics.FillRectangle(backgroundBrush, new RectangleF(col5X, Y, 150, font.Height));
// // 第六行
// // 冠角
// var c = getSelectData("CROWN_ANGLE");
// X = startX;
// Y += font.Height + 2;
// 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(col4X, Y));
// e.Graphics.DrawString($"{c.SymLevel}", font, brush, new PointF(col5X, Y));
// // 第七行
// // 冠高比
// var h = getSelectData("CROWN_HEIGHT");
// X = startX;
// Y += font.Height + 2;
// 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(col4X, Y));
// e.Graphics.DrawString($"{h.SymLevel}", font, brush, new PointF(col5X, Y));
// // 第八行
// // 波谷腰厚
// var g = getSelectData("GIRDLE");
// X = startX;
// Y += font.Height + 2;
// 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(col4X, Y));
// e.Graphics.DrawString($"{g.SymLevel}", font, brush, new PointF(col5X, Y));
// // 第九行
// // 亭深比
// var p = getSelectData("PAV_DEPTH");
// X = startX;
// Y += font.Height + 2;
// 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(col4X, Y));
// e.Graphics.DrawString($"{p.SymLevel}", font, brush, new PointF(col5X, Y));
// // 第十行
// X = startX;
// Y += font.Height + 2;
// 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));
//
// X = col2X;
// e.Graphics.DrawString(CutLevelTotal, font, Brushes.Black, new PointF(X, Y));
// // 第十一行
// X = startX;
// Y += font.Height + 2;
// 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));
// X = col2X;
// e.Graphics.DrawString(SymLevelTotal, font, Brushes.Black, new PointF(X, Y));
// X = col3X;
// e.Graphics.DrawString($"{MultilingualHelper.getString("DateOfIssue")}: {DateTime.Now:yyyy/M/d}", font, brush, new PointF(X, Y));
//
// }
[Log]
private string GenerateTempExcelFile()
{
@ -2690,151 +2379,6 @@ public class GradingResultVM : BaseViewModel
ICell cell = row.GetCell(cellRef.Col) ?? row.CreateCell(cellRef.Col);
cell.SetCellValue(value?.ToString() ?? "");
}
// [Log]
// 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));
//
// }
[Log]
private void InitializeSerialPort()
{
try
{
string _serialPortName = "COM1"; // 根据实际情况设置串口号
int _baudRate = 9600; // 根据实际情况设置波特率
_serialPort = new SerialPort(_serialPortName, _baudRate);
_serialPort.ReadTimeout = 500;
_serialPort.WriteTimeout = 500;
}
catch (UnauthorizedAccessException ex)
{
Logger.Error($"无法访问串口: {ex.Message}");
Growl.Error(MultilingualHelper.getString("DiamodResultPrintError"));
}
catch (IOException ex)
{
Logger.Error($"串口操作失败: {ex.Message}");
Growl.Error(MultilingualHelper.getString("DiamodResultPrintError"));
}
catch (ArgumentOutOfRangeException ex)
{
Logger.Error($"参数超出范围: {ex.Message}");
Growl.Error(MultilingualHelper.getString("DiamodResultPrintError"));
}
}
#region 钻石操作相关
//暂略
//部分代码(直接操作控件)需要在xaml.cs里边写
//涉及到计算部分,这里做一个中转
#endregion
}
public class CalGradeInfo{
public int gradeOrder { get; set; }
@ -2904,8 +2448,7 @@ public class Name
{
string sql = $"SELECT NAME, EN_NAME FROM NAME WHERE ID = '{id}'";
DataTable data = DataBaseHelper.ExecuteQuery(sql);
var now = MultilingualHelper.getLangType();
string nameType = "zn-ch".Equals(now)?"NAME":MultilingualHelper.getString("NameType");
string nameType = "zn-ch".Equals(MultilingualHelper.getLangType())?"NAME":MultilingualHelper.getString("NameType");
if (data.Rows.Count>0)
{
return data.Rows[0][nameType].ToString();

@ -23,7 +23,7 @@ public partial class HelperPage
try
{
string language = "";
if ("zh-cn".Equals(MultilingualHelper.getLangType()))
if ("zn-ch".Equals(MultilingualHelper.getLangType()) || "zh-cn".Equals(MultilingualHelper.getLangType()))
{
language = "zh-CN";
}

Loading…
Cancel
Save