rework autoupdate to script only

zoom fix
This commit is contained in:
Alex Bezdieniezhnykh
2025-07-06 23:22:21 +03:00
parent 75d3a2412f
commit 6229ca8a03
12 changed files with 179 additions and 80 deletions
+19 -9
View File
@@ -126,9 +126,26 @@ public class CanvasEditor : Canvas
public void SetImageSource(ImageSource? source)
{
SetZoom();
_backgroundImage.Source = source;
}
private void SetZoom(Matrix? matrix = null)
{
if (matrix == null)
{
_matrixTransform.Matrix = Matrix.Identity;
_isZoomedIn = false;
}
else
{
_matrixTransform.Matrix = matrix.Value;
_isZoomedIn = true;
}
foreach (var detection in CurrentDetections)
detection.UpdateAdornerScale(scale: _matrixTransform.Matrix.M11);
}
private void CanvasWheel(object sender, MouseWheelEventArgs e)
{
if (Keyboard.Modifiers != ModifierKeys.Control)
@@ -139,19 +156,12 @@ public class CanvasEditor : Canvas
var matrix = _matrixTransform.Matrix;
if (scale < 1 && matrix.M11 * scale < 1.0)
{
_matrixTransform.Matrix = Matrix.Identity;
_isZoomedIn = false;
}
SetZoom();
else
{
matrix.ScaleAt(scale, scale, mousePos.X, mousePos.Y);
_matrixTransform.Matrix = matrix;
_isZoomedIn = true;
SetZoom(matrix);
}
foreach (var detection in CurrentDetections)
detection.UpdateAdornerScale(scale: _matrixTransform.Matrix.M11);
}
private void Init(object sender, RoutedEventArgs e)