编辑索引

This commit is contained in:
zqm
2026-03-26 09:08:34 +08:00
parent c460df73c9
commit 25f93232a8
2 changed files with 65 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ namespace Camera
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();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
@@ -101,7 +102,8 @@ namespace Camera
this.toolStripButton1,
this.toolStripButton2,
this.toolStripButton3,
this.toolStripButton4});
this.toolStripButton4,
this.toolStripTextBox1});
this.toolStrip1.Location = new System.Drawing.Point(0, 0);
this.toolStrip1.Name = "toolStrip1";
this.toolStrip1.Size = new System.Drawing.Size(80, 40);
@@ -144,6 +146,17 @@ namespace Camera
this.toolStripButton4.Visible = false;
this.toolStripButton4.Click += new System.EventHandler(this.ToolStripButton4_Click);
//
// toolStripTextBox1
//
this.toolStripTextBox1.Alignment = System.Windows.Forms.ToolStripItemAlignment.Right;
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);
this.toolStripTextBox1.ToolTipText = "Led区编号";
this.toolStripTextBox1.Visible = false;
this.toolStripTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ToolStripTextBox1_KeyDown);
this.toolStripTextBox1.TextChanged += new System.EventHandler(this.ToolStripTextBox1_TextChanged);
//
// dataGridView1
//
this.dataGridView1.AllowUserToAddRows = false;
@@ -199,6 +212,7 @@ namespace Camera
private System.Windows.Forms.ToolStripButton toolStripButton2;
private System.Windows.Forms.ToolStripButton toolStripButton3;
private System.Windows.Forms.ToolStripButton toolStripButton4;
private System.Windows.Forms.ToolStripTextBox toolStripTextBox1;
private System.Windows.Forms.DataGridView dataGridView1;
}
}

View File

@@ -1112,12 +1112,56 @@ namespace Camera
toolStripButton2.Visible = true;
toolStripButton2.ToolTipText = "绘制Led区(点击开启)";
toolStripButton1.Visible = true;
toolStripTextBox1.Visible = false;
toolStripTextBox1.Text = "";
UpdateLedZoneButtonsVisibility(0);
UpdateDataGridView();
picBoxCamera.Invalidate();
}
}
private void ToolStripTextBox1_TextChanged(object sender, EventArgs e)
{
if (_currentLedIndex >= 0 && int.TryParse(toolStripTextBox1.Text, out int newIndex))
{
if (newIndex > 0)
{
Rectangle ledZone = _camera.GetLedZone(_currentLedIndex);
Color ledColor = _camera.GetLedZoneColor(_currentLedIndex);
_camera.RemoveLedZone(_currentLedIndex);
_camera.AddLedZone(newIndex, ledZone, ledColor);
_currentLedIndex = newIndex;
_selectedZoneIndex = newIndex;
UpdateDataGridView();
picBoxCamera.Invalidate();
}
}
}
private void ToolStripTextBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (_currentLedIndex >= 0 && int.TryParse(toolStripTextBox1.Text, out int newIndex))
{
if (newIndex > 0)
{
Rectangle ledZone = _camera.GetLedZone(_currentLedIndex);
Color ledColor = _camera.GetLedZoneColor(_currentLedIndex);
_camera.RemoveLedZone(_currentLedIndex);
_camera.AddLedZone(newIndex, ledZone, ledColor);
_currentLedIndex = newIndex;
_selectedZoneIndex = newIndex;
toolStripTextBox1.Text = newIndex.ToString();
UpdateDataGridView();
picBoxCamera.Invalidate();
}
}
toolStripTextBox1.SelectAll();
e.SuppressKeyPress = true;
}
}
private void UpdateColorButtonIcon()
{
Color currentColor;
@@ -1154,16 +1198,22 @@ namespace Camera
toolStripButton2.Visible = true;
toolStripButton3.Visible = false;
toolStripButton4.Visible = false;
toolStripTextBox1.Visible = false;
toolStripTextBox1.Text = "";
break;
case 1: // 选中状态
toolStripButton2.Visible = false;
toolStripButton3.Visible = true;
toolStripButton4.Visible = true;
toolStripTextBox1.Visible = true;
toolStripTextBox1.Text = _currentLedIndex.ToString();
break;
case 2: // 绘制状态
toolStripButton2.Visible = true;
toolStripButton3.Visible = true;
toolStripButton4.Visible = false;
toolStripTextBox1.Visible = false;
toolStripTextBox1.Text = "";
break;
}
}