This commit is contained in:
2025-03-18 14:25:41 +08:00
58 changed files with 1088 additions and 535 deletions

View File

@ -49,6 +49,7 @@
<ProjectReference Include="..\DH.Devices.Motion\DH.Devices.Motion.csproj" />
<ProjectReference Include="..\DH.Devices.PLC\DH.Devices.PLC.csproj" />
<ProjectReference Include="..\DH.Devices.Vision\DH.Devices.Vision.csproj" />
<ProjectReference Include="..\DH.Process\DH.Process.csproj" />
<ProjectReference Include="..\DH.UI.Model.Winform\DH.UI.Model.Winform.csproj" />
</ItemGroup>

View File

@ -6,6 +6,7 @@ using DH.Devices.Devices;
using DH.Devices.Motion;
using DH.Devices.PLC;
using DH.Devices.Vision;
using DH.Process;
using DHSoftware.Languages;
using DHSoftware.Models;
using DHSoftware.Utils;
@ -18,17 +19,22 @@ using System;
using System.CodeDom;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using XKRS.UI.Device.Winform;
using static AntdUI.Math3D;
using static DH.Commons.Enums.EnumHelper;
using Camera = DHSoftware.Models.Camera;
using IOType = DH.Commons.Enums.IOType;
namespace DHSoftware
{
@ -229,7 +235,7 @@ namespace DHSoftware
SLDMotion sLDMotion = new SLDMotion();
private void MainWindow_Load(object sender, EventArgs e)
{
Json();
}
private void MainWindow_FormClosed(object sender, FormClosedEventArgs e)
@ -278,21 +284,15 @@ namespace DHSoftware
public volatile int ProductNum_OK = 0;
private readonly object _cameraSummaryLock = new object();
public SimboVisionDriver? _visionEngine = null;
List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
ProcessConfigBase DHconfig;
//
// List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
Dictionary<string, HDevEngineTool> HalconToolDict = new Dictionary<string, HDevEngineTool>();
public List<RecongnitionLabel> RecongnitionLabelList { get; set; } = new List<RecongnitionLabel>();
public DateTime startTime;
private void HandleStartButton()
private void Json()
{
CurrentMachine = true;
//_visionEngine.Start();
//[Category("深度学习检测配置")]
//[DisplayName("检测标签定义集合")]
//[Description("定义检测标签的集合例如Seg/Detection模式断裂、油污、划伤...Class模式ok、ng、上面、下面、套环、正常...")]
//[TypeConverter(typeof(CollectionCountConvert))]
//[Editor(typeof(ComplexCollectionEditor<RecongnitionLabel>), typeof(UITypeEditor))]
List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
RecongnitionLabel recongnition = new RecongnitionLabel
{
LabelName = "youwu",
@ -315,7 +315,7 @@ namespace DHSoftware
RecongnitionLabelList.Add(recongnition2);
RecongnitionLabelList.Add(recongnition3);
var det1 = new DetectionConfig("相机1", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam1.onnx", false, "Cam1");
var det2 = new DetectionConfig("相机2", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam2.onnx", false, "Cam2");
@ -353,6 +353,13 @@ namespace DHSoftware
det1.IsEnabled = true;
det1.ShowLocation.X = 1;
det1.ShowLocation.Y = 1;
det1.DetectionLableList = new List<DetectionLable>()
{ new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1} ,
};
det2.CameraCollects = CameraCollects2;
det2.ModelconfThreshold = Conf;
@ -362,7 +369,13 @@ namespace DHSoftware
det2.IsEnabled = true;
det2.ShowLocation.X = 2;
det2.ShowLocation.Y = 1;
det2.DetectionLableList = new List<DetectionLable>()
{ new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
};
det3.CameraCollects = CameraCollects3;
det3.ModelconfThreshold = Conf;
det3.ModelWidth = 640;
@ -371,6 +384,13 @@ namespace DHSoftware
det3.IsEnabled = true;
det3.ShowLocation.X = 3;
det3.ShowLocation.Y = 1;
det3.DetectionLableList = new List<DetectionLable>()
{ new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
};
det4.CameraCollects = CameraCollects4;
det4.ModelconfThreshold = Conf;
@ -380,6 +400,13 @@ namespace DHSoftware
det4.IsEnabled = true;
det4.ShowLocation.X = 4;
det4.ShowLocation.Y = 1;
det4.DetectionLableList = new List<DetectionLable>()
{ new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
};
@ -391,6 +418,23 @@ namespace DHSoftware
det5.IsEnabled = true;
det5.ShowLocation.X = 1;
det5.ShowLocation.Y = 2;
det5.DetectionLableList = new List<DetectionLable>()
{ new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
};
det5.PreTreatCollects = new List<SizeTreatParam>()
{
new SizeTreatParam()
{
PreName="高度测量",
IsEnable=true,
PreType=SizeEnum.,
ResultShow="sssssss",
OutResultShow="sssssss",
},
};
det6.CameraCollects = CameraCollects6;
det6.ModelconfThreshold = Conf;
@ -400,6 +444,13 @@ namespace DHSoftware
det6.IsEnabled = true;
det6.ShowLocation.X = 2;
det6.ShowLocation.Y = 2;
det6.DetectionLableList = new List<DetectionLable>()
{ new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
};
det7.CameraCollects = CameraCollects7;
det7.ModelconfThreshold = Conf;
@ -409,6 +460,13 @@ namespace DHSoftware
det7.IsEnabled = true;
det7.ShowLocation.X = 3;
det7.ShowLocation.Y = 2;
det7.DetectionLableList = new List<DetectionLable>()
{ new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
};
det8.CameraCollects = CameraCollects8;
det8.ModelconfThreshold = Conf;
@ -416,8 +474,27 @@ namespace DHSoftware
det8.ModelHeight = 640;
det8.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam8.txt";
det8.IsEnabled = true;
det8.IsAddStation = true;
det8.ShowLocation.X = 4;
det8.ShowLocation.Y = 2;
det8.DetectionLableList = new List<DetectionLable>()
{ new DetectionLable{ LabelName="xinquexian1",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian2",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian3",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
new DetectionLable{ LabelName="xinquexian4",MaxArea=99999999,MinArea=1,MinSource=0.6,MaxSource=1 } ,
};
det8.PreTreatCollects = new List<SizeTreatParam>()
{
new SizeTreatParam()
{
PreName="高度测量",
IsEnable=true,
PreType=SizeEnum.,
ResultShow="sssssss",
OutResultShow="sssssss",
},
};
DetectionConfigs.Add(det1);
DetectionConfigs.Add(det2);
@ -428,6 +505,32 @@ namespace DHSoftware
DetectionConfigs.Add(det7);
DetectionConfigs.Add(det8);
DHconfig = new ProcessConfigBase();
DHconfig.StationCode = "小齿轮";
DHconfig.DetectionConfigCollection = DetectionConfigs;
// DHconfig.ca = "小齿轮";
// **序列化**
string json = JsonSerializer.Serialize(DHconfig, new JsonSerializerOptions { WriteIndented = true });
Console.WriteLine("序列化后的 JSON:\n" + json);
var deserializedConfig = JsonSerializer.Deserialize<ProcessConfigBase>(json);
Console.WriteLine("Station Code: " + deserializedConfig?.StationCode);
}
private void HandleStartButton()
{
CurrentMachine = true;
//_visionEngine.Start();
//[Category("深度学习检测配置")]
//[DisplayName("检测标签定义集合")]
//[Description("定义检测标签的集合例如Seg/Detection模式断裂、油污、划伤...Class模式ok、ng、上面、下面、套环、正常...")]
//[TypeConverter(typeof(CollectionCountConvert))]
//[Editor(typeof(ComplexCollectionEditor<RecongnitionLabel>), typeof(UITypeEditor))]
Cameras.Clear();
HKCameras.Clear();
Dectection.Clear();
@ -477,7 +580,7 @@ namespace DHSoftware
#endif
DetectionConfigs.ForEach(detection =>
DHconfig?.DetectionConfigCollection.ForEach(detection =>
{
detection.CameraCollects.ForEach(cam =>
@ -504,7 +607,7 @@ namespace DHSoftware
_visionEngine = new SimboVisionDriver();
_visionEngine.DetectionConfigs = DetectionConfigs;
_visionEngine.DetectionConfigs =DHconfig?.DetectionConfigCollection;
_visionEngine.Init();
CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine);
@ -1020,7 +1123,7 @@ namespace DHSoftware
listCamBase.Add(cam1);
listCamBase.Add(cam2);
SettingWindow1 settingWindow = new SettingWindow1();
SettingWindow1 settingWindow = new SettingWindow1(DHconfig);
settingWindow.Show();
//s.cameras = listCamBase;
//s.Show();

View File

@ -9,7 +9,7 @@ namespace DHSoftware
{
private static MainWindow mainWindow;
/// <summary>
/// 应用程序的主入口点
/// 应用程序的主入口点
/// </summary>
[STAThread]
static void Main()

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成
// 此代码由工具生成
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失
// 重新生成代码,这些更改将会丢失
// </auto-generated>
//------------------------------------------------------------------------------
@ -13,12 +13,12 @@ namespace DHSoftware.Properties {
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等
/// 一个强类型的资源类,用于查找本地化的字符串等
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目
// (以 /str 作为命令选项),或重新生成 VS 项目
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@ -33,7 +33,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例
/// 返回此类使用的缓存的 ResourceManager 实例
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
@ -48,7 +48,7 @@ namespace DHSoftware.Properties {
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写
/// 使用此强类型资源类的所有资源查找执行重写
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
@ -61,7 +61,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap bg1 {
get {
@ -71,7 +71,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap bg2 {
get {
@ -81,7 +81,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap bg3 {
get {
@ -91,7 +91,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap head {
get {
@ -101,7 +101,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap head2 {
get {
@ -111,7 +111,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap logo {
get {
@ -121,7 +121,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap {
get {

View File

@ -4,14 +4,14 @@
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -25,7 +25,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class CameraConfigControl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class CorrelatedCameraEdit
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class CtrlVisionDisplay
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -4,14 +4,14 @@ namespace XKRS.UI.Device.Winform
partial class CtrlVisionRunBase
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -25,7 +25,7 @@ namespace XKRS.UI.Device.Winform
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class DefectRowEdit
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class DetectConfigControl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class DetectControl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{
@ -41,9 +41,9 @@
preTable = new AntdUI.Table();
label3 = new AntdUI.Label();
btnPath = new AntdUI.Button();
switch1 = new AntdUI.Switch();
swtPre = new AntdUI.Switch();
label2 = new AntdUI.Label();
iptPath = new AntdUI.Input();
iptPrePath = new AntdUI.Input();
label1 = new AntdUI.Label();
tabPage2 = new AntdUI.TabPage();
btnLableDelete = new AntdUI.Button();
@ -59,28 +59,26 @@
label6 = new AntdUI.Label();
switch5 = new AntdUI.Switch();
label12 = new AntdUI.Label();
input1 = new AntdUI.Input();
iptScore = new AntdUI.Input();
label5 = new AntdUI.Label();
flowPanel1 = new AntdUI.FlowPanel();
label11 = new AntdUI.Label();
switch3 = new AntdUI.Switch();
swIsAddStation = new AntdUI.Switch();
label10 = new AntdUI.Label();
stDetectType = new AntdUI.Select();
label9 = new AntdUI.Label();
btnCorrelatedCamera = new AntdUI.Button();
btnPath2 = new AntdUI.Button();
switch2 = new AntdUI.Switch();
swIsEnabled = new AntdUI.Switch();
label7 = new AntdUI.Label();
iptPath2 = new AntdUI.Input();
iptModelPath = new AntdUI.Input();
label8 = new AntdUI.Label();
tabPage3 = new AntdUI.TabPage();
tabPage4 = new AntdUI.TabPage();
switch8 = new AntdUI.Switch();
btnSizeDel = new AntdUI.Button();
btnSizeAdd = new AntdUI.Button();
SizeTable = new AntdUI.Table();
label17 = new AntdUI.Label();
label18 = new AntdUI.Label();
tabs1.SuspendLayout();
tabPage1.SuspendLayout();
tabPage2.SuspendLayout();
@ -98,7 +96,6 @@
tabs1.Pages.Add(tabPage1);
tabs1.Pages.Add(tabPage2);
tabs1.Pages.Add(tabPage3);
tabs1.SelectedIndex = 2;
tabs1.Size = new Size(915, 609);
tabs1.Style = styleLine1;
tabs1.TabIndex = 1;
@ -115,11 +112,11 @@
tabPage1.Controls.Add(preTable);
tabPage1.Controls.Add(label3);
tabPage1.Controls.Add(btnPath);
tabPage1.Controls.Add(switch1);
tabPage1.Controls.Add(swtPre);
tabPage1.Controls.Add(label2);
tabPage1.Controls.Add(iptPath);
tabPage1.Controls.Add(iptPrePath);
tabPage1.Controls.Add(label1);
tabPage1.Location = new Point(-909, -575);
tabPage1.Location = new Point(3, 31);
tabPage1.Name = "tabPage1";
tabPage1.Size = new Size(909, 575);
tabPage1.TabIndex = 0;
@ -222,14 +219,14 @@
btnPath.TabIndex = 7;
btnPath.Text = "打开";
//
// switch1
// swtPre
//
switch1.CheckedText = "启用";
switch1.Location = new Point(207, 33);
switch1.Name = "switch1";
switch1.Size = new Size(82, 33);
switch1.TabIndex = 4;
switch1.UnCheckedText = "关闭";
swtPre.CheckedText = "启用";
swtPre.Location = new Point(207, 33);
swtPre.Name = "swtPre";
swtPre.Size = new Size(82, 33);
swtPre.TabIndex = 4;
swtPre.UnCheckedText = "关闭";
//
// label2
//
@ -239,22 +236,22 @@
label2.TabIndex = 3;
label2.Text = "状 态";
//
// iptPath
// iptPrePath
//
iptPath.Location = new Point(191, 79);
iptPath.Name = "iptPath";
iptPath.PlaceholderText = "请点击打开按钮选择模型路径";
iptPath.ReadOnly = true;
iptPath.Size = new Size(423, 42);
iptPath.TabIndex = 1;
iptPrePath.Location = new Point(191, 79);
iptPrePath.Name = "iptPrePath";
iptPrePath.PlaceholderText = "请点击打开按钮选择预处理路径";
iptPrePath.ReadOnly = true;
iptPrePath.Size = new Size(423, 42);
iptPrePath.TabIndex = 1;
//
// label1
//
label1.Location = new Point(110, 89);
label1.Name = "label1";
label1.Size = new Size(75, 23);
label1.Size = new Size(86, 23);
label1.TabIndex = 0;
label1.Text = "模型路径";
label1.Text = "预处理路径";
//
// tabPage2
//
@ -271,19 +268,19 @@
tabPage2.Controls.Add(label6);
tabPage2.Controls.Add(switch5);
tabPage2.Controls.Add(label12);
tabPage2.Controls.Add(input1);
tabPage2.Controls.Add(iptScore);
tabPage2.Controls.Add(label5);
tabPage2.Controls.Add(flowPanel1);
tabPage2.Controls.Add(label11);
tabPage2.Controls.Add(switch3);
tabPage2.Controls.Add(swIsAddStation);
tabPage2.Controls.Add(label10);
tabPage2.Controls.Add(stDetectType);
tabPage2.Controls.Add(label9);
tabPage2.Controls.Add(btnCorrelatedCamera);
tabPage2.Controls.Add(btnPath2);
tabPage2.Controls.Add(switch2);
tabPage2.Controls.Add(swIsEnabled);
tabPage2.Controls.Add(label7);
tabPage2.Controls.Add(iptPath2);
tabPage2.Controls.Add(iptModelPath);
tabPage2.Controls.Add(label8);
tabPage2.Location = new Point(-909, -575);
tabPage2.Name = "tabPage2";
@ -416,14 +413,13 @@
label12.TabIndex = 36;
label12.Text = "OK原图";
//
// input1
// iptScore
//
input1.Location = new Point(649, 24);
input1.Name = "input1";
input1.PlaceholderText = "";
input1.ReadOnly = true;
input1.Size = new Size(117, 42);
input1.TabIndex = 35;
iptScore.Location = new Point(649, 24);
iptScore.Name = "iptScore";
iptScore.PlaceholderText = "";
iptScore.Size = new Size(117, 42);
iptScore.TabIndex = 35;
//
// label5
//
@ -451,14 +447,14 @@
label11.TabIndex = 32;
label11.Text = "关联相机";
//
// switch3
// swIsAddStation
//
switch3.CheckedText = "启用";
switch3.Location = new Point(270, 26);
switch3.Name = "switch3";
switch3.Size = new Size(82, 33);
switch3.TabIndex = 31;
switch3.UnCheckedText = "关闭";
swIsAddStation.CheckedText = "启用";
swIsAddStation.Location = new Point(270, 26);
swIsAddStation.Name = "swIsAddStation";
swIsAddStation.Size = new Size(82, 33);
swIsAddStation.TabIndex = 31;
swIsAddStation.UnCheckedText = "关闭";
//
// label10
//
@ -512,14 +508,14 @@
btnPath2.TabIndex = 20;
btnPath2.Text = "打开";
//
// switch2
// swIsEnabled
//
switch2.CheckedText = "启用";
switch2.Location = new Point(110, 26);
switch2.Name = "switch2";
switch2.Size = new Size(82, 33);
switch2.TabIndex = 19;
switch2.UnCheckedText = "关闭";
swIsEnabled.CheckedText = "启用";
swIsEnabled.Location = new Point(110, 26);
swIsEnabled.Name = "swIsEnabled";
swIsEnabled.Size = new Size(82, 33);
swIsEnabled.TabIndex = 19;
swIsEnabled.UnCheckedText = "关闭";
//
// label7
//
@ -529,14 +525,14 @@
label7.TabIndex = 18;
label7.Text = "状 态";
//
// iptPath2
// iptModelPath
//
iptPath2.Location = new Point(110, 75);
iptPath2.Name = "iptPath2";
iptPath2.PlaceholderText = "请点击打开按钮选择模型路径";
iptPath2.ReadOnly = true;
iptPath2.Size = new Size(656, 42);
iptPath2.TabIndex = 17;
iptModelPath.Location = new Point(110, 75);
iptModelPath.Name = "iptModelPath";
iptModelPath.PlaceholderText = "请点击打开按钮选择模型路径";
iptModelPath.ReadOnly = true;
iptModelPath.Size = new Size(656, 42);
iptModelPath.TabIndex = 17;
//
// label8
//
@ -549,7 +545,7 @@
// tabPage3
//
tabPage3.Controls.Add(tabPage4);
tabPage3.Location = new Point(3, 31);
tabPage3.Location = new Point(-909, -575);
tabPage3.Name = "tabPage3";
tabPage3.Size = new Size(909, 575);
tabPage3.TabIndex = 3;
@ -557,27 +553,16 @@
//
// tabPage4
//
tabPage4.Controls.Add(switch8);
tabPage4.Controls.Add(btnSizeDel);
tabPage4.Controls.Add(btnSizeAdd);
tabPage4.Controls.Add(SizeTable);
tabPage4.Controls.Add(label17);
tabPage4.Controls.Add(label18);
tabPage4.Location = new Point(8, 8);
tabPage4.Name = "tabPage4";
tabPage4.Size = new Size(909, 575);
tabPage4.TabIndex = 1;
tabPage4.Text = "预处理";
//
// switch8
//
switch8.CheckedText = "启用";
switch8.Location = new Point(120, 33);
switch8.Name = "switch8";
switch8.Size = new Size(82, 33);
switch8.TabIndex = 11;
switch8.UnCheckedText = "关闭";
//
// btnSizeDel
//
btnSizeDel.BorderWidth = 2F;
@ -585,7 +570,7 @@
btnSizeDel.Ghost = true;
btnSizeDel.IconRatio = 0.8F;
btnSizeDel.IconSvg = resources.GetString("btnSizeDel.IconSvg");
btnSizeDel.Location = new Point(747, 192);
btnSizeDel.Location = new Point(775, 192);
btnSizeDel.Name = "btnSizeDel";
btnSizeDel.Size = new Size(80, 38);
btnSizeDel.TabIndex = 10;
@ -598,7 +583,7 @@
btnSizeAdd.Ghost = true;
btnSizeAdd.IconRatio = 0.8F;
btnSizeAdd.IconSvg = resources.GetString("btnSizeAdd.IconSvg");
btnSizeAdd.Location = new Point(747, 148);
btnSizeAdd.Location = new Point(775, 148);
btnSizeAdd.Name = "btnSizeAdd";
btnSizeAdd.Size = new Size(80, 38);
btnSizeAdd.TabIndex = 9;
@ -606,28 +591,21 @@
//
// SizeTable
//
SizeTable.Location = new Point(38, 118);
SizeTable.AutoSizeColumnsMode = AntdUI.ColumnsMode.Fill;
SizeTable.Location = new Point(38, 65);
SizeTable.Name = "SizeTable";
SizeTable.Size = new Size(686, 402);
SizeTable.Size = new Size(705, 455);
SizeTable.TabIndex = 8;
SizeTable.Text = "table1";
//
// label17
//
label17.Location = new Point(38, 89);
label17.Location = new Point(38, 24);
label17.Name = "label17";
label17.Size = new Size(91, 23);
label17.TabIndex = 1;
label17.Text = "配 置";
//
// label18
//
label18.Location = new Point(38, 43);
label18.Name = "label18";
label18.Size = new Size(91, 23);
label18.TabIndex = 3;
label18.Text = "状 态";
//
// DetectControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
@ -635,6 +613,7 @@
Controls.Add(tabs1);
Name = "DetectControl";
Size = new Size(915, 609);
Load += DetectControl_Load;
tabs1.ResumeLayout(false);
tabPage1.ResumeLayout(false);
tabPage2.ResumeLayout(false);
@ -650,9 +629,9 @@
private AntdUI.TabPage tabPage2;
private AntdUI.TabPage tabPage3;
private AntdUI.Label label1;
private AntdUI.Input iptPath;
private AntdUI.Input iptPrePath;
private AntdUI.Label label2;
private AntdUI.Switch switch1;
private AntdUI.Switch swtPre;
private AntdUI.Button btnPath;
private AntdUI.Label label3;
private AntdUI.Button btnPreDelete;
@ -664,18 +643,18 @@
private AntdUI.Table PreOutTable;
private AntdUI.Button btnCorrelatedCamera;
private AntdUI.Button btnPath2;
private AntdUI.Switch switch2;
private AntdUI.Switch swIsEnabled;
private AntdUI.Label label7;
private AntdUI.Input iptPath2;
private AntdUI.Input iptModelPath;
private AntdUI.Label label8;
private AntdUI.Select stDetectType;
private AntdUI.Label label9;
private AntdUI.Switch switch3;
private AntdUI.Switch swIsAddStation;
private AntdUI.Label label10;
private AntdUI.Label label11;
private AntdUI.FlowPanel flowPanel1;
private AntdUI.Label label5;
private AntdUI.Input input1;
private AntdUI.Input iptScore;
private AntdUI.Switch switch4;
private AntdUI.Label label6;
private AntdUI.Switch switch5;
@ -694,7 +673,5 @@
private AntdUI.Button btnSizeAdd;
private AntdUI.Table SizeTable;
private AntdUI.Label label17;
private AntdUI.Label label18;
private AntdUI.Switch switch8;
}
}

View File

@ -21,16 +21,198 @@ namespace DHSoftware.Views
public partial class DetectControl : UserControl
{
Window window;
// DetectionConfig detectionConfig;
private DetectionConfig _config;
List<RelatedCamera> relatedCameras = new List<RelatedCamera>();
AntList<PreTreatParam> PreTreatList;
AntList<PreTreatParam> PreOutTreatList;
AntList<DetectionLable> DetectionLableList;
AntList<SizeTreatParam> SizeLableList;
PreTreatParam curPreTreat;
PreTreatParam curPreOutTreat;
DetectionLable curDetectionLable;
SizeTreatParam SizeParamLable;
public DetectionConfig detectionConfig
{
get => _config;
set
{
if (_config != null)
{
_config.PropertyChanged -= Config_PropertyChanged; // 解绑旧的
}
_config = value;
if (_config != null)
{
_config.PropertyChanged += Config_PropertyChanged; // 绑定新的
UpdateUI(); // 初始化 UI
}
}
}
private void Config_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
// 监听所有属性变化
switch (e.PropertyName)
{
case nameof(DetectionConfig.IsAddStation):
swIsAddStation.Checked = _config.IsAddStation;
break;
case nameof(DetectionConfig.IsEnabled):
swIsEnabled.Checked = _config.IsEnabled;
break;
case nameof(DetectionConfig.ModelType):
stDetectType.SelectedIndex = (int)_config.ModelType-1;
break;
case nameof(DetectionConfig.ModelconfThreshold):
if (iptScore.InvokeRequired)
{
iptScore.Invoke(() => iptScore.Text = _config.ModelconfThreshold.ToString());
}
else
{
iptScore.Text = _config.ModelconfThreshold.ToString();
}
break;
case nameof(DetectionConfig.PreTreatCollects):
break;
}
}
private void UpdateUI()
{
if (_config == null) return;
swIsAddStation.Checked = _config.IsAddStation;
swIsEnabled.Checked = _config.IsEnabled;
stDetectType.SelectedIndex = (int)_config.ModelType - 1;
iptScore.Text = _config.ModelconfThreshold.ToString();
iptModelPath.Text = _config.ModelPath;
swtPre.Checked = _config.IsPreEnabled;
iptPrePath.Text = _config.HalconAlgorithemPath_Pre;
// textBoxName.Text = _config.Name;
// checkBoxEnableGPU.Checked = _config.IsEnableGPU;
}
public DetectControl(Window _window)
{
window = _window;
InitializeComponent();
//this.detectionConfig = detectionConfig;
//初始化表格列头
InitTableColumns();
InitData();
BindEventHandler();
}
foreach (var item in MLModelTypes)
{
stDetectType.Items.Add(item.Key);
}
BindEventHandler();
// 如果你的控件是通过设计器生成的,确保事件已经在设计器文件中绑定。
swtPre.CheckedChanged += swtPre_CheckedChanged; // 确保控件的事件处理器被注册
swIsAddStation.CheckedChanged += swIsAddStation_CheckedChanged; // 确保控件的事件处理器被注册
swIsEnabled.CheckedChanged += swIsEnabled_CheckedChanged; // 确保控件的事件处理器被注册
stDetectType.SelectedIndexChanged += stDetectType_SelectedIndexChanged; // 确保控件的事件处理器被注册
iptScore.TextChanged += IptScore_TextChanged;
iptModelPath.TextChanged += IptModelPath_TextChanged;
}
private void IptScore_TextChanged(object sender, EventArgs e)
{
if (_config != null && !string.IsNullOrEmpty(iptScore.Text))
{
if (float.TryParse(iptScore.Text, out float score) && _config.ModelconfThreshold != score)
{
_config.ModelconfThreshold = score;
}
else
{
iptScore.Text = _config.ModelconfThreshold.ToString();
}
}
}
private void IptModelPath_TextChanged(object sender, EventArgs e)
{
if (_config != null && !string.IsNullOrEmpty(iptModelPath.Text))
{
if ( _config.ModelPath != iptModelPath.Text)
{
_config.ModelPath = iptModelPath.Text;
}
else
{
iptModelPath.Text = _config.ModelPath;
}
}
}
private void stDetectType_SelectedIndexChanged(object sender, EventArgs e)
{
// 下拉选项变更事件处理
if (_config != null && stDetectType.SelectedIndex != -1)
{
// 防止循环更新
if ((int)_config.ModelType != stDetectType.SelectedIndex + 1)
{
_config.ModelType = (MLModelType)(stDetectType.SelectedIndex + 1);
}
}
}
private void swtPre_CheckedChanged(object sender, EventArgs e)
{
// 当用户改变控件的值时,更新数据模型的属性
if (_config != null)
{
_config.IsPreEnabled = swtPre.Checked;
}
}
private void swIsAddStation_CheckedChanged(object sender, EventArgs e)
{
// 当用户改变控件的值时,更新数据模型的属性
if (_config != null)
{
_config.IsAddStation = swIsAddStation.Checked;
}
}
private void swIsEnabled_CheckedChanged(object sender, EventArgs e)
{
// 当用户改变控件的值时,更新数据模型的属性
if (_config != null)
{
_config.IsEnabled = swIsEnabled.Checked;
}
}
/// <summary>
/// 更新尺寸测量表格
/// </summary>
private void UpdatePreTreatCollectsFromSizeTable()
{
// 假设 SizeLableList 是 SizeTable 的数据源
List<SizeTreatParam> updatedPreTreatCollects = new List<SizeTreatParam>();
foreach (var sizeTreat in SizeLableList)
{
var preTreatCollect = new SizeTreatParam
{
IsEnable = sizeTreat.IsEnable,
PreName = sizeTreat.PreName,
PrePix = sizeTreat.PrePix,
PreType = sizeTreat.PreType,
ResultShow = sizeTreat.ResultShow,
OutResultShow = sizeTreat.OutResultShow
};
updatedPreTreatCollects.Add(preTreatCollect);
}
// 将更新后的数据设置到 PreTreatCollects
detectionConfig.PreTreatCollects = updatedPreTreatCollects;
}
private void BindEventHandler()
{
//预处理
@ -46,6 +228,9 @@ namespace DHSoftware.Views
//中处理
btnPath2.Click += BtnPath2_Click;
btnCorrelatedCamera.Click += BtnCorrelatedCamera_Click;
btnPic.Click += BtnPic_Click;
btnLableAdd.Click += BtnLableAdd_Click;
btnLableDelete.Click += BtnLableDelete_Click;
@ -113,6 +298,8 @@ namespace DHSoftware.Views
OnClose = () =>
{
AntdUI.Message.info(window, "结束编辑", autoClose: 1);
UpdatePreTreatCollectsFromSizeTable();
}
});
break;
@ -120,6 +307,7 @@ namespace DHSoftware.Views
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
if (result == DialogResult.OK)
SizeLableList.Remove(sizeTreat);
UpdatePreTreatCollectsFromSizeTable();
break;
case "进行测量":
var sizeType = ((int)SizeParamLable.PreType).ToString();
@ -150,7 +338,7 @@ namespace DHSoftware.Views
MessageBox.Show("未定义的测量类型!");
break;
}
UpdatePreTreatCollectsFromSizeTable();
//使用clone可以防止table中的image被修改
//Preview.open(new Preview.Config(window, (Image)SizeParamLable.CellImages[0].Image.Clone()));
break;
@ -237,7 +425,7 @@ namespace DHSoftware.Views
//CellBadge = new CellBadge(SizeEnum.Circle.GetEnumDescription()),
CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary),
new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error),
new CellButton(Guid.NewGuid().ToString(),"进行测量",TTypeMini.Primary)
}
@ -260,7 +448,7 @@ namespace DHSoftware.Views
}
List<RelatedCamera> relatedCameras = new List<RelatedCamera>();
private void BtnCorrelatedCamera_Click(object? sender, EventArgs e)
{
@ -274,37 +462,8 @@ namespace DHSoftware.Views
if (form.submit)
{
flowPanel1.Controls.Clear();
if (relatedCameras.Count > 0)
{
foreach (var item in relatedCameras)
{
var control = new AntdUI.Tag()
{
Font = new System.Drawing.Font("Microsoft YaHei UI", 9F),
Size = new Size(90, 42),
Text = item.CameraSourceId,
CloseIcon = true
};
control.CloseChanged += (sender, e) =>
{
var tag = sender as Tag;
foreach (var item in relatedCameras)
{
if (item.CameraSourceId.Equals(tag.Text))
{
relatedCameras.Remove(item);
break;
}
}
return true;
};
// 通过主窗口设置DPI控制添加控件保持缩放比例
window.AutoDpi(control);
flowPanel1.Controls.Add(control);
control.BringToFront();
}
}
InitRelatedCamera();
detectionConfig.CameraCollects=relatedCameras;
}
}
@ -329,8 +488,8 @@ namespace DHSoftware.Views
{
string filePath = openFileDialog.FileName;
iptPath2.Text = filePath;
iptModelPath.Text = filePath;
_config.ModelPath = filePath;
}
}
}
@ -398,7 +557,7 @@ namespace DHSoftware.Views
{
PreTreatParam preParam = new PreTreatParam()
{
CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary),
new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error),
@ -500,37 +659,112 @@ namespace DHSoftware.Views
}
}
AntList<PreTreatParam> PreTreatList;
AntList<PreTreatParam> PreOutTreatList;
AntList<DetectionLable> DetectionLableList;
AntList<SizeTreatParam> SizeLableList;
PreTreatParam curPreTreat;
PreTreatParam curPreOutTreat;
DetectionLable curDetectionLable;
SizeTreatParam SizeParamLable;
//加载相机
private void InitRelatedCamera()
{
if (relatedCameras.Count > 0)
{
foreach (var item in relatedCameras)
{
var control = new AntdUI.Tag()
{
Font = new System.Drawing.Font("Microsoft YaHei UI", 9F),
Size = new Size(90, 42),
Text = item.CameraSourceId,
CloseIcon = true
};
control.CloseChanged += (sender, e) =>
{
var tag = sender as Tag;
foreach (var item in relatedCameras)
{
if (item.CameraSourceId.Equals(tag.Text))
{
relatedCameras.Remove(item);
break;
}
}
detectionConfig.CameraCollects = relatedCameras;
return true;
};
// 通过主窗口设置DPI控制添加控件保持缩放比例
window.AutoDpi(control);
flowPanel1.Controls.Add(control);
control.BringToFront();
}
}
}
private void InitData()
{
PreTreatList = new AntList<PreTreatParam>();
relatedCameras = detectionConfig.CameraCollects;
InitRelatedCamera();
// swIsAddStation. = detectionConfig.IsAddStation;
PreTreatList = new AntList<PreTreatParam>();
foreach (var item in detectionConfig.PreTreatParams)
{
PreTreatParam lable = item;
lable.CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary),
new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error),
};
PreTreatList.Add(lable);
}
preTable.Binding(PreTreatList);
PreOutTreatList = new AntList<PreTreatParam>();
foreach (var item in detectionConfig.OUTPreTreatParams)
{
PreTreatParam lable = item;
lable.CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary),
new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error),
};
PreOutTreatList.Add(lable);
}
PreOutTable.Binding(PreOutTreatList);
foreach (var item in MLModelTypes)
DetectionLableList = new AntList<DetectionLable>();
foreach (var item in detectionConfig.DetectionLableList)
{
stDetectType.Items.Add(item.Key);
DetectionLable lable = item;
lable.CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary),
new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error),
};
DetectionLableList.Add(lable);
}
DetectionLableList = new AntList<DetectionLable>();
lableTable.Binding(DetectionLableList);
SizeLableList = new AntList<SizeTreatParam>();
// SizeLableList = new AntList<SizeTreatParam>(_config.PreTreatCollects);
foreach (var item in _config.PreTreatCollects)
{
item.CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary),
new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error),
new CellButton(Guid.NewGuid().ToString(),"进行测量",TTypeMini.Primary)
};
// SizeLableList.Add(item);
}
// 将 List<PreTreatCollect> 转换为 AntList<PreTreatCollect>
SizeLableList = new AntList<SizeTreatParam>(_config.PreTreatCollects);
// 绑定转换后的数据到 SizeTable
SizeTable.Binding(SizeLableList);
//SizeTable.Binding(_config.PreTreatCollects);
}
@ -564,14 +798,16 @@ namespace DHSoftware.Views
SizeTable.Columns = new ColumnCollection() {
new ColumnCheck("Selected"){Fixed = true},
new ColumnSwitch("IsEnable", "是否启用", ColumnAlign.Center),
new Column("PreName", "测量名称",ColumnAlign.Center),
new Column("PreType", "测量类型", ColumnAlign.Center),
new Column("PrePix", "阈值", ColumnAlign.Center),
new Column("ResultShow", "输入参数", ColumnAlign.Center),
new Column("OutResultShow", "输出参数", ColumnAlign.Center),
new Column("CellLinks", "操作", ColumnAlign.Center)
new ColumnSwitch("IsEnable", "是否启用") {Width = "10%" },
new Column("PreName", "测量名称") { Width = "15%" },
new Column("PreType", "测量类型") { Width = "10%" },
new Column("PrePix", "阈值") { Width = "5%" },
new Column("ResultShow", "输入参数") { Width = "15%" },
new Column("OutResultShow", "输出参数") { Width = "15%" },
new Column("CellLinks", "操作") { Width = "30%" }
};
}
private void btnPath_Click(object? sender, EventArgs e)
@ -590,7 +826,7 @@ namespace DHSoftware.Views
{
string filePath = openFileDialog.FileName;
iptPath.Text = filePath;
iptPrePath.Text = filePath;
}
}
@ -608,6 +844,12 @@ namespace DHSoftware.Views
}
private void DetectControl_Load(object sender, EventArgs e)
{
InitData();
}
public static List<KeyValuePair<string, int>> GetFilteredEnumDescriptionsAndValues<T>() where T : Enum
{
return Enum.GetValues(typeof(T))

View File

@ -3,14 +3,14 @@
partial class DetectionLableEdit
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class PreTreatEdit
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class PreTreatUserControl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -179,6 +179,7 @@
Name = "SettingWindow1";
StartPosition = FormStartPosition.CenterScreen;
Text = "SettingWinform";
Load += SettingWindow1_Load;
panel1.ResumeLayout(false);
panel2.ResumeLayout(false);
panel3.ResumeLayout(false);

View File

@ -158,6 +158,62 @@ namespace DHSoftware.Views
bool isUpdatingTabs = false;
}
}
private void LoadMenu(string filter = "")
{
menu1.Items.Clear();
Dictionary<string, List<MenuItems>> Menu_decetion = new Dictionary<string, List<MenuItems>>();
string lang = AntdUI.Localization.CurrentLanguage;
var menuItems = DataUtil.Menu_decetion;
//var menuIcons = DataUtil.MenuIcons_zhcn;
//if (lang.StartsWith("en"))
//{
// menuItems = DataUtil.MenuItems_enus;
// menuIcons = DataUtil.MenuIcons_enus;
//}
foreach (var rootItem in Menu_decetion)
{
var rootKey = rootItem.Key.ToLower();
var rootMenu = new AntdUI.MenuItem
{
Text = rootItem.Key,
//IconSvg = menuIcons.TryGetValue(rootItem.Key, out var icon) ? icon : "UnorderedListOutlined",
};
bool rootVisible = false; // 用于标记是否显示根节点
foreach (var item in rootItem.Value)
{
var childText = item.Text.ToLower();
// 如果子节点包含搜索文本
if (childText.Contains(filter))
{
var menuItem = new AntdUI.MenuItem
{
Text = item.Text,
IconSvg = item.IconSvg,
Tag = item.Tag,
};
rootMenu.Sub.Add(menuItem);
rootVisible = true; // 如果有子节点包含,则显示根节点
}
}
// 如果根节点包含搜索文本,或有可见的子节点,则显示根节点
if (rootKey.Contains(filter) || rootVisible)
{
menu1.Items.Add(rootMenu);
}
}
}
private void menu1_MouseDown(object sender, MouseEventArgs e)
{

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
@ -48,7 +48,7 @@
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter

View File

@ -3,14 +3,14 @@
partial class SizeConfigControl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class SizeLabelEdit
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class UserConfigFrm
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class UserDetetion
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class _MotionControl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -6,15 +6,15 @@
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点
以下节点之一替换 requestedExecutionLevel 节点
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
元素
元素
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
@ -24,8 +24,8 @@
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表取消评论适当的元素,
Windows 将自动选择最兼容的环境 -->
Windows 版本的列表 取消评论适当的元素,
Windows 将自动选择最兼容的环境 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
@ -46,11 +46,11 @@
</compatibility>
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放Windows Presentation Foundation (WPF)应用程序自动感知 DPI无需
选择加入选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"
自动缩放 Windows Presentation Foundation (WPF)应用程序自动感知 DPI无需
选择加入 选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"
将应用程序设为感知长路径请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
将应用程序设为感知长路径 请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>