This commit is contained in:
2025-03-21 08:51:20 +08:00
parent 0dedff36fd
commit 9a5d3be528
70 changed files with 4542 additions and 2207 deletions

View File

@ -29,6 +29,7 @@
private void InitializeComponent()
{
panel1 = new AntdUI.Panel();
lbTitleName = new AntdUI.Label();
input_name = new AntdUI.Input();
label3 = new AntdUI.Label();
divider1 = new AntdUI.Divider();
@ -36,7 +37,6 @@
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
label1 = new AntdUI.Label();
panel1.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
@ -48,7 +48,7 @@
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(label1);
panel1.Controls.Add(lbTitleName);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
@ -58,6 +58,16 @@
panel1.TabIndex = 0;
panel1.Text = "panel1";
//
// lbTitleName
//
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 23;
lbTitleName.Text = "新增相机操作";
//
// input_name
//
input_name.Dock = DockStyle.Top;
@ -66,7 +76,7 @@
input_name.Name = "input_name";
input_name.Radius = 3;
input_name.Size = new Size(464, 38);
input_name.TabIndex = 22;
input_name.TabIndex = 28;
//
// label3
//
@ -75,7 +85,7 @@
label3.Location = new Point(18, 110);
label3.Name = "label3";
label3.Size = new Size(464, 24);
label3.TabIndex = 21;
label3.TabIndex = 27;
label3.Text = "相机名称";
//
// divider1
@ -84,7 +94,7 @@
divider1.Location = new Point(18, 98);
divider1.Name = "divider1";
divider1.Size = new Size(464, 12);
divider1.TabIndex = 20;
divider1.TabIndex = 26;
//
// stackPanel1
//
@ -95,7 +105,7 @@
stackPanel1.Name = "stackPanel1";
stackPanel1.RightToLeft = RightToLeft.No;
stackPanel1.Size = new Size(464, 44);
stackPanel1.TabIndex = 19;
stackPanel1.TabIndex = 25;
stackPanel1.Text = "stackPanel1";
//
// button_cancel
@ -125,17 +135,7 @@
divider2.Location = new Point(18, 42);
divider2.Name = "divider2";
divider2.Size = new Size(464, 12);
divider2.TabIndex = 18;
//
// label1
//
label1.Dock = DockStyle.Top;
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label1.Location = new Point(18, 18);
label1.Name = "label1";
label1.Size = new Size(464, 24);
label1.TabIndex = 17;
label1.Text = "新增相机操作";
divider2.TabIndex = 24;
//
// AddCameraControl
//
@ -150,7 +150,6 @@
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label label1;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.Divider divider1;
@ -158,5 +157,6 @@
private AntdUI.Button button_cancel;
private AntdUI.Button button_ok;
private AntdUI.Divider divider2;
private AntdUI.Label lbTitleName;
}
}

View File

@ -7,10 +7,12 @@ namespace DHSoftware.Views
private AntdUI.Window window;
public bool submit;
public string CubicleName;
public AddCameraControl(AntdUI.Window _window)
public AddCameraControl(AntdUI.Window _window, string TitleName)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}

View File

@ -36,7 +36,7 @@
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
label1 = new AntdUI.Label();
lbTitleName = new AntdUI.Label();
panel1.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
@ -48,7 +48,7 @@
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(label1);
panel1.Controls.Add(lbTitleName);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
@ -127,15 +127,15 @@
divider2.Size = new Size(464, 12);
divider2.TabIndex = 18;
//
// label1
// lbTitleName
//
label1.Dock = DockStyle.Top;
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label1.Location = new Point(18, 18);
label1.Name = "label1";
label1.Size = new Size(464, 24);
label1.TabIndex = 17;
label1.Text = "新增工位操作";
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 17;
lbTitleName.Text = "新增工位操作";
//
// AddCubicleControl
//
@ -150,7 +150,7 @@
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label label1;
private AntdUI.Label lbTitleName;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.Divider divider1;

View File

@ -7,10 +7,11 @@ namespace DHSoftware.Views
private AntdUI.Window window;
public bool submit;
public string CubicleName;
public AddCubicleControl(AntdUI.Window _window)
public AddCubicleControl(AntdUI.Window _window,string TitleName)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}

View File

@ -36,31 +36,25 @@
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
label1 = new AntdUI.Label();
label2 = new AntdUI.Label();
divider3 = new AntdUI.Divider();
select_type = new AntdUI.Select();
lbTitleName = new AntdUI.Label();
panel1.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(select_type);
panel1.Controls.Add(label2);
panel1.Controls.Add(divider3);
panel1.Controls.Add(input_name);
panel1.Controls.Add(label3);
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(label1);
panel1.Controls.Add(lbTitleName);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
panel1.Padding = new Padding(12);
panel1.Shadow = 6;
panel1.Size = new Size(500, 260);
panel1.Size = new Size(500, 192);
panel1.TabIndex = 0;
panel1.Text = "panel1";
//
@ -133,47 +127,21 @@
divider2.Size = new Size(464, 12);
divider2.TabIndex = 18;
//
// label1
// lbTitleName
//
label1.Dock = DockStyle.Top;
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label1.Location = new Point(18, 18);
label1.Name = "label1";
label1.Size = new Size(464, 24);
label1.TabIndex = 17;
label1.Text = "新增运动控制操作";
//
// label2
//
label2.Dock = DockStyle.Top;
label2.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label2.Location = new Point(18, 184);
label2.Name = "label2";
label2.Size = new Size(464, 24);
label2.TabIndex = 24;
label2.Text = "运动控制类型";
//
// divider3
//
divider3.Dock = DockStyle.Top;
divider3.Location = new Point(18, 172);
divider3.Name = "divider3";
divider3.Size = new Size(464, 12);
divider3.TabIndex = 23;
//
// select_type
//
select_type.Dock = DockStyle.Top;
select_type.Location = new Point(18, 208);
select_type.Name = "select_type";
select_type.Size = new Size(464, 37);
select_type.TabIndex = 25;
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 17;
lbTitleName.Text = "新增运动控制操作";
//
// AddMotionControl
//
Controls.Add(panel1);
Name = "AddMotionControl";
Size = new Size(500, 260);
Size = new Size(500, 192);
panel1.ResumeLayout(false);
stackPanel1.ResumeLayout(false);
ResumeLayout(false);
@ -182,7 +150,7 @@
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label label1;
private AntdUI.Label lbTitleName;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.Divider divider1;
@ -190,8 +158,5 @@
private AntdUI.Button button_cancel;
private AntdUI.Button button_ok;
private AntdUI.Divider divider2;
private AntdUI.Select select_type;
private AntdUI.Label label2;
private AntdUI.Divider divider3;
}
}

View File

@ -8,10 +8,11 @@ namespace DHSoftware.Views
public bool submit;
public string MotionName;
public string MotionType;
public AddMotionControl(AntdUI.Window _window)
public AddMotionControl(AntdUI.Window _window,string TitleName)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}
@ -39,7 +40,6 @@ namespace DHSoftware.Views
return;
}
MotionName = input_name.Text;
MotionType = select_type.Text;
submit = true;
this.Dispose();
}

View File

@ -0,0 +1,201 @@
namespace DHSoftware.Views
{
partial class AddSchemeControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
panel1 = new AntdUI.Panel();
input_name = new AntdUI.Input();
label3 = new AntdUI.Label();
stackPanel2 = new AntdUI.StackPanel();
label1 = new AntdUI.Label();
ckNullScheme = new AntdUI.Checkbox();
divider1 = new AntdUI.Divider();
stackPanel1 = new AntdUI.StackPanel();
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
lbTitleName = new AntdUI.Label();
panel1.SuspendLayout();
stackPanel2.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(input_name);
panel1.Controls.Add(label3);
panel1.Controls.Add(stackPanel2);
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(lbTitleName);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
panel1.Padding = new Padding(12);
panel1.Shadow = 6;
panel1.Size = new Size(500, 234);
panel1.TabIndex = 0;
panel1.Text = "panel1";
//
// input_name
//
input_name.Dock = DockStyle.Top;
input_name.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
input_name.Location = new Point(18, 164);
input_name.Name = "input_name";
input_name.Radius = 3;
input_name.Size = new Size(464, 38);
input_name.TabIndex = 25;
//
// label3
//
label3.Dock = DockStyle.Top;
label3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label3.Location = new Point(18, 140);
label3.Name = "label3";
label3.Size = new Size(464, 24);
label3.TabIndex = 24;
label3.Text = "方案名称";
//
// stackPanel2
//
stackPanel2.Controls.Add(label1);
stackPanel2.Controls.Add(ckNullScheme);
stackPanel2.Dock = DockStyle.Top;
stackPanel2.Location = new Point(18, 110);
stackPanel2.Name = "stackPanel2";
stackPanel2.RightToLeft = RightToLeft.No;
stackPanel2.Size = new Size(464, 30);
stackPanel2.TabIndex = 23;
stackPanel2.Text = "stackPanel2";
//
// label1
//
label1.Dock = DockStyle.Fill;
label1.Location = new Point(84, 3);
label1.Name = "label1";
label1.Size = new Size(333, 24);
label1.TabIndex = 1;
label1.Text = "默认从当前方案派生,若想创建新方案选中此项";
//
// ckNullScheme
//
ckNullScheme.Dock = DockStyle.Left;
ckNullScheme.Location = new Point(3, 3);
ckNullScheme.Name = "ckNullScheme";
ckNullScheme.Size = new Size(75, 24);
ckNullScheme.TabIndex = 0;
ckNullScheme.Text = "新方案";
//
// divider1
//
divider1.Dock = DockStyle.Top;
divider1.Location = new Point(18, 98);
divider1.Name = "divider1";
divider1.Size = new Size(464, 12);
divider1.TabIndex = 20;
//
// stackPanel1
//
stackPanel1.Controls.Add(button_cancel);
stackPanel1.Controls.Add(button_ok);
stackPanel1.Dock = DockStyle.Top;
stackPanel1.Location = new Point(18, 54);
stackPanel1.Name = "stackPanel1";
stackPanel1.RightToLeft = RightToLeft.No;
stackPanel1.Size = new Size(464, 44);
stackPanel1.TabIndex = 19;
stackPanel1.Text = "stackPanel1";
//
// button_cancel
//
button_cancel.BorderWidth = 1F;
button_cancel.Font = new Font("Microsoft YaHei UI", 9F);
button_cancel.Ghost = true;
button_cancel.Location = new Point(84, 3);
button_cancel.Name = "button_cancel";
button_cancel.Size = new Size(75, 38);
button_cancel.TabIndex = 1;
button_cancel.Text = "取消";
//
// button_ok
//
button_ok.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
button_ok.Location = new Point(3, 3);
button_ok.Name = "button_ok";
button_ok.Size = new Size(75, 38);
button_ok.TabIndex = 0;
button_ok.Text = "确定";
button_ok.Type = AntdUI.TTypeMini.Primary;
//
// divider2
//
divider2.Dock = DockStyle.Top;
divider2.Location = new Point(18, 42);
divider2.Name = "divider2";
divider2.Size = new Size(464, 12);
divider2.TabIndex = 18;
//
// lbTitleName
//
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 17;
lbTitleName.Text = "新增方案操作";
//
// AddSchemeControl
//
Controls.Add(panel1);
Name = "AddSchemeControl";
Size = new Size(500, 234);
panel1.ResumeLayout(false);
stackPanel2.ResumeLayout(false);
stackPanel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label lbTitleName;
private AntdUI.Divider divider1;
private AntdUI.StackPanel stackPanel1;
private AntdUI.Button button_cancel;
private AntdUI.Button button_ok;
private AntdUI.Divider divider2;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.StackPanel stackPanel2;
private AntdUI.Checkbox ckNullScheme;
private AntdUI.Label label1;
}
}

View File

@ -0,0 +1,52 @@

namespace DHSoftware.Views
{
public partial class AddSchemeControl : UserControl
{
private AntdUI.Window window;
public bool submit;
public string SchemeName;
public bool NullScheme;
public AddSchemeControl(AntdUI.Window _window,string TitleName)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}
private void BindEventHandler()
{
button_ok.Click += Button_ok_Click;
button_cancel.Click += Button_cancel_Click;
}
private void Button_cancel_Click(object sender, EventArgs e)
{
submit = false;
this.Dispose();
}
private void Button_ok_Click(object sender, EventArgs e)
{
input_name.Status = AntdUI.TType.None;
//检查输入内容
if (String.IsNullOrEmpty(input_name.Text))
{
input_name.Status = AntdUI.TType.Error;
AntdUI.Message.warn(window, "方案名称不能为空!", autoClose: 3);
return;
}
SchemeName = input_name.Text;
NullScheme = ckNullScheme.Checked;
submit = true;
this.Dispose();
}
}
}

View File

@ -1,5 +1,5 @@
using DH.Commons.Enums;
using DH.Devices.Devices;
using DH.Commons.Base;
using DH.Commons.Enums;
using DVPCameraType;
using System;
using System.Collections.Generic;

View File

@ -1,5 +1,5 @@
using AntdUI;
using DH.Devices.Devices;
using DH.Commons.Base;
using System;
using System.Collections.Generic;
using System.ComponentModel;

View File

@ -50,6 +50,8 @@
button1 = new AntdUI.Button();
button2 = new AntdUI.Button();
button3 = new AntdUI.Button();
sthPic = new AntdUI.Switch();
label6 = new AntdUI.Label();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout();
//
@ -72,7 +74,7 @@
//
// label1
//
label1.Location = new Point(28, 71);
label1.Location = new Point(28, 114);
label1.Name = "label1";
label1.Size = new Size(59, 23);
label1.TabIndex = 14;
@ -80,7 +82,7 @@
//
// label2
//
label2.Location = new Point(28, 113);
label2.Location = new Point(28, 156);
label2.Name = "label2";
label2.Size = new Size(59, 23);
label2.TabIndex = 15;
@ -88,7 +90,7 @@
//
// label3
//
label3.Location = new Point(28, 155);
label3.Location = new Point(28, 198);
label3.Name = "label3";
label3.Size = new Size(59, 23);
label3.TabIndex = 16;
@ -96,7 +98,7 @@
//
// iptExposure
//
iptExposure.Location = new Point(84, 57);
iptExposure.Location = new Point(84, 100);
iptExposure.Name = "iptExposure";
iptExposure.Size = new Size(93, 37);
iptExposure.TabIndex = 17;
@ -105,7 +107,7 @@
//
// iptGain
//
iptGain.Location = new Point(84, 100);
iptGain.Location = new Point(84, 143);
iptGain.Name = "iptGain";
iptGain.Size = new Size(93, 37);
iptGain.TabIndex = 18;
@ -113,7 +115,7 @@
//
// iptRevolve
//
iptRevolve.Location = new Point(84, 143);
iptRevolve.Location = new Point(84, 186);
iptRevolve.Name = "iptRevolve";
iptRevolve.Size = new Size(93, 37);
iptRevolve.TabIndex = 19;
@ -121,7 +123,7 @@
//
// label4
//
label4.Location = new Point(28, 199);
label4.Location = new Point(28, 242);
label4.Name = "label4";
label4.Size = new Size(59, 23);
label4.TabIndex = 20;
@ -130,14 +132,14 @@
// sltAcquisitionMode
//
sltAcquisitionMode.List = true;
sltAcquisitionMode.Location = new Point(84, 186);
sltAcquisitionMode.Location = new Point(84, 229);
sltAcquisitionMode.Name = "sltAcquisitionMode";
sltAcquisitionMode.Size = new Size(93, 36);
sltAcquisitionMode.TabIndex = 21;
//
// label5
//
label5.Location = new Point(28, 244);
label5.Location = new Point(28, 287);
label5.Name = "label5";
label5.Size = new Size(59, 23);
label5.TabIndex = 22;
@ -146,14 +148,14 @@
// sltTriggerMode
//
sltTriggerMode.List = true;
sltTriggerMode.Location = new Point(84, 231);
sltTriggerMode.Location = new Point(84, 274);
sltTriggerMode.Name = "sltTriggerMode";
sltTriggerMode.Size = new Size(93, 36);
sltTriggerMode.TabIndex = 26;
//
// label7
//
label7.Location = new Point(28, 354);
label7.Location = new Point(28, 397);
label7.Name = "label7";
label7.Size = new Size(59, 23);
label7.TabIndex = 28;
@ -161,7 +163,7 @@
//
// iptROIW
//
iptROIW.Location = new Point(84, 371);
iptROIW.Location = new Point(84, 414);
iptROIW.Name = "iptROIW";
iptROIW.Size = new Size(93, 37);
iptROIW.TabIndex = 31;
@ -169,7 +171,7 @@
//
// iptROIY
//
iptROIY.Location = new Point(84, 328);
iptROIY.Location = new Point(84, 371);
iptROIY.Name = "iptROIY";
iptROIY.Size = new Size(93, 37);
iptROIY.TabIndex = 30;
@ -177,7 +179,7 @@
//
// iptROIX
//
iptROIX.Location = new Point(84, 285);
iptROIX.Location = new Point(84, 328);
iptROIX.Name = "iptROIX";
iptROIX.Size = new Size(93, 37);
iptROIX.TabIndex = 29;
@ -186,7 +188,7 @@
//
// iptROIH
//
iptROIH.Location = new Point(84, 414);
iptROIH.Location = new Point(84, 457);
iptROIH.Name = "iptROIH";
iptROIH.Size = new Size(93, 37);
iptROIH.TabIndex = 32;
@ -253,10 +255,29 @@
button3.TabIndex = 37;
button3.Text = "连续触发";
//
// sthPic
//
sthPic.CheckedText = "启用";
sthPic.Location = new Point(84, 60);
sthPic.Name = "sthPic";
sthPic.Size = new Size(93, 33);
sthPic.TabIndex = 39;
sthPic.UnCheckedText = "关闭";
//
// label6
//
label6.Location = new Point(28, 70);
label6.Name = "label6";
label6.Size = new Size(59, 23);
label6.TabIndex = 38;
label6.Text = "相 机 图";
//
// CameraControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(sthPic);
Controls.Add(label6);
Controls.Add(button3);
Controls.Add(button2);
Controls.Add(button1);
@ -309,5 +330,7 @@
private AntdUI.Button button1;
private AntdUI.Button button2;
private AntdUI.Button button3;
private AntdUI.Switch sthPic;
private AntdUI.Label label6;
}
}

