fix show image, fix zoom

This commit is contained in:
Alex Bezdieniezhnykh
2025-07-03 12:53:43 +03:00
parent bb6413c4f0
commit ea7c487493
4 changed files with 41 additions and 21 deletions
+19 -2
View File
@@ -43,6 +43,7 @@ public class DetectionControl : Border
private readonly Rectangle _selectionFrame;
private bool _isSelected;
public bool IsSelected
{
get => _isSelected;
@@ -53,6 +54,21 @@ public class DetectionControl : Border
}
}
public void UpdateAdornerScale(double scale)
{
if (Math.Abs(scale) < 0.0001)
return;
var inverseScale = 1.0 / scale;
BorderThickness = new Thickness(4 * inverseScale);
foreach (var rect in _resizedRectangles)
{
rect.Width = 2 * RESIZE_RECT_SIZE * inverseScale;
rect.Height = 2 * RESIZE_RECT_SIZE * inverseScale;;
rect.Margin = new Thickness(-RESIZE_RECT_SIZE * 0.7);
}
}
public (HorizontalAlignment Horizontal, VerticalAlignment Vertical) DetectionLabelPosition
{
get => (DetectionLabelContainer.HorizontalAlignment, DetectionLabelContainer.VerticalAlignment);
@@ -66,14 +82,15 @@ public class DetectionControl : Border
private string _detectionLabelText(string detectionClassName) =>
_confidence >= 0.995 ? detectionClassName : $"{detectionClassName}: {_confidence * 100:F0}%"; //double
public DetectionControl(DetectionClass detectionClass, TimeSpan time, Action<object, MouseButtonEventArgs> resizeStart, CanvasLabel canvasLabel)
public DetectionControl(DetectionClass detectionClass, TimeSpan time, Action<object,
MouseButtonEventArgs> resizeStart, CanvasLabel canvasLabel)
{
Width = canvasLabel.Width;
Height = canvasLabel.Height;
Time = time;
_resizeStart = resizeStart;
_confidence = canvasLabel.Confidence;
DetectionLabelContainer = new Canvas
{
HorizontalAlignment = HorizontalAlignment.Right,