实现微调
This commit is contained in:
@@ -129,6 +129,7 @@ namespace Camera
|
||||
// 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);
|
||||
@@ -138,6 +139,7 @@ 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);
|
||||
@@ -331,7 +333,7 @@ namespace Camera
|
||||
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView1.Name = "dataGridView1";
|
||||
this.dataGridView1.ReadOnly = true;
|
||||
this.dataGridView1.ReadOnly = false;
|
||||
this.dataGridView1.RowHeadersVisible = false;
|
||||
this.dataGridView1.RowTemplate.Height = 25;
|
||||
this.dataGridView1.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
|
||||
@@ -31,9 +31,10 @@ namespace Camera
|
||||
private Rectangle _originalResizeRect;
|
||||
private int _hoveredHandle = -1;
|
||||
private int _currentLedIndex = -1;
|
||||
private int[] _handleOffsetsX = { 0, 1, 2, 2, 2, 1, 0, 0 };
|
||||
private int[] _handleOffsetsX = { 0, 1, 2, 2, 1, 0, 0 };
|
||||
private int[] _handleOffsetsY = { 0, 0, 0, 1, 2, 2, 2, 1 };
|
||||
|
||||
private int _lastSelectedZoneIndex = -1;
|
||||
private bool _isUpdatingDataGridView = false;
|
||||
public Setting()
|
||||
{
|
||||
InitializeComponent();
|
||||
@@ -104,6 +105,7 @@ namespace Camera
|
||||
splitContainer1.SplitterDistance = splitContainer1.Width - 380;
|
||||
splitContainer2.Panel1MinSize = 40;
|
||||
UpdateDataGridView();
|
||||
UpdateLedZoneButtonsVisibility(0);
|
||||
}
|
||||
|
||||
private void CreateToolIcons()
|
||||
@@ -232,6 +234,8 @@ namespace Camera
|
||||
|
||||
private void UpdateDataGridView()
|
||||
{
|
||||
if (_isUpdatingDataGridView) return;
|
||||
_isUpdatingDataGridView = true;
|
||||
dataGridView1.Rows.Clear();
|
||||
|
||||
if (_camera != null)
|
||||
@@ -249,8 +253,8 @@ namespace Camera
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
picBoxCamera.Invalidate();
|
||||
_isUpdatingDataGridView = false;
|
||||
}
|
||||
|
||||
private void PicBoxCamera_Paint(object sender, PaintEventArgs e)
|
||||
@@ -589,8 +593,6 @@ namespace Camera
|
||||
_isDrawingLedMode = false;
|
||||
_currentLedIndex = clickedLedIndex;
|
||||
_selectedZoneIndex = clickedLedIndex;
|
||||
toolStripButton2.Checked = false;
|
||||
toolStripButton2.Visible = false;
|
||||
toolStripButton1.Visible = false;
|
||||
UpdateLedZoneButtonsVisibility(1);
|
||||
UpdateColorButtonIcon();
|
||||
@@ -645,7 +647,6 @@ namespace Camera
|
||||
_isDrawingLedMode = true; // 确保处于LED绘制模式
|
||||
_startPoint = imagePoint;
|
||||
_resizeStartPoint = controlPoint;
|
||||
toolStripButton2.Checked = true; // 保持LED编辑按钮按下状态
|
||||
UpdateLedZoneButtonsVisibility(2);
|
||||
}
|
||||
}
|
||||
@@ -1022,21 +1023,25 @@ namespace Camera
|
||||
|
||||
private void DataGridView1_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
System.Diagnostics.Debug.WriteLine("DataGridView1_SelectionChanged 被触发, SelectedRows.Count=" + dataGridView1.SelectedRows.Count);
|
||||
if (dataGridView1.SelectedRows.Count > 0)
|
||||
{
|
||||
_selectedZoneIndex = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Index"].Value);
|
||||
// 更新位置和宽高值
|
||||
if (_selectedZoneIndex >= 0 && _camera != null)
|
||||
int newSelectedZoneIndex = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Index"].Value);
|
||||
if (newSelectedZoneIndex != _lastSelectedZoneIndex)
|
||||
{
|
||||
Rectangle zone = _camera.GetLedZone(_selectedZoneIndex);
|
||||
toolStripNumericUpDown1.Value = zone.X;
|
||||
toolStripNumericUpDown2.Value = zone.Y;
|
||||
toolStripNumericUpDown3.Value = zone.Width;
|
||||
toolStripNumericUpDown4.Value = zone.Height;
|
||||
_lastSelectedZoneIndex = newSelectedZoneIndex;
|
||||
_selectedZoneIndex = newSelectedZoneIndex;
|
||||
// 更新位置和宽高值
|
||||
if (_selectedZoneIndex >= 0 && _camera != null)
|
||||
{
|
||||
Rectangle zone = _camera.GetLedZone(_selectedZoneIndex);
|
||||
toolStripNumericUpDown1.Value = zone.X;
|
||||
toolStripNumericUpDown2.Value = zone.Y;
|
||||
toolStripNumericUpDown3.Value = zone.Width;
|
||||
toolStripNumericUpDown4.Value = zone.Height;
|
||||
}
|
||||
picBoxCamera.Invalidate();
|
||||
}
|
||||
// 确保控件在就绪状态下显示
|
||||
UpdateLedZoneButtonsVisibility(0);
|
||||
picBoxCamera.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1048,11 +1053,9 @@ namespace Camera
|
||||
_isEditingLedZone = false;
|
||||
_selectedZoneIndex = 0;
|
||||
toolStripButton1.ToolTipText = "修改检测区(点击关闭)";
|
||||
toolStripButton2.Checked = false;
|
||||
toolStripButton2.Visible = false;
|
||||
toolStripButton3.Visible = true;
|
||||
UpdateColorButtonIcon();
|
||||
toolStripButton2.ToolTipText = "绘制Led区(点击开启/关闭)";
|
||||
toolStripButton2.ToolTipText = "绘制Led区(点击开启)";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1313,7 +1316,6 @@ namespace Camera
|
||||
Rectangle zone = _camera.GetLedZone(index);
|
||||
zone.X = x;
|
||||
_camera.SetLedZone(index, zone);
|
||||
UpdateDataGridView();
|
||||
picBoxCamera.Invalidate();
|
||||
}
|
||||
|
||||
@@ -1327,7 +1329,6 @@ namespace Camera
|
||||
Rectangle zone = _camera.GetLedZone(index);
|
||||
zone.Y = y;
|
||||
_camera.SetLedZone(index, zone);
|
||||
UpdateDataGridView();
|
||||
picBoxCamera.Invalidate();
|
||||
}
|
||||
|
||||
@@ -1341,7 +1342,6 @@ namespace Camera
|
||||
Rectangle zone = _camera.GetLedZone(index);
|
||||
zone.Width = width;
|
||||
_camera.SetLedZone(index, zone);
|
||||
UpdateDataGridView();
|
||||
picBoxCamera.Invalidate();
|
||||
}
|
||||
|
||||
@@ -1355,7 +1355,6 @@ namespace Camera
|
||||
Rectangle zone = _camera.GetLedZone(index);
|
||||
zone.Height = height;
|
||||
_camera.SetLedZone(index, zone);
|
||||
UpdateDataGridView();
|
||||
picBoxCamera.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user