View File

@ -8,8 +8,8 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AntdUI;
using DH.Commons.Base;
using DH.Commons.Enums;
using DH.Devices.Devices;
namespace DHSoftware.Views
{
@ -48,6 +48,10 @@ namespace DHSoftware.Views
private void BindData()
{
sthPic.DataBindings.Add(nameof(sthPic.Checked), CameraBase, nameof(CameraBase.IsSavePicEnabled),
true, DataSourceUpdateMode.OnPropertyChanged);
// 启用状态绑定
swhEnable.DataBindings.Add(nameof(swhEnable.Checked), CameraBase, nameof(CameraBase.IsEnabled),
true, DataSourceUpdateMode.OnPropertyChanged);

View File

@ -3,7 +3,7 @@
using System.ComponentModel;
using System.Reflection;
using AntdUI;
using DH.Commons.Enums;
using DH.Commons.Base;
using DH.Devices.Vision;
namespace DHSoftware.Views

View File

@ -7,10 +7,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using DH.Commons.Enums;
using DH.Devices.Devices;
using DH.Commons.Base;
namespace XKRS.UI.Device.Winform

View File

@ -15,6 +15,7 @@ using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DH.Devices.Vision;
using DH.Commons.Base;
namespace DHSoftware.Views
{
@ -23,7 +24,7 @@ namespace DHSoftware.Views
private DetectionConfig _currentConfig = new DetectionConfig();
private readonly string _configName;
List<KeyValuePair<string, int>> MLModelTypes = GetFilteredEnumDescriptionsAndValues<MLModelType>();
List<KeyValuePair<string, int>> MLModelTypes = GetFilteredEnumDescriptionsAndValues<ModelType>();
public static List<KeyValuePair<string, int>> GetFilteredEnumDescriptionsAndValues<T>() where T : Enum
{

View File

@ -40,10 +40,10 @@
btnPreAdd = new AntdUI.Button();
preTable = new AntdUI.Table();
label3 = new AntdUI.Label();
btnPath = new AntdUI.Button();
switch1 = new AntdUI.Switch();
btnPrePath = new AntdUI.Button();
sthPreStatus = 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();
@ -51,36 +51,33 @@
lableTable = new AntdUI.Table();
label15 = new AntdUI.Label();
btnPic = new AntdUI.Button();
switch6 = new AntdUI.Switch();
sthDetectNG = new AntdUI.Switch();
label13 = new AntdUI.Label();
switch7 = new AntdUI.Switch();
sthOKDetect = new AntdUI.Switch();
label14 = new AntdUI.Label();
switch4 = new AntdUI.Switch();
sthNGOriginal = new AntdUI.Switch();
label6 = new AntdUI.Label();
switch5 = new AntdUI.Switch();
sthOKOriginal = new AntdUI.Switch();
label12 = new AntdUI.Label();
input1 = new AntdUI.Input();
iptConfidence = new AntdUI.Input();
label5 = new AntdUI.Label();
flowPanel1 = new AntdUI.FlowPanel();
flowCameraPanel = new AntdUI.FlowPanel();
label11 = new AntdUI.Label();
switch3 = new AntdUI.Switch();
sthStation = 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();
sthDetectStatus = new AntdUI.Switch();
label7 = new AntdUI.Label();
iptPath2 = new AntdUI.Input();
iptDetectPath = 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();
@ -114,10 +111,10 @@
tabPage1.Controls.Add(btnPreAdd);
tabPage1.Controls.Add(preTable);
tabPage1.Controls.Add(label3);
tabPage1.Controls.Add(btnPath);
tabPage1.Controls.Add(switch1);
tabPage1.Controls.Add(btnPrePath);
tabPage1.Controls.Add(sthPreStatus);
tabPage1.Controls.Add(label2);
tabPage1.Controls.Add(iptPath);
tabPage1.Controls.Add(iptPrePath);
tabPage1.Controls.Add(label1);
tabPage1.Location = new Point(-909, -575);
tabPage1.Name = "tabPage1";
@ -161,6 +158,8 @@
//
// PreOutTable
//
PreOutTable.EmptyHeader = true;
PreOutTable.EnableHeaderResizing = true;
PreOutTable.Location = new Point(191, 355);
PreOutTable.Name = "PreOutTable";
PreOutTable.Size = new Size(423, 181);
@ -195,6 +194,8 @@
//
// preTable
//
preTable.EmptyHeader = true;
preTable.EnableHeaderResizing = true;
preTable.Location = new Point(191, 148);
preTable.Name = "preTable";
preTable.Size = new Size(423, 181);
@ -209,27 +210,27 @@
label3.TabIndex = 1;
label3.Text = "输入参数";
//
// btnPath
// btnPrePath
//
btnPath.BorderWidth = 2F;
btnPath.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnPath.Ghost = true;
btnPath.IconRatio = 0.8F;
btnPath.IconSvg = resources.GetString("btnPath.IconSvg");
btnPath.Location = new Point(620, 79);
btnPath.Name = "btnPath";
btnPath.Size = new Size(80, 38);
btnPath.TabIndex = 7;
btnPath.Text = "打开";
btnPrePath.BorderWidth = 2F;
btnPrePath.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnPrePath.Ghost = true;
btnPrePath.IconRatio = 0.8F;
btnPrePath.IconSvg = resources.GetString("btnPrePath.IconSvg");
btnPrePath.Location = new Point(620, 79);
btnPrePath.Name = "btnPrePath";
btnPrePath.Size = new Size(80, 38);
btnPrePath.TabIndex = 7;
btnPrePath.Text = "打开";
//
// switch1
// sthPreStatus
//
switch1.CheckedText = "启用";
switch1.Location = new Point(207, 33);
switch1.Name = "switch1";
switch1.Size = new Size(82, 33);
switch1.TabIndex = 4;
switch1.UnCheckedText = "关闭";
sthPreStatus.CheckedText = "启用";
sthPreStatus.Location = new Point(207, 33);
sthPreStatus.Name = "sthPreStatus";
sthPreStatus.Size = new Size(82, 33);
sthPreStatus.TabIndex = 4;
sthPreStatus.UnCheckedText = "关闭";
//
// label2
//
@ -239,14 +240,14 @@
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
//
@ -263,34 +264,33 @@
tabPage2.Controls.Add(lableTable);
tabPage2.Controls.Add(label15);
tabPage2.Controls.Add(btnPic);
tabPage2.Controls.Add(switch6);
tabPage2.Controls.Add(sthDetectNG);
tabPage2.Controls.Add(label13);
tabPage2.Controls.Add(switch7);
tabPage2.Controls.Add(sthOKDetect);
tabPage2.Controls.Add(label14);
tabPage2.Controls.Add(switch4);
tabPage2.Controls.Add(sthNGOriginal);
tabPage2.Controls.Add(label6);
tabPage2.Controls.Add(switch5);
tabPage2.Controls.Add(sthOKOriginal);
tabPage2.Controls.Add(label12);
tabPage2.Controls.Add(input1);
tabPage2.Controls.Add(iptConfidence);
tabPage2.Controls.Add(label5);
tabPage2.Controls.Add(flowPanel1);
tabPage2.Controls.Add(flowCameraPanel);
tabPage2.Controls.Add(label11);
tabPage2.Controls.Add(switch3);
tabPage2.Controls.Add(sthStation);
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(sthDetectStatus);
tabPage2.Controls.Add(label7);
tabPage2.Controls.Add(iptPath2);
tabPage2.Controls.Add(iptDetectPath);
tabPage2.Controls.Add(label8);
tabPage2.Location = new Point(-909, -575);
tabPage2.Name = "tabPage2";
tabPage2.Size = new Size(909, 575);
tabPage2.TabIndex = 1;
tabPage2.Text = "模型检测";
tabPage2.Click += tabPage2_Click;
//
// btnLableDelete
//
@ -320,7 +320,8 @@
//
// lableTable
//
lableTable.BackColor = SystemColors.ControlLight;
lableTable.BackColor = SystemColors.Window;
lableTable.EmptyHeader = true;
lableTable.Location = new Point(110, 252);
lableTable.Name = "lableTable";
lableTable.Size = new Size(656, 288);
@ -348,14 +349,14 @@
btnPic.TabIndex = 44;
btnPic.Text = "查看图片";
//
// switch6
// sthDetectNG
//
switch6.CheckedText = "启用";
switch6.Location = new Point(607, 194);
switch6.Name = "switch6";
switch6.Size = new Size(82, 33);
switch6.TabIndex = 43;
switch6.UnCheckedText = "关闭";
sthDetectNG.CheckedText = "启用";
sthDetectNG.Location = new Point(607, 194);
sthDetectNG.Name = "sthDetectNG";
sthDetectNG.Size = new Size(82, 33);
sthDetectNG.TabIndex = 43;
sthDetectNG.UnCheckedText = "关闭";
//
// label13
//
@ -365,14 +366,14 @@
label13.TabIndex = 42;
label13.Text = "NG检测图";
//
// switch7
// sthOKDetect
//
switch7.CheckedText = "启用";
switch7.Location = new Point(438, 194);
switch7.Name = "switch7";
switch7.Size = new Size(82, 33);
switch7.TabIndex = 41;
switch7.UnCheckedText = "关闭";
sthOKDetect.CheckedText = "启用";
sthOKDetect.Location = new Point(438, 194);
sthOKDetect.Name = "sthOKDetect";
sthOKDetect.Size = new Size(82, 33);
sthOKDetect.TabIndex = 41;
sthOKDetect.UnCheckedText = "关闭";
//
// label14
//
@ -382,14 +383,14 @@
label14.TabIndex = 40;
label14.Text = "OK检测图";
//
// switch4
// sthNGOriginal
//
switch4.CheckedText = "启用";
switch4.Location = new Point(270, 194);
switch4.Name = "switch4";
switch4.Size = new Size(82, 33);
switch4.TabIndex = 39;
switch4.UnCheckedText = "关闭";
sthNGOriginal.CheckedText = "启用";
sthNGOriginal.Location = new Point(270, 194);
sthNGOriginal.Name = "sthNGOriginal";
sthNGOriginal.Size = new Size(82, 33);
sthNGOriginal.TabIndex = 39;
sthNGOriginal.UnCheckedText = "关闭";
//
// label6
//
@ -399,14 +400,14 @@
label6.TabIndex = 38;
label6.Text = "NG原图";
//
// switch5
// sthOKOriginal
//
switch5.CheckedText = "启用";
switch5.Location = new Point(110, 194);
switch5.Name = "switch5";
switch5.Size = new Size(82, 33);
switch5.TabIndex = 37;
switch5.UnCheckedText = "关闭";
sthOKOriginal.CheckedText = "启用";
sthOKOriginal.Location = new Point(110, 194);
sthOKOriginal.Name = "sthOKOriginal";
sthOKOriginal.Size = new Size(82, 33);
sthOKOriginal.TabIndex = 37;
sthOKOriginal.UnCheckedText = "关闭";
//
// label12
//
@ -416,14 +417,14 @@
label12.TabIndex = 36;
label12.Text = "OK原图";
//
// input1
// iptConfidence
//
input1.Location = new Point(649, 24);
input1.Name = "input1";
input1.PlaceholderText = "";
input1.ReadOnly = true;
input1.Size = new Size(117, 42);
input1.TabIndex = 35;
iptConfidence.Location = new Point(649, 24);
iptConfidence.Name = "iptConfidence";
iptConfidence.PlaceholderText = "";
iptConfidence.ReadOnly = true;
iptConfidence.Size = new Size(117, 42);
iptConfidence.TabIndex = 35;
//
// label5
//
@ -433,15 +434,15 @@
label5.TabIndex = 34;
label5.Text = "置信度";
//
// flowPanel1
// flowCameraPanel
//
flowPanel1.AutoScroll = true;
flowPanel1.BackColor = SystemColors.ControlLight;
flowPanel1.Location = new Point(110, 136);
flowPanel1.Name = "flowPanel1";
flowPanel1.Size = new Size(656, 49);
flowPanel1.TabIndex = 33;
flowPanel1.Text = "flowPanel1";
flowCameraPanel.AutoScroll = true;
flowCameraPanel.BackColor = SystemColors.Window;
flowCameraPanel.Location = new Point(110, 136);
flowCameraPanel.Name = "flowCameraPanel";
flowCameraPanel.Size = new Size(656, 49);
flowCameraPanel.TabIndex = 33;
flowCameraPanel.Text = "flowPanel1";
//
// label11
//
@ -451,14 +452,14 @@
label11.TabIndex = 32;
label11.Text = "关联相机";
//
// switch3
// sthStation
//
switch3.CheckedText = "启用";
switch3.Location = new Point(270, 26);
switch3.Name = "switch3";
switch3.Size = new Size(82, 33);
switch3.TabIndex = 31;
switch3.UnCheckedText = "关闭";
sthStation.CheckedText = "启用";
sthStation.Location = new Point(270, 26);
sthStation.Name = "sthStation";
sthStation.Size = new Size(82, 33);
sthStation.TabIndex = 31;
sthStation.UnCheckedText = "关闭";
//
// label10
//
@ -512,14 +513,14 @@
btnPath2.TabIndex = 20;
btnPath2.Text = "打开";
//
// switch2
// sthDetectStatus
//
switch2.CheckedText = "启用";
switch2.Location = new Point(110, 26);
switch2.Name = "switch2";
switch2.Size = new Size(82, 33);
switch2.TabIndex = 19;
switch2.UnCheckedText = "关闭";
sthDetectStatus.CheckedText = "启用";
sthDetectStatus.Location = new Point(110, 26);
sthDetectStatus.Name = "sthDetectStatus";
sthDetectStatus.Size = new Size(82, 33);
sthDetectStatus.TabIndex = 19;
sthDetectStatus.UnCheckedText = "关闭";
//
// label7
//
@ -529,14 +530,14 @@
label7.TabIndex = 18;
label7.Text = "状 态";
//
// iptPath2
// iptDetectPath
//
iptPath2.Location = new Point(110, 75);
iptPath2.Name = "iptPath2";
iptPath2.PlaceholderText = "请点击打开按钮选择模型路径";
iptPath2.ReadOnly = true;
iptPath2.Size = new Size(656, 42);
iptPath2.TabIndex = 17;
iptDetectPath.Location = new Point(110, 75);
iptDetectPath.Name = "iptDetectPath";
iptDetectPath.PlaceholderText = "请点击打开按钮选择模型路径";
iptDetectPath.ReadOnly = true;
iptDetectPath.Size = new Size(656, 42);
iptDetectPath.TabIndex = 17;
//
// label8
//
@ -557,27 +558,15 @@
//
// 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 +574,7 @@
btnSizeDel.Ghost = true;
btnSizeDel.IconRatio = 0.8F;
btnSizeDel.IconSvg = resources.GetString("btnSizeDel.IconSvg");
btnSizeDel.Location = new Point(747, 192);
btnSizeDel.Location = new Point(745, 147);
btnSizeDel.Name = "btnSizeDel";
btnSizeDel.Size = new Size(80, 38);
btnSizeDel.TabIndex = 10;
@ -598,7 +587,7 @@
btnSizeAdd.Ghost = true;
btnSizeAdd.IconRatio = 0.8F;
btnSizeAdd.IconSvg = resources.GetString("btnSizeAdd.IconSvg");
btnSizeAdd.Location = new Point(747, 148);
btnSizeAdd.Location = new Point(745, 103);
btnSizeAdd.Name = "btnSizeAdd";
btnSizeAdd.Size = new Size(80, 38);
btnSizeAdd.TabIndex = 9;
@ -606,28 +595,13 @@
//
// SizeTable
//
SizeTable.Location = new Point(38, 118);
SizeTable.EmptyHeader = true;
SizeTable.Location = new Point(20, 52);
SizeTable.Name = "SizeTable";
SizeTable.Size = new Size(686, 402);
SizeTable.Size = new Size(706, 402);
SizeTable.TabIndex = 8;
SizeTable.Text = "table1";
//
// label17
//
label17.Location = new Point(38, 89);
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);
@ -650,10 +624,10 @@
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.Button btnPath;
private AntdUI.Switch sthPreStatus;
private AntdUI.Button btnPrePath;
private AntdUI.Label label3;
private AntdUI.Button btnPreDelete;
private AntdUI.Button btnPreAdd;
@ -664,25 +638,25 @@
private AntdUI.Table PreOutTable;
private AntdUI.Button btnCorrelatedCamera;
private AntdUI.Button btnPath2;
private AntdUI.Switch switch2;
private AntdUI.Switch sthDetectStatus;
private AntdUI.Label label7;
private AntdUI.Input iptPath2;
private AntdUI.Input iptDetectPath;
private AntdUI.Label label8;
private AntdUI.Select stDetectType;
private AntdUI.Label label9;
private AntdUI.Switch switch3;
private AntdUI.Switch sthStation;
private AntdUI.Label label10;
private AntdUI.Label label11;
private AntdUI.FlowPanel flowPanel1;
private AntdUI.FlowPanel flowCameraPanel;
private AntdUI.Label label5;
private AntdUI.Input input1;
private AntdUI.Switch switch4;
private AntdUI.Input iptConfidence;
private AntdUI.Switch sthNGOriginal;
private AntdUI.Label label6;
private AntdUI.Switch switch5;
private AntdUI.Switch sthOKOriginal;
private AntdUI.Label label12;
private AntdUI.Switch switch6;
private AntdUI.Switch sthDetectNG;
private AntdUI.Label label13;
private AntdUI.Switch switch7;
private AntdUI.Switch sthOKDetect;
private AntdUI.Label label14;
private AntdUI.Button btnPic;
private AntdUI.Label label15;
@ -693,8 +667,5 @@
private AntdUI.Button btnSizeDel;
private AntdUI.Button btnSizeAdd;
private AntdUI.Table SizeTable;
private AntdUI.Label label17;
private AntdUI.Label label18;
private AntdUI.Switch switch8;
}
}

View File

@ -1,19 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using AntdUI;
using DH.Commons.Base;
using DH.Commons.Enums;
using DH.Devices.Vision;
using DH.Devices.PLC;
using XKRS.CanFly;
using static AntdUI.Table;
using static System.Windows.Forms.AxHost;
using static DH.Commons.Enums.EnumHelper;
namespace DHSoftware.Views
@ -21,9 +14,11 @@ namespace DHSoftware.Views
public partial class DetectControl : UserControl
{
Window window;
public DetectControl(Window _window)
DetectionConfig detectionConfig;
public DetectControl(Window _window,DetectionConfig _detection)
{
window = _window;
detectionConfig = _detection;
InitializeComponent();
//初始化表格列头
InitTableColumns();
@ -34,7 +29,7 @@ namespace DHSoftware.Views
private void BindEventHandler()
{
//预处理
btnPath.Click += btnPath_Click;
btnPrePath.Click += btnPath_Click;
btnPreAdd.Click += BtnPreAdd_Click; ;
btnPreDelete.Click += BtnPreDelete_Click; ;
preTable.CellClick += PreTable_CellClick; ;
@ -63,12 +58,11 @@ namespace DHSoftware.Views
if (e.Record is DetectionLable DetectionLable)
{
curDetectionLable = DetectionLable;
switch (buttontext)
{
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
case "编辑":
var form = new DetectionLableEdit(window, curDetectionLable) { Size = new Size(500, 300) };
var form = new DetectionLableEdit(window, DetectionLable) { Size = new Size(500, 300) };
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
{
OnLoad = () =>
@ -84,7 +78,7 @@ namespace DHSoftware.Views
case "删除":
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
if (result == DialogResult.OK)
DetectionLableList.Remove(DetectionLable);
detectionConfig.DetectionLableList.Remove(DetectionLable);
break;
}
@ -98,12 +92,11 @@ namespace DHSoftware.Views
if (e.Record is SizeTreatParam sizeTreat)
{
SizeParamLable = sizeTreat;
switch (buttontext)
{
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
case "编辑":
var form = new SizeLabelEdit(window, SizeParamLable) { Size = new Size(500, 300) };
var form = new SizeLabelEdit(window, sizeTreat) { Size = new Size(500, 300) };
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
{
OnLoad = () =>
@ -119,10 +112,10 @@ namespace DHSoftware.Views
case "删除":
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
if (result == DialogResult.OK)
SizeLableList.Remove(sizeTreat);
detectionConfig.SizeTreatParamList.Remove(sizeTreat);
break;
case "进行测量":
var sizeType = ((int)SizeParamLable.PreType).ToString();
var sizeType = ((int)sizeTreat.PreType).ToString();
// 根据测量类型打开不同的窗口
switch (sizeType)
@ -162,7 +155,7 @@ namespace DHSoftware.Views
private void BtnLableDelete_Click(object? sender, EventArgs e)
{
if (DetectionLableList.Count == 0 || !DetectionLableList.Any(x => x.Selected))
if (detectionConfig.DetectionLableList.Count == 0 || !detectionConfig.DetectionLableList.Any(x => x.Selected))
{
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
return;
@ -172,12 +165,12 @@ namespace DHSoftware.Views
if (result == DialogResult.OK)
{
// 使用反转for循环删除主列表中选中的项
for (int i = DetectionLableList.Count - 1; i >= 0; i--)
for (int i = detectionConfig.DetectionLableList.Count - 1; i >= 0; i--)
{
// 删除选中的主列表项
if (DetectionLableList[i].Selected)
if (detectionConfig.DetectionLableList[i].Selected)
{
DetectionLableList.RemoveAt(i);
detectionConfig.DetectionLableList.RemoveAt(i);
}
}
// 提示删除完成
@ -201,13 +194,13 @@ namespace DHSoftware.Views
});
if (form.submit)
{
DetectionLableList.Add(detectionLable);
detectionConfig.DetectionLableList.Add(detectionLable);
}
}
private void BtnSizeDelete_Click(object? sender, EventArgs e)
{
if (SizeLableList.Count == 0 || !SizeLableList.Any(x => x.Selected))
if (detectionConfig.SizeTreatParamList.Count == 0 || !detectionConfig.SizeTreatParamList.Any(x => x.Selected))
{
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
return;
@ -217,12 +210,12 @@ namespace DHSoftware.Views
if (result == DialogResult.OK)
{
// 使用反转for循环删除主列表中选中的项
for (int i = SizeLableList.Count - 1; i >= 0; i--)
for (int i = detectionConfig.SizeTreatParamList.Count - 1; i >= 0; i--)
{
// 删除选中的主列表项
if (SizeLableList[i].Selected)
if (detectionConfig.SizeTreatParamList[i].Selected)
{
SizeLableList.RemoveAt(i);
detectionConfig.SizeTreatParamList.RemoveAt(i);
}
}
// 提示删除完成
@ -251,7 +244,7 @@ namespace DHSoftware.Views
});
if (form.submit)
{
SizeLableList.Add(SizeParamLable);
detectionConfig.SizeTreatParamList.Add(SizeParamLable);
}
}
@ -260,23 +253,20 @@ namespace DHSoftware.Views
}
List<RelatedCamera> relatedCameras = new List<RelatedCamera>();
private void BtnCorrelatedCamera_Click(object? sender, EventArgs e)
{
var form = new CorrelatedCameraEdit(window, relatedCameras) { Size = new Size(500, 400) };
var form = new CorrelatedCameraEdit(window, detectionConfig.CameraCollects) { Size = new Size(500, 400) };
AntdUI.Modal.open(new AntdUI.Modal.Config(window, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit)
{
flowPanel1.Controls.Clear();
if (relatedCameras.Count > 0)
flowCameraPanel.Controls.Clear();
if (detectionConfig.CameraCollects.Count > 0)
{
foreach (var item in relatedCameras)
foreach (var item in detectionConfig.CameraCollects)
{
var control = new AntdUI.Tag()
{
@ -288,11 +278,11 @@ namespace DHSoftware.Views
control.CloseChanged += (sender, e) =>
{
var tag = sender as Tag;
foreach (var item in relatedCameras)
foreach (var item in detectionConfig.CameraCollects)
{
if (item.CameraSourceId.Equals(tag.Text))
{
relatedCameras.Remove(item);
detectionConfig.CameraCollects.Remove(item);
break;
}
}
@ -301,7 +291,7 @@ namespace DHSoftware.Views
};
// 通过主窗口设置DPI控制添加控件保持缩放比例
window.AutoDpi(control);
flowPanel1.Controls.Add(control);
flowCameraPanel.Controls.Add(control);
control.BringToFront();
}
}
@ -329,7 +319,7 @@ namespace DHSoftware.Views
{
string filePath = openFileDialog.FileName;
iptPath2.Text = filePath;
iptDetectPath.Text = filePath;
}
}
@ -341,12 +331,11 @@ namespace DHSoftware.Views
if (e.Record is PreTreatParam PreTreat)
{
curPreOutTreat = PreTreat;
switch (buttontext)
{
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
case "编辑":
var form = new PreTreatEdit(window, curPreOutTreat) { Size = new Size(500, 300) };
var form = new PreTreatEdit(window, PreTreat) { Size = new Size(500, 300) };
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
{
OnLoad = () =>
@ -362,7 +351,7 @@ namespace DHSoftware.Views
case "删除":
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
if (result == DialogResult.OK)
PreOutTreatList.Remove(PreTreat);
detectionConfig.OUTPreTreatParams.Remove(PreTreat);
break;
}
@ -371,7 +360,7 @@ namespace DHSoftware.Views
private void BtnOutDelete_Click(object? sender, EventArgs e)
{
if (PreOutTreatList.Count == 0 || !PreOutTreatList.Any(x => x.Selected))
if (detectionConfig.OUTPreTreatParams.Count == 0 || !detectionConfig.OUTPreTreatParams.Any(x => x.Selected))
{
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
return;
@ -381,12 +370,12 @@ namespace DHSoftware.Views
if (result == DialogResult.OK)
{
// 使用反转for循环删除主列表中选中的项
for (int i = PreOutTreatList.Count - 1; i >= 0; i--)
for (int i = detectionConfig.OUTPreTreatParams.Count - 1; i >= 0; i--)
{
// 删除选中的主列表项
if (PreOutTreatList[i].Selected)
if (detectionConfig.OUTPreTreatParams[i].Selected)
{
PreOutTreatList.RemoveAt(i);
detectionConfig.OUTPreTreatParams.RemoveAt(i);
}
}
// 提示删除完成
@ -411,7 +400,7 @@ namespace DHSoftware.Views
});
if (form.submit)
{
PreOutTreatList.Add(preParam);
detectionConfig.OUTPreTreatParams.Add(preParam);
}
}
@ -421,12 +410,11 @@ namespace DHSoftware.Views
if (e.Record is PreTreatParam PreTreat)
{
curPreTreat = PreTreat;
switch (buttontext)
{
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
case "编辑":
var form = new PreTreatEdit(window, curPreTreat) { Size = new Size(500, 300) };
var form = new PreTreatEdit(window, PreTreat) { Size = new Size(500, 300) };
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
{
OnLoad = () =>
@ -442,7 +430,7 @@ namespace DHSoftware.Views
case "删除":
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
if (result == DialogResult.OK)
PreTreatList.Remove(PreTreat);
detectionConfig.PreTreatParams.Remove(PreTreat);
break;
}
@ -457,7 +445,7 @@ namespace DHSoftware.Views
private void BtnPreDelete_Click(object? sender, EventArgs e)
{
if (PreTreatList.Count == 0 || !PreTreatList.Any(x => x.Selected))
if (detectionConfig.PreTreatParams.Count == 0 || !detectionConfig.PreTreatParams.Any(x => x.Selected))
{
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
return;
@ -467,12 +455,12 @@ namespace DHSoftware.Views
if (result == DialogResult.OK)
{
// 使用反转for循环删除主列表中选中的项
for (int i = PreTreatList.Count - 1; i >= 0; i--)
for (int i = detectionConfig.PreTreatParams.Count - 1; i >= 0; i--)
{
// 删除选中的主列表项
if (PreTreatList[i].Selected)
if (detectionConfig.PreTreatParams[i].Selected)
{
PreTreatList.RemoveAt(i);
detectionConfig.PreTreatParams.RemoveAt(i);
}
}
// 提示删除完成
@ -496,41 +484,102 @@ namespace DHSoftware.Views
});
if (form.submit)
{
PreTreatList.Add(preParam);
detectionConfig.PreTreatParams.Add(preParam);
}
}
AntList<PreTreatParam> PreTreatList;
AntList<PreTreatParam> PreOutTreatList;
AntList<DetectionLable> DetectionLableList;
AntList<SizeTreatParam> SizeLableList;
PreTreatParam curPreTreat;
PreTreatParam curPreOutTreat;
DetectionLable curDetectionLable;
SizeTreatParam SizeParamLable;
private void InitData()
{
PreTreatList = new AntList<PreTreatParam>();
preTable.Binding(PreTreatList);
PreOutTreatList = new AntList<PreTreatParam>();
PreOutTable.Binding(PreOutTreatList);
foreach (var item in MLModelTypes)
stDetectType.Items.Clear();
foreach (ModelType value in Enum.GetValues(typeof(ModelType)))
{
stDetectType.Items.Add(item.Key);
stDetectType.Items.Add(value.ToString());
}
preTable.Binding(detectionConfig.PreTreatParams);
PreOutTable.Binding(detectionConfig.OUTPreTreatParams);
lableTable.Binding(detectionConfig.DetectionLableList);
SizeTable.Binding(detectionConfig.SizeTreatParamList);
if (detectionConfig.PreTreatParams.Count > 0)
{
foreach (var item in detectionConfig.PreTreatParams)
{
item.CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
};
}
}
if (detectionConfig.OUTPreTreatParams.Count > 0)
{
foreach (var item in detectionConfig.OUTPreTreatParams)
{
DetectionLableList = new AntList<DetectionLable>();
item.CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
};
}
}
lableTable.Binding(DetectionLableList);
if (detectionConfig.DetectionLableList.Count > 0)
{
foreach (var item in detectionConfig.DetectionLableList)
{
SizeLableList = new AntList<SizeTreatParam>();
SizeTable.Binding(SizeLableList);
item.CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
};
}
}
if (detectionConfig.SizeTreatParamList.Count > 0)
{
foreach (var item in detectionConfig.SizeTreatParamList)
{
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)
};
}
}
if (detectionConfig.CameraCollects.Count > 0)
{
foreach (var item in detectionConfig.CameraCollects)
{
var control = new AntdUI.Tag()
{
Font = new System.Drawing.Font("Microsoft YaHei UI", 9F),
Size = new Size(90, 42),
Text = item.CameraSourceId,
CloseIcon = true
};
window.AutoDpi(control);
flowCameraPanel.Controls.Add(control);
control.BringToFront();
}
}
//1
sthPreStatus.DataBindings.Add("Checked", detectionConfig, "IsPreEnabled", true, DataSourceUpdateMode.OnPropertyChanged);
iptPrePath.DataBindings.Add("Text", detectionConfig, "HalconAlgorithemPath_Pre", true, DataSourceUpdateMode.OnPropertyChanged);
//2
sthDetectStatus.DataBindings.Add("Checked", detectionConfig, "IsEnabled", true, DataSourceUpdateMode.OnPropertyChanged);
sthStation.DataBindings.Add("Checked", detectionConfig, "IsAddStation", true, DataSourceUpdateMode.OnPropertyChanged);
stDetectType.DataBindings.Add("Text", detectionConfig, "ModelType",true, DataSourceUpdateMode.OnPropertyChanged);
iptConfidence.DataBindings.Add("Text", detectionConfig, "ModelconfThreshold", true, DataSourceUpdateMode.OnPropertyChanged);
iptDetectPath.DataBindings.Add("Text", detectionConfig, "ModelPath", true, DataSourceUpdateMode.OnPropertyChanged);
sthOKOriginal.DataBindings.Add("Checked", detectionConfig, "SaveOKOriginal", true, DataSourceUpdateMode.OnPropertyChanged);
sthNGOriginal.DataBindings.Add("Checked", detectionConfig, "SaveNGOriginal", true, DataSourceUpdateMode.OnPropertyChanged);
sthOKDetect.DataBindings.Add("Checked", detectionConfig, "SaveOKDetect", true, DataSourceUpdateMode.OnPropertyChanged);
sthDetectNG.DataBindings.Add("Checked", detectionConfig, "SaveNGDetect", true, DataSourceUpdateMode.OnPropertyChanged);
}
@ -590,7 +639,7 @@ namespace DHSoftware.Views
{
string filePath = openFileDialog.FileName;
iptPath.Text = filePath;
iptPrePath.Text = filePath;
}
}
@ -600,31 +649,11 @@ namespace DHSoftware.Views
List<KeyValuePair<string, int>> MLModelTypes = GetFilteredEnumDescriptionsAndValues<MLModelType>();
List<KeyValuePair<string, int>> SizeEnum = GetFilteredEnumDescriptionsAndValues<SizeEnum>();
private void tabPage2_Click(object sender, EventArgs e)
{
}
public static List<KeyValuePair<string, int>> GetFilteredEnumDescriptionsAndValues<T>() where T : Enum
{
return Enum.GetValues(typeof(T))
.Cast<T>()
.Select(e =>
{
// 获取枚举的 Description 属性,如果没有,则使用枚举的名称
var description = e.GetType()
.GetField(e.ToString())
?.GetCustomAttribute<DescriptionAttribute>()
?.Description ?? e.ToString();
// 返回枚举的描述和对应的整数值
return new KeyValuePair<string, int>(description, Convert.ToInt32(e));
})
.ToList();
}
}
}

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
@ -129,7 +129,7 @@
<data name="btnPreAdd.IconSvg" xml:space="preserve">
<value>&lt;svg t="1741939836774" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21349" width="200" height="200"&gt;&lt;path d="M1003.153333 404.96a52.933333 52.933333 0 0 0-42.38-20.96H896V266.666667a53.393333 53.393333 0 0 0-53.333333-53.333334H461.253333a10.573333 10.573333 0 0 1-7.54-3.126666L344.46 100.953333A52.986667 52.986667 0 0 0 306.746667 85.333333H53.333333a53.393333 53.393333 0 0 0-53.333333 53.333334v704a53.393333 53.393333 0 0 0 53.333333 53.333333h796.893334a53.453333 53.453333 0 0 0 51.453333-39.333333l110.546667-405.333334a52.953333 52.953333 0 0 0-9.073334-46.373333zM53.333333 128h253.413334a10.573333 10.573333 0 0 1 7.54 3.126667l109.253333 109.253333A52.986667 52.986667 0 0 0 461.253333 256H842.666667a10.666667 10.666667 0 0 1 10.666666 10.666667v117.333333H173.773333a53.453333 53.453333 0 0 0-51.453333 39.333333L42.666667 715.366667V138.666667a10.666667 10.666667 0 0 1 10.666666-10.666667zm917.726667 312.14l-110.546667 405.333333a10.666667 10.666667 0 0 1-10.286666 7.86H63.226667a10.666667 10.666667 0 0 1-10.286667-13.473333l110.546667-405.333333A10.666667 10.666667 0 0 1 173.773333 426.666667h787a10.666667 10.666667 0 0 1 10.286667 13.473333z" fill="#5C5C66" p-id="21350"/&gt;&lt;/svg&gt;</value>
</data>
<data name="btnPath.IconSvg" xml:space="preserve">
<data name="btnPrePath.IconSvg" xml:space="preserve">
<value>&lt;svg t="1741939836774" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21349" width="200" height="200"&gt;&lt;path d="M1003.153333 404.96a52.933333 52.933333 0 0 0-42.38-20.96H896V266.666667a53.393333 53.393333 0 0 0-53.333333-53.333334H461.253333a10.573333 10.573333 0 0 1-7.54-3.126666L344.46 100.953333A52.986667 52.986667 0 0 0 306.746667 85.333333H53.333333a53.393333 53.393333 0 0 0-53.333333 53.333334v704a53.393333 53.393333 0 0 0 53.333333 53.333333h796.893334a53.453333 53.453333 0 0 0 51.453333-39.333333l110.546667-405.333334a52.953333 52.953333 0 0 0-9.073334-46.373333zM53.333333 128h253.413334a10.573333 10.573333 0 0 1 7.54 3.126667l109.253333 109.253333A52.986667 52.986667 0 0 0 461.253333 256H842.666667a10.666667 10.666667 0 0 1 10.666666 10.666667v117.333333H173.773333a53.453333 53.453333 0 0 0-51.453333 39.333333L42.666667 715.366667V138.666667a10.666667 10.666667 0 0 1 10.666666-10.666667zm917.726667 312.14l-110.546667 405.333333a10.666667 10.666667 0 0 1-10.286666 7.86H63.226667a10.666667 10.666667 0 0 1-10.286667-13.473333l110.546667-405.333333A10.666667 10.666667 0 0 1 173.773333 426.666667h787a10.666667 10.666667 0 0 1 10.286667 13.473333z" fill="#5C5C66" p-id="21350"/&gt;&lt;/svg&gt;</value>
</data>
<data name="btnLableDelete.IconSvg" xml:space="preserve">

View File

@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Reflection;
using AntdUI;
using DH.Commons.Base;
using DH.Commons.Enums;
using DH.Devices.Vision;
using static System.Windows.Forms.AxHost;

422
DHSoftware/Views/MotionControl.Designer.cs generated Normal file
View File

@ -0,0 +1,422 @@
namespace DHSoftware.Views
{
partial class MotionControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
stackPanel2 = new AntdUI.StackPanel();
swhEnable = new AntdUI.Switch();
label4 = new AntdUI.Label();
stackPanel3 = new AntdUI.StackPanel();
sltTpye = new AntdUI.Select();
label1 = new AntdUI.Label();
stpCom = new AntdUI.StackPanel();
cmbCom = new AntdUI.Select();
label2 = new AntdUI.Label();
stackPanel1 = new AntdUI.StackPanel();
stpPort = new AntdUI.StackPanel();
iptPort = new AntdUI.Input();
label9 = new AntdUI.Label();
stpIP = new AntdUI.StackPanel();
iptIP = new AntdUI.Input();
label8 = new AntdUI.Label();
stpParity = new AntdUI.StackPanel();
cmbParity = new AntdUI.Select();
label7 = new AntdUI.Label();
stpStop = new AntdUI.StackPanel();
cmbStopBits = new AntdUI.Select();
label6 = new AntdUI.Label();
stpData = new AntdUI.StackPanel();
cmbDataBits = new AntdUI.Select();
label5 = new AntdUI.Label();
stpBaud = new AntdUI.StackPanel();
cmbBaudRate = new AntdUI.Select();
label3 = new AntdUI.Label();
PLCItemsTable = new AntdUI.Table();
btnDelete = new AntdUI.Button();
btnAdd = new AntdUI.Button();
stackPanel2.SuspendLayout();
stackPanel3.SuspendLayout();
stpCom.SuspendLayout();
stackPanel1.SuspendLayout();
stpPort.SuspendLayout();
stpIP.SuspendLayout();
stpParity.SuspendLayout();
stpStop.SuspendLayout();
stpData.SuspendLayout();
stpBaud.SuspendLayout();
SuspendLayout();
//
// stackPanel2
//
stackPanel2.Controls.Add(swhEnable);
stackPanel2.Controls.Add(label4);
stackPanel2.Dock = DockStyle.Top;
stackPanel2.Location = new Point(3, 3);
stackPanel2.Name = "stackPanel2";
stackPanel2.Size = new Size(217, 43);
stackPanel2.TabIndex = 0;
stackPanel2.Text = "stackPanel2";
//
// swhEnable
//
swhEnable.CheckedText = "启用";
swhEnable.Location = new Point(68, 3);
swhEnable.Name = "swhEnable";
swhEnable.Size = new Size(93, 37);
swhEnable.TabIndex = 25;
swhEnable.UnCheckedText = "关闭";
//
// label4
//
label4.Location = new Point(3, 3);
label4.Name = "label4";
label4.Size = new Size(59, 37);
label4.TabIndex = 24;
label4.Text = "状 态";
//
// stackPanel3
//
stackPanel3.Controls.Add(sltTpye);
stackPanel3.Controls.Add(label1);
stackPanel3.Dock = DockStyle.Top;
stackPanel3.Location = new Point(3, 52);
stackPanel3.Name = "stackPanel3";
stackPanel3.Size = new Size(217, 43);
stackPanel3.TabIndex = 1;
stackPanel3.Text = "stackPanel3";
//
// sltTpye
//
sltTpye.List = true;
sltTpye.Location = new Point(68, 3);
sltTpye.Name = "sltTpye";
sltTpye.Size = new Size(129, 37);
sltTpye.TabIndex = 25;
//
// label1
//
label1.Location = new Point(3, 3);
label1.Name = "label1";
label1.Size = new Size(59, 37);
label1.TabIndex = 24;
label1.Text = "类 型";
//
// stpCom
//
stpCom.Controls.Add(cmbCom);
stpCom.Controls.Add(label2);
stpCom.Dock = DockStyle.Top;
stpCom.Location = new Point(3, 101);
stpCom.Name = "stpCom";
stpCom.Size = new Size(217, 43);
stpCom.TabIndex = 2;
stpCom.Text = "stackPanel4";
//
// cmbCom
//
cmbCom.List = true;
cmbCom.Location = new Point(68, 3);
cmbCom.Name = "cmbCom";
cmbCom.Size = new Size(129, 37);
cmbCom.TabIndex = 25;
//
// label2
//
label2.Location = new Point(3, 3);
label2.Name = "label2";
label2.Size = new Size(59, 37);
label2.TabIndex = 24;
label2.Text = "串 口";
//
// stackPanel1
//
stackPanel1.Controls.Add(stpPort);
stackPanel1.Controls.Add(stpIP);
stackPanel1.Controls.Add(stpParity);
stackPanel1.Controls.Add(stpStop);
stackPanel1.Controls.Add(stpData);
stackPanel1.Controls.Add(stpBaud);
stackPanel1.Controls.Add(stpCom);
stackPanel1.Controls.Add(stackPanel3);
stackPanel1.Controls.Add(stackPanel2);
stackPanel1.Location = new Point(19, 16);
stackPanel1.Name = "stackPanel1";
stackPanel1.Size = new Size(223, 478);
stackPanel1.TabIndex = 25;
stackPanel1.Text = "stackPanel1";
stackPanel1.Vertical = true;
//
// stpPort
//
stpPort.Controls.Add(iptPort);
stpPort.Controls.Add(label9);
stpPort.Dock = DockStyle.Top;
stpPort.Location = new Point(3, 395);
stpPort.Name = "stpPort";
stpPort.Size = new Size(217, 43);
stpPort.TabIndex = 14;
stpPort.Text = "stackPanel10";
//
// iptPort
//
iptPort.Location = new Point(68, 3);
iptPort.Name = "iptPort";
iptPort.Size = new Size(129, 37);
iptPort.TabIndex = 26;
//
// label9
//
label9.Location = new Point(3, 3);
label9.Name = "label9";
label9.Size = new Size(59, 37);
label9.TabIndex = 24;
label9.Text = "端 口 号";
//
// stpIP
//
stpIP.Controls.Add(iptIP);
stpIP.Controls.Add(label8);
stpIP.Dock = DockStyle.Top;
stpIP.Location = new Point(3, 346);
stpIP.Name = "stpIP";
stpIP.Size = new Size(217, 43);
stpIP.TabIndex = 13;
stpIP.Text = "stackPanel9";
//
// iptIP
//
iptIP.Location = new Point(68, 3);
iptIP.Name = "iptIP";
iptIP.Size = new Size(129, 37);
iptIP.TabIndex = 25;
//
// label8
//
label8.Location = new Point(3, 3);
label8.Name = "label8";
label8.Size = new Size(59, 37);
label8.TabIndex = 24;
label8.Text = "I P 地 址";
//
// stpParity
//
stpParity.Controls.Add(cmbParity);
stpParity.Controls.Add(label7);
stpParity.Dock = DockStyle.Top;
stpParity.Location = new Point(3, 297);
stpParity.Name = "stpParity";
stpParity.Size = new Size(217, 43);
stpParity.TabIndex = 12;
stpParity.Text = "stackPanel8";
//
// cmbParity
//
cmbParity.List = true;
cmbParity.Location = new Point(68, 3);
cmbParity.Name = "cmbParity";
cmbParity.Size = new Size(129, 37);
cmbParity.TabIndex = 25;
//
// label7
//
label7.Location = new Point(3, 3);
label7.Name = "label7";
label7.Size = new Size(59, 37);
label7.TabIndex = 24;
label7.Text = "校 验 位";
//
// stpStop
//
stpStop.Controls.Add(cmbStopBits);
stpStop.Controls.Add(label6);
stpStop.Dock = DockStyle.Top;
stpStop.Location = new Point(3, 248);
stpStop.Name = "stpStop";
stpStop.Size = new Size(217, 43);
stpStop.TabIndex = 11;
stpStop.Text = "stackPanel7";
//
// cmbStopBits
//
cmbStopBits.List = true;
cmbStopBits.Location = new Point(68, 3);
cmbStopBits.Name = "cmbStopBits";
cmbStopBits.Size = new Size(129, 37);
cmbStopBits.TabIndex = 25;
//
// label6
//
label6.Location = new Point(3, 3);
label6.Name = "label6";
label6.Size = new Size(59, 37);
label6.TabIndex = 24;
label6.Text = "停 止 位";
//
// stpData
//
stpData.Controls.Add(cmbDataBits);
stpData.Controls.Add(label5);
stpData.Dock = DockStyle.Top;
stpData.Location = new Point(3, 199);
stpData.Name = "stpData";
stpData.Size = new Size(217, 43);
stpData.TabIndex = 10;
stpData.Text = "stackPanel6";
//
// cmbDataBits
//
cmbDataBits.List = true;
cmbDataBits.Location = new Point(68, 3);
cmbDataBits.Name = "cmbDataBits";
cmbDataBits.Size = new Size(129, 37);
cmbDataBits.TabIndex = 25;
//
// label5
//
label5.Location = new Point(3, 3);
label5.Name = "label5";
label5.Size = new Size(59, 37);
label5.TabIndex = 24;
label5.Text = "数 据 位";
//
// stpBaud
//
stpBaud.Controls.Add(cmbBaudRate);
stpBaud.Controls.Add(label3);
stpBaud.Dock = DockStyle.Top;
stpBaud.Location = new Point(3, 150);
stpBaud.Name = "stpBaud";
stpBaud.Size = new Size(217, 43);
stpBaud.TabIndex = 9;
stpBaud.Text = "stackPanel5";
//
// cmbBaudRate
//
cmbBaudRate.List = true;
cmbBaudRate.Location = new Point(68, 3);
cmbBaudRate.Name = "cmbBaudRate";
cmbBaudRate.Size = new Size(129, 37);
cmbBaudRate.TabIndex = 25;
//
// label3
//
label3.Location = new Point(3, 3);
label3.Name = "label3";
label3.Size = new Size(59, 37);
label3.TabIndex = 24;
label3.Text = "波 特 率";
//
// PLCItemsTable
//
PLCItemsTable.EmptyHeader = true;
PLCItemsTable.Location = new Point(238, 71);
PLCItemsTable.Name = "PLCItemsTable";
PLCItemsTable.Size = new Size(634, 392);
PLCItemsTable.TabIndex = 26;
PLCItemsTable.Text = "table1";
//
// btnDelete
//
btnDelete.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnDelete.Location = new Point(331, 27);
btnDelete.Name = "btnDelete";
btnDelete.Size = new Size(80, 32);
btnDelete.TabIndex = 28;
btnDelete.Text = "删除";
btnDelete.Type = AntdUI.TTypeMini.Error;
btnDelete.WaveSize = 0;
//
// btnAdd
//
btnAdd.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnAdd.Location = new Point(245, 27);
btnAdd.Name = "btnAdd";
btnAdd.Size = new Size(80, 32);
btnAdd.TabIndex = 27;
btnAdd.Text = "新增";
btnAdd.Type = AntdUI.TTypeMini.Primary;
btnAdd.WaveSize = 0;
//
// MotionControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(btnDelete);
Controls.Add(btnAdd);
Controls.Add(PLCItemsTable);
Controls.Add(stackPanel1);
Name = "MotionControl";
Size = new Size(898, 530);
stackPanel2.ResumeLayout(false);
stackPanel3.ResumeLayout(false);
stpCom.ResumeLayout(false);
stackPanel1.ResumeLayout(false);
stpPort.ResumeLayout(false);
stpIP.ResumeLayout(false);
stpParity.ResumeLayout(false);
stpStop.ResumeLayout(false);
stpData.ResumeLayout(false);
stpBaud.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private AntdUI.StackPanel stackPanel2;
private AntdUI.Label label4;
private AntdUI.StackPanel stackPanel3;
private AntdUI.Select sltTpye;
private AntdUI.Label label1;
private AntdUI.StackPanel stpCom;
private AntdUI.Select cmbCom;
private AntdUI.Label label2;
private AntdUI.StackPanel stackPanel1;
private AntdUI.Switch swhEnable;
private AntdUI.StackPanel stpPort;
private AntdUI.Input iptPort;
private AntdUI.Label label9;
private AntdUI.StackPanel stpIP;
private AntdUI.Input iptIP;
private AntdUI.Label label8;
private AntdUI.StackPanel stpParity;
private AntdUI.Select cmbParity;
private AntdUI.Label label7;
private AntdUI.StackPanel stpStop;
private AntdUI.Select cmbStopBits;
private AntdUI.Label label6;
private AntdUI.StackPanel stpData;
private AntdUI.Select cmbDataBits;
private AntdUI.Label label5;
private AntdUI.StackPanel stpBaud;
private AntdUI.Select cmbBaudRate;
private AntdUI.Label label3;
private AntdUI.Table PLCItemsTable;
private AntdUI.Button btnDelete;
private AntdUI.Button btnAdd;
}
}

View File

@ -0,0 +1,304 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AntdUI;
using DH.Commons.Base;
using DH.Commons.Enums;
using DH.Devices.PLC;
using XKRS.CanFly;
namespace DHSoftware.Views
{
public partial class MotionControl : UserControl
{
Window window;
PLCBase pLCBase;
public MotionControl(Window _window,PLCBase _pLCBase)
{
window= _window;
pLCBase= _pLCBase;
InitializeComponent();
BindEventHandler();
InitData();
SetupDataBindings();
}
private void BindEventHandler()
{
sltTpye.TextChanged += SltTpye_TextChanged;
btnAdd.Click += BtnAdd_Click;
btnDelete.Click += BtnDelete_Click;
PLCItemsTable.CellButtonClick += PLCItemsTable_CellButtonClick; ;
}
private void PLCItemsTable_CellButtonClick(object sender, TableButtonEventArgs e)
{
var buttontext = e.Btn.Text;
if (e.Record is PLCItem pLCItem)
{
switch (buttontext)
{
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
case "编辑":
var form = new MotionEdit(window, pLCItem) { Size = new Size(500, 300) };
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
{
OnLoad = () =>
{
AntdUI.Message.info(window, "进入编辑", autoClose: 1);
},
OnClose = () =>
{
pLCItem.CellTags = new CellTag[] { };
var tempList = pLCItem.CellTags.ToList();
if (pLCItem.StartExecute)
{
var newTag = new CellTag($"ON_{pLCItem.StartIndex}", TTypeMini.Primary);
tempList.Add(newTag);
}
if (pLCItem.EndExecute)
{
var newTag = new CellTag($"OFF_{pLCItem.EndIndex}", TTypeMini.Warn);
tempList.Add(newTag);
}
// 重新赋值回数组
pLCItem.CellTags = tempList.ToArray();
AntdUI.Message.info(window, "结束编辑", autoClose: 1);
}
});
break;
case "删除":
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
if (result == DialogResult.OK)
{
pLCBase.PLCItemList.Remove(pLCItem);
}
break;
}
}
}
private void BtnDelete_Click(object? sender, EventArgs e)
{
if (pLCBase.PLCItemList.Count == 0 || !pLCBase.PLCItemList.Any(x => x.Selected))
{
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
return;
}
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
if (result == DialogResult.OK)
{
// 使用反转for循环删除主列表中选中的项
for (int i = pLCBase.PLCItemList.Count - 1; i >= 0; i--)
{
// 删除选中的主列表项
if (pLCBase.PLCItemList[i].Selected)
{
pLCBase.PLCItemList.RemoveAt(i);
}
}
// 提示删除完成
AntdUI.Message.success(window, "删除成功!", autoClose: 3);
}
}
private void BtnAdd_Click(object? sender, EventArgs e)
{
PLCItem pLCItem = new PLCItem()
{
CellLinks = new CellLink[]
{
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary),
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
}
};
var form = new MotionEdit(window, pLCItem) { Size = new Size(450, 550) };
AntdUI.Modal.open(new AntdUI.Modal.Config(window, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit)
{
pLCItem.CellTags = new CellTag[] { };
var tempList = pLCItem.CellTags.ToList();
if (pLCItem.StartExecute)
{
var newTag = new CellTag($"ON_{pLCItem.StartIndex}", TTypeMini.Primary);
tempList.Add(newTag);
}
if (pLCItem.EndExecute)
{
var newTag = new CellTag($"OFF_{pLCItem.EndIndex}", TTypeMini.Warn);
tempList.Add(newTag);
}
// 重新赋值回数组
pLCItem.CellTags = tempList.ToArray();
pLCBase.PLCItemList.Add(pLCItem);
}
}
private void SltTpye_TextChanged(object? sender, EventArgs e)
{
if (sender is Select slt && !string.IsNullOrEmpty(slt.Text))
{
// 将文本转换为枚举值
if (Enum.TryParse<EnumPLCType>(slt.Text, out var plcType))
{
switch (plcType)
{
case EnumPLCType.XC网口:
case EnumPLCType.XD网口:
stpCom.Visible = false;
stpBaud.Visible = false;
stpData.Visible = false;
stpParity.Visible = false;
stpStop.Visible = false;
stpIP.Visible = true;
stpPort.Visible = true;
break;
case EnumPLCType.XD串口:
case EnumPLCType.XC串口:
stpCom.Visible = true;
stpBaud.Visible = true;
stpData.Visible = true;
stpParity.Visible = true;
stpStop.Visible = true;
stpIP.Visible = false;
stpPort.Visible = false;
break;
default:
break;
}
}
else
{
}
}
}
private void InitData()
{
// 获取枚举字段名列表(原描述改为字段名)
sltTpye.Items.Clear();
foreach (EnumPLCType value in Enum.GetValues(typeof(EnumPLCType)))
{
sltTpye.Items.Add(value.ToString());
}
// 波特率选项(保持不变)
cmbBaudRate.Items.AddRange(new object[] { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200 });
// 数据位选项(保持不变)
cmbDataBits.Items.AddRange(new object[] { 5, 6, 7, 8 });
// 停止位选项改为字段名
var stopBitsNames = Enum.GetNames(typeof(StopBits));
foreach (var name in stopBitsNames)
{
cmbStopBits.Items.Add(name);
}
// 校验位选项改为字段名
var parityNames = Enum.GetNames(typeof(Parity));
foreach (var name in parityNames)
{
cmbParity.Items.Add(name);
}
// COM端口列表保持不变
List<string> comList = SerialPort.GetPortNames().ToList();
foreach (var item in comList)
{
cmbCom.Items.Add(item);
}
PLCItemsTable.Columns = new ColumnCollection() {
new ColumnCheck("Selected"){Fixed = true},
new Column("Name", "名称", ColumnAlign.Center),
new Column("Type", "类型",ColumnAlign.Center),
new Column("Address", "地址",ColumnAlign.Center),
new Column("Value", "值",ColumnAlign.Center),
new Column("CellTags", "标签",ColumnAlign.Center),
new Column("CellLinks", "操作", ColumnAlign.Center)
};
if (pLCBase.PLCItemList.Count > 0)
{
foreach( var item in pLCBase.PLCItemList)
{
item.CellTags = new CellTag[] { };
var tempList = item.CellTags.ToList();
if (item.StartExecute)
{
var newTag = new CellTag($"ON_{item.StartIndex}", TTypeMini.Primary);
tempList.Add(newTag);
}
if (item.EndExecute)
{
var newTag = new CellTag($"OFF_{item.EndIndex}", TTypeMini.Warn);
tempList.Add(newTag);
}
// 重新赋值回数组
item.CellTags = tempList.ToArray();
item.CellLinks = new CellLink[] {
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
};
}
}
PLCItemsTable.Binding(pLCBase.PLCItemList);
}
private void SetupDataBindings()
{
// 添加双向类型转换
sltTpye.DataBindings.Add("Text", pLCBase, "PLCType", true, DataSourceUpdateMode.OnPropertyChanged, "");
cmbCom.DataBindings.Add(nameof(cmbCom.Text), pLCBase, nameof(pLCBase.COM));
cmbBaudRate.DataBindings.Add(nameof(cmbBaudRate.Text), pLCBase, nameof(pLCBase.BaudRate));
cmbDataBits.DataBindings.Add(nameof(cmbDataBits.Text), pLCBase, nameof(pLCBase.DataBit));
cmbParity.DataBindings.Add(nameof(cmbParity.Text), pLCBase, nameof(pLCBase.Parity));
cmbStopBits.DataBindings.Add(nameof(cmbStopBits.Text), pLCBase, nameof(pLCBase.StopBit));
iptIP.DataBindings.Add(nameof(iptIP.Text), pLCBase, nameof(pLCBase.IP));
iptPort.DataBindings.Add(nameof(iptPort.Text), pLCBase, nameof(pLCBase.Port));
swhEnable.DataBindings.Add(nameof(swhEnable.Checked),pLCBase, nameof(pLCBase.Enable));
}
}
}

392
DHSoftware/Views/MotionEdit.Designer.cs generated Normal file
View File

@ -0,0 +1,392 @@
namespace DHSoftware.Views
{
partial class MotionEdit
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
button_cancel = new AntdUI.Button();
sltName = new AntdUI.Select();
label2 = new AntdUI.Label();
divider2 = new AntdUI.Divider();
stackPanel1 = new AntdUI.StackPanel();
button_ok = new AntdUI.Button();
divider1 = new AntdUI.Divider();
label1 = new AntdUI.Label();
panel1 = new AntdUI.Panel();
sltDataType = new AntdUI.Select();
label3 = new AntdUI.Label();
iptAddress = new AntdUI.Input();
label7 = new AntdUI.Label();
stackPanel3 = new AntdUI.StackPanel();
iptEndIndex = new AntdUI.Input();
sltEnd = new AntdUI.Select();
label6 = new AntdUI.Label();
stackPanel2 = new AntdUI.StackPanel();
iptStartIndex = new AntdUI.Input();
sltStart = new AntdUI.Select();
label5 = new AntdUI.Label();
sltBoolValue = new AntdUI.Select();
stpNum = new AntdUI.StackPanel();
sltIntType = new AntdUI.Select();
iptValue = new AntdUI.Input();
label4 = new AntdUI.Label();
stackPanel1.SuspendLayout();
panel1.SuspendLayout();
stackPanel3.SuspendLayout();
stackPanel2.SuspendLayout();
stpNum.SuspendLayout();
SuspendLayout();
//
// button_cancel
//
button_cancel.BorderWidth = 1F;
button_cancel.Font = new Font("Microsoft YaHei UI", 9F);
button_cancel.Ghost = true;
button_cancel.Location = new Point(84, 3);
button_cancel.Name = "button_cancel";
button_cancel.Size = new Size(75, 38);
button_cancel.TabIndex = 1;
button_cancel.Text = "取消";
//
// sltName
//
sltName.Dock = DockStyle.Top;
sltName.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
sltName.Location = new Point(18, 134);
sltName.MaxCount = 10;
sltName.Name = "sltName";
sltName.Radius = 3;
sltName.Size = new Size(409, 38);
sltName.TabIndex = 23;
//
// label2
//
label2.Dock = DockStyle.Top;
label2.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label2.Location = new Point(18, 110);
label2.Name = "label2";
label2.Size = new Size(409, 24);
label2.TabIndex = 22;
label2.Text = "名称";
//
// divider2
//
divider2.Dock = DockStyle.Top;
divider2.Location = new Point(18, 98);
divider2.Name = "divider2";
divider2.Size = new Size(409, 12);
divider2.TabIndex = 21;
//
// stackPanel1
//
stackPanel1.Controls.Add(button_cancel);
stackPanel1.Controls.Add(button_ok);
stackPanel1.Dock = DockStyle.Top;
stackPanel1.Location = new Point(18, 54);
stackPanel1.Name = "stackPanel1";
stackPanel1.RightToLeft = RightToLeft.No;
stackPanel1.Size = new Size(409, 44);
stackPanel1.TabIndex = 20;
stackPanel1.Text = "stackPanel1";
//
// button_ok
//
button_ok.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
button_ok.Location = new Point(3, 3);
button_ok.Name = "button_ok";
button_ok.Size = new Size(75, 38);
button_ok.TabIndex = 0;
button_ok.Text = "确定";
button_ok.Type = AntdUI.TTypeMini.Primary;
//
// divider1
//
divider1.Dock = DockStyle.Top;
divider1.Location = new Point(18, 42);
divider1.Name = "divider1";
divider1.Size = new Size(409, 12);
divider1.TabIndex = 19;
//
// label1
//
label1.Dock = DockStyle.Top;
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label1.Location = new Point(18, 18);
label1.Name = "label1";
label1.Size = new Size(409, 24);
label1.TabIndex = 17;
label1.Text = "PLC点位操作";
//
// panel1
//
panel1.Controls.Add(stackPanel3);
panel1.Controls.Add(label6);
panel1.Controls.Add(stackPanel2);
panel1.Controls.Add(label5);
panel1.Controls.Add(sltBoolValue);
panel1.Controls.Add(stpNum);
panel1.Controls.Add(label4);
panel1.Controls.Add(iptAddress);
panel1.Controls.Add(label7);
panel1.Controls.Add(sltDataType);
panel1.Controls.Add(label3);
panel1.Controls.Add(sltName);
panel1.Controls.Add(label2);
panel1.Controls.Add(divider2);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider1);
panel1.Controls.Add(label1);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
panel1.Padding = new Padding(12);
panel1.Shadow = 6;
panel1.Size = new Size(445, 572);
panel1.TabIndex = 1;
panel1.Text = "panel1";
//
// sltDataType
//
sltDataType.Dock = DockStyle.Top;
sltDataType.List = true;
sltDataType.Location = new Point(18, 196);
sltDataType.Name = "sltDataType";
sltDataType.Size = new Size(409, 38);
sltDataType.TabIndex = 45;
//
// label3
//
label3.Dock = DockStyle.Top;
label3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label3.Location = new Point(18, 172);
label3.Name = "label3";
label3.Size = new Size(409, 24);
label3.TabIndex = 44;
label3.Text = "数据类型";
//
// iptAddress
//
iptAddress.Dock = DockStyle.Top;
iptAddress.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
iptAddress.Location = new Point(18, 258);
iptAddress.Name = "iptAddress";
iptAddress.Radius = 3;
iptAddress.Size = new Size(409, 38);
iptAddress.TabIndex = 54;
//
// label7
//
label7.Dock = DockStyle.Top;
label7.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label7.Location = new Point(18, 234);
label7.Name = "label7";
label7.Size = new Size(409, 24);
label7.TabIndex = 53;
label7.Text = "地址";
//
// stackPanel3
//
stackPanel3.BackColor = SystemColors.Window;
stackPanel3.Controls.Add(iptEndIndex);
stackPanel3.Controls.Add(sltEnd);
stackPanel3.Dock = DockStyle.Top;
stackPanel3.Location = new Point(18, 496);
stackPanel3.Name = "stackPanel3";
stackPanel3.Size = new Size(409, 45);
stackPanel3.TabIndex = 61;
stackPanel3.Text = "stackPanel3";
//
// iptEndIndex
//
iptEndIndex.Dock = DockStyle.Left;
iptEndIndex.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
iptEndIndex.Location = new Point(277, 3);
iptEndIndex.Name = "iptEndIndex";
iptEndIndex.PlaceholderText = "执行顺序标识(0开始)";
iptEndIndex.Radius = 3;
iptEndIndex.Size = new Size(132, 39);
iptEndIndex.TabIndex = 36;
//
// sltEnd
//
sltEnd.Dock = DockStyle.Left;
sltEnd.Items.AddRange(new object[] { "执行", "取消" });
sltEnd.List = true;
sltEnd.Location = new Point(3, 3);
sltEnd.Name = "sltEnd";
sltEnd.Size = new Size(268, 39);
sltEnd.TabIndex = 35;
//
// label6
//
label6.Dock = DockStyle.Top;
label6.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label6.Location = new Point(18, 472);
label6.Name = "label6";
label6.Size = new Size(409, 24);
label6.TabIndex = 60;
label6.Text = "流程结束执行";
//
// stackPanel2
//
stackPanel2.BackColor = SystemColors.Window;
stackPanel2.Controls.Add(iptStartIndex);
stackPanel2.Controls.Add(sltStart);
stackPanel2.Dock = DockStyle.Top;
stackPanel2.Location = new Point(18, 427);
stackPanel2.Name = "stackPanel2";
stackPanel2.Size = new Size(409, 45);
stackPanel2.TabIndex = 59;
stackPanel2.Text = "stackPanel2";
//
// iptStartIndex
//
iptStartIndex.Dock = DockStyle.Left;
iptStartIndex.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
iptStartIndex.Location = new Point(277, 3);
iptStartIndex.Name = "iptStartIndex";
iptStartIndex.PlaceholderText = "执行顺序标识(0开始)";
iptStartIndex.Radius = 3;
iptStartIndex.Size = new Size(132, 39);
iptStartIndex.TabIndex = 36;
//
// sltStart
//
sltStart.Dock = DockStyle.Left;
sltStart.Items.AddRange(new object[] { "执行", "取消" });
sltStart.List = true;
sltStart.Location = new Point(3, 3);
sltStart.Name = "sltStart";
sltStart.Size = new Size(268, 39);
sltStart.TabIndex = 35;
//
// label5
//
label5.Dock = DockStyle.Top;
label5.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label5.Location = new Point(18, 403);
label5.Name = "label5";
label5.Size = new Size(409, 24);
label5.TabIndex = 58;
label5.Text = "流程开始执行";
//
// sltBoolValue
//
sltBoolValue.Dock = DockStyle.Top;
sltBoolValue.Items.AddRange(new object[] { "True", "False" });
sltBoolValue.List = true;
sltBoolValue.Location = new Point(18, 365);
sltBoolValue.Name = "sltBoolValue";
sltBoolValue.Size = new Size(409, 38);
sltBoolValue.TabIndex = 57;
//
// stpNum
//
stpNum.BackColor = SystemColors.Window;
stpNum.Controls.Add(sltIntType);
stpNum.Controls.Add(iptValue);
stpNum.Dock = DockStyle.Top;
stpNum.Location = new Point(18, 320);
stpNum.Name = "stpNum";
stpNum.Size = new Size(409, 45);
stpNum.TabIndex = 56;
stpNum.Text = "stackPanel2";
//
// sltIntType
//
sltIntType.Dock = DockStyle.Left;
sltIntType.List = true;
sltIntType.Location = new Point(277, 3);
sltIntType.Name = "sltIntType";
sltIntType.Size = new Size(132, 39);
sltIntType.TabIndex = 35;
//
// iptValue
//
iptValue.Dock = DockStyle.Left;
iptValue.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
iptValue.Location = new Point(3, 3);
iptValue.Name = "iptValue";
iptValue.Radius = 3;
iptValue.Size = new Size(268, 39);
iptValue.TabIndex = 24;
//
// label4
//
label4.Dock = DockStyle.Top;
label4.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label4.Location = new Point(18, 296);
label4.Name = "label4";
label4.Size = new Size(409, 24);
label4.TabIndex = 55;
label4.Text = "值";
//
// MotionEdit
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Controls.Add(panel1);
Name = "MotionEdit";
Size = new Size(445, 572);
stackPanel1.ResumeLayout(false);
panel1.ResumeLayout(false);
stackPanel3.ResumeLayout(false);
stackPanel2.ResumeLayout(false);
stpNum.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private AntdUI.Button button_cancel;
private AntdUI.Select sltName;
private AntdUI.Label label2;
private AntdUI.Divider divider2;
private AntdUI.StackPanel stackPanel1;
private AntdUI.Button button_ok;
private AntdUI.Divider divider1;
private AntdUI.Label label1;
private AntdUI.Panel panel1;
private AntdUI.Select sltDataType;
private AntdUI.Label label3;
private AntdUI.StackPanel stackPanel3;
private AntdUI.Input iptEndIndex;
private AntdUI.Select sltEnd;
private AntdUI.Label label6;
private AntdUI.StackPanel stackPanel2;
private AntdUI.Input iptStartIndex;
private AntdUI.Select sltStart;
private AntdUI.Label label5;
private AntdUI.Select sltBoolValue;
private AntdUI.StackPanel stpNum;
private AntdUI.Select sltIntType;
private AntdUI.Input iptValue;
private AntdUI.Label label4;
private AntdUI.Input iptAddress;
private AntdUI.Label label7;
}
}

View File

@ -0,0 +1,125 @@
using AntdUI;
using DH.Commons.Base;
using DH.Commons.Enums;
using DH.Devices.PLC;
namespace DHSoftware.Views
{
public partial class MotionEdit : UserControl
{
private AntdUI.Window window;
private PLCItem plcItem;
public bool submit;
public MotionEdit(AntdUI.Window _window, PLCItem _plcItem)
{
InitializeComponent();
plcItem = _plcItem;
// 绑定事件
BindEventHandler();
//设置默认值
InitData();
}
private void BindEventHandler()
{
button_ok.Click += Button_ok_Click;
button_cancel.Click += Button_cancel_Click;
sltDataType.SelectedIndexChanged += SltDataType_SelectedIndexChanged;
sltStart.SelectedIndexChanged += SltStart_SelectedIndexChanged;
sltEnd.SelectedIndexChanged += SltEnd_SelectedIndexChanged;
}
private void SltEnd_SelectedIndexChanged(object sender, IntEventArgs e)
{
iptEndIndex.Visible = e.Value == 0;
}
private void SltDataType_SelectedIndexChanged(object sender, IntEventArgs e)
{
var isMType = e.Value == 2;
stpNum.Visible = !isMType;
sltBoolValue.Visible = isMType;
}
private void SltStart_SelectedIndexChanged(object sender, IntEventArgs e)
{
iptStartIndex.Visible = e.Value == 0;
}
private void Button_cancel_Click(object sender, EventArgs e)
{
submit = false;
this.Dispose();
}
private void Button_ok_Click(object sender, EventArgs e)
{
sltName.Status = AntdUI.TType.None;
//检查输入内容
if (String.IsNullOrEmpty(sltName.Text))
{
sltName.Status = AntdUI.TType.Error;
AntdUI.Message.warn(window, "参数名称不能为空!", autoClose: 3);
return;
}
plcItem.Name = sltName.Text;
plcItem.Address = iptAddress.Text;
plcItem.Type = sltDataType.Text;
plcItem.Value = sltDataType.SelectedIndex == 2 ? sltBoolValue.Text : iptValue.Text;
plcItem.NumTpye = sltDataType.SelectedIndex == 2 ? string.Empty : sltIntType.Text;
plcItem.StartExecute = sltStart.Text == "执行" ? true : false;
plcItem.StartIndex = sltStart.Text == "执行" ? Convert.ToInt32(iptStartIndex.Text) : -1;
plcItem.EndExecute = sltEnd.Text == "执行" ? true : false;
plcItem.EndIndex = sltEnd.Text == "执行" ? Convert.ToInt32(iptEndIndex.Text) : -1;
submit = true;
this.Dispose();
}
private void InitData()
{
var PLCItemNames = Enum.GetNames(typeof(EnumPLCOutputIO));
foreach (var name in PLCItemNames)
{
sltName.Items.Add(name);
}
var PLCDataTypes = Enum.GetNames(typeof(EnumPLCDataType));
foreach (var name in PLCDataTypes)
{
sltDataType.Items.Add(name);
}
sltDataType.SelectedIndex = 0;
var PLCINTTypes = Enum.GetNames(typeof(EnumPLCINTType));
foreach (var name in PLCINTTypes)
{
sltIntType.Items.Add(name);
}
sltStart.SelectedIndex = 1;
sltEnd.SelectedIndex = 1;
if (!string.IsNullOrEmpty(plcItem.Name))
{
sltName.Text = plcItem.Name;
iptAddress.Text = plcItem.Address;
sltDataType.SelectedValue = plcItem.Type;
iptValue.Text = sltDataType.SelectedIndex != 2 ? plcItem.Value : string.Empty;
sltBoolValue.SelectedValue = sltDataType.SelectedIndex == 2 ? plcItem.Value : string.Empty;
sltIntType.SelectedValue = sltDataType.SelectedIndex == 2 ? string.Empty : plcItem.NumTpye;
sltStart.SelectedValue = plcItem.StartExecute == true ? "执行" : "取消";
sltEnd.SelectedValue = plcItem.EndExecute == true ? "执行" : "取消";
iptStartIndex.Text = plcItem.StartExecute == true ? plcItem.StartIndex.ToString() : "-1";
iptEndIndex.Text = plcItem.EndExecute == true ? plcItem.EndIndex.ToString() : "-1";
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
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
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -1,6 +1,6 @@

using DH.Commons.Enums;
using DH.Commons.Base;
using DH.Devices.Vision;
namespace DHSoftware.Views

View File

@ -28,93 +28,24 @@
/// </summary>
private void InitializeComponent()
{
panel3 = new AntdUI.Panel();
panel1 = new AntdUI.Panel();
panel2 = new AntdUI.Panel();
btnSave = new AntdUI.Button();
btnAdd = new AntdUI.Button();
menu1 = new AntdUI.Menu();
AntdUI.MenuItem menuItem4 = new AntdUI.MenuItem();
AntdUI.MenuItem menuItem5 = new AntdUI.MenuItem();
AntdUI.MenuItem menuItem6 = new AntdUI.MenuItem();
AntdUI.Tabs.StyleCard styleCard2 = new AntdUI.Tabs.StyleCard();
pageHeader1 = new AntdUI.PageHeader();
panel3.SuspendLayout();
panel1 = new AntdUI.Panel();
panel2 = new AntdUI.StackPanel();
btnSave = new AntdUI.Dropdown();
btnAdd = new AntdUI.Dropdown();
menu1 = new AntdUI.Menu();
panel3 = new AntdUI.Panel();
tabs1 = new AntdUI.Tabs();
divider1 = new AntdUI.Divider();
panel1.SuspendLayout();
panel2.SuspendLayout();
panel3.SuspendLayout();
SuspendLayout();
//
// panel3
//
panel3.Controls.Add(panel1);
panel3.Controls.Add(pageHeader1);
panel3.Dock = DockStyle.Fill;
panel3.Location = new Point(0, 0);
panel3.Name = "panel3";
panel3.Size = new Size(838, 561);
panel3.TabIndex = 1;
panel3.Text = "panel3";
//
// panel1
//
panel1.Controls.Add(panel2);
panel1.Controls.Add(menu1);
panel1.Dock = DockStyle.Left;
panel1.Location = new Point(0, 33);
panel1.Name = "panel1";
panel1.Size = new Size(141, 528);
panel1.TabIndex = 2;
panel1.Text = "panel1";
//
// panel2
//
panel2.Back = SystemColors.Window;
panel2.BackColor = SystemColors.Window;
panel2.Controls.Add(btnSave);
panel2.Controls.Add(btnAdd);
panel2.Dock = DockStyle.Fill;
panel2.Location = new Point(0, 497);
panel2.Name = "panel2";
panel2.Size = new Size(141, 31);
panel2.TabIndex = 1;
panel2.Text = "panel2";
//
// btnSave
//
btnSave.BackActive = SystemColors.Control;
btnSave.BackColor = SystemColors.Control;
btnSave.Dock = DockStyle.Left;
btnSave.ForeColor = Color.Black;
btnSave.IconRatio = 1F;
btnSave.IconSvg = "AppstoreAddOutlined";
btnSave.Location = new Point(35, 0);
btnSave.Name = "btnSave";
btnSave.Size = new Size(35, 31);
btnSave.TabIndex = 2;
btnSave.Click += btnSave_Click;
//
// btnAdd
//
btnAdd.BackActive = SystemColors.Control;
btnAdd.BackColor = SystemColors.Control;
btnAdd.Dock = DockStyle.Left;
btnAdd.ForeColor = Color.Black;
btnAdd.IconRatio = 1F;
btnAdd.IconSvg = "AppstoreAddOutlined";
btnAdd.Location = new Point(0, 0);
btnAdd.Name = "btnAdd";
btnAdd.Size = new Size(35, 31);
btnAdd.TabIndex = 1;
btnAdd.Click += btnAdd_Click;
//
// menu1
//
menu1.BackColor = SystemColors.Window;
menu1.Dock = DockStyle.Top;
menu1.Location = new Point(0, 0);
menu1.Name = "menu1";
menu1.Size = new Size(141, 497);
menu1.TabIndex = 0;
menu1.Text = "menu1";
menu1.MouseClick += menu1_MouseClick;
menu1.MouseDown += Menu_MouseDown;
//
// pageHeader1
//
pageHeader1.BackColor = SystemColors.MenuHighlight;
@ -124,32 +55,146 @@
pageHeader1.Name = "pageHeader1";
pageHeader1.ShowButton = true;
pageHeader1.ShowIcon = true;
pageHeader1.Size = new Size(838, 33);
pageHeader1.Size = new Size(1042, 33);
pageHeader1.TabIndex = 1;
pageHeader1.Text = "设置";
//
// SettingWindow
// panel1
//
panel1.Controls.Add(panel2);
panel1.Controls.Add(menu1);
panel1.Dock = DockStyle.Left;
panel1.Location = new Point(0, 33);
panel1.Name = "panel1";
panel1.Size = new Size(141, 666);
panel1.TabIndex = 2;
panel1.Text = "panel1";
//
// panel2
//
panel2.BackColor = SystemColors.Window;
panel2.Controls.Add(btnSave);
panel2.Controls.Add(btnAdd);
panel2.Dock = DockStyle.Fill;
panel2.Location = new Point(0, 632);
panel2.Name = "panel2";
panel2.Size = new Size(141, 34);
panel2.TabIndex = 1;
panel2.Text = "panel2";
//
// btnSave
//
btnSave.BackActive = SystemColors.Control;
btnSave.BackColor = SystemColors.Control;
btnSave.Dock = DockStyle.Right;
btnSave.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnSave.ForeColor = Color.Black;
btnSave.IconSvg = "SaveOutlined";
btnSave.Location = new Point(72, 3);
btnSave.Name = "btnSave";
btnSave.Size = new Size(63, 28);
btnSave.TabIndex = 2;
btnSave.Text = "保存";
//
// btnAdd
//
btnAdd.BackActive = SystemColors.Control;
btnAdd.BackColor = SystemColors.Control;
btnAdd.Dock = DockStyle.Left;
btnAdd.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnAdd.ForeColor = Color.Black;
btnAdd.IconSvg = "AppstoreAddOutlined";
btnAdd.Location = new Point(3, 3);
btnAdd.Name = "btnAdd";
btnAdd.Placement = AntdUI.TAlignFrom.TL;
btnAdd.Size = new Size(63, 28);
btnAdd.TabIndex = 1;
btnAdd.Text = "新增";
btnAdd.Trigger = AntdUI.Trigger.Hover;
//
// menu1
//
menu1.BackColor = SystemColors.Window;
menu1.Dock = DockStyle.Top;
menuItem4.IconSvg = "VideoCameraOutlined";
menuItem4.Text = "相机设置";
menuItem5.IconSvg = "AppstoreOutlined";
menuItem5.Text = "工位设置";
menuItem6.IconSvg = "ControlOutlined";
menuItem6.Text = "运控设置";
menu1.Items.Add(menuItem4);
menu1.Items.Add(menuItem5);
menu1.Items.Add(menuItem6);
menu1.Location = new Point(0, 0);
menu1.Name = "menu1";
menu1.Size = new Size(141, 632);
menu1.TabIndex = 0;
menu1.Text = "menu1";
menu1.MouseDown += menu1_MouseDown;
//
// panel3
//
panel3.Controls.Add(tabs1);
panel3.Controls.Add(divider1);
panel3.Controls.Add(panel1);
panel3.Controls.Add(pageHeader1);
panel3.Dock = DockStyle.Fill;
panel3.Location = new Point(0, 0);
panel3.Name = "panel3";
panel3.Size = new Size(1042, 699);
panel3.TabIndex = 1;
panel3.Text = "panel3";
//
// tabs1
//
tabs1.BackColor = SystemColors.Window;
tabs1.Dock = DockStyle.Fill;
tabs1.Location = new Point(151, 33);
tabs1.Name = "tabs1";
tabs1.Size = new Size(891, 666);
styleCard2.Closable = true;
tabs1.Style = styleCard2;
tabs1.TabIndex = 5;
tabs1.Text = "tabs1";
tabs1.Type = AntdUI.TabType.Card;
//
// divider1
//
divider1.BackColor = SystemColors.Window;
divider1.Dock = DockStyle.Left;
divider1.Location = new Point(141, 33);
divider1.Name = "divider1";
divider1.OrientationMargin = 0F;
divider1.Size = new Size(10, 666);
divider1.TabIndex = 4;
divider1.Text = "";
divider1.Vertical = true;
//
// SettingWindow1
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(838, 561);
ClientSize = new Size(1042, 699);
Controls.Add(panel3);
Name = "SettingWindow";
Name = "SettingWindow1";
StartPosition = FormStartPosition.CenterScreen;
Text = "SettingWinform";
panel3.ResumeLayout(false);
panel1.ResumeLayout(false);
panel2.ResumeLayout(false);
panel3.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private AntdUI.Panel panel3;
private AntdUI.PageHeader pageHeader1;
private AntdUI.Panel panel1;
private AntdUI.Panel panel2;
private AntdUI.Button btnAdd;
private AntdUI.StackPanel panel2;
private AntdUI.Menu menu1;
private AntdUI.Panel panel3;
private AntdUI.Tabs tabs1;
private AntdUI.Divider divider1;
private AntdUI.Dropdown btnAdd;
private AntdUI.Button btnSave;
}
}

View File

@ -1,43 +1,145 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;
using AntdUI;
using DH.Commons.Enums;
using DH.Devices.Devices;
using DH.Devices.Vision;
using DH.Commons.Helper;
using DH.Commons.Models;
using DHSoftware.Utils;
using DH.Commons.Base;
namespace DHSoftware.Views
{
public partial class SettingWindow : Window
{
public List<CameraBase> cameras = new List<CameraBase>();
public List<DetectionConfig> detections = new List<DetectionConfig>();
private UserControl currControl;
public SettingWindow()
{
InitializeComponent();
AntdUI.TooltipComponent tooltip = new AntdUI.TooltipComponent()
{
Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
};
tooltip.ArrowAlign = AntdUI.TAlign.Right;
tooltip.SetTip(btnAdd, "新增工位");
BindEventHandler();
InitData();
}
private void Menu_MouseDown(object sender, MouseEventArgs e)
private void BindEventHandler()
{
if (e.Button == MouseButtons.Right)
Resize += SettingWindow1_Resize;
btnAdd.SelectedValueChanged += btnAdd_SelectedValueChanged;
btnSave.Click += BtnSave_Click;
}
private float x; //定义当前窗体的宽度
private float y; //定义当前窗体的高度
private void InitData()
{
btnAdd.Items.Clear();
btnAdd.Items.Add("相机设置");
btnAdd.Items.Add("工位设置");
btnAdd.Items.Add("运控设置");
x = Width;
y = Height;
AdaptiveHelper.setTag(this);
if (ConfigModel.CameraBaseList.Count > 0)
{
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
if (workstationItem != null)
{
foreach (var item in ConfigModel.CameraBaseList)
{
var newItem = new MenuItem();
newItem.Text = item.CameraName;
newItem.IconSvg = "VideoCameraOutlined";
workstationItem.Sub.Add(newItem);
}
}
}
if (ConfigModel.DetectionList.Count > 0)
{
var workstationItem = FindMenuItem(menu1.Items, "工位设置");
if (workstationItem != null)
{
foreach (var item in ConfigModel.DetectionList)
{
var newItem = new MenuItem();
newItem.Text = item.Name;
newItem.IconSvg = "AppstoreOutlined";
workstationItem.Sub.Add(newItem);
}
}
}
if (ConfigModel.PLCBaseList.Count > 0)
{
var workstationItem = FindMenuItem(menu1.Items, "运控设置");
if (workstationItem != null)
{
foreach (var item in ConfigModel.PLCBaseList)
{
var newItem = new MenuItem();
newItem.Text = item.PLCName;
newItem.IconSvg = "ControlOutlined";
workstationItem.Sub.Add(newItem);
}
}
}
}
private void BtnSave_Click(object? sender, EventArgs e)
{
ConfigHelper.SaveConfig();
AntdUI.Message.success(this, "保存成功!", autoClose: 3);
}
private void SettingWindow1_Resize(object? sender, EventArgs e)
{
var newx = Width / x;
var newy = Height / y;
AdaptiveHelper.setControls(newx, newy, this);
}
// 递归查找菜单项
private MenuItem FindMenuItem(MenuItemCollection items, string targetText)
{
foreach (MenuItem item in items)
{
if (item.Text == targetText) return item;
if (item.Sub != null)
{
var subResult = FindMenuItem(item.Sub, targetText);
if (subResult != null) return subResult;
}
}
return null;
}
bool isUpdatingTabs = false;
private void menu1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
// 转换坐标到控件内部坐标系(考虑滚动条)
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
@ -47,21 +149,414 @@ namespace DHSoftware.Views
if (clickedItem != null)
{
// 显示节点名称弹窗
//MessageBox.Show($"右键点击的节点: {clickedItem.Text}");
var menulist = new AntdUI.IContextMenuStripItem[]
if (clickedItem.PARENTITEM == null)
{
new AntdUI.ContextMenuStripItem("关联相机", "")
{
IconSvg = "VideoCameraAddOutlined"
}
};
return;
}
switch (clickedItem.PARENTITEM.Text)
{
case "相机设置":
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;
}
}
//先获取是否存在该名称的配置
//如果没有新建项
CameraBase? CameraBase= ConfigModel.CameraBaseList.Where(c => c.CameraName == clickedItem.Text).FirstOrDefault();
if (CameraBase == null)
{
CameraBase=new CameraBase();
}
UserControl control = null;
control = new CameraControl(this, CameraBase);
if (control != null)
{
//容器添加控件需要调整dpi
control.Dock = DockStyle.Fill;
AutoDpi(control);
AntdUI.TabPage tabPage = new AntdUI.TabPage()
{
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
ReadOnly = false,
};
tabPage.Controls.Add(control);
tabs1.Pages.Add(tabPage);
isUpdatingTabs = true;
tabs1.SelectedTab = tabPage;
isUpdatingTabs = false;
currControl = control;
}
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;
}
}
DetectionConfig? detectionConfig = ConfigModel.DetectionList.Where(c => c.Name == clickedItem.Text).FirstOrDefault();
if (detectionConfig == null)
{
detectionConfig = new DetectionConfig();
}
UserControl control1 = null;
control1 = new DetectControl(this, detectionConfig);
if (control1 != null)
{
//容器添加控件需要调整dpi
control1.Dock = DockStyle.Fill;
AutoDpi(control1);
AntdUI.TabPage tabPage = new AntdUI.TabPage()
{
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
ReadOnly = false ,
};
tabPage.Controls.Add(control1);
tabs1.Pages.Add(tabPage);
isUpdatingTabs = true;
tabs1.SelectedTab = tabPage;
isUpdatingTabs = false;
currControl = control1;
}
break;
case "运控设置":
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;
}
}
//先获取是否存在该名称的配置
//如果没有新建项
PLCBase? pLCBase = ConfigModel.PLCBaseList.Where(c => c.PLCName == clickedItem.Text).FirstOrDefault();
if (pLCBase == null)
{
pLCBase = new PLCBase();
}
UserControl control2 = null;
control = new MotionControl(this, pLCBase);
if (control != null)
{
//容器添加控件需要调整dpi
control.Dock = DockStyle.Fill;
AutoDpi(control);
AntdUI.TabPage tabPage = new AntdUI.TabPage()
{
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
ReadOnly = false,
};
tabPage.Controls.Add(control);
tabs1.Pages.Add(tabPage);
isUpdatingTabs = true;
tabs1.SelectedTab = tabPage;
isUpdatingTabs = false;
currControl = control;
}
break;
}
}
}
else if (e.Button == MouseButtons.Right)
{
// 转换坐标到控件内部坐标系(考虑滚动条)
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
// 递归查找命中的菜单项
MenuItem clickedItem = FindClickedItem(menu1.Items, clickPoint);
if (clickedItem != null)
{
if (clickedItem.PARENTITEM == null)
{
return;
}
switch (clickedItem.PARENTITEM.Text)
{
case "相机设置":
var menulist = new AntdUI.IContextMenuStripItem[]
{
new AntdUI.ContextMenuStripItem("重命名", "")
{
IconSvg = "RetweetOutlined"
},
new AntdUI.ContextMenuStripItem("删除相机", "")
{
IconSvg = "DeleteOutlined"
}
};
AntdUI.ContextMenuStrip.open(menu1, it =>
{
switch (it.Text)
{
case "删除相机":
menu1.Remove(clickedItem);
foreach (var tab in tabs1.Pages)
{
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
{
isUpdatingTabs = true;
tabs1.Pages.Remove(tab);
ConfigModel.CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
isUpdatingTabs = false;
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
return;
}
}
ConfigModel.CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
break;
case "重命名":
// 保存原始名称用于查找
string originalName = clickedItem.Text;
var form = new AddCameraControl(this, "重命名相机操作")
{
Size = new Size(300, 200),
// 传递当前名称到表单
CubicleName = originalName
};
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit && !string.IsNullOrWhiteSpace(form.CubicleName))
{
string newName = form.CubicleName.Trim();
if (ConfigModel.CameraBaseList.Any(c =>
c.CameraName.Equals(newName, StringComparison.OrdinalIgnoreCase) &&
c.CameraName != originalName))
{
AntdUI.Message.warn(this, $"相机名称 '{newName}' 已存在!", autoClose: 3);
return;
}
clickedItem.Text= newName;
var camera = ConfigModel.CameraBaseList.FirstOrDefault(c =>
c.CameraName.Equals(originalName, StringComparison.OrdinalIgnoreCase));
camera.CameraName = newName;
foreach (var tab in tabs1.Pages)
{
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{originalName}")
{
isUpdatingTabs = true;
existingTab.Text = $"{clickedItem.PARENTITEM.Text}-{newName}";
isUpdatingTabs = false;
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
return;
}
}
AntdUI.Message.success(this, $"已将 '{originalName}重命名成{newName}'", autoClose: 3);
}
break;
}
}, menulist);
break;
case "工位设置":
var menulist1 = new AntdUI.IContextMenuStripItem[]
{ new AntdUI.ContextMenuStripItem("重命名", "")
{
IconSvg = "RetweetOutlined"
},
new AntdUI.ContextMenuStripItem("删除工位", "")
{
IconSvg = "DeleteOutlined"
}
};
AntdUI.ContextMenuStrip.open(menu1, it =>
{
switch (it.Text)
{
case "删除工位":
menu1.Remove(clickedItem);
foreach (var tab in tabs1.Pages)
{
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
{
isUpdatingTabs = true;
tabs1.Pages.Remove(tab);
isUpdatingTabs = false;
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
return;
}
}
ConfigModel.DetectionList.RemoveAll(c => c.Name == clickedItem.Text);
break;
case "重命名":
// 保存原始名称用于查找
string originalName = clickedItem.Text;
var form = new AddCubicleControl(this, "重命名工位操作")
{
Size = new Size(300, 200),
// 传递当前名称到表单
CubicleName = originalName
};
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit && !string.IsNullOrWhiteSpace(form.CubicleName))
{
string newName = form.CubicleName.Trim();
if (ConfigModel.DetectionList.Any(c =>
c.Name.Equals(newName, StringComparison.OrdinalIgnoreCase) &&
c.Name != originalName))
{
AntdUI.Message.warn(this, $"工位名称 '{newName}' 已存在!", autoClose: 3);
return;
}
clickedItem.Text = newName;
var detection = ConfigModel.DetectionList.FirstOrDefault(c =>
c.Name.Equals(originalName, StringComparison.OrdinalIgnoreCase));
detection.Name = newName;
foreach (var tab in tabs1.Pages)
{
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{originalName}")
{
isUpdatingTabs = true;
existingTab.Text = $"{clickedItem.PARENTITEM.Text}-{newName}";
isUpdatingTabs = false;
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
return;
}
}
AntdUI.Message.success(this, $"已将 '{originalName}重命名成{newName}'", autoClose: 3);
}
break;
}
}, menulist1);
break;
case "运控设置":
var menulist2 = new AntdUI.IContextMenuStripItem[]
{
new AntdUI.ContextMenuStripItem("重命名", "")
{
IconSvg = "RetweetOutlined"
},
new AntdUI.ContextMenuStripItem("删除运控", "")
{
IconSvg = "DeleteOutlined"
}
};
AntdUI.ContextMenuStrip.open(menu1, it =>
{
switch (it.Text)
{
case "删除运控":
menu1.Remove(clickedItem);
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
tabs1.Pages.Remove(tab);
ConfigModel.PLCBaseList.RemoveAll(c => c.PLCName == clickedItem.Text);
isUpdatingTabs = false;
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
return;
}
}
ConfigModel.PLCBaseList.RemoveAll(c => c.PLCName == clickedItem.Text);
break;
case "重命名":
var form = new AddMotionControl(this, "重命名运动控制操作") { Size = new Size(300, 200) };
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit)
{
string originalName = clickedItem.Text;
if (form.submit && !string.IsNullOrWhiteSpace(form.MotionName))
{
string newName = form.MotionName.Trim();
if (ConfigModel.PLCBaseList.Any(c =>
c.PLCName.Equals(newName, StringComparison.OrdinalIgnoreCase) &&
c.PLCName != originalName))
{
AntdUI.Message.warn(this, $"运动控制名称 '{newName}' 已存在!", autoClose: 3);
return;
}
clickedItem.Text = newName;
var plc = ConfigModel.PLCBaseList.FirstOrDefault(c =>
c.PLCName.Equals(originalName, StringComparison.OrdinalIgnoreCase));
plc.PLCName = newName;
foreach (var tab in tabs1.Pages)
{
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{originalName}")
{
isUpdatingTabs = true;
existingTab.Text = $"{clickedItem.PARENTITEM.Text}-{newName}";
isUpdatingTabs = false;
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
return;
}
}
AntdUI.Message.success(this, $"已将 '{originalName}重命名成{newName}'", autoClose: 3);
}
}
break;
}
}, menulist2);
break;
}
}
}
}
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
{
foreach (MenuItem item in items)
@ -82,50 +577,104 @@ namespace DHSoftware.Views
return null;
}
private void btnAdd_Click(object sender, EventArgs e)
private void btnAdd_SelectedValueChanged(object sender, ObjectNEventArgs e)
{
var form = new AddCubicleControl(this) { Size = new Size(400, 300) };
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
string selectedValue = e.Value.ToString();
switch (selectedValue)
{
BtnHeight = 0,
});
if (form.submit)
{
var newItem = new MenuItem(form.CubicleName);
newItem.IconSvg = "AppstoreOutlined";
// 防止重复添加
if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
{
menu1.Items.Add(newItem);
}
else
{
AntdUI.Notification.warn(this, "新增工位失败", $"{form.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
}
}
case "相机设置":
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
}
if (workstationItem != null)
{
private void menu1_MouseClick(object sender, MouseEventArgs e)
{
//if (e.Button == MouseButtons.Right)
//{
// var menu =sender as Menu;
// if (menu?.Items.Count == 0)
// {
// return;
// }
var form = new AddCameraControl(this,"新增相机操作") { Size = new Size(300, 200) };
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit)
{
var newItem = new MenuItem(form.CubicleName);
newItem.IconSvg = "VideoCameraOutlined";
// 防止重复添加
if (!workstationItem.Sub.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
{
workstationItem.Sub.Add(newItem);
CameraBase cameraBase = new CameraBase();
cameraBase.CameraName = form.CubicleName;
ConfigModel.CameraBaseList.Add(cameraBase);
}
else
{
AntdUI.Message.warn(this, $"相机名称 '{form.CubicleName}' 已存在!", autoClose: 3);
}
}
}
break;
case "工位设置":
// 查找工位设置项
var workstationItem1= FindMenuItem(menu1.Items, "工位设置");
//}
}
if (workstationItem1 != null)
{
private void btnSave_Click(object sender, EventArgs e)
{
foreach(var item in menu1.Items)
{
var form = new AddCubicleControl(this,"新增工位操作") { Size = new Size(300, 200) };
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit)
{
var newItem = new MenuItem(form.CubicleName);
newItem.IconSvg = "AppstoreOutlined";
// 防止重复添加
if (!workstationItem1.Sub.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
{
workstationItem1.Sub.Add(newItem);
DetectionConfig detection = new DetectionConfig();
detection.Name = form.CubicleName;
ConfigModel.DetectionList.Add(detection);
}
else
{
AntdUI.Message.warn(this, $"工位名称 '{form.CubicleName}' 已存在!", autoClose: 3);
}
}
}
break;
case "运控设置":
var workstationItem2 = FindMenuItem(menu1.Items, "运控设置");
if (workstationItem2 != null)
{
var form = new AddMotionControl(this,"新增运动控制操作") { Size = new Size(300, 200) };
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit)
{
var newItem = new MenuItem(form.MotionName);
newItem.IconSvg = "ControlOutlined";
// 防止重复添加
if (!workstationItem2.Sub.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
{
workstationItem2.Sub.Add(newItem);
PLCBase pLCBase = new PLCBase();
pLCBase.PLCName = form.MotionName;
ConfigModel.PLCBaseList.Add(pLCBase);
}
else
{
AntdUI.Message.warn(this, $"运动控制名称 '{form.MotionName}' 已存在!", autoClose: 3);
}
}
}
break;
}
}
}

