句柄检测

This commit is contained in:
zqm
2026-03-25 13:21:24 +08:00
parent 9f0ae9afa9
commit ddcfe7aa86
2 changed files with 21 additions and 5 deletions

View File

@@ -17,6 +17,9 @@ namespace Camera
private const string USER = "admin";
private const string PASSWD = "Yexian.net.168";
// 调试模式
private const Boolean IsDebug = false;
// 配置文件目录
private string _configPath;
@@ -296,6 +299,11 @@ namespace Camera
/// </summary>
private Image GetCameraImage()
{
if (IsDebug)
{
if (File.Exists("test.jpg"))
return new Bitmap("test.jpg");
}
string url = "http://" + IP + SNAPSHOT_URI;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

View File

@@ -478,8 +478,8 @@ namespace Camera
return;
}
float scaleX = (float)imageWidth / picBoxCamera.ClientSize.Width;
float scaleY = (float)imageHeight / picBoxCamera.ClientSize.Height;
float scaleX = (float)picBoxCamera.ClientSize.Width / imageWidth;
float scaleY = (float)picBoxCamera.ClientSize.Height / imageHeight;
Rectangle detectionZone = _camera.GetDetectionZone();
Rectangle ledZone = _camera.GetLedZone();
@@ -501,9 +501,12 @@ namespace Camera
if (_isEditingDetectionZone || _isEditingLedZone)
{
Rectangle editRect = _isEditingDetectionZone ? scaledDetectionZone : scaledLedZone;
int handle = GetHoveredHandle(editRect, e.Location);
if (_hoveredHandle >= 0 && _isResizing)
if (_isResizing && handle >= 0)
{
picBoxCamera.Cursor = GetResizeCursor(handle);
int dx = e.Location.X - _resizeStartPoint.X;
int dy = e.Location.Y - _resizeStartPoint.Y;
@@ -562,7 +565,6 @@ namespace Camera
}
else
{
int handle = GetHoveredHandle(editRect, e.Location);
if (handle >= 0)
{
picBoxCamera.Cursor = GetResizeCursor(handle);
@@ -579,6 +581,8 @@ namespace Camera
}
else if (_isMoving)
{
picBoxCamera.Cursor = Cursors.SizeAll;
Point imagePoint = new Point((int)(e.X * scaleX), (int)(e.Y * scaleY));
int dx = imagePoint.X - _startPoint.X;
@@ -619,6 +623,7 @@ namespace Camera
_isEditingDetectionZone = false;
toolStripButton1.Checked = false;
toolStripButton1.ToolTipText = "修改检测区(点击开启)";
picBoxCamera.Invalidate();
return;
}
if (_isEditingLedZone)
@@ -626,6 +631,7 @@ namespace Camera
_isEditingLedZone = false;
toolStripButton2.Checked = false;
toolStripButton2.ToolTipText = "绘制Led区(点击开启)";
picBoxCamera.Invalidate();
return;
}
}
@@ -680,7 +686,7 @@ namespace Camera
private int GetHoveredHandle(Rectangle rect, Point point)
{
int handleSize = 10;
int handleSize = 8;
int[] xPoints = { rect.X, rect.X + rect.Width / 2, rect.X + rect.Width, rect.X + rect.Width, rect.X + rect.Width, rect.X + rect.Width / 2, rect.X, rect.X };
int[] yPoints = { rect.Y, rect.Y, rect.Y, rect.Y + rect.Height / 2, rect.Y + rect.Height, rect.Y + rect.Height, rect.Y + rect.Height, rect.Y + rect.Height / 2 };
@@ -799,6 +805,7 @@ namespace Camera
_selectedZoneIndex = -1;
toolStripButton1.ToolTipText = "修改检测区(点击开启)";
}
picBoxCamera.Invalidate();
UpdateDataGridView();
}
@@ -820,6 +827,7 @@ namespace Camera
_selectedZoneIndex = -1;
toolStripButton2.ToolTipText = "绘制Led区(点击开启)";
}
picBoxCamera.Invalidate();
UpdateDataGridView();
}