From 49092fd833df3d70c67b5545a830de474af4144d Mon Sep 17 00:00:00 2001 From: zqm Date: Thu, 26 Mar 2026 16:10:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E5=85=B7=E6=A0=8F?= =?UTF-8?q?=E6=8E=92=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Framework4.0/Camera/Camera/Camera.csproj | 7 +- .../Camera/Camera/Setting.Designer.cs | 80 ++++++++----- .../CS/Framework4.0/Camera/Camera/Setting.cs | 104 ++++++++++++++++ .../Framework4.0/Camera/Camera/Setting.resx | 3 + .../Camera/Camera/ToolStripNumericUpDown.cs | 111 ------------------ 5 files changed, 161 insertions(+), 144 deletions(-) delete mode 100644 Windows/CS/Framework4.0/Camera/Camera/ToolStripNumericUpDown.cs diff --git a/Windows/CS/Framework4.0/Camera/Camera/Camera.csproj b/Windows/CS/Framework4.0/Camera/Camera/Camera.csproj index 2a12287..7c4f9d4 100644 --- a/Windows/CS/Framework4.0/Camera/Camera/Camera.csproj +++ b/Windows/CS/Framework4.0/Camera/Camera/Camera.csproj @@ -1,4 +1,4 @@ - + @@ -48,13 +48,10 @@ - - Form - + Setting.cs - diff --git a/Windows/CS/Framework4.0/Camera/Camera/Setting.Designer.cs b/Windows/CS/Framework4.0/Camera/Camera/Setting.Designer.cs index b943dfb..7d59b1f 100644 --- a/Windows/CS/Framework4.0/Camera/Camera/Setting.Designer.cs +++ b/Windows/CS/Framework4.0/Camera/Camera/Setting.Designer.cs @@ -20,12 +20,14 @@ namespace Camera this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.picBoxCamera = new System.Windows.Forms.PictureBox(); this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.toolStripContainer1 = new System.Windows.Forms.ToolStripContainer(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.toolStripButton1 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton2 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton3 = new System.Windows.Forms.ToolStripButton(); this.toolStripButton4 = new System.Windows.Forms.ToolStripButton(); this.toolStripTextBox1 = new System.Windows.Forms.ToolStripTextBox(); + this.toolStrip2 = new System.Windows.Forms.ToolStrip(); this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel(); this.toolStripNumericUpDown1 = new ToolStripNumericUpDown(); this.toolStripLabel2 = new System.Windows.Forms.ToolStripLabel(); @@ -45,6 +47,8 @@ namespace Camera this.splitContainer2.Panel2.SuspendLayout(); this.splitContainer2.SuspendLayout(); this.toolStrip1.SuspendLayout(); + this.toolStrip2.SuspendLayout(); + this.toolStripContainer1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.SuspendLayout(); // @@ -91,8 +95,21 @@ namespace Camera // // splitContainer2.Panel1 // - this.splitContainer2.Panel1.Controls.Add(this.toolStrip1); - this.splitContainer2.Panel1MinSize = 40; + this.splitContainer2.Panel1.Controls.Add(this.toolStripContainer1); + this.splitContainer2.Panel1MinSize = 120; + // + // toolStripContainer1 + // + this.toolStripContainer1.Dock = System.Windows.Forms.DockStyle.Fill; + this.toolStripContainer1.Location = new System.Drawing.Point(0, 0); + this.toolStripContainer1.Name = "toolStripContainer1"; + this.toolStripContainer1.Size = new System.Drawing.Size(559, 120); + this.toolStripContainer1.TabIndex = 0; + this.toolStripContainer1.Text = "toolStripContainer1"; + this.toolStripContainer1.TopToolStripPanel.Dock = System.Windows.Forms.DockStyle.Top; + this.toolStripContainer1.TopToolStripPanel.Padding = new System.Windows.Forms.Padding(0); + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip1); + this.toolStripContainer1.TopToolStripPanel.Controls.Add(this.toolStrip2); // // splitContainer2.Panel2 // @@ -104,32 +121,24 @@ namespace Camera // // toolStrip1 // - this.toolStrip1.Dock = System.Windows.Forms.DockStyle.None; + this.toolStrip1.Dock = System.Windows.Forms.DockStyle.Top; + this.toolStrip1.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.HorizontalStackWithOverflow; this.toolStrip1.ImageScalingSize = new System.Drawing.Size(32, 32); this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripButton1, this.toolStripButton2, this.toolStripButton3, this.toolStripButton4, - this.toolStripTextBox1, - this.toolStripLabel1, - this.toolStripNumericUpDown1, - this.toolStripLabel2, - this.toolStripNumericUpDown2, - this.toolStripLabel3, - this.toolStripNumericUpDown3, - this.toolStripLabel4, - this.toolStripNumericUpDown4}); + this.toolStripTextBox1}); this.toolStrip1.Location = new System.Drawing.Point(0, 0); this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(58, 25); + this.toolStrip1.Size = new System.Drawing.Size(200, 25); this.toolStrip1.TabIndex = 0; this.toolStrip1.ItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.toolStrip1_ItemClicked); // // toolStripButton1 // this.toolStripButton1.CheckOnClick = true; - this.toolStripButton1.Checked = false; this.toolStripButton1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton1.Name = "toolStripButton1"; this.toolStripButton1.Size = new System.Drawing.Size(23, 22); @@ -139,7 +148,6 @@ namespace Camera // toolStripButton2 // this.toolStripButton2.CheckOnClick = true; - this.toolStripButton2.Checked = false; this.toolStripButton2.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; this.toolStripButton2.Name = "toolStripButton2"; this.toolStripButton2.Size = new System.Drawing.Size(23, 22); @@ -166,7 +174,7 @@ namespace Camera // // toolStripTextBox1 // - this.toolStripTextBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right; + this.toolStripTextBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Left; this.toolStripTextBox1.Margin = new System.Windows.Forms.Padding(0, 2, 3, 2); this.toolStripTextBox1.Name = "toolStripTextBox1"; this.toolStripTextBox1.Size = new System.Drawing.Size(60, 27); @@ -175,12 +183,29 @@ namespace Camera this.toolStripTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ToolStripTextBox1_KeyDown); this.toolStripTextBox1.TextChanged += new System.EventHandler(this.ToolStripTextBox1_TextChanged); // + // toolStrip2 + // + this.toolStrip2.Dock = System.Windows.Forms.DockStyle.Top; + this.toolStrip2.Location = new System.Drawing.Point(0, 25); + this.toolStrip2.ImageScalingSize = new System.Drawing.Size(32, 32); + this.toolStrip2.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripLabel1, + this.toolStripNumericUpDown1, + this.toolStripLabel2, + this.toolStripNumericUpDown2, + this.toolStripLabel3, + this.toolStripNumericUpDown3, + this.toolStripLabel4, + this.toolStripNumericUpDown4}); + this.toolStrip2.Name = "toolStrip2"; + this.toolStrip2.Size = new System.Drawing.Size(353, 30); + this.toolStrip2.TabIndex = 1; + // // toolStripLabel1 // this.toolStripLabel1.Name = "toolStripLabel1"; this.toolStripLabel1.Size = new System.Drawing.Size(23, 27); this.toolStripLabel1.Text = "X:"; - this.toolStripLabel1.Visible = false; // // toolStripNumericUpDown1 // @@ -209,7 +234,6 @@ namespace Camera 0, 0, 0}); - this.toolStripNumericUpDown1.Visible = false; this.toolStripNumericUpDown1.ValueChanged += new System.EventHandler(this.ToolStripNumericUpDown1_ValueChanged); // // toolStripLabel2 @@ -217,7 +241,6 @@ namespace Camera this.toolStripLabel2.Name = "toolStripLabel2"; this.toolStripLabel2.Size = new System.Drawing.Size(22, 27); this.toolStripLabel2.Text = "Y:"; - this.toolStripLabel2.Visible = false; // // toolStripNumericUpDown2 // @@ -246,15 +269,13 @@ namespace Camera 0, 0, 0}); - this.toolStripNumericUpDown2.Visible = false; this.toolStripNumericUpDown2.ValueChanged += new System.EventHandler(this.ToolStripNumericUpDown2_ValueChanged); // // toolStripLabel3 // this.toolStripLabel3.Name = "toolStripLabel3"; this.toolStripLabel3.Size = new System.Drawing.Size(28, 27); - this.toolStripLabel3.Text = "W:"; - this.toolStripLabel3.Visible = false; + this.toolStripLabel3.Text = "宽:"; // // toolStripNumericUpDown3 // @@ -283,15 +304,13 @@ namespace Camera 0, 0, 0}); - this.toolStripNumericUpDown3.Visible = false; this.toolStripNumericUpDown3.ValueChanged += new System.EventHandler(this.ToolStripNumericUpDown3_ValueChanged); // // toolStripLabel4 // this.toolStripLabel4.Name = "toolStripLabel4"; - this.toolStripLabel4.Size = new System.Drawing.Size(25, 27); - this.toolStripLabel4.Text = "H:"; - this.toolStripLabel4.Visible = false; + this.toolStripLabel4.Size = new System.Drawing.Size(28, 27); + this.toolStripLabel4.Text = "高:"; // // toolStripNumericUpDown4 // @@ -320,7 +339,6 @@ namespace Camera 0, 0, 0}); - this.toolStripNumericUpDown4.Visible = false; this.toolStripNumericUpDown4.ValueChanged += new System.EventHandler(this.ToolStripNumericUpDown4_ValueChanged); // // dataGridView1 @@ -331,9 +349,9 @@ namespace Camera this.dataGridView1.ColumnHeadersHeight = 25; this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill; + this.dataGridView1.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically; this.dataGridView1.Location = new System.Drawing.Point(0, 0); this.dataGridView1.Name = "dataGridView1"; - this.dataGridView1.ReadOnly = false; this.dataGridView1.RowHeadersVisible = false; this.dataGridView1.RowTemplate.Height = 25; this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -364,6 +382,10 @@ namespace Camera this.splitContainer2.ResumeLayout(false); this.toolStrip1.ResumeLayout(false); this.toolStrip1.PerformLayout(); + this.toolStrip2.ResumeLayout(false); + this.toolStrip2.PerformLayout(); + this.toolStripContainer1.ResumeLayout(false); + this.toolStripContainer1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit(); this.ResumeLayout(false); @@ -374,7 +396,9 @@ namespace Camera private System.Windows.Forms.SplitContainer splitContainer1; private System.Windows.Forms.SplitContainer splitContainer2; private System.Windows.Forms.PictureBox picBoxCamera; + private System.Windows.Forms.ToolStripContainer toolStripContainer1; private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.ToolStrip toolStrip2; private System.Windows.Forms.ToolStripButton toolStripButton1; private System.Windows.Forms.ToolStripButton toolStripButton2; private System.Windows.Forms.ToolStripButton toolStripButton3; diff --git a/Windows/CS/Framework4.0/Camera/Camera/Setting.cs b/Windows/CS/Framework4.0/Camera/Camera/Setting.cs index ad21752..dc81136 100644 --- a/Windows/CS/Framework4.0/Camera/Camera/Setting.cs +++ b/Windows/CS/Framework4.0/Camera/Camera/Setting.cs @@ -11,6 +11,110 @@ using System.Windows.Forms; namespace Camera { + // 自定义ToolStripNumericUpDown控件 + [System.ComponentModel.ToolboxItem(false)] + [System.ComponentModel.DesignerCategory("Code")] + public class ToolStripNumericUpDown : ToolStripControlHost + { + private NumericUpDown _numericUpDown; + + // 公开的无参构造函数 - 设计器必需 + public ToolStripNumericUpDown() : this(new NumericUpDown()) { } + + // 私有的带参数构造函数 - 仅用于无参构造函数调用 + private ToolStripNumericUpDown(NumericUpDown numericUpDown) : base(numericUpDown) + { + _numericUpDown = numericUpDown ?? throw new ArgumentNullException(nameof(numericUpDown)); + this.AutoSize = false; + + // 设置NumericUpDown的基本属性 + _numericUpDown.Size = new Size(60, 22); + _numericUpDown.TextAlign = HorizontalAlignment.Right; + } + + [System.ComponentModel.Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public NumericUpDown NumericUpDownControl => _numericUpDown; + + // 下面的属性、事件都保持不变 + public decimal Value + { + get => _numericUpDown.Value; + set => _numericUpDown.Value = value; + } + + public decimal Minimum + { + get => _numericUpDown.Minimum; + set => _numericUpDown.Minimum = value; + } + + public decimal Maximum + { + get => _numericUpDown.Maximum; + set => _numericUpDown.Maximum = value; + } + + public decimal Increment + { + get => _numericUpDown.Increment; + set => _numericUpDown.Increment = value; + } + + public int DecimalPlaces + { + get => _numericUpDown.DecimalPlaces; + set => _numericUpDown.DecimalPlaces = value; + } + + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public new string Text + { + get => _numericUpDown.Text; + set => _numericUpDown.Text = value; + } + + public event EventHandler ValueChanged; + + protected override void OnSubscribeControlEvents(Control control) + { + base.OnSubscribeControlEvents(control); + if (control is NumericUpDown nud) + nud.ValueChanged += Nud_ValueChanged; + } + + protected override void OnUnsubscribeControlEvents(Control control) + { + base.OnUnsubscribeControlEvents(control); + if (control is NumericUpDown nud) + nud.ValueChanged -= Nud_ValueChanged; + } + + private void Nud_ValueChanged(object sender, EventArgs e) + { + ValueChanged?.Invoke(this, e); + } + + protected override Size DefaultSize => new Size(60, 27); + + // 重写GetPreferredSize以改进布局 + public override Size GetPreferredSize(Size constrainingSize) + { + return new Size(base.GetPreferredSize(constrainingSize).Width, 27); + } + + // 清理资源 + protected override void Dispose(bool disposing) + { + if (disposing && _numericUpDown != null) + { + _numericUpDown.Dispose(); + } + base.Dispose(disposing); + } + } + public partial class Setting : Form { private Camera _camera; diff --git a/Windows/CS/Framework4.0/Camera/Camera/Setting.resx b/Windows/CS/Framework4.0/Camera/Camera/Setting.resx index 5da7a24..d48b6fe 100644 --- a/Windows/CS/Framework4.0/Camera/Camera/Setting.resx +++ b/Windows/CS/Framework4.0/Camera/Camera/Setting.resx @@ -118,6 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 147, 17 + + 17, 17 \ No newline at end of file diff --git a/Windows/CS/Framework4.0/Camera/Camera/ToolStripNumericUpDown.cs b/Windows/CS/Framework4.0/Camera/Camera/ToolStripNumericUpDown.cs deleted file mode 100644 index abb3c80..0000000 --- a/Windows/CS/Framework4.0/Camera/Camera/ToolStripNumericUpDown.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.ComponentModel; -using System.Drawing; -using System.Windows.Forms; - -namespace Camera -{ - // 自定义ToolStripNumericUpDown控件 - [System.ComponentModel.ToolboxItem(false)] - [System.ComponentModel.DesignerCategory("Code")] - public class ToolStripNumericUpDown : ToolStripControlHost - { - private NumericUpDown _numericUpDown; - - // 公开的无参构造函数 - 设计器必需 - public ToolStripNumericUpDown() : this(new NumericUpDown()) { } - - // 私有的带参数构造函数 - 仅用于无参构造函数调用 - private ToolStripNumericUpDown(NumericUpDown numericUpDown) : base(numericUpDown) - { - _numericUpDown = numericUpDown ?? throw new ArgumentNullException(nameof(numericUpDown)); - this.AutoSize = false; - - // 设置NumericUpDown的基本属性 - _numericUpDown.Size = new Size(60, 22); - _numericUpDown.TextAlign = HorizontalAlignment.Right; - } - - [System.ComponentModel.Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public NumericUpDown NumericUpDownControl => _numericUpDown; - - // 下面的属性、事件都保持不变 - public decimal Value - { - get => _numericUpDown.Value; - set => _numericUpDown.Value = value; - } - - public decimal Minimum - { - get => _numericUpDown.Minimum; - set => _numericUpDown.Minimum = value; - } - - public decimal Maximum - { - get => _numericUpDown.Maximum; - set => _numericUpDown.Maximum = value; - } - - public decimal Increment - { - get => _numericUpDown.Increment; - set => _numericUpDown.Increment = value; - } - - public int DecimalPlaces - { - get => _numericUpDown.DecimalPlaces; - set => _numericUpDown.DecimalPlaces = value; - } - - [Browsable(false)] - [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] - public new string Text - { - get => _numericUpDown.Text; - set => _numericUpDown.Text = value; - } - - public event EventHandler ValueChanged; - - protected override void OnSubscribeControlEvents(Control control) - { - base.OnSubscribeControlEvents(control); - if (control is NumericUpDown nud) - nud.ValueChanged += Nud_ValueChanged; - } - - protected override void OnUnsubscribeControlEvents(Control control) - { - base.OnUnsubscribeControlEvents(control); - if (control is NumericUpDown nud) - nud.ValueChanged -= Nud_ValueChanged; - } - - private void Nud_ValueChanged(object sender, EventArgs e) - { - ValueChanged?.Invoke(this, e); - } - - protected override Size DefaultSize => new Size(60, 27); - - // 重写GetPreferredSize以改进布局 - public override Size GetPreferredSize(Size constrainingSize) - { - return new Size(base.GetPreferredSize(constrainingSize).Width, 27); - } - - // 清理资源 - protected override void Dispose(bool disposing) - { - if (disposing && _numericUpDown != null) - { - _numericUpDown.Dispose(); - } - base.Dispose(disposing); - } - } -}