diff --git a/Windows/CS/Framework4.0/Camera/Camera/Setting.cs b/Windows/CS/Framework4.0/Camera/Camera/Setting.cs index 7aa05f2..fb27f30 100644 --- a/Windows/CS/Framework4.0/Camera/Camera/Setting.cs +++ b/Windows/CS/Framework4.0/Camera/Camera/Setting.cs @@ -339,6 +339,31 @@ namespace Camera 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 y = (int)(Math.Min(_startPoint.Y, _startPoint.Y + (_currentMousePoint.Y - _resizeStartPoint.Y) / scaleY) * scaleY); int w = (int)(Math.Abs(_currentMousePoint.X - _resizeStartPoint.X)); @@ -601,10 +626,14 @@ namespace Camera _resizeStartPoint = controlPoint; _originalZone = _isEditingDetectionZone ? detectionZone : ledZone; } - else if (_isDrawingLedMode) + else if ((_isDrawingLedMode || _isEditingLedZone) && !clickedOnLedZone) { _currentLedIndex = -1; _selectedZoneIndex = -1; + if (_isEditingLedZone) + { + _isEditingLedZone = false; + } _isDrawing = true; _startPoint = imagePoint; _resizeStartPoint = controlPoint; @@ -613,7 +642,7 @@ namespace Camera } else { - if (detectionZone.Contains(imagePoint)) + if (_isEditingDetectionZone && detectionZone.Contains(imagePoint)) { _selectedZoneIndex = 0; _isMoving = true; @@ -621,11 +650,11 @@ namespace Camera _resizeStartPoint = controlPoint; _originalZone = detectionZone; } - else + else if (!_isEditingDetectionZone && !_isEditingLedZone && !_isDrawingLedMode) { _selectedZoneIndex = -1; - _isDrawing = true; - _startPoint = imagePoint; + _isDrawing = false; + picBoxCamera.Invalidate(); } } @@ -1013,6 +1042,9 @@ namespace Camera { _isDrawingLedMode = true; _isEditingDetectionZone = false; + _isMoving = false; + _isResizing = false; + _isDrawing = false; _selectedZoneIndex = -1; _currentLedIndex = -1; toolStripButton2.ToolTipText = "绘制Led区(点击关闭)";