add manual Tile Processor

zoom on video on pause (temp image)
This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-07-28 12:39:52 +03:00
parent fefd054ea0
commit fc6e5db795
34 changed files with 716 additions and 209 deletions
+16 -9
View File
@@ -6,6 +6,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Azaion.Common.DTO;
using Azaion.Common.Events;
using MediatR;
using Color = System.Windows.Media.Color;
using Image = System.Windows.Controls.Image;
@@ -34,10 +35,10 @@ public class CanvasEditor : Canvas
private Point _panStartPoint;
private bool _isZoomedIn;
private const int MIN_SIZE = 20;
private const int MIN_SIZE = 12;
private readonly TimeSpan _viewThreshold = TimeSpan.FromMilliseconds(400);
private Image _backgroundImage { get; set; } = new() { Stretch = Stretch.Fill };
public Image BackgroundImage { get; set; } = new() { Stretch = Stretch.Uniform };
public IMediator Mediator { get; set; } = null!;
public static readonly DependencyProperty GetTimeFuncProp =
@@ -113,7 +114,7 @@ public class CanvasEditor : Canvas
MouseUp += CanvasMouseUp;
SizeChanged += CanvasResized;
Cursor = Cursors.Cross;
Children.Insert(0, _backgroundImage);
Children.Insert(0, BackgroundImage);
Children.Add(_newAnnotationRect);
Children.Add(_horizontalLine);
Children.Add(_verticalLine);
@@ -127,7 +128,7 @@ public class CanvasEditor : Canvas
public void SetBackground(ImageSource? source)
{
SetZoom();
_backgroundImage.Source = source;
BackgroundImage.Source = source;
}
private void SetZoom(Matrix? matrix = null)
@@ -142,8 +143,8 @@ public class CanvasEditor : Canvas
_matrixTransform.Matrix = matrix.Value;
_isZoomedIn = true;
}
foreach (var detection in CurrentDetections)
detection.UpdateAdornerScale(scale: _matrixTransform.Matrix.M11);
// foreach (var detection in CurrentDetections)
// detection.UpdateAdornerScale(scale: _matrixTransform.Matrix.M11);
}
private void CanvasWheel(object sender, MouseWheelEventArgs e)
@@ -175,6 +176,8 @@ public class CanvasEditor : Canvas
private void CanvasMouseDown(object sender, MouseButtonEventArgs e)
{
ClearSelections();
if (e.LeftButton != MouseButtonState.Pressed)
return;
if (Keyboard.Modifiers == ModifierKeys.Control && _isZoomedIn)
{
_panStartPoint = e.GetPosition(this);
@@ -182,11 +185,13 @@ public class CanvasEditor : Canvas
}
else
NewAnnotationStart(sender, e);
(sender as UIElement)?.CaptureMouse();
}
private void CanvasMouseMove(object sender, MouseEventArgs e)
{
var pos = e.GetPosition(this);
Mediator.Publish(new SetStatusTextEvent($"Mouse Coordinates: {pos.X}, {pos.Y}"));
_horizontalLine.Y1 = _horizontalLine.Y2 = pos.Y;
_verticalLine.X1 = _verticalLine.X2 = pos.X;
SetLeft(_classNameHint, pos.X + 10);
@@ -216,11 +221,14 @@ public class CanvasEditor : Canvas
var matrix = _matrixTransform.Matrix;
matrix.Translate(delta.X, delta.Y);
_matrixTransform.Matrix = matrix;
Mediator.Publish(new SetStatusTextEvent(_matrixTransform.Matrix.ToString()));
}
private void CanvasMouseUp(object sender, MouseButtonEventArgs e)
{
(sender as UIElement)?.ReleaseMouseCapture();
if (SelectionState == SelectionState.NewAnnCreating)
{
var endPos = e.GetPosition(this);
@@ -279,8 +287,8 @@ public class CanvasEditor : Canvas
{
_horizontalLine.X2 = e.NewSize.Width;
_verticalLine.Y2 = e.NewSize.Height;
_backgroundImage.Width = e.NewSize.Width;
_backgroundImage.Height = e.NewSize.Height;
BackgroundImage.Width = e.NewSize.Width;
BackgroundImage.Height = e.NewSize.Height;
}
#region Annotation Resizing & Moving
@@ -383,7 +391,6 @@ public class CanvasEditor : Canvas
private void NewAnnotationStart(object sender, MouseButtonEventArgs e)
{
_newAnnotationStartPos = e.GetPosition(this);
SetLeft(_newAnnotationRect, _newAnnotationStartPos.X);
SetTop(_newAnnotationRect, _newAnnotationStartPos.Y);
_newAnnotationRect.MouseMove += NewAnnotationCreatingMove;