View File

@ -1,200 +0,0 @@
namespace DHSoftware.Views
{
partial class SettingWindow1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
AntdUI.MenuItem menuItem4 = new AntdUI.MenuItem();
AntdUI.MenuItem menuItem5 = new AntdUI.MenuItem();
AntdUI.MenuItem menuItem6 = new AntdUI.MenuItem();
AntdUI.Tabs.StyleCard styleCard2 = new AntdUI.Tabs.StyleCard();
pageHeader1 = new AntdUI.PageHeader();
panel1 = new AntdUI.Panel();
panel2 = new AntdUI.StackPanel();
btnSave = new AntdUI.Dropdown();
btnAdd = new AntdUI.Dropdown();
menu1 = new AntdUI.Menu();
panel3 = new AntdUI.Panel();
tabs1 = new AntdUI.Tabs();
divider1 = new AntdUI.Divider();
panel1.SuspendLayout();
panel2.SuspendLayout();
panel3.SuspendLayout();
SuspendLayout();
//
// pageHeader1
//
pageHeader1.BackColor = SystemColors.MenuHighlight;
pageHeader1.Dock = DockStyle.Top;
pageHeader1.Location = new Point(0, 0);
pageHeader1.Mode = AntdUI.TAMode.Dark;
pageHeader1.Name = "pageHeader1";
pageHeader1.ShowButton = true;
pageHeader1.ShowIcon = true;
pageHeader1.Size = new Size(1042, 33);
pageHeader1.TabIndex = 1;
pageHeader1.Text = "设置";
//
// panel1
//
panel1.Controls.Add(panel2);
panel1.Controls.Add(menu1);
panel1.Dock = DockStyle.Left;
panel1.Location = new Point(0, 33);
panel1.Name = "panel1";
panel1.Size = new Size(141, 666);
panel1.TabIndex = 2;
panel1.Text = "panel1";
//
// panel2
//
panel2.BackColor = SystemColors.Window;
panel2.Controls.Add(btnSave);
panel2.Controls.Add(btnAdd);
panel2.Dock = DockStyle.Fill;
panel2.Location = new Point(0, 632);
panel2.Name = "panel2";
panel2.Size = new Size(141, 34);
panel2.TabIndex = 1;
panel2.Text = "panel2";
//
// btnSave
//
btnSave.BackActive = SystemColors.Control;
btnSave.BackColor = SystemColors.Control;
btnSave.Dock = DockStyle.Right;
btnSave.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnSave.ForeColor = Color.Black;
btnSave.IconSvg = "SaveOutlined";
btnSave.Location = new Point(72, 3);
btnSave.Name = "btnSave";
btnSave.Size = new Size(63, 28);
btnSave.TabIndex = 2;
btnSave.Text = "保存";
//
// btnAdd
//
btnAdd.BackActive = SystemColors.Control;
btnAdd.BackColor = SystemColors.Control;
btnAdd.Dock = DockStyle.Left;
btnAdd.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
btnAdd.ForeColor = Color.Black;
btnAdd.IconSvg = "AppstoreAddOutlined";
btnAdd.Location = new Point(3, 3);
btnAdd.Name = "btnAdd";
btnAdd.Placement = AntdUI.TAlignFrom.TL;
btnAdd.Size = new Size(63, 28);
btnAdd.TabIndex = 1;
btnAdd.Text = "新增";
btnAdd.Trigger = AntdUI.Trigger.Hover;
//
// menu1
//
menu1.BackColor = SystemColors.Window;
menu1.Dock = DockStyle.Top;
menuItem4.IconSvg = "VideoCameraOutlined";
menuItem4.Text = "相机设置";
menuItem5.IconSvg = "AppstoreOutlined";
menuItem5.Text = "工位设置";
menuItem6.IconSvg = "ControlOutlined";
menuItem6.Text = "运控设置";
menu1.Items.Add(menuItem4);
menu1.Items.Add(menuItem5);
menu1.Items.Add(menuItem6);
menu1.Location = new Point(0, 0);
menu1.Name = "menu1";
menu1.Size = new Size(141, 632);
menu1.TabIndex = 0;
menu1.Text = "menu1";
menu1.MouseDown += menu1_MouseDown;
//
// panel3
//
panel3.Controls.Add(tabs1);
panel3.Controls.Add(divider1);
panel3.Controls.Add(panel1);
panel3.Controls.Add(pageHeader1);
panel3.Dock = DockStyle.Fill;
panel3.Location = new Point(0, 0);
panel3.Name = "panel3";
panel3.Size = new Size(1042, 699);
panel3.TabIndex = 1;
panel3.Text = "panel3";
//
// tabs1
//
tabs1.BackColor = SystemColors.Window;
tabs1.Dock = DockStyle.Fill;
tabs1.Location = new Point(151, 33);
tabs1.Name = "tabs1";
tabs1.Size = new Size(891, 666);
styleCard2.Closable = true;
tabs1.Style = styleCard2;
tabs1.TabIndex = 5;
tabs1.Text = "tabs1";
tabs1.Type = AntdUI.TabType.Card;
//
// divider1
//
divider1.BackColor = SystemColors.Window;
divider1.Dock = DockStyle.Left;
divider1.Location = new Point(141, 33);
divider1.Name = "divider1";
divider1.OrientationMargin = 0F;
divider1.Size = new Size(10, 666);
divider1.TabIndex = 4;
divider1.Text = "";
divider1.Vertical = true;
//
// SettingWindow1
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1042, 699);
Controls.Add(panel3);
Name = "SettingWindow1";
StartPosition = FormStartPosition.CenterScreen;
Text = "SettingWinform";
panel1.ResumeLayout(false);
panel2.ResumeLayout(false);
panel3.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private AntdUI.PageHeader pageHeader1;
private AntdUI.Panel panel1;
private AntdUI.StackPanel panel2;
private AntdUI.Menu menu1;
private AntdUI.Panel panel3;
private AntdUI.Tabs tabs1;
private AntdUI.Divider divider1;
private AntdUI.Dropdown btnAdd;
private AntdUI.Button btnSave;
}
}

