取消选定
This commit is contained in:
@@ -339,6 +339,31 @@ namespace Camera
|
|||||||
g.DrawRectangle(pen, scaledDetectionZone);
|
g.DrawRectangle(pen, scaledDetectionZone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var allLedZones = _camera.GetLedZones();
|
||||||
|
foreach (var kvp in allLedZones)
|
||||||
|
{
|
||||||
|
int index = kvp.Key;
|
||||||
|
Rectangle ledZone = kvp.Value;
|
||||||
|
Color ledColor = _camera.GetLedZoneColor(index);
|
||||||
|
|
||||||
|
Rectangle scaledLed = new Rectangle(
|
||||||
|
(int)(ledZone.X * scaleX),
|
||||||
|
(int)(ledZone.Y * scaleY),
|
||||||
|
(int)(ledZone.Width * scaleX),
|
||||||
|
(int)(ledZone.Height * scaleY)
|
||||||
|
);
|
||||||
|
|
||||||
|
using (Pen ledPen = new Pen(ledColor, 2))
|
||||||
|
{
|
||||||
|
g.DrawRectangle(ledPen, scaledLed);
|
||||||
|
}
|
||||||
|
|
||||||
|
using (Font font = new Font("Arial", 10))
|
||||||
|
{
|
||||||
|
g.DrawString(index.ToString(), font, new SolidBrush(ledColor), scaledLed.X, scaledLed.Y - 15);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int x = (int)(Math.Min(_startPoint.X, _startPoint.X + (_currentMousePoint.X - _resizeStartPoint.X) / scaleX) * scaleX);
|
int x = (int)(Math.Min(_startPoint.X, _startPoint.X + (_currentMousePoint.X - _resizeStartPoint.X) / scaleX) * scaleX);
|
||||||
int y = (int)(Math.Min(_startPoint.Y, _startPoint.Y + (_currentMousePoint.Y - _resizeStartPoint.Y) / scaleY) * scaleY);
|
int y = (int)(Math.Min(_startPoint.Y, _startPoint.Y + (_currentMousePoint.Y - _resizeStartPoint.Y) / scaleY) * scaleY);
|
||||||
int w = (int)(Math.Abs(_currentMousePoint.X - _resizeStartPoint.X));
|
int w = (int)(Math.Abs(_currentMousePoint.X - _resizeStartPoint.X));
|
||||||
@@ -601,10 +626,14 @@ namespace Camera
|
|||||||
_resizeStartPoint = controlPoint;
|
_resizeStartPoint = controlPoint;
|
||||||
_originalZone = _isEditingDetectionZone ? detectionZone : ledZone;
|
_originalZone = _isEditingDetectionZone ? detectionZone : ledZone;
|
||||||
}
|
}
|
||||||
else if (_isDrawingLedMode)
|
else if ((_isDrawingLedMode || _isEditingLedZone) && !clickedOnLedZone)
|
||||||
{
|
{
|
||||||
_currentLedIndex = -1;
|
_currentLedIndex = -1;
|
||||||
_selectedZoneIndex = -1;
|
_selectedZoneIndex = -1;
|
||||||
|
if (_isEditingLedZone)
|
||||||
|
{
|
||||||
|
_isEditingLedZone = false;
|
||||||
|
}
|
||||||
_isDrawing = true;
|
_isDrawing = true;
|
||||||
_startPoint = imagePoint;
|
_startPoint = imagePoint;
|
||||||
_resizeStartPoint = controlPoint;
|
_resizeStartPoint = controlPoint;
|
||||||
@@ -613,7 +642,7 @@ namespace Camera
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (detectionZone.Contains(imagePoint))
|
if (_isEditingDetectionZone && detectionZone.Contains(imagePoint))
|
||||||
{
|
{
|
||||||
_selectedZoneIndex = 0;
|
_selectedZoneIndex = 0;
|
||||||
_isMoving = true;
|
_isMoving = true;
|
||||||
@@ -621,11 +650,11 @@ namespace Camera
|
|||||||
_resizeStartPoint = controlPoint;
|
_resizeStartPoint = controlPoint;
|
||||||
_originalZone = detectionZone;
|
_originalZone = detectionZone;
|
||||||
}
|
}
|
||||||
else
|
else if (!_isEditingDetectionZone && !_isEditingLedZone && !_isDrawingLedMode)
|
||||||
{
|
{
|
||||||
_selectedZoneIndex = -1;
|
_selectedZoneIndex = -1;
|
||||||
_isDrawing = true;
|
_isDrawing = false;
|
||||||
_startPoint = imagePoint;
|
picBoxCamera.Invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1013,6 +1042,9 @@ namespace Camera
|
|||||||
{
|
{
|
||||||
_isDrawingLedMode = true;
|
_isDrawingLedMode = true;
|
||||||
_isEditingDetectionZone = false;
|
_isEditingDetectionZone = false;
|
||||||
|
_isMoving = false;
|
||||||
|
_isResizing = false;
|
||||||
|
_isDrawing = false;
|
||||||
_selectedZoneIndex = -1;
|
_selectedZoneIndex = -1;
|
||||||
_currentLedIndex = -1;
|
_currentLedIndex = -1;
|
||||||
toolStripButton2.ToolTipText = "绘制Led区(点击关闭)";
|
toolStripButton2.ToolTipText = "绘制Led区(点击关闭)";
|
||||||
|
|||||||
Reference in New Issue
Block a user