From ca6476b87c665fabb0b49efb2afcba2dc5df4379 Mon Sep 17 00:00:00 2001 From: "xhm\\HP" <1173131411@qq.com> Date: Sat, 15 Mar 2025 09:47:09 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DHSoftware/DHSoftware.csproj | 4 + DHSoftware/MainWindow.cs | 35 +- DHSoftware/Models/DataModel.cs | 38 + DHSoftware/Models/DataUtil.cs | 2 +- DHSoftware/Views/AddCameraWindow.Designer.cs | 81 ++ DHSoftware/Views/AddCameraWindow.cs | 64 ++ DHSoftware/Views/AddCameraWindow.resx | 120 +++ DHSoftware/Views/AddCubicleWindow.Designer.cs | 82 +++ DHSoftware/Views/AddCubicleWindow.cs | 55 ++ DHSoftware/Views/AddCubicleWindow.resx | 120 +++ DHSoftware/Views/CamConfigFrm.Designer.cs | 23 - DHSoftware/Views/CamConfigFrm.cs | 9 +- .../Views/CameraConfigControl.Designer.cs | 163 ++-- DHSoftware/Views/DefectRowEdit.Designer.cs | 283 +++++++ DHSoftware/Views/DefectRowEdit.cs | 62 ++ ...loatButtonDemo.resx => DefectRowEdit.resx} | 50 +- .../Views/DetectConfigControl.Designer.cs | 198 ++--- DHSoftware/Views/DetectConfigControl.cs | 431 ++++++++++- DHSoftware/Views/FloatButtonDemo.Designer.cs | 694 ------------------ DHSoftware/Views/FloatButtonDemo.cs | 241 ------ .../Views/PreTreatUserControl.Designer.cs | 150 ++-- DHSoftware/Views/SettingWindow.Designer.cs | 155 ++++ DHSoftware/Views/SettingWindow.cs | 144 ++++ DHSoftware/Views/SettingWindow.resx | 120 +++ .../Views/SizeConfigControl.Designer.cs | 56 +- DHSoftware/Views/UserConfigFrm.Designer.cs | 134 +++- DHSoftware/Views/UserConfigFrm.cs | 111 ++- DHSoftware/Views/UserDetetion.Designer.cs | 1 + DHSoftware/Views/UserDetetion.cs | 221 ++++-- 29 files changed, 2497 insertions(+), 1350 deletions(-) create mode 100644 DHSoftware/Models/DataModel.cs create mode 100644 DHSoftware/Views/AddCameraWindow.Designer.cs create mode 100644 DHSoftware/Views/AddCameraWindow.cs create mode 100644 DHSoftware/Views/AddCameraWindow.resx create mode 100644 DHSoftware/Views/AddCubicleWindow.Designer.cs create mode 100644 DHSoftware/Views/AddCubicleWindow.cs create mode 100644 DHSoftware/Views/AddCubicleWindow.resx create mode 100644 DHSoftware/Views/DefectRowEdit.Designer.cs create mode 100644 DHSoftware/Views/DefectRowEdit.cs rename DHSoftware/Views/{FloatButtonDemo.resx => DefectRowEdit.resx} (93%) delete mode 100644 DHSoftware/Views/FloatButtonDemo.Designer.cs delete mode 100644 DHSoftware/Views/FloatButtonDemo.cs create mode 100644 DHSoftware/Views/SettingWindow.Designer.cs create mode 100644 DHSoftware/Views/SettingWindow.cs create mode 100644 DHSoftware/Views/SettingWindow.resx diff --git a/DHSoftware/DHSoftware.csproj b/DHSoftware/DHSoftware.csproj index 073fe36..ebca883 100644 --- a/DHSoftware/DHSoftware.csproj +++ b/DHSoftware/DHSoftware.csproj @@ -17,6 +17,10 @@ + + + + diff --git a/DHSoftware/MainWindow.cs b/DHSoftware/MainWindow.cs index 673471c..e42539b 100644 --- a/DHSoftware/MainWindow.cs +++ b/DHSoftware/MainWindow.cs @@ -62,6 +62,7 @@ namespace DHSoftware UserConfigFrm userControlFrm = new UserConfigFrm(); // tabImgDisplay.Pages.Clear(); // tabPage2.Controls.Clear(); + userControlFrm.Window = this; userControlFrm.Dock = DockStyle.Fill; tabPage2.Controls.Add(userControlFrm); @@ -222,7 +223,7 @@ namespace DHSoftware - public List HKCameras { get; } = new List(); + public List HKCameras { get; } = new List(); public List Cameras { get; } = new List(); public Dictionary Dectection { get; } = new Dictionary(); public XinJEPLCTcpNet PLC { get; } = new XinJEPLCTcpNet(); @@ -240,7 +241,8 @@ namespace DHSoftware } foreach (var camera in HKCameras) { - camera.CameraDisConnect(); + //var hk as HikVisionCamera; + //camera.CameraDisConnect(); } PLC.PLCDisConnect(); } @@ -1496,8 +1498,35 @@ namespace DHSoftware private void HandleSettingsButton() { // Add the code for the "设置" button click here - MessageBox.Show("设置按钮按下"); + // MessageBox.Show("设置按钮按下"); + List listCamBase = new List(); + CameraBase cam1 = new CameraBase + { + CameraName = "Cam1", + CameraIP = "192.168.1.101", + SerialNumber = "1000001", + Gain = 60, + Exposure = 10, + RotateImage = 0, + isEnabled = false, + }; + CameraBase cam2 = new CameraBase + { + CameraName = "Cam2", + CameraIP = "192.168.1.101", + SerialNumber = "1000002", + Gain = 60, + Exposure = 10, + RotateImage = 0, + isEnabled = false, + }; + listCamBase.Add(cam1); + listCamBase.Add(cam2); + + SettingWindow s = new SettingWindow(); + s.cameras = listCamBase; + s.Show(); } diff --git a/DHSoftware/Models/DataModel.cs b/DHSoftware/Models/DataModel.cs new file mode 100644 index 0000000..2d36f4c --- /dev/null +++ b/DHSoftware/Models/DataModel.cs @@ -0,0 +1,38 @@ +using AntdUI; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DHSoftware.Models +{ + public class DataModel + { + } + public class DefectRow:NotifyProperty + { + private bool selected = false; + public string LabelId { get; set; } + public string LabelDescription { get; set; } + public bool IsEnable { get; set; } + public double ScoreMinValue { get; set; } + public double ScoreMaxValue { get; set; } + public bool IsScoreEnable { get; set; } + public double AreaMinValue { get; set; } + public double AreaMaxValue { get; set; } + public bool isAreaEnable { get; set; } + public int ResultState { get; set; } // 结果状态(枚举值对应整数) + + public bool Selected + { + get { return selected; } + set + { + if (selected == value) return; + selected = value; + OnPropertyChanged(nameof(Selected)); + } + } + } +} diff --git a/DHSoftware/Models/DataUtil.cs b/DHSoftware/Models/DataUtil.cs index 6e47e95..cec7af6 100644 --- a/DHSoftware/Models/DataUtil.cs +++ b/DHSoftware/Models/DataUtil.cs @@ -11,7 +11,7 @@ namespace AntdUIDemo.Models new MenuItems { Text = "工位1" , Tag = "工位1"}, new MenuItems { Text = "工位2", Tag = "工位2"}, new MenuItems { Text = "工位3", Tag = "工位3"}, - new MenuItems { Text = "保存配置", Tag = "保存配置"}, + //new MenuItems { Text = "保存配置", Tag = "保存配置"}, } }, //{ "布局", new List diff --git a/DHSoftware/Views/AddCameraWindow.Designer.cs b/DHSoftware/Views/AddCameraWindow.Designer.cs new file mode 100644 index 0000000..8ef3df1 --- /dev/null +++ b/DHSoftware/Views/AddCameraWindow.Designer.cs @@ -0,0 +1,81 @@ +namespace DHSoftware.Views +{ + partial class AddCameraWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + btnOK = new AntdUI.Button(); + btnCancel = new AntdUI.Button(); + stName = new AntdUI.Select(); + SuspendLayout(); + // + // btnOK + // + btnOK.Location = new Point(170, 136); + btnOK.Name = "btnOK"; + btnOK.Size = new Size(75, 40); + btnOK.TabIndex = 1; + btnOK.Text = "确定"; + btnOK.Click += btnOK_Click; + // + // btnCancel + // + btnCancel.Location = new Point(259, 136); + btnCancel.Name = "btnCancel"; + btnCancel.Size = new Size(75, 40); + btnCancel.TabIndex = 2; + btnCancel.Text = "取消"; + btnCancel.Click += btnCancel_Click; + // + // stName + // + stName.Location = new Point(39, 46); + stName.Name = "stName"; + stName.PlaceholderText = "请选择关联相机"; + stName.Size = new Size(281, 50); + stName.TabIndex = 3; + // + // AddCameraWindow + // + AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(369, 188); + Controls.Add(stName); + Controls.Add(btnCancel); + Controls.Add(btnOK); + Name = "AddCameraWindow"; + StartPosition = FormStartPosition.CenterParent; + Text = "AddCubicleWindow"; + ResumeLayout(false); + } + + #endregion + private AntdUI.Button btnOK; + private AntdUI.Button btnCancel; + private AntdUI.Select stName; + } +} \ No newline at end of file diff --git a/DHSoftware/Views/AddCameraWindow.cs b/DHSoftware/Views/AddCameraWindow.cs new file mode 100644 index 0000000..3ae260e --- /dev/null +++ b/DHSoftware/Views/AddCameraWindow.cs @@ -0,0 +1,64 @@ +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.Xml.Linq; +using AntdUI; +using DH.Devices.Devices; + +namespace DHSoftware.Views +{ + public partial class AddCameraWindow : Window + { + public AddCameraWindow(List cameras) + { + InitializeComponent(); + + + btnOK.DialogResult = DialogResult.OK; + btnCancel.DialogResult = DialogResult.Cancel; + this.AcceptButton = btnOK; + this.CancelButton = btnCancel; + + + stName.Items.Clear(); + for (int i = 0; i < cameras.Count; i++) + { + stName.Items.Add(cameras[i].CameraName); + } + } + public string CubicleName { get; private set; } + private void btnOK_Click(object sender, EventArgs e) + { + if (ValidateInput()) + { + this.DialogResult = DialogResult.OK; + this.Close(); + } + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + + private bool ValidateInput() + { + if (string.IsNullOrWhiteSpace(stName.Text)) + { + MessageBox.Show("请选择关联相机", "输入错误", + MessageBoxButtons.OK, + MessageBoxIcon.Warning); + return false; + } + CubicleName = stName.Text.Trim(); + return true; + } + } +} diff --git a/DHSoftware/Views/AddCameraWindow.resx b/DHSoftware/Views/AddCameraWindow.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/DHSoftware/Views/AddCameraWindow.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DHSoftware/Views/AddCubicleWindow.Designer.cs b/DHSoftware/Views/AddCubicleWindow.Designer.cs new file mode 100644 index 0000000..260d7d8 --- /dev/null +++ b/DHSoftware/Views/AddCubicleWindow.Designer.cs @@ -0,0 +1,82 @@ +namespace DHSoftware.Views +{ + partial class AddCubicleWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + txtName = new AntdUI.Input(); + btnOK = new AntdUI.Button(); + btnCancel = new AntdUI.Button(); + SuspendLayout(); + // + // txtName + // + txtName.Location = new Point(35, 47); + txtName.Name = "txtName"; + txtName.PlaceholderText = "请输入新增工位名称"; + txtName.Size = new Size(299, 48); + txtName.TabIndex = 0; + // + // btnOK + // + btnOK.Location = new Point(170, 136); + btnOK.Name = "btnOK"; + btnOK.Size = new Size(75, 40); + btnOK.TabIndex = 1; + btnOK.Text = "确定"; + btnOK.Click += btnOK_Click; + // + // btnCancel + // + btnCancel.Location = new Point(259, 136); + btnCancel.Name = "btnCancel"; + btnCancel.Size = new Size(75, 40); + btnCancel.TabIndex = 2; + btnCancel.Text = "取消"; + btnCancel.Click += btnCancel_Click; + // + // AddCubicleWindow + // + AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(369, 188); + Controls.Add(btnCancel); + Controls.Add(btnOK); + Controls.Add(txtName); + Name = "AddCubicleWindow"; + StartPosition = FormStartPosition.CenterParent; + Text = "AddCubicleWindow"; + ResumeLayout(false); + } + + #endregion + + private AntdUI.Input txtName; + private AntdUI.Button btnOK; + private AntdUI.Button btnCancel; + } +} \ No newline at end of file diff --git a/DHSoftware/Views/AddCubicleWindow.cs b/DHSoftware/Views/AddCubicleWindow.cs new file mode 100644 index 0000000..803f083 --- /dev/null +++ b/DHSoftware/Views/AddCubicleWindow.cs @@ -0,0 +1,55 @@ +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.Xml.Linq; +using AntdUI; + +namespace DHSoftware.Views +{ + public partial class AddCubicleWindow : Window + { + public AddCubicleWindow() + { + InitializeComponent(); + btnOK.DialogResult = DialogResult.OK; + btnCancel.DialogResult = DialogResult.Cancel; + this.AcceptButton = btnOK; + this.CancelButton = btnCancel; + } + public string CubicleName { get; private set; } + private void btnOK_Click(object sender, EventArgs e) + { + if (ValidateInput()) + { + this.DialogResult = DialogResult.OK; + this.Close(); + } + } + + private void btnCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + + private bool ValidateInput() + { + if (string.IsNullOrWhiteSpace(txtName.Text)) + { + MessageBox.Show("请输入有效的名称", "输入错误", + MessageBoxButtons.OK, + MessageBoxIcon.Warning); + txtName.Focus(); + return false; + } + CubicleName = txtName.Text.Trim(); + return true; + } + } +} diff --git a/DHSoftware/Views/AddCubicleWindow.resx b/DHSoftware/Views/AddCubicleWindow.resx new file mode 100644 index 0000000..8b2ff64 --- /dev/null +++ b/DHSoftware/Views/AddCubicleWindow.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DHSoftware/Views/CamConfigFrm.Designer.cs b/DHSoftware/Views/CamConfigFrm.Designer.cs index 4a3084a..69a68a6 100644 --- a/DHSoftware/Views/CamConfigFrm.Designer.cs +++ b/DHSoftware/Views/CamConfigFrm.Designer.cs @@ -39,8 +39,6 @@ Serinum = new DataGridViewTextBoxColumn(); IP = new DataGridViewTextBoxColumn(); COMBO_DEVICES = new ComboBox(); - label2 = new Label(); - inputNumber1 = new AntdUI.InputNumber(); tabs1.SuspendLayout(); tabPage1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dgvCams).BeginInit(); @@ -60,8 +58,6 @@ // // tabPage1 // - tabPage1.Controls.Add(inputNumber1); - tabPage1.Controls.Add(label2); tabPage1.Controls.Add(label1); tabPage1.Controls.Add(btnRefreshCamList); tabPage1.Controls.Add(dgvCams); @@ -125,23 +121,6 @@ COMBO_DEVICES.Size = new Size(359, 25); COMBO_DEVICES.TabIndex = 0; // - // label2 - // - label2.AutoSize = true; - label2.Location = new Point(36, 321); - label2.Name = "label2"; - label2.Size = new Size(68, 17); - label2.TabIndex = 5; - label2.Text = "工位配置数"; - // - // inputNumber1 - // - inputNumber1.Location = new Point(100, 309); - inputNumber1.Name = "inputNumber1"; - inputNumber1.Size = new Size(141, 39); - inputNumber1.TabIndex = 6; - inputNumber1.Text = "inputNumber1"; - // // CamConfigFrm // AutoScaleDimensions = new SizeF(7F, 17F); @@ -167,7 +146,5 @@ private DataGridViewTextBoxColumn CamName; private DataGridViewTextBoxColumn Serinum; private DataGridViewTextBoxColumn IP; - private AntdUI.InputNumber inputNumber1; - private Label label2; } } diff --git a/DHSoftware/Views/CamConfigFrm.cs b/DHSoftware/Views/CamConfigFrm.cs index 0dc527b..29427c2 100644 --- a/DHSoftware/Views/CamConfigFrm.cs +++ b/DHSoftware/Views/CamConfigFrm.cs @@ -1,4 +1,5 @@ using DH.Commons.Enums; +using DH.Devices.Devices; using DVPCameraType; using System; using System.Collections.Generic; @@ -22,7 +23,7 @@ namespace DHSoftware.Views public static dvpCameraInfo[] m_info = new dvpCameraInfo[16]; // 在窗体类中声明一个绑定列表(用于动态更新) - private BindingList _cameraList = new BindingList(); + private BindingList _cameraList = new BindingList(); public CamConfigFrm() { InitializeComponent(); @@ -131,10 +132,10 @@ namespace DHSoftware.Views { // add FriendlyName item = COMBO_DEVICES.Items.Add(dev_info.FriendlyName); - CameraInfo info = new CameraInfo + CameraBase info = new CameraBase { - CamName = dev_info.FriendlyName, - Serinum = dev_info.SerialNumber, + CameraName = dev_info.FriendlyName, + SerialNumber = dev_info.SerialNumber, // IP = dev_info.IP }; diff --git a/DHSoftware/Views/CameraConfigControl.Designer.cs b/DHSoftware/Views/CameraConfigControl.Designer.cs index 185e9ed..7dc37bf 100644 --- a/DHSoftware/Views/CameraConfigControl.Designer.cs +++ b/DHSoftware/Views/CameraConfigControl.Designer.cs @@ -29,94 +29,97 @@ private void InitializeComponent() { label1 = new AntdUI.Label(); - comboBox1 = new ComboBox(); - switch1 = new AntdUI.Switch(); + cbxCamName = new ComboBox(); + switchCamEnable = new AntdUI.Switch(); label2 = new AntdUI.Label(); - inputNumber1 = new AntdUI.InputNumber(); - inputNumber2 = new AntdUI.InputNumber(); + numExpose = new AntdUI.InputNumber(); + numGain = new AntdUI.InputNumber(); label3 = new AntdUI.Label(); - inputNumber3 = new AntdUI.InputNumber(); + numRotate = new AntdUI.InputNumber(); label4 = new AntdUI.Label(); label5 = new AntdUI.Label(); label6 = new AntdUI.Label(); - switch2 = new AntdUI.Switch(); + switchSaveCamPic = new AntdUI.Switch(); + panel1 = new Panel(); + panel1.SuspendLayout(); SuspendLayout(); // // label1 // - label1.Location = new Point(12, 12); + label1.Location = new Point(15, 14); label1.Name = "label1"; label1.Size = new Size(58, 23); label1.TabIndex = 0; label1.Text = "相机名"; // - // comboBox1 + // cbxCamName // - comboBox1.FormattingEnabled = true; - comboBox1.Location = new Point(76, 10); - comboBox1.Name = "comboBox1"; - comboBox1.Size = new Size(165, 25); - comboBox1.TabIndex = 1; + cbxCamName.DropDownStyle = ComboBoxStyle.DropDownList; + cbxCamName.FormattingEnabled = true; + cbxCamName.Location = new Point(79, 12); + cbxCamName.Name = "cbxCamName"; + cbxCamName.Size = new Size(165, 25); + cbxCamName.TabIndex = 1; // - // switch1 + // switchCamEnable // - switch1.Location = new Point(327, 10); - switch1.Name = "switch1"; - switch1.Size = new Size(57, 23); - switch1.TabIndex = 2; - switch1.Text = "switch1"; + switchCamEnable.Location = new Point(330, 12); + switchCamEnable.Name = "switchCamEnable"; + switchCamEnable.Size = new Size(57, 23); + switchCamEnable.TabIndex = 2; + switchCamEnable.Text = "switch1"; // // label2 // - label2.Location = new Point(12, 41); + label2.Location = new Point(15, 43); label2.Name = "label2"; label2.Size = new Size(58, 38); label2.TabIndex = 3; label2.Text = "曝光时间"; // - // inputNumber1 + // numExpose // - inputNumber1.Location = new Point(76, 41); - inputNumber1.Maximum = new decimal(new int[] { 10000000, 0, 0, 0 }); - inputNumber1.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); - inputNumber1.Name = "inputNumber1"; - inputNumber1.Size = new Size(165, 38); - inputNumber1.TabIndex = 4; - inputNumber1.Text = "200"; - inputNumber1.Value = new decimal(new int[] { 1, 0, 0, 0 }); + numExpose.Location = new Point(79, 43); + numExpose.Maximum = new decimal(new int[] { 10000000, 0, 0, 0 }); + numExpose.Minimum = new decimal(new int[] { 1, 0, 0, 0 }); + numExpose.Name = "numExpose"; + numExpose.Size = new Size(165, 38); + numExpose.TabIndex = 4; + numExpose.Text = "1"; + numExpose.Value = new decimal(new int[] { 1, 0, 0, 0 }); // - // inputNumber2 + // numGain // - inputNumber2.Location = new Point(76, 85); - inputNumber2.Maximum = new decimal(new int[] { 16, 0, 0, 0 }); - inputNumber2.Minimum = new decimal(new int[] { 0, 0, 0, 0 }); - inputNumber2.Name = "inputNumber2"; - inputNumber2.Size = new Size(165, 38); - inputNumber2.TabIndex = 6; - inputNumber2.Text = "6"; + numGain.Location = new Point(79, 87); + numGain.Maximum = new decimal(new int[] { 16, 0, 0, 0 }); + numGain.Minimum = new decimal(new int[] { 0, 0, 0, 0 }); + numGain.Name = "numGain"; + numGain.Size = new Size(165, 38); + numGain.TabIndex = 6; + numGain.Text = "0"; // // label3 // - label3.Location = new Point(12, 85); + label3.Location = new Point(15, 87); label3.Name = "label3"; label3.Size = new Size(58, 38); label3.TabIndex = 5; label3.Text = "增益"; // - // inputNumber3 + // numRotate // - inputNumber3.Increment = new decimal(new int[] { 90, 0, 0, 0 }); - inputNumber3.Location = new Point(76, 129); - inputNumber3.Maximum = new decimal(new int[] { 360, 0, 0, 0 }); - inputNumber3.Minimum = new decimal(new int[] { 0, 0, 0, 0 }); - inputNumber3.Name = "inputNumber3"; - inputNumber3.Size = new Size(165, 38); - inputNumber3.TabIndex = 8; - inputNumber3.Text = "0"; + numRotate.Increment = new decimal(new int[] { 90, 0, 0, 0 }); + numRotate.Location = new Point(79, 131); + numRotate.Maximum = new decimal(new int[] { 360, 0, 0, 0 }); + numRotate.Minimum = new decimal(new int[] { 0, 0, 0, 0 }); + numRotate.Name = "numRotate"; + numRotate.Size = new Size(165, 38); + numRotate.TabIndex = 8; + numRotate.Text = "0"; // // label4 // - label4.Location = new Point(12, 129); + label4.Location = new Point(15, 131); label4.Name = "label4"; label4.Size = new Size(58, 38); label4.TabIndex = 7; @@ -124,7 +127,7 @@ // // label5 // - label5.Location = new Point(263, 3); + label5.Location = new Point(266, 5); label5.Name = "label5"; label5.Size = new Size(58, 36); label5.TabIndex = 9; @@ -132,54 +135,66 @@ // // label6 // - label6.Location = new Point(263, 45); + label6.Location = new Point(266, 47); label6.Name = "label6"; label6.Size = new Size(58, 36); label6.TabIndex = 11; label6.Text = "保存原图"; // - // switch2 + // switchSaveCamPic // - switch2.Location = new Point(327, 52); - switch2.Name = "switch2"; - switch2.Size = new Size(57, 23); - switch2.TabIndex = 10; - switch2.Text = "switch2"; + switchSaveCamPic.Location = new Point(330, 54); + switchSaveCamPic.Name = "switchSaveCamPic"; + switchSaveCamPic.Size = new Size(57, 23); + switchSaveCamPic.TabIndex = 10; + switchSaveCamPic.Text = "switch2"; + // + // panel1 + // + panel1.BorderStyle = BorderStyle.FixedSingle; + panel1.Controls.Add(cbxCamName); + panel1.Controls.Add(label6); + panel1.Controls.Add(label1); + panel1.Controls.Add(switchSaveCamPic); + panel1.Controls.Add(switchCamEnable); + panel1.Controls.Add(label5); + panel1.Controls.Add(label2); + panel1.Controls.Add(numRotate); + panel1.Controls.Add(numExpose); + panel1.Controls.Add(label4); + panel1.Controls.Add(label3); + panel1.Controls.Add(numGain); + panel1.Dock = DockStyle.Fill; + panel1.Location = new Point(0, 0); + panel1.Name = "panel1"; + panel1.Size = new Size(620, 201); + panel1.TabIndex = 12; // // CameraConfigControl // AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleMode = AutoScaleMode.Font; - Controls.Add(label6); - Controls.Add(switch2); - Controls.Add(label5); - Controls.Add(inputNumber3); - Controls.Add(label4); - Controls.Add(inputNumber2); - Controls.Add(label3); - Controls.Add(inputNumber1); - Controls.Add(label2); - Controls.Add(switch1); - Controls.Add(comboBox1); - Controls.Add(label1); + Controls.Add(panel1); Name = "CameraConfigControl"; Size = new Size(620, 201); + panel1.ResumeLayout(false); ResumeLayout(false); } #endregion private AntdUI.Label label1; - private ComboBox comboBox1; - private AntdUI.Switch switch1; + private ComboBox cbxCamName; + private AntdUI.Switch switchCamEnable; private AntdUI.Label label2; - private AntdUI.InputNumber inputNumber1; - private AntdUI.InputNumber inputNumber2; + private AntdUI.InputNumber numExpose; + private AntdUI.InputNumber numGain; private AntdUI.Label label3; - private AntdUI.InputNumber inputNumber3; + private AntdUI.InputNumber numRotate; private AntdUI.Label label4; private AntdUI.Label label5; private AntdUI.Label label6; - private AntdUI.Switch switch2; + private AntdUI.Switch switchSaveCamPic; + private Panel panel1; } } diff --git a/DHSoftware/Views/DefectRowEdit.Designer.cs b/DHSoftware/Views/DefectRowEdit.Designer.cs new file mode 100644 index 0000000..e422d73 --- /dev/null +++ b/DHSoftware/Views/DefectRowEdit.Designer.cs @@ -0,0 +1,283 @@ +namespace AntdUIDemo.Views.Table +{ + partial class DefectRowEdit + { + /// + /// 必需的设计器变量。 + /// + private System.ComponentModel.IContainer components = null; + + /// + /// 清理所有正在使用的资源。 + /// + /// 如果应释放托管资源,为 true;否则为 false。 + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region 组件设计器生成的代码 + + /// + /// 设计器支持所需的方法 - 不要修改 + /// 使用代码编辑器修改此方法的内容。 + /// + private void InitializeComponent() + { + panel1 = new AntdUI.Panel(); + label2 = new AntdUI.Label(); + input_minScore = new AntdUI.InputNumber(); + label1 = new AntdUI.Label(); + input_name = new AntdUI.Input(); + 标签名 = new AntdUI.Label(); + divider1 = new AntdUI.Divider(); + stackPanel1 = new AntdUI.StackPanel(); + button_cancel = new AntdUI.Button(); + button_ok = new AntdUI.Button(); + input_maxScore = new AntdUI.InputNumber(); + input_maxArea = new AntdUI.InputNumber(); + label3 = new AntdUI.Label(); + input_minArea = new AntdUI.InputNumber(); + label4 = new AntdUI.Label(); + label5 = new AntdUI.Label(); + select_Result = new AntdUI.Select(); + panel1.SuspendLayout(); + stackPanel1.SuspendLayout(); + SuspendLayout(); + // + // panel1 + // + panel1.Controls.Add(select_Result); + panel1.Controls.Add(label5); + panel1.Controls.Add(input_maxArea); + panel1.Controls.Add(label3); + panel1.Controls.Add(input_minArea); + panel1.Controls.Add(label4); + panel1.Controls.Add(input_maxScore); + panel1.Controls.Add(label2); + panel1.Controls.Add(input_minScore); + panel1.Controls.Add(label1); + panel1.Controls.Add(input_name); + panel1.Controls.Add(标签名); + panel1.Controls.Add(divider1); + panel1.Controls.Add(stackPanel1); + 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, 505); + panel1.TabIndex = 0; + panel1.Text = "panel1"; + // + // label2 + // + label2.Dock = DockStyle.Top; + label2.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + label2.Location = new Point(18, 198); + label2.Name = "label2"; + label2.Size = new Size(464, 24); + label2.TabIndex = 19; + label2.Text = "最大得分"; + // + // input_minScore + // + input_minScore.Dock = DockStyle.Top; + input_minScore.Font = new Font("Microsoft YaHei UI", 9F); + input_minScore.Increment = new decimal(new int[] { 1, 0, 0, 65536 }); + input_minScore.Location = new Point(18, 160); + input_minScore.Maximum = new decimal(new int[] { 1, 0, 0, 0 }); + input_minScore.Minimum = new decimal(new int[] { 0, 0, 0, 0 }); + input_minScore.Name = "input_minScore"; + input_minScore.Radius = 3; + input_minScore.Size = new Size(464, 38); + input_minScore.TabIndex = 18; + input_minScore.Text = "0.3"; + // + // label1 + // + label1.Dock = DockStyle.Top; + label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + label1.Location = new Point(18, 136); + label1.Name = "label1"; + label1.Size = new Size(464, 24); + label1.TabIndex = 17; + label1.Text = "最小得分"; + // + // 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, 98); + input_name.Name = "input_name"; + input_name.Radius = 3; + input_name.Size = new Size(464, 38); + input_name.TabIndex = 16; + // + // 标签名 + // + 标签名.Dock = DockStyle.Top; + 标签名.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + 标签名.Location = new Point(18, 74); + 标签名.Name = "标签名"; + 标签名.Size = new Size(464, 24); + 标签名.TabIndex = 15; + 标签名.Text = "标签名"; + // + // divider1 + // + divider1.Dock = DockStyle.Top; + divider1.Location = new Point(18, 62); + divider1.Name = "divider1"; + divider1.Size = new Size(464, 12); + divider1.TabIndex = 14; + // + // stackPanel1 + // + stackPanel1.Controls.Add(button_cancel); + stackPanel1.Controls.Add(button_ok); + stackPanel1.Dock = DockStyle.Top; + stackPanel1.Location = new Point(18, 18); + stackPanel1.Name = "stackPanel1"; + stackPanel1.RightToLeft = RightToLeft.No; + stackPanel1.Size = new Size(464, 44); + stackPanel1.TabIndex = 3; + 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 = "Cancel"; + // + // 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 = "Submit"; + button_ok.Type = AntdUI.TTypeMini.Primary; + // + // input_maxScore + // + input_maxScore.Dock = DockStyle.Top; + input_maxScore.Font = new Font("Microsoft YaHei UI", 9F); + input_maxScore.Increment = new decimal(new int[] { 1, 0, 0, 65536 }); + input_maxScore.Location = new Point(18, 222); + input_maxScore.Maximum = new decimal(new int[] { 1, 0, 0, 0 }); + input_maxScore.Minimum = new decimal(new int[] { 0, 0, 0, 0 }); + input_maxScore.Name = "input_maxScore"; + input_maxScore.Radius = 3; + input_maxScore.Size = new Size(464, 38); + input_maxScore.TabIndex = 20; + input_maxScore.Text = "0"; + // + // input_maxArea + // + input_maxArea.Dock = DockStyle.Top; + input_maxArea.Font = new Font("Microsoft YaHei UI", 9F); + input_maxArea.Increment = new decimal(new int[] { 10, 0, 0, 0 }); + input_maxArea.Location = new Point(18, 346); + input_maxArea.Maximum = new decimal(new int[] { 999999999, 0, 0, 0 }); + input_maxArea.Minimum = new decimal(new int[] { 0, 0, 0, 0 }); + input_maxArea.Name = "input_maxArea"; + input_maxArea.Radius = 3; + input_maxArea.Size = new Size(464, 38); + input_maxArea.TabIndex = 24; + input_maxArea.Text = "0"; + // + // label3 + // + label3.Dock = DockStyle.Top; + label3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + label3.Location = new Point(18, 322); + label3.Name = "label3"; + label3.Size = new Size(464, 24); + label3.TabIndex = 23; + label3.Text = "最大面积"; + // + // input_minArea + // + input_minArea.Dock = DockStyle.Top; + input_minArea.Font = new Font("Microsoft YaHei UI", 9F); + input_minArea.Increment = new decimal(new int[] { 10, 0, 0, 0 }); + input_minArea.Location = new Point(18, 284); + input_minArea.Maximum = new decimal(new int[] { 999999999, 0, 0, 0 }); + input_minArea.Minimum = new decimal(new int[] { 0, 0, 0, 0 }); + input_minArea.Name = "input_minArea"; + input_minArea.Radius = 3; + input_minArea.Size = new Size(464, 38); + input_minArea.TabIndex = 22; + input_minArea.Text = "0"; + // + // label4 + // + label4.Dock = DockStyle.Top; + label4.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + label4.Location = new Point(18, 260); + label4.Name = "label4"; + label4.Size = new Size(464, 24); + label4.TabIndex = 21; + label4.Text = "最小面积"; + // + // label5 + // + label5.Dock = DockStyle.Top; + label5.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134); + label5.Location = new Point(18, 384); + label5.Name = "label5"; + label5.Size = new Size(464, 24); + label5.TabIndex = 25; + label5.Text = "标签结果"; + // + // select_Result + // + select_Result.Location = new Point(21, 414); + select_Result.Name = "select_Result"; + select_Result.Size = new Size(458, 41); + select_Result.TabIndex = 27; + select_Result.Text = "select1"; + // + // DefectRowEdit + // + Controls.Add(panel1); + Name = "DefectRowEdit"; + Size = new Size(500, 505); + panel1.ResumeLayout(false); + stackPanel1.ResumeLayout(false); + ResumeLayout(false); + } + + #endregion + + private AntdUI.Panel panel1; + private AntdUI.StackPanel stackPanel1; + private AntdUI.Button button_cancel; + private AntdUI.Button button_ok; + private AntdUI.Divider divider1; + private AntdUI.Input input_addr; + private AntdUI.Label label2; + private AntdUI.InputNumber input_minScore; + private AntdUI.Label label1; + private AntdUI.Input input_name; + private AntdUI.Label 标签名; + private AntdUI.InputNumber input_maxScore; + private AntdUI.InputNumber input_maxArea; + private AntdUI.Label label3; + private AntdUI.InputNumber input_minArea; + private AntdUI.Label label4; + private AntdUI.Label label5; + private AntdUI.Select select_Result; + } +} diff --git a/DHSoftware/Views/DefectRowEdit.cs b/DHSoftware/Views/DefectRowEdit.cs new file mode 100644 index 0000000..72b885d --- /dev/null +++ b/DHSoftware/Views/DefectRowEdit.cs @@ -0,0 +1,62 @@ +using AntdUIDemo.Models; +using DHSoftware.Models; +using DHSoftware.Views; +using System; +using System.Windows.Forms; + +namespace AntdUIDemo.Views.Table +{ + public partial class DefectRowEdit : UserControl + { + DetectConfigControl detectConfigControl; + private AntdUI.Window window; + private DefectRow user; + public bool submit; + public DefectRowEdit(AntdUI.Window _window, DefectRow _user) + { + this.window = _window; + user = _user; + InitializeComponent(); + //设置默认值 + InitData(); + // 绑定事件 + 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; + } + user.LabelDescription = input_name.Text; + user.ScoreMinValue =(double)input_minScore.Value; + user.ScoreMaxValue = (double)input_maxScore.Value; + submit = true; + this.Dispose(); + } + + private void InitData() + { + input_name.Text = user.LabelDescription; + // input_addr.Text = user.Address; + input_minScore.Value =(decimal) user.ScoreMinValue; + } + } +} diff --git a/DHSoftware/Views/FloatButtonDemo.resx b/DHSoftware/Views/DefectRowEdit.resx similarity index 93% rename from DHSoftware/Views/FloatButtonDemo.resx rename to DHSoftware/Views/DefectRowEdit.resx index 1af7de1..af32865 100644 --- a/DHSoftware/Views/FloatButtonDemo.resx +++ b/DHSoftware/Views/DefectRowEdit.resx @@ -1,17 +1,17 @@  - diff --git a/DHSoftware/Views/DetectConfigControl.Designer.cs b/DHSoftware/Views/DetectConfigControl.Designer.cs index 5cee9fb..bcccd74 100644 --- a/DHSoftware/Views/DetectConfigControl.Designer.cs +++ b/DHSoftware/Views/DetectConfigControl.Designer.cs @@ -32,23 +32,23 @@ button3 = new AntdUI.Button(); panel2 = new Panel(); label2 = new Label(); - button2 = new AntdUI.Button(); - table1 = new AntdUI.Table(); - button1 = new AntdUI.Button(); + buttonDEL = new AntdUI.Button(); + table_base = new AntdUI.Table(); + buttonADD = new AntdUI.Button(); label10 = new AntdUI.Label(); - switch4 = new AntdUI.Switch(); + sthSaveNGPic = new AntdUI.Switch(); label9 = new AntdUI.Label(); - switch3 = new AntdUI.Switch(); + swSaveOKPic = new AntdUI.Switch(); label7 = new AntdUI.Label(); - switch2 = new AntdUI.Switch(); + sthPic = new AntdUI.Switch(); label8 = new AntdUI.Label(); - switch1 = new AntdUI.Switch(); - textBox1 = new TextBox(); + switchEnable = new AntdUI.Switch(); + tbDetectName = new TextBox(); label6 = new AntdUI.Label(); - comboBox1 = new ComboBox(); + cbxDetectType = new ComboBox(); label5 = new AntdUI.Label(); btnPreOpen = new AntdUI.Button(); - tbxPrePath = new TextBox(); + tbModelpath = new TextBox(); label1 = new AntdUI.Label(); panel1.SuspendLayout(); panel2.SuspendLayout(); @@ -60,43 +60,45 @@ panel1.Controls.Add(button3); panel1.Controls.Add(panel2); panel1.Controls.Add(label10); - panel1.Controls.Add(switch4); + panel1.Controls.Add(sthSaveNGPic); panel1.Controls.Add(label9); - panel1.Controls.Add(switch3); + panel1.Controls.Add(swSaveOKPic); panel1.Controls.Add(label7); - panel1.Controls.Add(switch2); + panel1.Controls.Add(sthPic); panel1.Controls.Add(label8); - panel1.Controls.Add(switch1); - panel1.Controls.Add(textBox1); + panel1.Controls.Add(switchEnable); + panel1.Controls.Add(tbDetectName); panel1.Controls.Add(label6); - panel1.Controls.Add(comboBox1); + panel1.Controls.Add(cbxDetectType); panel1.Controls.Add(label5); panel1.Controls.Add(btnPreOpen); - panel1.Controls.Add(tbxPrePath); + panel1.Controls.Add(tbModelpath); panel1.Controls.Add(label1); panel1.Dock = DockStyle.Fill; panel1.Location = new Point(0, 0); panel1.Name = "panel1"; - panel1.Size = new Size(785, 445); + panel1.Size = new Size(683, 445); panel1.TabIndex = 0; // // button3 // - button3.Location = new Point(472, 101); + button3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + button3.Location = new Point(538, 70); button3.Name = "button3"; - button3.Size = new Size(118, 34); + button3.Size = new Size(115, 34); button3.TabIndex = 37; button3.Text = "查看文件夹"; // // panel2 // + panel2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; panel2.Controls.Add(label2); - panel2.Controls.Add(button2); - panel2.Controls.Add(table1); - panel2.Controls.Add(button1); + panel2.Controls.Add(buttonDEL); + panel2.Controls.Add(table_base); + panel2.Controls.Add(buttonADD); panel2.Location = new Point(17, 141); panel2.Name = "panel2"; - panel2.Size = new Size(577, 286); + panel2.Size = new Size(639, 286); panel2.TabIndex = 35; // // label2 @@ -108,61 +110,62 @@ label2.TabIndex = 25; label2.Text = "模型参数"; // - // button2 + // buttonDEL // - button2.Location = new Point(93, 25); - button2.Name = "button2"; - button2.Size = new Size(84, 34); - button2.TabIndex = 24; - button2.Text = "删除"; + buttonDEL.Location = new Point(93, 25); + buttonDEL.Name = "buttonDEL"; + buttonDEL.Size = new Size(84, 34); + buttonDEL.TabIndex = 24; + buttonDEL.Text = "删除"; // - // table1 + // table_base // - table1.Location = new Point(3, 65); - table1.Name = "table1"; - table1.Size = new Size(570, 218); - table1.TabIndex = 22; - table1.Text = "table1"; + table_base.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + table_base.Location = new Point(3, 65); + table_base.Name = "table_base"; + table_base.Size = new Size(633, 218); + table_base.TabIndex = 22; + table_base.Text = "table1"; // - // button1 + // buttonADD // - button1.Location = new Point(3, 25); - button1.Name = "button1"; - button1.Size = new Size(84, 34); - button1.TabIndex = 23; - button1.Text = "新增"; + buttonADD.Location = new Point(3, 25); + buttonADD.Name = "buttonADD"; + buttonADD.Size = new Size(84, 34); + buttonADD.TabIndex = 23; + buttonADD.Text = "新增"; // // label10 // - label10.Location = new Point(487, 70); + label10.Location = new Point(171, 99); label10.Name = "label10"; label10.Size = new Size(73, 23); label10.TabIndex = 34; label10.Text = "保存NG原图"; // - // switch4 + // sthSaveNGPic // - switch4.Location = new Point(566, 70); - switch4.Name = "switch4"; - switch4.Size = new Size(57, 23); - switch4.TabIndex = 33; - switch4.Text = "switch4"; + sthSaveNGPic.Location = new Point(258, 99); + sthSaveNGPic.Name = "sthSaveNGPic"; + sthSaveNGPic.Size = new Size(57, 23); + sthSaveNGPic.TabIndex = 33; + sthSaveNGPic.Text = "switch4"; // // label9 // - label9.Location = new Point(333, 70); + label9.Location = new Point(17, 99); label9.Name = "label9"; label9.Size = new Size(73, 23); label9.TabIndex = 32; label9.Text = "保存OK原图"; // - // switch3 + // swSaveOKPic // - switch3.Location = new Point(412, 70); - switch3.Name = "switch3"; - switch3.Size = new Size(57, 23); - switch3.TabIndex = 31; - switch3.Text = "switch3"; + swSaveOKPic.Location = new Point(96, 99); + swSaveOKPic.Name = "swSaveOKPic"; + swSaveOKPic.Size = new Size(57, 23); + swSaveOKPic.TabIndex = 31; + swSaveOKPic.Text = "switch3"; // // label7 // @@ -172,13 +175,13 @@ label7.TabIndex = 30; label7.Text = "数据保存"; // - // switch2 + // sthPic // - switch2.Location = new Point(258, 70); - switch2.Name = "switch2"; - switch2.Size = new Size(57, 23); - switch2.TabIndex = 29; - switch2.Text = "switch2"; + sthPic.Location = new Point(258, 70); + sthPic.Name = "sthPic"; + sthPic.Size = new Size(57, 23); + sthPic.TabIndex = 29; + sthPic.Text = "switch2"; // // label8 // @@ -188,20 +191,20 @@ label8.TabIndex = 28; label8.Text = "模型启用"; // - // switch1 + // switchEnable // - switch1.Location = new Point(96, 70); - switch1.Name = "switch1"; - switch1.Size = new Size(57, 23); - switch1.TabIndex = 27; - switch1.Text = "switch1"; + switchEnable.Location = new Point(96, 70); + switchEnable.Name = "switchEnable"; + switchEnable.Size = new Size(57, 23); + switchEnable.TabIndex = 27; + switchEnable.Text = "switch1"; // - // textBox1 + // tbDetectName // - textBox1.Location = new Point(96, 12); - textBox1.Name = "textBox1"; - textBox1.Size = new Size(211, 23); - textBox1.TabIndex = 26; + tbDetectName.Location = new Point(96, 12); + tbDetectName.Name = "tbDetectName"; + tbDetectName.Size = new Size(211, 23); + tbDetectName.TabIndex = 26; // // label6 // @@ -211,13 +214,15 @@ label6.TabIndex = 25; label6.Text = "检测名称"; // - // comboBox1 + // cbxDetectType // - comboBox1.FormattingEnabled = true; - comboBox1.Location = new Point(402, 10); - comboBox1.Name = "comboBox1"; - comboBox1.Size = new Size(188, 25); - comboBox1.TabIndex = 24; + cbxDetectType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + cbxDetectType.DropDownStyle = ComboBoxStyle.DropDownList; + cbxDetectType.FormattingEnabled = true; + cbxDetectType.Location = new Point(402, 10); + cbxDetectType.Name = "cbxDetectType"; + cbxDetectType.Size = new Size(254, 25); + cbxDetectType.TabIndex = 24; // // label5 // @@ -229,18 +234,19 @@ // // btnPreOpen // + btnPreOpen.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; btnPreOpen.Location = new Point(613, 41); btnPreOpen.Name = "btnPreOpen"; - btnPreOpen.Size = new Size(46, 23); + btnPreOpen.Size = new Size(43, 23); btnPreOpen.TabIndex = 22; btnPreOpen.Text = "..."; // - // tbxPrePath + // tbModelpath // - tbxPrePath.Location = new Point(96, 41); - tbxPrePath.Name = "tbxPrePath"; - tbxPrePath.Size = new Size(498, 23); - tbxPrePath.TabIndex = 17; + tbModelpath.Location = new Point(96, 41); + tbModelpath.Name = "tbModelpath"; + tbModelpath.Size = new Size(511, 23); + tbModelpath.TabIndex = 17; // // label1 // @@ -256,7 +262,7 @@ AutoScaleMode = AutoScaleMode.Font; Controls.Add(panel1); Name = "DetectConfigControl"; - Size = new Size(785, 445); + Size = new Size(683, 445); panel1.ResumeLayout(false); panel1.PerformLayout(); panel2.ResumeLayout(false); @@ -268,25 +274,25 @@ private Panel panel1; private AntdUI.Label label1; - private TextBox tbxPrePath; - private TextBox textBox1; + private TextBox tbModelpath; + private TextBox tbDetectName; private AntdUI.Label label6; - private ComboBox comboBox1; + private ComboBox cbxDetectType; private AntdUI.Label label5; private AntdUI.Button btnPreOpen; private AntdUI.Label label7; - private AntdUI.Switch switch2; + private AntdUI.Switch sthPic; private AntdUI.Label label8; - private AntdUI.Switch switch1; + private AntdUI.Switch switchEnable; private AntdUI.Label label10; - private AntdUI.Switch switch4; + private AntdUI.Switch sthSaveNGPic; private AntdUI.Label label9; - private AntdUI.Switch switch3; + private AntdUI.Switch swSaveOKPic; private Panel panel2; private Label label2; - private AntdUI.Button button2; - private AntdUI.Table table1; - private AntdUI.Button button1; + private AntdUI.Button buttonDEL; + private AntdUI.Table table_base; + private AntdUI.Button buttonADD; private AntdUI.Button button3; } } diff --git a/DHSoftware/Views/DetectConfigControl.cs b/DHSoftware/Views/DetectConfigControl.cs index 7eff06c..09828ae 100644 --- a/DHSoftware/Views/DetectConfigControl.cs +++ b/DHSoftware/Views/DetectConfigControl.cs @@ -1,9 +1,15 @@ -using System; +using AntdUI; +using AntdUIDemo.Views.Table; +using DH.Devices.Vision; +using DHSoftware.Models; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; +using System.Data.Common; using System.Drawing; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -12,9 +18,432 @@ namespace DHSoftware.Views { public partial class DetectConfigControl : UserControl { + List> MLModelTypes = GetFilteredEnumDescriptionsAndValues(); + + public static List> GetFilteredEnumDescriptionsAndValues() where T : Enum + { + return Enum.GetValues(typeof(T)) + .Cast() + .Select(e => + { + // 获取枚举的 Description 属性,如果没有,则使用枚举的名称 + var description = e.GetType() + .GetField(e.ToString()) + ?.GetCustomAttribute() + ?.Description ?? e.ToString(); + + // 返回枚举的描述和对应的整数值 + return new KeyValuePair(description, Convert.ToInt32(e)); + }) + .ToList(); + } + + List> resultStates = GetFilteredEnumDescriptionsAndValues(); + // 获取枚举的描述和对应的值,只筛选出 OK 和 NG + public static List> GetFilteredEnumDescriptionsAndValuesres() where T : Enum + { + return Enum.GetValues(typeof(T)) + .Cast() + .Where(e => e.Equals(ResultState.OK) || e.Equals(ResultState.DetectNG)) // 只保留 OK 和 NG + .Select(e => + { + // 通过反射获取 DescriptionAttribute 描述,如果没有描述,则使用枚举项名称 + var description = e.GetType() + .GetField(e.ToString()) + ?.GetCustomAttribute() + ?.Description ?? e.ToString(); // 如果没有 DescriptionAttribute,则使用枚举名称 + + // 返回描述和值的键值对 + return new KeyValuePair(description, Convert.ToInt32(e)); + }) + .ToList(); + } + + + DetectionConfig Detection = new DetectionConfig(); + AntList antList; + public AntdUI.Window _window; + DefectRow curUser; public DetectConfigControl() { InitializeComponent(); + InitTableColumns(); + InitData(); + BindEventHandler(); + foreach (var item in MLModelTypes) + { + cbxDetectType.Items.Add(item.Key); + } + cbxDetectType.SelectedIndex = (int)Detection.ModelType - 1; + tbDetectName.Text = Detection.Name; + } + + public bool IsEnabled + { + get => switchEnable.AutoCheck; + set => switchEnable.AutoCheck = value; + } + // 模型路径属性 + public string ModelPath + { + get => Detection.ModelPath; + set + { + Detection.ModelPath = value; + tbModelpath.Text = value; // 更新到文本框 + } + } + + + public bool IsPicNGEnable + { + + get => sthSaveNGPic.AutoCheck; + set => sthSaveNGPic.AutoCheck = value; + } + public bool IsPicEnable + { + + get => sthPic.AutoCheck; + set => sthPic.AutoCheck = value; + } + //public MLModelType LModelType + //{ + + //} + + private string _picTag; + + public string picTag + { + get => _picTag; + set + { + _picTag = value; + } + } + + + + private string _afterTag; + + public string afterTag + { + get => _afterTag; + set + { + _afterTag = value; + } + } + private void InitTableColumns() + { + table_base.Columns = new ColumnCollection() { + new ColumnCheck("Selected"){Fixed = true}, + new Column("LabelDescription", "标签名", ColumnAlign.Center) + { + Width="120", + //设置树节点,名称需和User里的User[]名称保持一致 + KeyTree = "Users" + }, + new ColumnSwitch("IsEnable", "是否启用", ColumnAlign.Center){ + //支持点击回调 + Call= (value,record, i_row, i_col) =>{ + //执行耗时操作 + Thread.Sleep(1000); + // AntdUI.Message.info(window, value.ToString(),autoClose:1); + return value; + } + }, + new Column("ScoreMinValue", "最小得分",ColumnAlign.Center), + new Column("ScoreMaxValue", "最大得分",ColumnAlign.Center), + + new Column("AreaMinValue", "最小面积",ColumnAlign.Center), + new Column("AreaMaxValue", "最大面积",ColumnAlign.Center), + //new Column("CellBadge", "徽标",ColumnAlign.Center), + //new Column("CellText", "富文本") + //{ + // ColAlign = ColumnAlign.Center,//支持表头位置单独设置 + //}, + //new Column("CellProgress", "进度条",ColumnAlign.Center), + //new Column("CellDivider", "分割线",ColumnAlign.Center), + //new Column("CellLinks", "链接", ColumnAlign.Center) + //{ + // Fixed = true,//冻结列 + //}, + }; + } + + private void InitData() + { + antList = new AntList(); + + for (int i = 0; i < 10; i++) + { + antList.Add(new DefectRow + { + LabelDescription = "张三", + + }); + } + + + table_base.Binding(antList); + + //设置行禁用 + // table_base.SetRowEnable(0, false, true); + } + + + private void BindEventHandler() + { + buttonADD.Click += ButtonADD_Click; + buttonDEL.Click += ButtonDEL_Click; + + + table_base.CellClick += Table_base_CellClick; + table_base.CellButtonClick += Table_base_CellButtonClick; + } + + + private AntdUI.Table.CellStyleInfo Table_base_SetRowStyle(object sender, TableSetRowStyleEventArgs e) + { + if (e.RowIndex % 2 == 0) + { + return new AntdUI.Table.CellStyleInfo + { + BackColor = AntdUI.Style.Db.ErrorBg, + }; + } + return null; + } + + private void ButtonADD_Click(object sender, EventArgs e) + { + DefectRow useradd = new DefectRow() + { + LabelDescription="xinquexian" + + }; + var form = new DefectRowEdit(_window, useradd) { Size = new Size(700, 500) }; + AntdUI.Modal.open(new AntdUI.Modal.Config(_window, "", form, TType.None) + { + BtnHeight = 0, + }); + if (form.submit) + { + antList.Add(useradd); + } + + } + + private void Table_base_CellClick(object sender, TableClickEventArgs e) + { + var record = e.Record; + if (record is DefectRow user) + { + curUser = user; + //判断是否右键 + if (e.Button == MouseButtons.Right) + { + if (antList.Count == 0) return; + AntdUI.ContextMenuStrip.open(new AntdUI.ContextMenuStrip.Config(table_base, + (item) => + { + if (item.Text == "开启") + { + user.IsEnable = true; + } + else if (item.Text == "关闭") + { + user.IsEnable = false; + } + else if (item.Text == "编辑") + { + var form = new DefectRowEdit(_window, user) { Size = new Size(500, 300) }; + AntdUI.Drawer.open(new AntdUI.Drawer.Config(_window, form) + { + OnLoad = () => + { + AntdUI.Message.info(_window, "进入编辑", autoClose: 1); + }, + OnClose = () => + { + AntdUI.Message.info(_window, "结束编辑", autoClose: 1); + } + }); + } + else if (item.Text == "删除") + { + var result = Modal.open(_window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn); + if (result == DialogResult.OK) + { + //父元素没有勾选或者子元素也没有勾选,则删除当前行 + bool delCurrent = !antList.Any(x => x.Selected /*|| (x.?.Any(u => u.Selected) ?? false)*/); + + if (delCurrent) + { + //删除当前行,先判断是否父元素,再判断是否子元素,只支持一层子元素,需实现嵌套查询 + for (int i = 0; i < antList.Count; i++) + { + if (antList[i] == user) + { + antList.RemoveAt(i); + } + //else + //{ + // antList[i].Users = antList[i].Users?.Where(x => x != user).ToArray(); + //} + } + } + else + { + // 使用反转for循环删除主列表中选中的项 + for (int i = antList.Count - 1; i >= 0; i--) + { + // 1.删除选中的主列表项 + if (antList[i].Selected) + { + antList.RemoveAt(i); + } + //else + //{ + // // 删除子列表中选中的项 + // antList[i].Users = antList[i].Users?.Where(childUser => !childUser.Selected).ToArray(); + //} + } + } + + } + } + else if (item.Text == "查看图片") + { + //查看其他来源的高清图片 + Preview.open(new Preview.Config(_window, Properties.Resources.head2)); + } + else + AntdUI.Message.info(_window, item.Text, autoClose: 1); + }, + new IContextMenuStripItem[] { + //根据行数据动态修改右键菜单 + user.IsEnable? new ContextMenuStripItem("关闭") + { + IconSvg = "CloseOutlined" + }:new ContextMenuStripItem("开启") + { + IconSvg = "CheckOutlined" + }, + new AntdUI.ContextMenuStripItem("编辑"){ + IconSvg = "EditOutlined", + }, + new AntdUI.ContextMenuStripItem("删除"){ + IconSvg = "DeleteOutlined" + }, + new ContextMenuStripItem("查看图片") + { + IconSvg = "FundViewOutlined" + }, + new ContextMenuStripItemDivider(), + new AntdUI.ContextMenuStripItem("详情"){ + Sub = new IContextMenuStripItem[]{ new AntdUI.ContextMenuStripItem("打印", "Ctrl + P") { }, + new AntdUI.ContextMenuStripItem("另存为", "Ctrl + S") { } }, + IconSvg = "", + } + })); + } + else + { + + } + } + } + + //表格内部按钮事件 + private void Table_base_CellButtonClick(object sender, TableButtonEventArgs e) + { + //var buttontext = e.Btn.Text; + + //if (e.Record is User user) + //{ + // curUser = user; + // switch (buttontext) + // { + // //暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据 + // case "编辑": + // var form = new UserEdit(window, user) { Size = new Size(500, 300) }; + // AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form) + // { + // OnLoad = () => + // { + // AntdUI.Message.info(window, "进入编辑", autoClose: 1); + // }, + // OnClose = () => + // { + // AntdUI.Message.info(window, "结束编辑", autoClose: 1); + // } + // }); + // break; + // case "删除": + // var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn); + // if (result == DialogResult.OK) + // antList.Remove(user); + // break; + // case "AntdUI": + // //超链接内容 + // AntdUI.Message.info(window, user.CellLinks.FirstOrDefault().Id, autoClose: 1); + // break; + // case "查看图片": + // //使用clone可以防止table中的image被修改 + // Preview.open(new Preview.Config(window, (Image)curUser.CellImages[0].Image.Clone())); + // break; + // } + //} + } + + private void ButtonDEL_Click(object sender, EventArgs e) + { + //if (antList.Count == 0 || !antList.Any(x => x.Selected)) + //{ + // bool isSubSelected = false; + // // 判断子元素是否勾选 + // for (int i = 0; i < antList.Count; i++) + // { + // if (antList[i].Users != null && antList[i].Users.Any(x => x.Selected)) + // { + // isSubSelected = true; + // break; + // } + // } + // if (!isSubSelected) + // { + // AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3); + // return; + // } + //} + + //var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn); + //if (result == DialogResult.OK) + //{ + // // 使用反转for循环删除主列表中选中的项 + // for (int i = antList.Count - 1; i >= 0; i--) + // { + // // 删除选中的主列表项 + // if (antList[i].Selected) + // { + // antList.RemoveAt(i); + // } + // else + // { + // // 删除子列表中选中的项 + // antList[i].Users = antList[i].Users?.Where(user => !user.Selected).ToArray(); + // } + // } + // // 提示删除完成 + // // AntdUI.Message.success(this.w, "删除成功!", autoClose: 3); + // MessageBox.Show("删除成功!"); + //} + } + + } } diff --git a/DHSoftware/Views/FloatButtonDemo.Designer.cs b/DHSoftware/Views/FloatButtonDemo.Designer.cs deleted file mode 100644 index 46e24f3..0000000 --- a/DHSoftware/Views/FloatButtonDemo.Designer.cs +++ /dev/null @@ -1,694 +0,0 @@ -namespace AntdUIDemo.Views -{ - partial class FloatButtonDemo - { - /// - /// 必需的设计器变量。 - /// - private System.ComponentModel.IContainer components = null; - - /// - /// 清理所有正在使用的资源。 - /// - /// 如果应释放托管资源,为 true;否则为 false。 - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region 组件设计器生成的代码 - - /// - /// 设计器支持所需的方法 - 不要修改 - /// 使用代码编辑器修改此方法的内容。 - /// - private void InitializeComponent() - { - this.header1 = new AntdUI.PageHeader(); - this.stackPanel1 = new AntdUI.StackPanel(); - this.stackPanel2 = new AntdUI.StackPanel(); - this.buttonCZ = new AntdUI.Button(); - this.buttonClose = new AntdUI.Button(); - this.buttonOpen = new AntdUI.Button(); - this.stackPanel8 = new AntdUI.StackPanel(); - this.switch_enabled = new AntdUI.Switch(); - this.label18 = new AntdUI.Label(); - this.colorPicker = new AntdUI.ColorPicker(); - this.label16 = new AntdUI.Label(); - this.stackPanel6 = new AntdUI.StackPanel(); - this.switch_loading = new AntdUI.Switch(); - this.label2 = new AntdUI.Label(); - this.input_badgesize = new AntdUI.InputNumber(); - this.label15 = new AntdUI.Label(); - this.input_badge = new AntdUI.Input(); - this.label17 = new AntdUI.Label(); - this.stackPanel5 = new AntdUI.StackPanel(); - this.switch_round = new AntdUI.Switch(); - this.label14 = new AntdUI.Label(); - this.select_type = new AntdUI.Select(); - this.label13 = new AntdUI.Label(); - this.input_radius = new AntdUI.InputNumber(); - this.label12 = new AntdUI.Label(); - this.label11 = new AntdUI.Label(); - this.stackPanel7 = new AntdUI.StackPanel(); - this.input_gap = new AntdUI.InputNumber(); - this.label20 = new AntdUI.Label(); - this.stackPanel4 = new AntdUI.StackPanel(); - this.switch_topmost = new AntdUI.Switch(); - this.label6 = new AntdUI.Label(); - this.input_my = new AntdUI.InputNumber(); - this.label8 = new AntdUI.Label(); - this.input_size = new AntdUI.InputNumber(); - this.label9 = new AntdUI.Label(); - this.stackPanel3 = new AntdUI.StackPanel(); - this.switch_vertical = new AntdUI.Switch(); - this.label5 = new AntdUI.Label(); - this.input_mx = new AntdUI.InputNumber(); - this.label7 = new AntdUI.Label(); - this.select_align = new AntdUI.Select(); - this.label10 = new AntdUI.Label(); - this.label4 = new AntdUI.Label(); - this.label3 = new AntdUI.Label(); - this.stackPanel1.SuspendLayout(); - this.stackPanel2.SuspendLayout(); - this.stackPanel8.SuspendLayout(); - this.stackPanel6.SuspendLayout(); - this.stackPanel5.SuspendLayout(); - this.stackPanel7.SuspendLayout(); - this.stackPanel4.SuspendLayout(); - this.stackPanel3.SuspendLayout(); - this.SuspendLayout(); - // - // header1 - // - this.header1.Description = "悬浮于页面上方的按钮。"; - this.header1.DividerShow = true; - this.header1.Dock = System.Windows.Forms.DockStyle.Top; - this.header1.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F); - this.header1.LocalizationDescription = "FloatButton.Description"; - this.header1.LocalizationText = "FloatButton.Text"; - this.header1.Location = new System.Drawing.Point(0, 0); - this.header1.Name = "header1"; - this.header1.Padding = new System.Windows.Forms.Padding(0, 0, 0, 10); - this.header1.Size = new System.Drawing.Size(750, 74); - this.header1.TabIndex = 27; - this.header1.Text = "FloatButton 悬浮按钮"; - this.header1.UseTitleFont = true; - // - // stackPanel1 - // - this.stackPanel1.Controls.Add(this.stackPanel2); - this.stackPanel1.Controls.Add(this.stackPanel8); - this.stackPanel1.Controls.Add(this.stackPanel6); - this.stackPanel1.Controls.Add(this.stackPanel5); - this.stackPanel1.Controls.Add(this.label11); - this.stackPanel1.Controls.Add(this.stackPanel7); - this.stackPanel1.Controls.Add(this.stackPanel4); - this.stackPanel1.Controls.Add(this.stackPanel3); - this.stackPanel1.Controls.Add(this.label4); - this.stackPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.stackPanel1.Location = new System.Drawing.Point(0, 104); - this.stackPanel1.Name = "stackPanel1"; - this.stackPanel1.Size = new System.Drawing.Size(750, 388); - this.stackPanel1.TabIndex = 0; - this.stackPanel1.Text = "stackPanel1"; - this.stackPanel1.Vertical = true; - // - // stackPanel2 - // - this.stackPanel2.Controls.Add(this.buttonCZ); - this.stackPanel2.Controls.Add(this.buttonClose); - this.stackPanel2.Controls.Add(this.buttonOpen); - this.stackPanel2.Location = new System.Drawing.Point(3, 291); - this.stackPanel2.Name = "stackPanel2"; - this.stackPanel2.Size = new System.Drawing.Size(744, 38); - this.stackPanel2.TabIndex = 28; - this.stackPanel2.Text = "stackPanel2"; - // - // buttonCZ - // - this.buttonCZ.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.buttonCZ.LocalizationText = "reset"; - this.buttonCZ.Location = new System.Drawing.Point(165, 3); - this.buttonCZ.Name = "buttonCZ"; - this.buttonCZ.Size = new System.Drawing.Size(75, 32); - this.buttonCZ.TabIndex = 7; - this.buttonCZ.Text = "重 置"; - this.buttonCZ.Type = AntdUI.TTypeMini.Warn; - this.buttonCZ.WaveSize = 0; - // - // buttonClose - // - this.buttonClose.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.buttonClose.LocalizationText = "close"; - this.buttonClose.Location = new System.Drawing.Point(84, 3); - this.buttonClose.Name = "buttonClose"; - this.buttonClose.Size = new System.Drawing.Size(75, 32); - this.buttonClose.TabIndex = 6; - this.buttonClose.Text = "关 闭"; - this.buttonClose.Type = AntdUI.TTypeMini.Error; - this.buttonClose.WaveSize = 0; - // - // buttonOpen - // - this.buttonOpen.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.buttonOpen.LocalizationText = "open"; - this.buttonOpen.Location = new System.Drawing.Point(3, 3); - this.buttonOpen.Name = "buttonOpen"; - this.buttonOpen.Size = new System.Drawing.Size(75, 32); - this.buttonOpen.TabIndex = 5; - this.buttonOpen.Text = "打 开"; - this.buttonOpen.Type = AntdUI.TTypeMini.Success; - this.buttonOpen.WaveSize = 0; - // - // stackPanel8 - // - this.stackPanel8.Controls.Add(this.switch_enabled); - this.stackPanel8.Controls.Add(this.label18); - this.stackPanel8.Controls.Add(this.colorPicker); - this.stackPanel8.Controls.Add(this.label16); - this.stackPanel8.Gap = 4; - this.stackPanel8.Location = new System.Drawing.Point(3, 253); - this.stackPanel8.Name = "stackPanel8"; - this.stackPanel8.Size = new System.Drawing.Size(744, 32); - this.stackPanel8.TabIndex = 27; - this.stackPanel8.Text = "stackPanel8"; - // - // switch_enabled - // - this.switch_enabled.Location = new System.Drawing.Point(292, 3); - this.switch_enabled.Name = "switch_enabled"; - this.switch_enabled.Size = new System.Drawing.Size(50, 26); - this.switch_enabled.TabIndex = 32; - this.switch_enabled.Text = "switch1"; - // - // label18 - // - this.label18.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label18.Location = new System.Drawing.Point(190, 3); - this.label18.Name = "label18"; - this.label18.Size = new System.Drawing.Size(92, 26); - this.label18.TabIndex = 31; - this.label18.Text = "Enabled"; - // - // colorPicker - // - this.colorPicker.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.colorPicker.Location = new System.Drawing.Point(105, 3); - this.colorPicker.Name = "colorPicker"; - this.colorPicker.Size = new System.Drawing.Size(75, 26); - this.colorPicker.TabIndex = 30; - this.colorPicker.Text = "colorPicker1"; - this.colorPicker.Value = System.Drawing.Color.FromArgb(((int)(((byte)(22)))), ((int)(((byte)(119)))), ((int)(((byte)(255))))); - this.colorPicker.WaveSize = 0; - // - // label16 - // - this.label16.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label16.Location = new System.Drawing.Point(3, 3); - this.label16.Name = "label16"; - this.label16.Size = new System.Drawing.Size(92, 26); - this.label16.TabIndex = 29; - this.label16.Text = "BadgeBack"; - // - // stackPanel6 - // - this.stackPanel6.Controls.Add(this.switch_loading); - this.stackPanel6.Controls.Add(this.label2); - this.stackPanel6.Controls.Add(this.input_badgesize); - this.stackPanel6.Controls.Add(this.label15); - this.stackPanel6.Controls.Add(this.input_badge); - this.stackPanel6.Controls.Add(this.label17); - this.stackPanel6.Gap = 4; - this.stackPanel6.Location = new System.Drawing.Point(3, 215); - this.stackPanel6.Name = "stackPanel6"; - this.stackPanel6.Size = new System.Drawing.Size(744, 32); - this.stackPanel6.TabIndex = 25; - this.stackPanel6.Text = "stackPanel6"; - // - // switch_loading - // - this.switch_loading.Location = new System.Drawing.Point(492, 3); - this.switch_loading.Name = "switch_loading"; - this.switch_loading.Size = new System.Drawing.Size(50, 26); - this.switch_loading.TabIndex = 30; - this.switch_loading.Text = "switch1"; - // - // label2 - // - this.label2.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label2.Location = new System.Drawing.Point(390, 3); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(92, 26); - this.label2.TabIndex = 29; - this.label2.Text = "Loading"; - // - // input_badgesize - // - this.input_badgesize.DecimalPlaces = 1; - this.input_badgesize.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.input_badgesize.Increment = new decimal(new int[] { - 1, - 0, - 0, - 65536}); - this.input_badgesize.Location = new System.Drawing.Point(292, 3); - this.input_badgesize.Minimum = new decimal(new int[] { - 0, - 0, - 0, - 0}); - this.input_badgesize.Name = "input_badgesize"; - this.input_badgesize.Size = new System.Drawing.Size(88, 26); - this.input_badgesize.TabIndex = 13; - this.input_badgesize.Text = "0.6"; - this.input_badgesize.Value = new decimal(new int[] { - 6, - 0, - 0, - 65536}); - this.input_badgesize.WaveSize = 0; - // - // label15 - // - this.label15.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label15.Location = new System.Drawing.Point(190, 3); - this.label15.Name = "label15"; - this.label15.Size = new System.Drawing.Size(92, 26); - this.label15.TabIndex = 12; - this.label15.Text = "BadgeSize"; - // - // input_badge - // - this.input_badge.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.input_badge.Location = new System.Drawing.Point(105, 3); - this.input_badge.Name = "input_badge"; - this.input_badge.Size = new System.Drawing.Size(75, 26); - this.input_badge.TabIndex = 5; - this.input_badge.WaveSize = 0; - // - // label17 - // - this.label17.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label17.Location = new System.Drawing.Point(3, 3); - this.label17.Name = "label17"; - this.label17.Size = new System.Drawing.Size(92, 26); - this.label17.TabIndex = 4; - this.label17.Text = "Badge"; - // - // stackPanel5 - // - this.stackPanel5.Controls.Add(this.switch_round); - this.stackPanel5.Controls.Add(this.label14); - this.stackPanel5.Controls.Add(this.select_type); - this.stackPanel5.Controls.Add(this.label13); - this.stackPanel5.Controls.Add(this.input_radius); - this.stackPanel5.Controls.Add(this.label12); - this.stackPanel5.Gap = 4; - this.stackPanel5.Location = new System.Drawing.Point(3, 177); - this.stackPanel5.Name = "stackPanel5"; - this.stackPanel5.Size = new System.Drawing.Size(744, 32); - this.stackPanel5.TabIndex = 24; - this.stackPanel5.Text = "stackPanel5"; - // - // switch_round - // - this.switch_round.Location = new System.Drawing.Point(492, 3); - this.switch_round.Name = "switch_round"; - this.switch_round.Size = new System.Drawing.Size(50, 26); - this.switch_round.TabIndex = 24; - this.switch_round.Text = "switch1"; - // - // label14 - // - this.label14.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label14.Location = new System.Drawing.Point(390, 3); - this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(92, 26); - this.label14.TabIndex = 23; - this.label14.Text = "Round"; - // - // select_type - // - this.select_type.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.select_type.List = true; - this.select_type.Location = new System.Drawing.Point(292, 3); - this.select_type.Name = "select_type"; - this.select_type.Size = new System.Drawing.Size(88, 26); - this.select_type.TabIndex = 22; - this.select_type.WaveSize = 0; - // - // label13 - // - this.label13.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label13.Location = new System.Drawing.Point(190, 3); - this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(92, 26); - this.label13.TabIndex = 21; - this.label13.Text = "Type"; - // - // input_radius - // - this.input_radius.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.input_radius.Location = new System.Drawing.Point(105, 3); - this.input_radius.Minimum = new decimal(new int[] { - 0, - 0, - 0, - 0}); - this.input_radius.Name = "input_radius"; - this.input_radius.Size = new System.Drawing.Size(75, 26); - this.input_radius.TabIndex = 18; - this.input_radius.Text = "6"; - this.input_radius.Value = new decimal(new int[] { - 6, - 0, - 0, - 0}); - this.input_radius.WaveSize = 0; - // - // label12 - // - this.label12.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label12.Location = new System.Drawing.Point(3, 3); - this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(92, 26); - this.label12.TabIndex = 17; - this.label12.Text = "Radius"; - // - // label11 - // - this.label11.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F); - this.label11.LocalizationText = "button_option"; - this.label11.Location = new System.Drawing.Point(3, 147); - this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(744, 24); - this.label11.TabIndex = 23; - this.label11.Text = "按钮配置"; - // - // stackPanel7 - // - this.stackPanel7.Controls.Add(this.input_gap); - this.stackPanel7.Controls.Add(this.label20); - this.stackPanel7.Gap = 4; - this.stackPanel7.Location = new System.Drawing.Point(3, 109); - this.stackPanel7.Name = "stackPanel7"; - this.stackPanel7.Size = new System.Drawing.Size(744, 32); - this.stackPanel7.TabIndex = 22; - this.stackPanel7.Text = "stackPanel7"; - // - // input_gap - // - this.input_gap.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.input_gap.Location = new System.Drawing.Point(105, 3); - this.input_gap.Minimum = new decimal(new int[] { - 0, - 0, - 0, - 0}); - this.input_gap.Name = "input_gap"; - this.input_gap.Size = new System.Drawing.Size(75, 26); - this.input_gap.TabIndex = 5; - this.input_gap.Text = "40"; - this.input_gap.Value = new decimal(new int[] { - 40, - 0, - 0, - 0}); - this.input_gap.WaveSize = 0; - // - // label20 - // - this.label20.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label20.Location = new System.Drawing.Point(3, 3); - this.label20.Name = "label20"; - this.label20.Size = new System.Drawing.Size(92, 26); - this.label20.TabIndex = 4; - this.label20.Text = "Gap"; - // - // stackPanel4 - // - this.stackPanel4.Controls.Add(this.switch_topmost); - this.stackPanel4.Controls.Add(this.label6); - this.stackPanel4.Controls.Add(this.input_my); - this.stackPanel4.Controls.Add(this.label8); - this.stackPanel4.Controls.Add(this.input_size); - this.stackPanel4.Controls.Add(this.label9); - this.stackPanel4.Gap = 4; - this.stackPanel4.Location = new System.Drawing.Point(3, 71); - this.stackPanel4.Name = "stackPanel4"; - this.stackPanel4.Size = new System.Drawing.Size(744, 32); - this.stackPanel4.TabIndex = 17; - this.stackPanel4.Text = "stackPanel4"; - // - // switch_topmost - // - this.switch_topmost.Checked = true; - this.switch_topmost.Location = new System.Drawing.Point(492, 3); - this.switch_topmost.Name = "switch_topmost"; - this.switch_topmost.Size = new System.Drawing.Size(50, 26); - this.switch_topmost.TabIndex = 15; - this.switch_topmost.Text = "switch1"; - // - // label6 - // - this.label6.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label6.Location = new System.Drawing.Point(390, 3); - this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(92, 26); - this.label6.TabIndex = 14; - this.label6.Text = "TopMost"; - // - // input_my - // - this.input_my.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.input_my.Location = new System.Drawing.Point(292, 3); - this.input_my.Minimum = new decimal(new int[] { - 0, - 0, - 0, - 0}); - this.input_my.Name = "input_my"; - this.input_my.Size = new System.Drawing.Size(88, 26); - this.input_my.TabIndex = 9; - this.input_my.Text = "24"; - this.input_my.Value = new decimal(new int[] { - 24, - 0, - 0, - 0}); - this.input_my.WaveSize = 0; - // - // label8 - // - this.label8.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label8.Location = new System.Drawing.Point(190, 3); - this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(92, 26); - this.label8.TabIndex = 8; - this.label8.Text = "MarginY"; - // - // input_size - // - this.input_size.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.input_size.Location = new System.Drawing.Point(105, 3); - this.input_size.Minimum = new decimal(new int[] { - 0, - 0, - 0, - 0}); - this.input_size.Name = "input_size"; - this.input_size.Size = new System.Drawing.Size(75, 26); - this.input_size.TabIndex = 5; - this.input_size.Text = "40"; - this.input_size.Value = new decimal(new int[] { - 40, - 0, - 0, - 0}); - this.input_size.WaveSize = 0; - // - // label9 - // - this.label9.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(3, 3); - this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(92, 26); - this.label9.TabIndex = 4; - this.label9.Text = "Size"; - // - // stackPanel3 - // - this.stackPanel3.Controls.Add(this.switch_vertical); - this.stackPanel3.Controls.Add(this.label5); - this.stackPanel3.Controls.Add(this.input_mx); - this.stackPanel3.Controls.Add(this.label7); - this.stackPanel3.Controls.Add(this.select_align); - this.stackPanel3.Controls.Add(this.label10); - this.stackPanel3.Gap = 4; - this.stackPanel3.Location = new System.Drawing.Point(3, 33); - this.stackPanel3.Name = "stackPanel3"; - this.stackPanel3.Size = new System.Drawing.Size(744, 32); - this.stackPanel3.TabIndex = 16; - this.stackPanel3.Text = "stackPanel3"; - // - // switch_vertical - // - this.switch_vertical.Checked = true; - this.switch_vertical.Location = new System.Drawing.Point(492, 3); - this.switch_vertical.Name = "switch_vertical"; - this.switch_vertical.Size = new System.Drawing.Size(50, 26); - this.switch_vertical.TabIndex = 19; - this.switch_vertical.Text = "switch1"; - // - // label5 - // - this.label5.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label5.Location = new System.Drawing.Point(390, 3); - this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(92, 26); - this.label5.TabIndex = 18; - this.label5.Text = "Vertical"; - // - // input_mx - // - this.input_mx.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.input_mx.Location = new System.Drawing.Point(292, 3); - this.input_mx.Minimum = new decimal(new int[] { - 0, - 0, - 0, - 0}); - this.input_mx.Name = "input_mx"; - this.input_mx.Size = new System.Drawing.Size(88, 26); - this.input_mx.TabIndex = 17; - this.input_mx.Text = "24"; - this.input_mx.Value = new decimal(new int[] { - 24, - 0, - 0, - 0}); - this.input_mx.WaveSize = 0; - // - // label7 - // - this.label7.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label7.Location = new System.Drawing.Point(190, 3); - this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(92, 26); - this.label7.TabIndex = 16; - this.label7.Text = "MarginX"; - // - // select_align - // - this.select_align.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.select_align.List = true; - this.select_align.Location = new System.Drawing.Point(105, 3); - this.select_align.Name = "select_align"; - this.select_align.Size = new System.Drawing.Size(75, 26); - this.select_align.TabIndex = 5; - this.select_align.WaveSize = 0; - // - // label10 - // - this.label10.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label10.Location = new System.Drawing.Point(3, 3); - this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(92, 26); - this.label10.TabIndex = 4; - this.label10.Text = "Align"; - // - // label4 - // - this.label4.Font = new System.Drawing.Font("Microsoft YaHei UI", 12F); - this.label4.LocalizationText = "control_option"; - this.label4.Location = new System.Drawing.Point(3, 3); - this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(744, 24); - this.label4.TabIndex = 15; - this.label4.Text = "控件配置"; - // - // label3 - // - this.label3.Dock = System.Windows.Forms.DockStyle.Top; - this.label3.Font = new System.Drawing.Font("Microsoft YaHei UI", 9F); - this.label3.LocalizationText = "FloatButton.Tip"; - this.label3.Location = new System.Drawing.Point(0, 74); - this.label3.Name = "label3"; - this.label3.Padding = new System.Windows.Forms.Padding(0, 0, 0, 6); - this.label3.Size = new System.Drawing.Size(750, 30); - this.label3.TabIndex = 4; - this.label3.Text = "FloatButton没有工具箱控件,使用代码方式调用。"; - // - // FloatButtonDemo - // - this.Controls.Add(this.stackPanel1); - this.Controls.Add(this.label3); - this.Controls.Add(this.header1); - this.Name = "FloatButtonDemo"; - this.Size = new System.Drawing.Size(750, 492); - this.stackPanel1.ResumeLayout(false); - this.stackPanel2.ResumeLayout(false); - this.stackPanel8.ResumeLayout(false); - this.stackPanel6.ResumeLayout(false); - this.stackPanel5.ResumeLayout(false); - this.stackPanel7.ResumeLayout(false); - this.stackPanel4.ResumeLayout(false); - this.stackPanel3.ResumeLayout(false); - this.ResumeLayout(false); - - } - - #endregion - - private AntdUI.PageHeader header1; - private AntdUI.StackPanel stackPanel1; - private AntdUI.Label label3; - private AntdUI.StackPanel stackPanel4; - private AntdUI.InputNumber input_my; - private AntdUI.Label label8; - private AntdUI.InputNumber input_size; - private AntdUI.Label label9; - private AntdUI.StackPanel stackPanel3; - private AntdUI.Select select_align; - private AntdUI.Label label10; - private AntdUI.Label label4; - private AntdUI.StackPanel stackPanel6; - private AntdUI.InputNumber input_badgesize; - private AntdUI.Label label15; - private AntdUI.Input input_badge; - private AntdUI.Label label17; - private AntdUI.StackPanel stackPanel5; - private AntdUI.Label label11; - private AntdUI.StackPanel stackPanel7; - private AntdUI.InputNumber input_gap; - private AntdUI.Label label20; - private AntdUI.InputNumber input_radius; - private AntdUI.Label label12; - private AntdUI.Switch switch_topmost; - private AntdUI.Label label6; - private AntdUI.Switch switch_vertical; - private AntdUI.Label label5; - private AntdUI.InputNumber input_mx; - private AntdUI.Label label7; - private AntdUI.Switch switch_round; - private AntdUI.Label label14; - private AntdUI.Select select_type; - private AntdUI.Label label13; - private AntdUI.StackPanel stackPanel2; - private AntdUI.StackPanel stackPanel8; - private AntdUI.Switch switch_enabled; - private AntdUI.Label label18; - private AntdUI.ColorPicker colorPicker; - private AntdUI.Label label16; - private AntdUI.Switch switch_loading; - private AntdUI.Label label2; - private AntdUI.Button buttonCZ; - private AntdUI.Button buttonClose; - private AntdUI.Button buttonOpen; - } -} diff --git a/DHSoftware/Views/FloatButtonDemo.cs b/DHSoftware/Views/FloatButtonDemo.cs deleted file mode 100644 index 93da584..0000000 --- a/DHSoftware/Views/FloatButtonDemo.cs +++ /dev/null @@ -1,241 +0,0 @@ -using AntdUI; -using System; -using System.Drawing; -using System.Windows.Forms; - -namespace AntdUIDemo.Views -{ - public partial class FloatButtonDemo : UserControl - { - private Window window; - private FormFloatButton floatButtonForm = null; - public FloatButtonDemo(Window _window) - { - window = _window; - InitializeComponent(); - //初始化下拉框 - InitSelectItems(); - //设置默认值 - InitData(); - // 绑定事件 - BindEventHandler(); - } - - private void BindEventHandler() - { - buttonOpen.Click += ButtonOpen_Click; - buttonClose.Click += buttonClose_Click; - buttonCZ.Click += buttonCZ_Click; - - select_align.SelectedIndexChanged += select_intvalue_SelectedIndexChanged; - select_type.SelectedIndexChanged += select_intvalue_SelectedIndexChanged; - - switch_round.CheckedChanged += Switch_CheckedChanged; - switch_vertical.CheckedChanged += Switch_CheckedChanged; - switch_topmost.CheckedChanged += Switch_CheckedChanged; - switch_enabled.CheckedChanged += Switch_CheckedChanged; - switch_loading.CheckedChanged += Switch_CheckedChanged; - - input_size.ValueChanged += input_decimalvalue_ValeChanged; - input_mx.ValueChanged += input_decimalvalue_ValeChanged; - input_my.ValueChanged += input_decimalvalue_ValeChanged; - input_gap.ValueChanged += input_decimalvalue_ValeChanged; - input_radius.ValueChanged += input_decimalvalue_ValeChanged; - input_badgesize.ValueChanged += input_decimalvalue_ValeChanged; - - input_badge.TextChanged += input_badge_TextChanged; - - colorPicker.ValueChanged += colorPicker_ValueChanged; - } - - private void ButtonOpen_Click(object sender, EventArgs e) - { - LoadFloatButton(); - } - - // 初始化下拉框 - private void InitSelectItems() - { - //初始化方向 - select_align.Items.Clear(); - foreach (TAlign align in Enum.GetValues(typeof(TAlign))) - { - select_align.Items.Add(align); - } - //初始化类型 - select_type.Items.Clear(); - foreach (TTypeMini type in Enum.GetValues(typeof(TTypeMini))) - { - select_type.Items.Add(type); - } - } - - // 设置默认值 - private void InitData() - { - select_align.SelectedIndex = 7; - select_type.SelectedIndex = 0; - - switch_round.Checked = false; - switch_vertical.Checked = true; - switch_topmost.Checked = false; - switch_enabled.Checked = true; - switch_loading.Checked = false; - - input_size.Value = 40; - input_mx.Value = 24; - input_my.Value = 24; - input_gap.Value = 40; - input_radius.Value = 6; - input_badge.Text = ""; - input_badgesize.Value = 0.6m; - colorPicker.Value = Color.FromArgb(22, 119, 255); - } - - // 加载浮动按钮 - private void LoadFloatButton() - { - if (floatButtonForm == null) - { - floatButtonForm = FloatButton.open(new FloatButton.Config(window, new FloatButton.ConfigBtn[] - { - // 使用 svg 图片 - // ConfigBtn第二个text参数默认设置为IconSvg,或者如下在配置里面设置IconSvg - new FloatButton.ConfigBtn("button1","",true) - { - // isSvg设置为true,text参数会赋值给IconSvg,否则赋值给Text,所以需要单独设置Text - Text = "SVG Picture", - IconSvg = "", - Tooltip = "SVG Button", - Round = switch_round.Checked, - Type = (TTypeMini)select_type.SelectedValue, - Radius = (int)input_radius.Value, - Badge = input_badge.Text==""? null:input_badge.Text, - BadgeSize = (float)input_badgesize.Value, - BadgeBack = colorPicker.Value, - Enabled = switch_enabled.Checked, - Loading = switch_loading.Checked, - }, - // 使用资源图片 - new FloatButton.ConfigBtn("button2", DHSoftware.Properties.Resources.关闭) - { - Text = "Resource Picture", - Tooltip = "Resource Picture Button", - Round = switch_round.Checked, - Type = (TTypeMini)select_type.SelectedValue, - Radius = (int)input_radius.Value, - Badge = input_badge.Text==""? null:input_badge.Text, - BadgeSize = (float)input_badgesize.Value, - BadgeBack = colorPicker.Value, - Enabled = switch_enabled.Checked, - Loading = switch_loading.Checked, - }, - // 使用文本 - new FloatButton.ConfigBtn("button3", "Text") - { - Tooltip = "Text Button", - Round = switch_round.Checked, - Type = (TTypeMini)select_type.SelectedValue, - Radius = (int)input_radius.Value, - Badge = input_badge.Text==""? null:input_badge.Text, - BadgeSize = (float)input_badgesize.Value, - BadgeBack = colorPicker.Value, - Enabled = switch_enabled.Checked, - Loading = switch_loading.Checked, - }, - //获取button示例,可以通过button的属性判断点击了哪个按钮,推荐用Name - }, button => - { - //回调事件 - AntdUI.Message.info(window, "Text:" + button.Text + ", Name:" + button.Name, autoClose: 3); - }) - // 浮动全局配置 - { - //字体 - Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point), - //附着控件 - Control = null, - //位置 - Align = (TAlign)select_align.SelectedIndex, - //是否垂直方向 - Vertical = switch_vertical.Checked, - //是否置顶 - TopMost = switch_topmost.Checked, - //尺寸大小 - Size = (int)input_size.Value, - //相对于Align位置X轴偏移 - MarginX = (int)input_mx.Value, - //相对于Align位置Y轴偏移 - MarginY = (int)input_my.Value, - //按钮间距 - Gap = (int)input_gap.Value, - }); - } - } - - // 添加清理逻辑 - public void CloseFloatButtonForm() - { - if (InvokeRequired) - { - Invoke(new Action(CloseFloatButtonForm)); - } - else - { - // Ensure that floatButtonForm is not null before attempting to close it - if (floatButtonForm != null) - { - floatButtonForm.Close(); - floatButtonForm.Dispose(); - floatButtonForm = null; - } - } - } - - #region EventHandler - private void select_intvalue_SelectedIndexChanged(object sender, IntEventArgs e) - { - CloseFloatButtonForm(); - LoadFloatButton(); - } - - private void Switch_CheckedChanged(object sender, BoolEventArgs e) - { - CloseFloatButtonForm(); - LoadFloatButton(); - } - - private void colorPicker_ValueChanged(object sender, ColorEventArgs e) - { - CloseFloatButtonForm(); - LoadFloatButton(); - } - - private void input_badge_TextChanged(object sender, EventArgs e) - { - CloseFloatButtonForm(); - LoadFloatButton(); - } - - private void input_decimalvalue_ValeChanged(object sender, DecimalEventArgs e) - { - CloseFloatButtonForm(); - LoadFloatButton(); - } - - // 重置 - private void buttonCZ_Click(object sender, EventArgs e) - { - InitData(); - CloseFloatButtonForm(); - LoadFloatButton(); - } - - // 关闭 - private void buttonClose_Click(object sender, EventArgs e) - { - CloseFloatButtonForm(); - } - #endregion - } -} diff --git a/DHSoftware/Views/PreTreatUserControl.Designer.cs b/DHSoftware/Views/PreTreatUserControl.Designer.cs index c0aaca8..e56e24b 100644 --- a/DHSoftware/Views/PreTreatUserControl.Designer.cs +++ b/DHSoftware/Views/PreTreatUserControl.Designer.cs @@ -32,26 +32,27 @@ tbxPrePath = new TextBox(); label1 = new AntdUI.Label(); panel1 = new Panel(); - panel3 = new Panel(); + btnOParmDel = new Panel(); label3 = new Label(); - button3 = new AntdUI.Button(); - table2 = new AntdUI.Table(); - button4 = new AntdUI.Button(); + btnDelOParm = new AntdUI.Button(); + tbOutputParm = new AntdUI.Table(); + btnAddOParm = new AntdUI.Button(); panel2 = new Panel(); label2 = new Label(); - button2 = new AntdUI.Button(); - table1 = new AntdUI.Table(); - button1 = new AntdUI.Button(); + btnDelIParm = new AntdUI.Button(); + tbInputParm = new AntdUI.Table(); + btnAddIParm = new AntdUI.Button(); panel1.SuspendLayout(); - panel3.SuspendLayout(); + btnOParmDel.SuspendLayout(); panel2.SuspendLayout(); SuspendLayout(); // // btnPreOpen // - btnPreOpen.Location = new Point(646, 17); + btnPreOpen.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + btnPreOpen.Location = new Point(570, 17); btnPreOpen.Name = "btnPreOpen"; - btnPreOpen.Size = new Size(46, 23); + btnPreOpen.Size = new Size(28, 23); btnPreOpen.TabIndex = 21; btnPreOpen.Text = "..."; // @@ -59,7 +60,7 @@ // tbxPrePath.Location = new Point(91, 17); tbxPrePath.Name = "tbxPrePath"; - tbxPrePath.Size = new Size(549, 23); + tbxPrePath.Size = new Size(473, 23); tbxPrePath.TabIndex = 20; // // label1 @@ -72,28 +73,29 @@ // // panel1 // + panel1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; panel1.BorderStyle = BorderStyle.FixedSingle; - panel1.Controls.Add(panel3); + panel1.Controls.Add(btnOParmDel); panel1.Controls.Add(panel2); panel1.Controls.Add(label1); panel1.Controls.Add(btnPreOpen); panel1.Controls.Add(tbxPrePath); - panel1.Dock = DockStyle.Fill; panel1.Location = new Point(0, 0); panel1.Name = "panel1"; - panel1.Size = new Size(759, 243); + panel1.Size = new Size(633, 243); panel1.TabIndex = 22; // - // panel3 + // btnOParmDel // - panel3.Controls.Add(label3); - panel3.Controls.Add(button3); - panel3.Controls.Add(table2); - panel3.Controls.Add(button4); - panel3.Location = new Point(379, 46); - panel3.Name = "panel3"; - panel3.Size = new Size(264, 194); - panel3.TabIndex = 26; + btnOParmDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + btnOParmDel.Controls.Add(label3); + btnOParmDel.Controls.Add(btnDelOParm); + btnOParmDel.Controls.Add(tbOutputParm); + btnOParmDel.Controls.Add(btnAddOParm); + btnOParmDel.Location = new Point(352, 44); + btnOParmDel.Name = "btnOParmDel"; + btnOParmDel.Size = new Size(246, 194); + btnOParmDel.TabIndex = 26; // // label3 // @@ -104,37 +106,38 @@ label3.TabIndex = 25; label3.Text = "输出参数"; // - // button3 + // btnDelOParm // - button3.Location = new Point(93, 25); - button3.Name = "button3"; - button3.Size = new Size(84, 34); - button3.TabIndex = 24; - button3.Text = "删除"; + btnDelOParm.Location = new Point(93, 25); + btnDelOParm.Name = "btnDelOParm"; + btnDelOParm.Size = new Size(84, 34); + btnDelOParm.TabIndex = 24; + btnDelOParm.Text = "删除"; // - // table2 + // tbOutputParm // - table2.Location = new Point(3, 65); - table2.Name = "table2"; - table2.Size = new Size(258, 126); - table2.TabIndex = 22; - table2.Text = "table2"; + tbOutputParm.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + tbOutputParm.Location = new Point(3, 65); + tbOutputParm.Name = "tbOutputParm"; + tbOutputParm.Size = new Size(240, 126); + tbOutputParm.TabIndex = 22; + tbOutputParm.Text = "table2"; // - // button4 + // btnAddOParm // - button4.Location = new Point(3, 25); - button4.Name = "button4"; - button4.Size = new Size(84, 34); - button4.TabIndex = 23; - button4.Text = "新增"; + btnAddOParm.Location = new Point(3, 25); + btnAddOParm.Name = "btnAddOParm"; + btnAddOParm.Size = new Size(84, 34); + btnAddOParm.TabIndex = 23; + btnAddOParm.Text = "新增"; // // panel2 // panel2.Controls.Add(label2); - panel2.Controls.Add(button2); - panel2.Controls.Add(table1); - panel2.Controls.Add(button1); - panel2.Location = new Point(91, 46); + panel2.Controls.Add(btnDelIParm); + panel2.Controls.Add(tbInputParm); + panel2.Controls.Add(btnAddIParm); + panel2.Location = new Point(12, 45); panel2.Name = "panel2"; panel2.Size = new Size(264, 194); panel2.TabIndex = 25; @@ -148,29 +151,30 @@ label2.TabIndex = 25; label2.Text = "输入参数"; // - // button2 + // btnDelIParm // - button2.Location = new Point(93, 25); - button2.Name = "button2"; - button2.Size = new Size(84, 34); - button2.TabIndex = 24; - button2.Text = "删除"; + btnDelIParm.Location = new Point(93, 25); + btnDelIParm.Name = "btnDelIParm"; + btnDelIParm.Size = new Size(84, 34); + btnDelIParm.TabIndex = 24; + btnDelIParm.Text = "删除"; // - // table1 + // tbInputParm // - table1.Location = new Point(3, 65); - table1.Name = "table1"; - table1.Size = new Size(258, 126); - table1.TabIndex = 22; - table1.Text = "table1"; + tbInputParm.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + tbInputParm.Location = new Point(3, 65); + tbInputParm.Name = "tbInputParm"; + tbInputParm.Size = new Size(258, 126); + tbInputParm.TabIndex = 22; + tbInputParm.Text = "table1"; // - // button1 + // btnAddIParm // - button1.Location = new Point(3, 25); - button1.Name = "button1"; - button1.Size = new Size(84, 34); - button1.TabIndex = 23; - button1.Text = "新增"; + btnAddIParm.Location = new Point(3, 25); + btnAddIParm.Name = "btnAddIParm"; + btnAddIParm.Size = new Size(84, 34); + btnAddIParm.TabIndex = 23; + btnAddIParm.Text = "新增"; // // PreTreatUserControl // @@ -178,11 +182,11 @@ AutoScaleMode = AutoScaleMode.Font; Controls.Add(panel1); Name = "PreTreatUserControl"; - Size = new Size(759, 243); + Size = new Size(635, 243); panel1.ResumeLayout(false); panel1.PerformLayout(); - panel3.ResumeLayout(false); - panel3.PerformLayout(); + btnOParmDel.ResumeLayout(false); + btnOParmDel.PerformLayout(); panel2.ResumeLayout(false); panel2.PerformLayout(); ResumeLayout(false); @@ -194,15 +198,15 @@ private TextBox tbxPrePath; private AntdUI.Label label1; private Panel panel1; - private AntdUI.Button button2; - private AntdUI.Button button1; - private AntdUI.Table table1; + private AntdUI.Button btnDelIParm; + private AntdUI.Button btnAddIParm; + private AntdUI.Table tbInputParm; private Panel panel2; - private Panel panel3; + private Panel btnOParmDel; private Label label3; - private AntdUI.Button button3; - private AntdUI.Table table2; - private AntdUI.Button button4; + private AntdUI.Button btnDelOParm; + private AntdUI.Table tbOutputParm; + private AntdUI.Button btnAddOParm; private Label label2; } } diff --git a/DHSoftware/Views/SettingWindow.Designer.cs b/DHSoftware/Views/SettingWindow.Designer.cs new file mode 100644 index 0000000..c087be4 --- /dev/null +++ b/DHSoftware/Views/SettingWindow.Designer.cs @@ -0,0 +1,155 @@ +namespace DHSoftware.Views +{ + partial class SettingWindow + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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(); + pageHeader1 = new AntdUI.PageHeader(); + panel3.SuspendLayout(); + panel1.SuspendLayout(); + panel2.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; + 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(838, 33); + pageHeader1.TabIndex = 1; + pageHeader1.Text = "设置"; + // + // SettingWindow + // + AutoScaleDimensions = new SizeF(7F, 17F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(838, 561); + Controls.Add(panel3); + Name = "SettingWindow"; + StartPosition = FormStartPosition.CenterScreen; + Text = "SettingWinform"; + panel3.ResumeLayout(false); + panel1.ResumeLayout(false); + panel2.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.Menu menu1; + private AntdUI.Button btnSave; + } +} \ No newline at end of file diff --git a/DHSoftware/Views/SettingWindow.cs b/DHSoftware/Views/SettingWindow.cs new file mode 100644 index 0000000..d754de3 --- /dev/null +++ b/DHSoftware/Views/SettingWindow.cs @@ -0,0 +1,144 @@ +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 AntdUI; +using DH.Devices.Devices; +using DH.Devices.Vision; + +namespace DHSoftware.Views +{ + + public partial class SettingWindow : Window + { + public List cameras = new List(); + public List detections = new List(); + 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, "新增工位"); + + + + + } + + private void Menu_MouseDown(object sender, MouseEventArgs e) + { + 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) + { + // 显示节点名称弹窗 + //MessageBox.Show($"右键点击的节点: {clickedItem.Text}"); + + var menulist = new AntdUI.IContextMenuStripItem[] + { + new AntdUI.ContextMenuStripItem("关联相机", "") + { + IconSvg = "VideoCameraAddOutlined" + } + }; + AntdUI.ContextMenuStrip.open(menu1, it => + { + if (it.Text == "关联相机") + { + using (var dlg = new AddCameraWindow(cameras)) + { + if (dlg.ShowDialog() == DialogResult.OK) + { + var newItem = new MenuItem(dlg.CubicleName); + newItem.IconSvg = "VideoCameraOutlined"; + //// 防止重复添加 + //if (!menu1.Items.Cast().Any(m => m.Text == newItem.Text)) + //{ + clickedItem.Sub.Add(newItem); + //} + //else + //{ + // AntdUI.Notification.warn(this, "新增失败", $"{dlg.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR); + //} + } + } + } + }, menulist); + } + } + } + + private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint) + { + foreach (MenuItem item in items) + { + // 检查当前项是否可见且包含点击坐标 + if (item.Visible && item.Rect.Contains(clickPoint)) + { + return item; + } + + + } + return null; + } + + private void btnAdd_Click(object sender, EventArgs e) + { + using (var dlg = new AddCubicleWindow()) + { + if (dlg.ShowDialog() == DialogResult.OK) + { + var newItem = new MenuItem(dlg.CubicleName); + newItem.IconSvg = "AppstoreOutlined"; + // 防止重复添加 + if (!menu1.Items.Cast().Any(m => m.Text == newItem.Text)) + { + menu1.Items.Add(newItem); + } + else + { + AntdUI.Notification.warn(this, "新增工位失败", $"{dlg.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR); + } + } + } + } + + private void menu1_MouseClick(object sender, MouseEventArgs e) + { + //if (e.Button == MouseButtons.Right) + //{ + // var menu =sender as Menu; + // if (menu?.Items.Count == 0) + // { + // return; + // } + + //} + } + + private void btnSave_Click(object sender, EventArgs e) + { + foreach(var item in menu1.Items) + { + + } + } + } +} + diff --git a/DHSoftware/Views/SettingWindow.resx b/DHSoftware/Views/SettingWindow.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/DHSoftware/Views/SettingWindow.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/DHSoftware/Views/SizeConfigControl.Designer.cs b/DHSoftware/Views/SizeConfigControl.Designer.cs index dfb92eb..5f94d86 100644 --- a/DHSoftware/Views/SizeConfigControl.Designer.cs +++ b/DHSoftware/Views/SizeConfigControl.Designer.cs @@ -30,18 +30,18 @@ { panel2 = new Panel(); label2 = new Label(); - button2 = new AntdUI.Button(); - table1 = new AntdUI.Table(); - button1 = new AntdUI.Button(); + btnDelSizeParm = new AntdUI.Button(); + tbSizeParm = new AntdUI.Table(); + btnAddSizeParm = new AntdUI.Button(); panel2.SuspendLayout(); SuspendLayout(); // // panel2 // panel2.Controls.Add(label2); - panel2.Controls.Add(button2); - panel2.Controls.Add(table1); - panel2.Controls.Add(button1); + panel2.Controls.Add(btnDelSizeParm); + panel2.Controls.Add(tbSizeParm); + panel2.Controls.Add(btnAddSizeParm); panel2.Location = new Point(3, 3); panel2.Name = "panel2"; panel2.Size = new Size(779, 286); @@ -54,31 +54,31 @@ label2.Name = "label2"; label2.Size = new Size(56, 17); label2.TabIndex = 25; - label2.Text = "模型参数"; + label2.Text = "尺寸参数"; // - // button2 + // btnDelSizeParm // - button2.Location = new Point(93, 25); - button2.Name = "button2"; - button2.Size = new Size(84, 34); - button2.TabIndex = 24; - button2.Text = "删除"; + btnDelSizeParm.Location = new Point(93, 25); + btnDelSizeParm.Name = "btnDelSizeParm"; + btnDelSizeParm.Size = new Size(84, 34); + btnDelSizeParm.TabIndex = 24; + btnDelSizeParm.Text = "删除"; // - // table1 + // tbSizeParm // - table1.Location = new Point(3, 65); - table1.Name = "table1"; - table1.Size = new Size(773, 218); - table1.TabIndex = 22; - table1.Text = "table1"; + tbSizeParm.Location = new Point(3, 65); + tbSizeParm.Name = "tbSizeParm"; + tbSizeParm.Size = new Size(773, 218); + tbSizeParm.TabIndex = 22; + tbSizeParm.Text = "table1"; // - // button1 + // btnAddSizeParm // - button1.Location = new Point(3, 25); - button1.Name = "button1"; - button1.Size = new Size(84, 34); - button1.TabIndex = 23; - button1.Text = "新增"; + btnAddSizeParm.Location = new Point(3, 25); + btnAddSizeParm.Name = "btnAddSizeParm"; + btnAddSizeParm.Size = new Size(84, 34); + btnAddSizeParm.TabIndex = 23; + btnAddSizeParm.Text = "新增"; // // SizeConfigControl // @@ -97,8 +97,8 @@ private Panel panel2; private Label label2; - private AntdUI.Button button2; - private AntdUI.Table table1; - private AntdUI.Button button1; + private AntdUI.Button btnDelSizeParm; + private AntdUI.Table tbSizeParm; + private AntdUI.Button btnAddSizeParm; } } diff --git a/DHSoftware/Views/UserConfigFrm.Designer.cs b/DHSoftware/Views/UserConfigFrm.Designer.cs index 296ab4d..c426746 100644 --- a/DHSoftware/Views/UserConfigFrm.Designer.cs +++ b/DHSoftware/Views/UserConfigFrm.Designer.cs @@ -29,53 +29,111 @@ private void InitializeComponent() { AntdUI.Tabs.StyleCard styleCard1 = new AntdUI.Tabs.StyleCard(); + pnlMenu = new AntdUI.Panel(); + panel3 = new AntdUI.Panel(); + btnSave = new AntdUI.Button(); + btnAdd = new AntdUI.Button(); menu = new AntdUI.Menu(); - UCFpanel1 = new Panel(); - panel1 = new Panel(); + panel2 = new AntdUI.Panel(); + divider1 = new AntdUI.Divider(); tabs = new AntdUI.Tabs(); - UCFpanel1.SuspendLayout(); + pnlMenu.SuspendLayout(); + panel3.SuspendLayout(); + panel2.SuspendLayout(); SuspendLayout(); // + // pnlMenu + // + pnlMenu.Controls.Add(panel3); + pnlMenu.Controls.Add(menu); + pnlMenu.Dock = DockStyle.Left; + pnlMenu.Location = new Point(0, 0); + pnlMenu.Name = "pnlMenu"; + pnlMenu.Size = new Size(135, 542); + pnlMenu.TabIndex = 0; + pnlMenu.Text = "panel1"; + // + // panel3 + // + panel3.Back = SystemColors.Window; + panel3.BackColor = SystemColors.Window; + panel3.Controls.Add(btnSave); + panel3.Controls.Add(btnAdd); + panel3.Dock = DockStyle.Bottom; + panel3.Location = new Point(0, 516); + panel3.Name = "panel3"; + panel3.Size = new Size(135, 26); + panel3.TabIndex = 2; + panel3.Text = "panel3"; + // + // 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, 26); + btnSave.TabIndex = 2; + // + // 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, 26); + btnAdd.TabIndex = 1; + btnAdd.Click += btnAdd_Click; + // // menu // - menu.Dock = DockStyle.Left; + menu.Dock = DockStyle.Fill; menu.Location = new Point(0, 0); menu.Name = "menu"; - menu.Size = new Size(127, 536); - menu.TabIndex = 8; + menu.Size = new Size(135, 542); + menu.TabIndex = 0; menu.Text = "menu1"; menu.SelectChanged += Menu_SelectChanged; + menu.MouseDown += Menu_MouseDown; // - // UCFpanel1 + // panel2 // - UCFpanel1.AutoSize = true; - UCFpanel1.Controls.Add(panel1); - UCFpanel1.Controls.Add(tabs); - UCFpanel1.Controls.Add(menu); - UCFpanel1.Dock = DockStyle.Fill; - UCFpanel1.Location = new Point(0, 0); - UCFpanel1.Name = "UCFpanel1"; - UCFpanel1.Size = new Size(749, 536); - UCFpanel1.TabIndex = 1; + panel2.Controls.Add(divider1); + panel2.Controls.Add(tabs); + panel2.Dock = DockStyle.Fill; + panel2.Location = new Point(135, 0); + panel2.Name = "panel2"; + panel2.Size = new Size(745, 542); + panel2.TabIndex = 1; + panel2.Text = "panel2"; // - // panel1 + // divider1 // - panel1.BackColor = SystemColors.Highlight; - panel1.Dock = DockStyle.Left; - panel1.Location = new Point(127, 0); - panel1.Name = "panel1"; - panel1.Size = new Size(5, 536); - panel1.TabIndex = 10; + divider1.BackColor = SystemColors.ActiveCaption; + divider1.Dock = DockStyle.Left; + divider1.Location = new Point(0, 0); + divider1.Name = "divider1"; + divider1.Size = new Size(10, 542); + divider1.TabIndex = 1; + divider1.Text = ""; + divider1.Vertical = true; // // tabs // tabs.Dock = DockStyle.Fill; - tabs.ForeColor = SystemColors.Control; - tabs.Location = new Point(127, 0); + tabs.Location = new Point(0, 0); tabs.Name = "tabs"; - tabs.Size = new Size(622, 536); + tabs.Size = new Size(745, 542); tabs.Style = styleCard1; - tabs.TabIndex = 9; + tabs.TabIndex = 0; tabs.Text = "tabs1"; tabs.Type = AntdUI.TabType.Card; tabs.SelectedIndexChanged += tabs_SelectedIndexChanged; @@ -85,19 +143,25 @@ AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleMode = AutoScaleMode.Font; AutoSize = true; - Controls.Add(UCFpanel1); + Controls.Add(panel2); + Controls.Add(pnlMenu); Name = "UserConfigFrm"; - Size = new Size(749, 536); - UCFpanel1.ResumeLayout(false); + Size = new Size(880, 542); + pnlMenu.ResumeLayout(false); + panel3.ResumeLayout(false); + panel2.ResumeLayout(false); ResumeLayout(false); - PerformLayout(); } #endregion - - private AntdUI.Menu menu; - private Panel UCFpanel1; private AntdUI.Tabs tabs; - private Panel panel1; + private AntdUI.Panel pnlMenu; + private AntdUI.Panel panel2; + private AntdUI.Menu menu; + private AntdUI.Panel panel3; + private AntdUI.Button btnSave; + private AntdUI.Button btnAdd; + private AntdUI.Divider divider1; + // private AntdUI.Tabs tabs; } } diff --git a/DHSoftware/Views/UserConfigFrm.cs b/DHSoftware/Views/UserConfigFrm.cs index 4177522..26ee30b 100644 --- a/DHSoftware/Views/UserConfigFrm.cs +++ b/DHSoftware/Views/UserConfigFrm.cs @@ -1,6 +1,7 @@ using AntdUI; using AntdUIDemo.Models; -using AntdUIDemo.Views; +using DH.Devices.Devices; +using DH.Devices.Vision; using System; using System.Collections.Generic; using System.ComponentModel; @@ -11,17 +12,21 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using static System.Windows.Forms.VisualStyles.VisualStyleElement; +using Window = AntdUI.Window; namespace DHSoftware.Views { public partial class UserConfigFrm : UserControl { + public List cameras = new List(); + public List detections = new List(); private UserControl currControl; private bool isUpdatingTabs = false;//用于阻止Tabs更新 + public Window Window; public UserConfigFrm() { InitializeComponent(); - + LoadMenu(); menu.Width = (int)(100 * Config.Dpi); @@ -104,15 +109,79 @@ namespace DHSoftware.Views } menu.SelectIndex(rootIndex, subIndex, true); } + private void Menu_MouseDown(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right) + { + // 转换坐标到控件内部坐标系(考虑滚动条) + Point clickPoint = new Point(e.X, e.Y + menu.ScrollBar.Value); + + // 递归查找命中的菜单项 + MenuItem clickedItem = FindClickedItem(menu.Items, clickPoint); + + if (clickedItem != null) + { + // 显示节点名称弹窗 + //MessageBox.Show($"右键点击的节点: {clickedItem.Text}"); + + var menulist = new AntdUI.IContextMenuStripItem[] + { + new AntdUI.ContextMenuStripItem("关联相机", "") + { + IconSvg = "VideoCameraAddOutlined" + } + }; + AntdUI.ContextMenuStrip.open(menu, it => + { + if (it.Text == "关联相机") + { + using (var dlg = new AddCameraWindow(cameras)) + { + if (dlg.ShowDialog() == DialogResult.OK) + { + var newItem = new MenuItem(dlg.CubicleName); + newItem.IconSvg = "VideoCameraOutlined"; + //// 防止重复添加 + //if (!menu1.Items.Cast().Any(m => m.Text == newItem.Text)) + //{ + clickedItem.Sub.Add(newItem); + //} + //else + //{ + // AntdUI.Notification.warn(this, "新增失败", $"{dlg.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR); + //} + } + } + } + }, menulist); + } + } + } + + private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint) + { + foreach (MenuItem item in items) + { + // 检查当前项是否可见且包含点击坐标 + if (item.Visible && item.Rect.Contains(clickPoint)) + { + return item; + } + + + } + return null; + } + private void Menu_SelectChanged(object sender, MenuSelectEventArgs e) { string name = (string)e.Value.Tag; - // 清理上一个浮动按钮窗体 - if (currControl is FloatButtonDemo floatButtonDemo) - { - floatButtonDemo.CloseFloatButtonForm(); - } + //// 清理上一个浮动按钮窗体 + //if (currControl is FloatButtonDemo floatButtonDemo) + //{ + // floatButtonDemo.CloseFloatButtonForm(); + //} // 检查是否已存在同名 TabPage foreach (var tab in tabs.Pages) @@ -129,11 +198,12 @@ namespace DHSoftware.Views int width = tabs.Width; int height = tabs.Height; // 创建新 TabPage - UserControl control =new UserDetetion(width, height); + UserDetetion control = new UserDetetion(width, height); + control._windows = Window; switch (name) { case "工位1": - // control = + // control = break; } @@ -144,7 +214,7 @@ namespace DHSoftware.Views var tabPage = new AntdUI.TabPage { - Dock = DockStyle.Fill, + Dock = DockStyle.Fill, Text = name, }; tabPage.Controls.Add(control); @@ -162,5 +232,26 @@ namespace DHSoftware.Views { SelectMenu(); } + + private void btnAdd_Click(object sender, EventArgs e) + { + using (var dlg = new AddCubicleWindow()) + { + if (dlg.ShowDialog() == DialogResult.OK) + { + var newItem = new MenuItem(dlg.CubicleName); + //newItem.IconSvg = "AppstoreOutlined"; + // 防止重复添加 + if (!menu.Items.Cast().Any(m => m.Text == newItem.Text)) + { + menu.Items.Add(newItem); + } + else + { + // AntdUI.Notification.warn(this, "新增工位失败", $"{dlg.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR); + } + } + } + } } } diff --git a/DHSoftware/Views/UserDetetion.Designer.cs b/DHSoftware/Views/UserDetetion.Designer.cs index 69319b4..92b08bc 100644 --- a/DHSoftware/Views/UserDetetion.Designer.cs +++ b/DHSoftware/Views/UserDetetion.Designer.cs @@ -65,5 +65,6 @@ private AntdUI.Collapse collapse1; private Panel panel1; + //private AntdUI.Button button1; } } diff --git a/DHSoftware/Views/UserDetetion.cs b/DHSoftware/Views/UserDetetion.cs index 480b1ba..2a70177 100644 --- a/DHSoftware/Views/UserDetetion.cs +++ b/DHSoftware/Views/UserDetetion.cs @@ -8,81 +8,218 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using Button = AntdUI.Button; namespace DHSoftware.Views { public partial class UserDetetion : UserControl { + private StackPanel panel, panel2, panel3, panel4; + public Window _windows; //根据检测配置 将对应的相机配置、中处理预处理、尺寸测量 public UserDetetion(int parentWidth, int parentHeight) { InitializeComponent(); AntdUI.CollapseItem group1 = new CollapseItem(); - group1.Height = parentHeight / 3; + group1.Height = parentHeight / 4; group1.Text = "相机配置"; AntdUI.CollapseItem group2 = new CollapseItem(); - group2.Text = "预处理中处理"; - group2.Height = parentHeight -300; + group2.Text = "预处理"; + group2.Height = parentHeight/4; + AntdUI.CollapseItem group3 = new CollapseItem(); - group3.Text = "尺寸测量"; - group3.Height = parentHeight/3; + group3.Text = "中处理"; + group3.Height = parentHeight - 300; + + AntdUI.CollapseItem group4 = new CollapseItem(); + group4.Text = "尺寸测量"; + group4.Height = parentHeight / 4; + // 初始化内容面板 + panel = CreateScrollPanel(); + panel2 = CreateScrollPanel(); + panel3 = CreateScrollPanel(); + panel4 = CreateScrollPanel(); - // 父容器(如 Panel)设置自动滚动 - System.Windows.Forms.Panel panel = new System.Windows.Forms.Panel - { - Dock = DockStyle.Fill, - AutoScroll = true // 关键:启用滚动条 - }; + // 添加预处理控件 + var ptuc = new PreTreatUserControl { AutoScroll = true, Dock = DockStyle.Top }; + var detect = new DetectConfigControl { AutoScroll = true , Dock = DockStyle.Fill }; + detect._window = this._windows; + // 添加尺寸测量控件 + var sizeFrm = new SizeConfigControl(); + - // 父容器(如 Panel)设置自动滚动 - System.Windows.Forms.FlowLayoutPanel panel2 = new System.Windows.Forms.FlowLayoutPanel - { - Dock = DockStyle.Fill, - AutoScroll = true // 关键:启用滚动条 - }; - - // 父容器(如 Panel)设置自动滚动 - System.Windows.Forms.Panel panel3 = new System.Windows.Forms.Panel - { - Dock = DockStyle.Fill, - AutoScroll = true // 关键:启用滚动条 - }; - - CameraConfigControl camConfigFrm = new CameraConfigControl(); camConfigFrm.Dock = DockStyle.Fill; + + + + //PreTreatUserControl ptuc = new PreTreatUserControl(); + //ptuc.AutoScroll = true; + //panel2.Controls.Add(ptuc); + //DetectConfigControl detect = new DetectConfigControl(); + //// detect.Dock = DockStyle.Fill; + //detect.AutoScroll = true; + //panel2.Controls.Add(detect); + + + //SizeConfigControl Sizefc = new SizeConfigControl(); + //Sizefc.Dock = DockStyle.Fill; + //panel3.Controls.Add(Sizefc); + + + + Button btnAddCam = new Button + { + Width = 100, + Height = 30, + Text = "添加相机配置", + //Dock=DockStyle.Bottom + }; + Button btnDelCam = new Button + { + Width = 100, + Height = 30, + Text = "删除相机配置", + // Dock = DockStyle.Bottom + }; + + + Button btnAddModel = new Button + { + Width = 100, + Height = 30, + Text = "添加模型配置", + //Dock=DockStyle.Bottom + }; + Button btnDelModel = new Button + { + Width = 100, + Height = 30, + Text = "删除模型配置", + // Dock = DockStyle.Bottom + }; + + FlowLayoutPanel flow = new FlowLayoutPanel(); + flow.Dock = DockStyle.Bottom; + flow.Controls.Add(btnAddCam); + flow.Controls.Add(btnDelCam); + + FlowLayoutPanel flowmodel = new FlowLayoutPanel(); + flowmodel.Dock = DockStyle.Bottom; + flowmodel.Controls.Add(btnAddModel); + flowmodel.Controls.Add(btnDelModel); + btnAddCam.Click += btnAddCam_Click; + btnDelCam.Click += btnDelCam_Click; + btnAddModel.Click += btnAddModel_Click; + btnDelModel.Click += btnDelModel_Click; + + panel.Controls.Add(flow); panel.Controls.Add(camConfigFrm); - - PreTreatUserControl ptuc = new PreTreatUserControl(); - ptuc.AutoScroll = true; + panel2.Controls.Add(ptuc); - DetectConfigControl detect = new DetectConfigControl(); - // detect.Dock = DockStyle.Fill; - detect.AutoScroll = true; - panel2.Controls.Add(detect); - - - SizeConfigControl Sizefc = new SizeConfigControl(); - Sizefc.Dock = DockStyle.Fill; - panel3.Controls.Add(Sizefc); - - - - + panel3.Controls.Add(flowmodel); + panel3.Controls.Add(detect); + panel4.Controls.Add(sizeFrm); group1.Controls.Add(panel); group2.Controls.Add(panel2); group3.Controls.Add(panel3); + group4.Controls.Add(panel4); //collapse1.Items.Add(group1); collapse1.Items.Add(group1); collapse1.Items.Add(group2); collapse1.Items.Add(group3); + collapse1.Items.Add(group4); } + + // 统一事件处理 + private void CameraOperation_Click(object sender, EventArgs e) + { + if (sender is Button btn) + { + switch (btn.Tag?.ToString()) + { + case "Add": + AddCameraConfig(); + break; + case "Delete": + DeleteCameraConfig(); + break; + } + } + } + + // 实际业务方法 + private void AddCameraConfig() + { + var newCamConfig = new CameraConfigControl { Dock = DockStyle.Top }; + panel.Controls.Add(newCamConfig); + panel.ScrollControlIntoView(newCamConfig); + } + + private void DeleteCameraConfig() + { + if (panel.Controls.Count > 1) + { + panel.Controls.RemoveAt(panel.Controls.Count - 2); + } + } + // 创建带滚动条的面板 + private StackPanel CreateScrollPanel() + { + return new StackPanel + { + Dock = DockStyle.Fill, + Vertical = true, + AutoScroll = true, + Padding = new Padding(5) // 添加内边距避免内容贴边 + }; + } + + private void btnAddCam_Click(object sender, EventArgs e) + { + CameraConfigControl camConfigFrm2 = new CameraConfigControl(); + camConfigFrm2.Dock = DockStyle.Fill; + + panel.Controls.Add(camConfigFrm2); + } + private void btnDelCam_Click(object sender, EventArgs e) + { + // 遍历 panel 的 Controls,找到最后一个 CameraConfigControl 并移除 + for (int i = panel.Controls.Count - 1; i >= 0; i--) + { + if (panel.Controls[i] is CameraConfigControl) + { + panel.Controls.RemoveAt(i); + break; // 只删除一个 + } + } + } + private void btnAddModel_Click(object sender, EventArgs e) + { + DetectConfigControl DetectFrm = new DetectConfigControl(); + DetectFrm._window = this._windows; + DetectFrm.Dock = DockStyle.Fill; + + panel3.Controls.Add(DetectFrm); + } + private void btnDelModel_Click(object sender, EventArgs e) + { + // 遍历 panel 的 Controls,找到最后一个 CameraConfigControl 并移除 + for (int i = panel3.Controls.Count - 1; i >= 0; i--) + { + if (panel3.Controls[i] is CameraConfigControl) + { + panel3.Controls.RemoveAt(i); + break; // 只删除一个 + } + } + } } }