修改config

This commit is contained in:
2025-03-18 14:20:11 +08:00
parent 25cd61c5cb
commit 6696c4e106
59 changed files with 1161 additions and 545 deletions

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

@ -102,6 +102,7 @@
menuItem1.IconSvg = "VideoCameraOutlined";
menuItem1.Text = "相机设置";
menuItem2.IconSvg = "AppstoreOutlined";
menuItem2.ID = "Station";
menuItem2.Text = "工位设置";
menuItem3.IconSvg = "ControlOutlined";
menuItem3.Text = "运控设置";
@ -161,6 +162,7 @@
Name = "SettingWindow1";
StartPosition = FormStartPosition.CenterScreen;
Text = "SettingWinform";
Load += SettingWindow1_Load;
panel1.ResumeLayout(false);
panel2.ResumeLayout(false);
panel3.ResumeLayout(false);

View File

@ -8,15 +8,20 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AntdUI;
using AntdUIDemo.Models;
using DH.Process;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using Window = AntdUI.Window;
namespace DHSoftware.Views
{
public partial class SettingWindow1 : Window
{
private UserControl currControl;
public SettingWindow1()
ProcessConfigBase DHconfig;
public SettingWindow1(ProcessConfigBase _DHconfig)
{
InitializeComponent();
DHconfig = _DHconfig;
AntdUI.TooltipComponent tooltip = new AntdUI.TooltipComponent()
{
Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
@ -98,7 +103,115 @@ namespace DHSoftware.Views
}
bool isUpdatingTabs = false;
private void InitDecetion()
{
MenuItem clickedItem = menu1.Items[1];
switch (clickedItem.Text)
{
case "相机设置":
break;
case "工位设置":
// 检查是否已存在同名 TabPage
//foreach (var tab in tabs1.Pages)
//{
// if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
// {
// isUpdatingTabs = true;
// tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
// isUpdatingTabs = false;
// currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
// return;
// }
//}
foreach (var item in DHconfig.DetectionConfigCollection)
{
AddSubItem(clickedItem, item.Name);
DetectControl control = new DetectControl(this);
control.detectionConfig = item;
if (control != null)
{
//容器添加控件需要调整dpi
control.Dock = DockStyle.Fill;
AutoDpi(control);
AntdUI.TabPage tabPage = new AntdUI.TabPage()
{
Text = $"{clickedItem.Text}-{item.Name}",
};
tabPage.Controls.Add(control);
tabs1.Pages.Add(tabPage);
isUpdatingTabs = true;
tabs1.SelectedTab = tabPage;
isUpdatingTabs = false;
currControl = control;
}
//tabs1.Pages[1].
}
break;
case "运控设置":
break;
}
}
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)
{
@ -115,7 +228,7 @@ namespace DHSoftware.Views
return;
}
switch (clickedItem.PARENTITEM.Text)
switch (clickedItem.PARENTITEM.Text)
{
case "相机设置":
@ -157,11 +270,11 @@ namespace DHSoftware.Views
case "运控设置":
break;
}
}
}
}
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
@ -183,6 +296,11 @@ namespace DHSoftware.Views
}
return null;
}
private void SettingWindow1_Load(object sender, EventArgs e)
{
InitDecetion();
}
}
}

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()
{