View File

@ -1,440 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using AntdUI;
using AntdUI.Svg;
using DH.Commons.Enums;
using DH.Commons.Helper;
using DH.Devices.Devices;
using DH.Devices.PLC;
using DHSoftware.Utils;
namespace DHSoftware.Views
{
public partial class SettingWindow1 : Window
{
private UserControl currControl;
List<CameraBase> CameraBaseList = new List<CameraBase>();
List<PLCBase> PLCBaseList = new List<PLCBase>();
List<DetectionConfig> DetectionList = new List<DetectionConfig>();
public SettingWindow1()
{
InitializeComponent();
BindEventHandler();
InitData();
}
private void BindEventHandler()
{
Resize += SettingWindow1_Resize;
btnAdd.SelectedValueChanged += btnAdd_SelectedValueChanged;
btnSave.Click += BtnSave_Click;
}
private float x; //定义当前窗体的宽度
private float y; //定义当前窗体的高度
private void InitData()
{
btnAdd.Items.Clear();
btnAdd.Items.Add("相机设置");
btnAdd.Items.Add("工位设置");
btnAdd.Items.Add("运控设置");
x = Width;
y = Height;
AdaptiveHelper.setTag(this);
// 从文件加载配置
var loadedConfig = ConfigManager.LoadConfig();
if (loadedConfig != null)
{
// 更新当前列表
CameraBaseList = loadedConfig.Cameras;
PLCBaseList = loadedConfig.PLCs;
DetectionList = loadedConfig.Detections;
if (CameraBaseList.Count > 0)
{
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
if (workstationItem != null)
{
foreach (var item in CameraBaseList)
{
var newItem = new MenuItem();
newItem.Text = item.CameraName;
newItem.IconSvg = "VideoCameraOutlined";
workstationItem.Sub.Add(newItem);
}
}
}
if (DetectionList.Count > 0)
{
var workstationItem = FindMenuItem(menu1.Items, "工位设置");
if (workstationItem != null)
{
foreach (var item in DetectionList)
{
var newItem = new MenuItem();
newItem.Text = item.Name;
newItem.IconSvg = "AppstoreOutlined";
workstationItem.Sub.Add(newItem);
}
}
}
if (PLCBaseList.Count > 0)
{
var workstationItem = FindMenuItem(menu1.Items, "运控设置");
if (workstationItem != null)
{
foreach (var item in PLCBaseList)
{
var newItem = new MenuItem();
newItem.Text = item.PLCName;
newItem.IconSvg = "ControlOutlined";
workstationItem.Sub.Add(newItem);
}
}
}
}
}
private void BtnSave_Click(object? sender, EventArgs e)
{
var config = ConfigManager.CreateConfig(CameraBaseList, PLCBaseList, DetectionList);
ConfigManager.SaveConfig(config);
MessageBox.Show("保存成功!");
}
private void SettingWindow1_Resize(object? sender, EventArgs e)
{
var newx = Width / x;
var newy = Height / y;
AdaptiveHelper.setControls(newx, newy, this);
}
// 递归查找菜单项
private MenuItem FindMenuItem(MenuItemCollection items, string targetText)
{
foreach (MenuItem item in items)
{
if (item.Text == targetText) return item;
if (item.Sub != null)
{
var subResult = FindMenuItem(item.Sub, targetText);
if (subResult != null) return subResult;
}
}
return null;
}
bool isUpdatingTabs = false;
private void menu1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
// 转换坐标到控件内部坐标系(考虑滚动条)
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
// 递归查找命中的菜单项
MenuItem clickedItem = FindClickedItem(menu1.Items, clickPoint);
if (clickedItem != null)
{
if (clickedItem.PARENTITEM == null)
{
return;
}
switch (clickedItem.PARENTITEM.Text)
{
case "相机设置":
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;
}
}
//先获取是否存在该名称的配置
//如果没有新建项
CameraBase? CameraBase= CameraBaseList.Where(c => c.CameraName == clickedItem.Text).FirstOrDefault();
if (CameraBase == null)
{
CameraBase=new CameraBase();
}
UserControl control = null;
control = new CameraControl(this, CameraBase);
if (control != null)
{
//容器添加控件需要调整dpi
control.Dock = DockStyle.Fill;
AutoDpi(control);
AntdUI.TabPage tabPage = new AntdUI.TabPage()
{
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
ReadOnly = false,
};
tabPage.Controls.Add(control);
tabs1.Pages.Add(tabPage);
isUpdatingTabs = true;
tabs1.SelectedTab = tabPage;
isUpdatingTabs = false;
currControl = control;
}
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;
}
}
UserControl control1 = null;
control1 = new DetectControl(this);
if (control1 != null)
{
//容器添加控件需要调整dpi
control1.Dock = DockStyle.Fill;
AutoDpi(control1);
AntdUI.TabPage tabPage = new AntdUI.TabPage()
{
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
ReadOnly = false ,
};
tabPage.Controls.Add(control1);
tabs1.Pages.Add(tabPage);
isUpdatingTabs = true;
tabs1.SelectedTab = tabPage;
isUpdatingTabs = false;
currControl = control1;
}
break;
case "运控设置":
break;
}
}
}
else if (e.Button == MouseButtons.Right)
{
// 转换坐标到控件内部坐标系(考虑滚动条)
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
// 递归查找命中的菜单项
MenuItem clickedItem = FindClickedItem(menu1.Items, clickPoint);
if (clickedItem != null)
{
if (clickedItem.PARENTITEM == null)
{
return;
}
switch (clickedItem.PARENTITEM.Text)
{
case "相机设置":
var menulist = new AntdUI.IContextMenuStripItem[]
{
new AntdUI.ContextMenuStripItem("删除相机", "")
{
IconSvg = "DeleteOutlined"
}
};
AntdUI.ContextMenuStrip.open(menu1, it =>
{
menu1.Remove(clickedItem);
foreach (var tab in tabs1.Pages)
{
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
{
isUpdatingTabs = true;
tabs1.Pages.Remove(tab);
CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
isUpdatingTabs = false;
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
return;
}
}
CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
}, menulist);
break;
case "工位设置":
var menulist1 = new AntdUI.IContextMenuStripItem[]
{
new AntdUI.ContextMenuStripItem("删除工位", "")
{
IconSvg = "DeleteOutlined"
}
};
AntdUI.ContextMenuStrip.open(menu1, it =>
{
menu1.Remove(clickedItem);
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
tabs1.Pages.Remove(tab);
isUpdatingTabs = false;
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
return;
}
}
}, menulist1);
break;
case "运控设置":
break;
}
}
}
}
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
{
foreach (MenuItem item in items)
{
// 检查当前项是否可见且包含点击坐标
if (item.Visible && item.Rect.Contains(clickPoint))
{
return item;
}
// 递归检查子项(如果展开)
if (item.Expand && item.Sub != null)
{
var childResult = FindClickedItem(item.Sub, clickPoint);
if (childResult != null) return childResult;
}
}
return null;
}
private void btnAdd_SelectedValueChanged(object sender, ObjectNEventArgs e)
{
string selectedValue = e.Value.ToString();
switch (selectedValue)
{
case "相机设置":
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
if (workstationItem != null)
{
var form = new AddCameraControl(this) { Size = new Size(300, 200) };
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit)
{
var newItem = new MenuItem(form.CubicleName);
newItem.IconSvg = "VideoCameraOutlined";
// 防止重复添加
if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
{
workstationItem.Sub.Add(newItem);
CameraBase cameraBase = new CameraBase();
cameraBase.CameraName = form.CubicleName;
CameraBaseList.Add(cameraBase);
}
else
{
AntdUI.Notification.warn(this, "新增相机失败", $"{form.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
}
}
}
break;
case "工位设置":
// 查找工位设置项
var workstationItem1= FindMenuItem(menu1.Items, "工位设置");
if (workstationItem1 != null)
{
var form = new AddCubicleControl(this) { Size = new Size(300, 200) };
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
{
BtnHeight = 0,
});
if (form.submit)
{
var newItem = new MenuItem(form.CubicleName);
newItem.IconSvg = "AppstoreOutlined";
// 防止重复添加
if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
{
workstationItem1.Sub.Add(newItem);
}
else
{
AntdUI.Notification.warn(this, "新增工位失败", $"{form.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
}
}
}
break;
case "运控设置":
break;
}
}
}
}

View File

@ -1,4 +1,5 @@
using DH.Commons.Enums;
using DH.Commons.Base;
using DH.Commons.Enums;
using System;
using System.Collections.Generic;
using System.ComponentModel;

View File

@ -1,7 +1,6 @@
using AntdUI;
using AntdUIDemo.Models;
using DH.Commons.Enums;
using DH.Devices.Devices;
using DH.Commons.Base;
using DH.Devices.Vision;
using System;
using System.Collections.Generic;

View File

@ -1,44 +0,0 @@
namespace DHSoftware.Views
{
partial class _MotionControl
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
SuspendLayout();
//
// _MotionControl
//
AutoScaleDimensions = new SizeF(7F, 17F);
AutoScaleMode = AutoScaleMode.Font;
Name = "_MotionControl";
Size = new Size(782, 481);
ResumeLayout(false);
}
#endregion
}
}

View File

@ -1,20 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DHSoftware.Views
{
public partial class _MotionControl : UserControl
{
public _MotionControl()
{
InitializeComponent();
}
}
}