diff --git a/App.config b/App.config
index a8904f7..f974c5c 100644
--- a/App.config
+++ b/App.config
@@ -8,6 +8,9 @@
+
+
+
diff --git a/Model/Attributes/LogAttribute.cs b/Model/Attributes/LogAttribute.cs
index 80d36df..15690f3 100644
--- a/Model/Attributes/LogAttribute.cs
+++ b/Model/Attributes/LogAttribute.cs
@@ -3,6 +3,7 @@ using MethodDecorator.Fody.Interfaces;
using Rougamo;
using Rougamo.Context;
using System.Reflection;
+using System.Text;
namespace SparkClient.Model.Attributes
{
@@ -10,25 +11,34 @@ namespace SparkClient.Model.Attributes
public class LogAttribute : MoAttribute
{
private static readonly ILog Logger = LogManager.GetLogger(typeof(LogAttribute));
-
- //public void OnEntry(MethodBase method)
- //{
- // Logger.Debug($"Entering {method.DeclaringType?.Name}.{method.Name}");
- //}
-
- //public void OnExit(MethodBase method)
- //{
- // Logger.Debug($"Exiting {method.DeclaringType?.Name}.{method.Name}");
- //}
+
public override void OnEntry(MethodContext context)
{
- Logger.Debug($"Entering {context.Method.DeclaringType?.Name}.{context.Method.Name}");
+ //Logger.Debug($"Entering {context.Method.DeclaringType?.Name}.{context.Method.Name}");
+ // 获取方法参数
+ var parameters = context.Method.GetParameters();
+ var arguments = context.Arguments;
+
+ // 构建参数字符串
+ var parameterLog = new StringBuilder();
+ for (int i = 0; i < parameters.Length; i++)
+ {
+ parameterLog.Append($"{parameters[i].Name} = {arguments[i]}, ");
+ }
+
+ // 记录日志
+ Logger.Debug($"Entering {context.Method.DeclaringType?.Name}.{context.Method.Name} with parameters: {parameterLog}");
}
public override void OnExit(MethodContext context)
{
- Logger.Debug($"Exiting {context.Method.DeclaringType?.Name}.{context.Method.Name}");
+ //Logger.Debug($"Exiting {context.Method.DeclaringType?.Name}.{context.Method.Name}");
+ // 获取返回值
+ var returnValue = context.ReturnValue;
+
+ // 记录日志
+ Logger.Debug($"Exiting {context.Method.DeclaringType?.Name}.{context.Method.Name} with return value: {returnValue}");
}
}
}
diff --git a/SparkClient.sln.DotSettings.user b/SparkClient.sln.DotSettings.user
index 95ab4b4..04b6804 100644
--- a/SparkClient.sln.DotSettings.user
+++ b/SparkClient.sln.DotSettings.user
@@ -40,6 +40,7 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded
@@ -60,8 +61,10 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded
@@ -72,6 +75,7 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded
@@ -80,6 +84,7 @@
ForceIncluded
ForceIncluded
ForceIncluded
+ ForceIncluded
ForceIncluded
ForceIncluded
ForceIncluded
diff --git a/ViewModel/Grading/DiamondSelectVM.cs b/ViewModel/Grading/DiamondSelectVM.cs
index 15b7ad6..fec0193 100644
--- a/ViewModel/Grading/DiamondSelectVM.cs
+++ b/ViewModel/Grading/DiamondSelectVM.cs
@@ -22,6 +22,7 @@ using SparkClient.Model.Common;
using Color = System.Windows.Media.Color;
using MessageBox = SparkClient.Views.Dialog.MessageBox;
using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices.JavaScript;
using SparkClient.Model.Attributes;
namespace SparkClient.ViewModel.Grading;
@@ -220,10 +221,10 @@ public class DiamondSelectVM : BaseViewModel
_algorithmServer = new AlgorithmServer();
// //图片集合
string image_files = JsonConvert.SerializeObject(socResolt.Images, Formatting.Indented);
- //string image_files =$"[ \"image_0.bmp\", \"image_1.bmp\", \"image_2.bmp\", \"image_3.bmp\", \"image_4.bmp\", \"image_5.bmp\", \"image_6.bmp\", \"image_7.bmp\", \"image_8.bmp\", \"image_9.bmp\", \"image_10.bmp\", \"image_11.bmp\", \"image_12.bmp\", \"image_13.bmp\", \"image_14.bmp\", \"image_15.bmp\", \"image_16.bmp\", \"image_17.bmp\", \"image_18.bmp\", \"image_19.bmp\", \"image_20.bmp\", \"image_21.bmp\", \"image_22.bmp\", \"image_23.bmp\", \"image_24.bmp\", \"image_25.bmp\", \"image_26.bmp\", \"image_27.bmp\", \"image_28.bmp\", \"image_29.bmp\", \"image_30.bmp\", \"image_31.bmp\", \"image_32.bmp\", \"image_33.bmp\", \"image_34.bmp\", \"image_35.bmp\", \"image_36.bmp\", \"image_37.bmp\", \"image_38.bmp\", \"image_39.bmp\", \"image_40.bmp\", \"image_41.bmp\", \"image_42.bmp\", \"image_43.bmp\", \"image_44.bmp\", \"image_45.bmp\", \"image_46.bmp\", \"image_47.bmp\", \"image_48.bmp\", \"image_49.bmp\", \"image_50.bmp\", \"image_51.bmp\", \"image_52.bmp\", \"image_53.bmp\", \"image_54.bmp\", \"image_55.bmp\", \"image_56.bmp\", \"image_57.bmp\", \"image_58.bmp\", \"image_59.bmp\", \"image_60.bmp\", \"image_61.bmp\", \"image_62.bmp\", \"image_63.bmp\", \"image_64.bmp\", \"image_65.bmp\", \"image_66.bmp\", \"image_67.bmp\", \"image_68.bmp\", \"image_69.bmp\", \"image_70.bmp\", \"image_71.bmp\", \"image_72.bmp\", \"image_73.bmp\", \"image_74.bmp\", \"image_75.bmp\", \"image_76.bmp\", \"image_77.bmp\", \"image_78.bmp\", \"image_79.bmp\", \"image_80.bmp\", \"image_81.bmp\", \"image_82.bmp\", \"image_83.bmp\", \"image_84.bmp\", \"image_85.bmp\", \"image_86.bmp\", \"image_87.bmp\", \"image_88.bmp\", \"image_89.bmp\", \"image_90.bmp\", \"image_91.bmp\", \"image_92.bmp\", \"image_93.bmp\", \"image_94.bmp\", \"image_95.bmp\", \"image_96.bmp\", \"image_97.bmp\", \"image_98.bmp\", \"image_99.bmp\"]" ;
+ // string image_files =$"[ \"image_0.bmp\", \"image_1.bmp\", \"image_2.bmp\", \"image_3.bmp\", \"image_4.bmp\", \"image_5.bmp\", \"image_6.bmp\", \"image_7.bmp\", \"image_8.bmp\", \"image_9.bmp\", \"image_10.bmp\", \"image_11.bmp\", \"image_12.bmp\", \"image_13.bmp\", \"image_14.bmp\", \"image_15.bmp\", \"image_16.bmp\", \"image_17.bmp\", \"image_18.bmp\", \"image_19.bmp\", \"image_20.bmp\", \"image_21.bmp\", \"image_22.bmp\", \"image_23.bmp\", \"image_24.bmp\", \"image_25.bmp\", \"image_26.bmp\", \"image_27.bmp\", \"image_28.bmp\", \"image_29.bmp\", \"image_30.bmp\", \"image_31.bmp\", \"image_32.bmp\", \"image_33.bmp\", \"image_34.bmp\", \"image_35.bmp\", \"image_36.bmp\", \"image_37.bmp\", \"image_38.bmp\", \"image_39.bmp\", \"image_40.bmp\", \"image_41.bmp\", \"image_42.bmp\", \"image_43.bmp\", \"image_44.bmp\", \"image_45.bmp\", \"image_46.bmp\", \"image_47.bmp\", \"image_48.bmp\", \"image_49.bmp\", \"image_50.bmp\", \"image_51.bmp\", \"image_52.bmp\", \"image_53.bmp\", \"image_54.bmp\", \"image_55.bmp\", \"image_56.bmp\", \"image_57.bmp\", \"image_58.bmp\", \"image_59.bmp\", \"image_60.bmp\", \"image_61.bmp\", \"image_62.bmp\", \"image_63.bmp\", \"image_64.bmp\", \"image_65.bmp\", \"image_66.bmp\", \"image_67.bmp\", \"image_68.bmp\", \"image_69.bmp\", \"image_70.bmp\", \"image_71.bmp\", \"image_72.bmp\", \"image_73.bmp\", \"image_74.bmp\", \"image_75.bmp\", \"image_76.bmp\", \"image_77.bmp\", \"image_78.bmp\", \"image_79.bmp\", \"image_80.bmp\", \"image_81.bmp\", \"image_82.bmp\", \"image_83.bmp\", \"image_84.bmp\", \"image_85.bmp\", \"image_86.bmp\", \"image_87.bmp\", \"image_88.bmp\", \"image_89.bmp\", \"image_90.bmp\", \"image_91.bmp\", \"image_92.bmp\", \"image_93.bmp\", \"image_94.bmp\", \"image_95.bmp\", \"image_96.bmp\", \"image_97.bmp\", \"image_98.bmp\", \"image_99.bmp\"]" ;
// 保存图片到历史记录文件夹
- HandleAlgorithmFailure(image_files);
+ HandleAlgorithmFailure(image_files, DiamondCode);
// 启动算法
@@ -250,6 +251,27 @@ public class DiamondSelectVM : BaseViewModel
parameter.CrownType = value.Split(" ")[1];
parameter.PavType = value.Split(" ")[2];
parameter.DiamondCode = DiamondCode;
+
+ //参数实体转json输出
+ try
+ {
+ string parameterJson = JsonConvert.SerializeObject(parameter);
+ ;
+ string outputPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "logs", "result");
+ if (!Directory.Exists(outputPath))
+ Directory.CreateDirectory(outputPath);
+ string outputFilePath = $"{outputPath}/{DiamondCode}-{DateTime.Now:yyyyMMdd_HHmmss}.json";
+ using (var file = File.Create(outputFilePath))
+ using (StreamWriter stream = new StreamWriter(file))
+ {
+ stream.Write(parameterJson);
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.Error("output输出失败:"+ex.Message);
+ }
+
isEnd = true;
//GradingResult(parameter);
await loading.Dispatcher.Invoke(async () =>
@@ -423,7 +445,7 @@ public class DiamondSelectVM : BaseViewModel
///
private static readonly ILog Logger = LogManager.GetLogger(typeof(AlgorithmServer));
[Log]
- private void HandleAlgorithmFailure(string image_files)
+ private void HandleAlgorithmFailure(string image_files, string dCode = "")
{
// 从配置文件中读取 imageHistoryPath
@@ -438,7 +460,7 @@ public class DiamondSelectVM : BaseViewModel
// 生成时间戳,格式为 yyyyMMddHHmmss
string timestamp = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
// 组合新的文件夹路径
- string newFolderPath = Path.Combine(imageHistoryPath, $"image-{timestamp}");
+ string newFolderPath = Path.Combine(imageHistoryPath, string.IsNullOrWhiteSpace(dCode) ? $"image-{timestamp}" : $"image-{dCode}-{timestamp}" );
// 检查 D 盘内存空间
DriveInfo dDrive = new DriveInfo("D");
diff --git a/ViewModel/Grading/GradingResultVM.cs b/ViewModel/Grading/GradingResultVM.cs
index 1bc9a47..66dfc02 100644
--- a/ViewModel/Grading/GradingResultVM.cs
+++ b/ViewModel/Grading/GradingResultVM.cs
@@ -1,4 +1,5 @@
using System.ComponentModel;
+using System.Configuration;
using System.Data;
using System.IO;
using System.IO.Ports;
@@ -31,6 +32,7 @@ using System.Windows.Media;
using Brush = System.Drawing.Brush;
using Brushes = System.Drawing.Brushes;
using SparkClient.Model.Attributes;
+using PaperSize = System.Drawing.Printing.PaperSize;
namespace SparkClient.ViewModel.Grading;
///
@@ -1833,40 +1835,60 @@ public class GradingResultVM : BaseViewModel
CustomPrintPreviewForm customPreviewForm = new CustomPrintPreviewForm(printDocument);
// 显示自定义打印预览窗体
- // DialogResult result = customPreviewForm.ShowDialog();
+
MessageBox messageBox = new MessageBox();
MessageBoxResult boxResult = messageBox.ShowAsk(MultilingualHelper.getString("YesOrNo"));
if (boxResult == MessageBoxResult.OK)
{
// 打开串口
- if (!_serialPort.IsOpen)
- {
- _serialPort.Open();
- }
+ // if (!_serialPort.IsOpen)
+ // {
+ // _serialPort.Open();
+ // }
// 将绘制内容转换为字节数组
- MemoryStream memoryStream = new MemoryStream();
- using (Bitmap bitmap = new Bitmap((int)printDocument.DefaultPageSettings.PrintableArea.Width, (int)printDocument.DefaultPageSettings.PrintableArea.Height))
+ // 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) )
{
- 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);
+ Logger.Info("缺少打印配置。");
+ throw new Exception("The printer parameter is invalid");
}
- byte[] dataToSend = memoryStream.ToArray();
-
+ 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);
+ //_serialPort.Write(dataToSend, 0, dataToSend.Length);
Logger.Info("数据已发送到热敏打印机。");
}
@@ -1879,10 +1901,10 @@ public class GradingResultVM : BaseViewModel
finally
{
// 关闭串口
- if (_serialPort.IsOpen)
- {
- _serialPort.Close();
- }
+ // if (_serialPort.IsOpen)
+ // {
+ // _serialPort.Close();
+ // }
}
}
@@ -1951,13 +1973,18 @@ public class GradingResultVM : BaseViewModel
[Log]
private void PreparePrintData(object sender, PrintPageEventArgs e)
{
+ int width = e.PageSettings.PaperSize.Width;
+
+
var result = algorithmResult.measurements;
- int startX = 10;
- int startY = 10;
- var col2X = startX + 160;
- var col3X = col2X + 100;
+ 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, 12, FontStyle.Bold);
+ Font font = new Font(FontFamily.GenericSerif, 6, FontStyle.Bold);
// 设置颜色
Brush brush = Brushes.Black;
@@ -1970,125 +1997,125 @@ public class GradingResultVM : BaseViewModel
// 绘制文本
// 第一行
- int X = startX;
- int Y = startY;
+ 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(540, Y));
+ e.Graphics.DrawString($"{MultilingualHelper.getString("Wight")}:{Wight}ct.", font, brush, new PointF(col5X, Y));
// 第二行
X = startX;
- Y += font.Height;
+ 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(420, Y));
- e.Graphics.DrawString($"{MultilingualHelper.getString("DiamondResultSymmetryGrade")}", font, brush, new PointF(540, 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;
+ 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(420, Y));
- e.Graphics.DrawString($"{d.SymLevel}", font, brush, new PointF(540, 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;
+ 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(420, Y));
- e.Graphics.FillRectangle(backgroundBrush, new RectangleF(540, Y, 100, font.Height));
+ 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;
+ 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(420, Y));
- e.Graphics.FillRectangle(backgroundBrush, new RectangleF(540, Y, 100, font.Height));
+ 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;
+ 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(420, Y));
- e.Graphics.DrawString($"{c.SymLevel}", font, brush, new PointF(540, Y));
+ 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;
+ 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(420, Y));
- e.Graphics.DrawString($"{h.SymLevel}", font, brush, new PointF(540, Y));
+ 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;
+ 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(420, Y));
- e.Graphics.DrawString($"{g.SymLevel}", font, brush, new PointF(540, 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;
+ 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(420, Y));
- e.Graphics.DrawString($"{p.SymLevel}", font, brush, new PointF(540, 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;
- e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, 130, font.Height));
+ 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.Red, new PointF(X, Y));
+ e.Graphics.DrawString(CutLevelTotal, font, Brushes.Black, new PointF(X, Y));
// 第十一行
X = startX;
- Y += font.Height;
- e.Graphics.FillRectangle(backgroundBrush, new RectangleF(X, Y, 130, font.Height));
+ 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.Red, new PointF(X, Y));
+ 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));
diff --git a/Views/UserControl/ViewportData/Helper/ViewportHelperPro.cs b/Views/UserControl/ViewportData/Helper/ViewportHelperPro.cs
index c200b7c..9ff21c3 100644
--- a/Views/UserControl/ViewportData/Helper/ViewportHelperPro.cs
+++ b/Views/UserControl/ViewportData/Helper/ViewportHelperPro.cs
@@ -363,6 +363,7 @@ public class ViewportHelperPro
foreach (var yaoFace in feactList)
{
+ if (feactList.Count == 1 && "0_0".Equals(yaoFace.Key)) return null;
List selFaceVector = new List();
foreach (var entity in yaoFace.Value)
{
diff --git a/Views/UserControl/ViewportData/Helper/ViewportManager.cs b/Views/UserControl/ViewportData/Helper/ViewportManager.cs
index 47b60a2..3e3e319 100644
--- a/Views/UserControl/ViewportData/Helper/ViewportManager.cs
+++ b/Views/UserControl/ViewportData/Helper/ViewportManager.cs
@@ -6,6 +6,7 @@ using HelixToolkit.Wpf.SharpDX;
using MathNet.Numerics;
using SharpDX;
using SharpDX.Direct3D11;
+using SparkClient.Views.Dialog;
using SparkClient.Views.UserControl.ViewportData.Entity;
using SparkClient.Views.UserControl.ViewportData.Enum;
using GeometryModel3D = HelixToolkit.Wpf.SharpDX.GeometryModel3D;
@@ -337,7 +338,25 @@ public class ViewportManager
MainModelLighting = ViewportHelperPro.GenerateLightingForModel(_viewport);
MainModelMeshes = ViewportHelperPro.GenerateModelByEntityGroupByType(entities);
- MainModelLines.AddRange(ViewportHelperPro.GentrateLineGirdleByEntity(entities));
+ var gridle = ViewportHelperPro.GentrateLineGirdleByEntity(entities);
+ if (gridle == null)
+ {
+ gridle = new List();
+ DicValueParamToFacet.Remove("DIAMETER");
+ DicValueParamToFacet.Remove("GIRDLE_BEZEL");
+ DicValueParamToFacet.Remove("GIRDLE_BONE");
+ DicValueParamToFacet.Remove("GIRDLE_VALLEY");
+ }
+ else
+ {
+ DicValueParamToFacet.TryAdd("DIAMETER", PlaneType.Girdle);
+ DicValueParamToFacet.TryAdd("GIRDLE_BEZEL", PlaneType.Girdle);
+ DicValueParamToFacet.TryAdd("GIRDLE_BONE", PlaneType.Girdle);
+ DicValueParamToFacet.TryAdd("GIRDLE_VALLEY", PlaneType.Girdle);
+ }
+
+
+ MainModelLines.AddRange(gridle);
//切换相机视角
_viewport.Camera = ViewportHelperPro.CalculateCamera(PositiveDirection, ModelBounds);