From fefd054ea0dce6379287dbb06e280a61a580556c Mon Sep 17 00:00:00 2001 From: Alex Bezdieniezhnykh Date: Fri, 11 Jul 2025 22:46:25 +0300 Subject: [PATCH] fixed selection on editor fixed image view and play --- Azaion.Annotator/Annotator.xaml.cs | 4 ++-- Azaion.Annotator/AnnotatorEventHandler.cs | 6 ++--- Azaion.Common/Controls/CanvasEditor.cs | 28 +++++++++++------------ 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Azaion.Annotator/Annotator.xaml.cs b/Azaion.Annotator/Annotator.xaml.cs index 958cce2..bc2091f 100644 --- a/Azaion.Annotator/Annotator.xaml.cs +++ b/Azaion.Annotator/Annotator.xaml.cs @@ -304,7 +304,7 @@ public partial class Annotator { if (File.Exists(annotation.ImagePath)) { - Editor.SetImageSource(await annotation.ImagePath.OpenImage()); + Editor.SetBackground(await annotation.ImagePath.OpenImage()); _formState.BackgroundTime = annotation.Time; videoSize = Editor.RenderSize; } @@ -534,7 +534,7 @@ public partial class Annotator if (LvFiles.SelectedIndex == -1) LvFiles.SelectedIndex = 0; - Dispatcher.Invoke(() => Editor.ResetBackground()); + Dispatcher.Invoke(() => Editor.SetBackground(null)); IsInferenceNow = true; AIDetectBtn.IsEnabled = false; diff --git a/Azaion.Annotator/AnnotatorEventHandler.cs b/Azaion.Annotator/AnnotatorEventHandler.cs index 37d1aba..92dc415 100644 --- a/Azaion.Annotator/AnnotatorEventHandler.cs +++ b/Azaion.Annotator/AnnotatorEventHandler.cs @@ -143,7 +143,7 @@ public class AnnotatorEventHandler( if (formState.BackgroundTime.HasValue) { - mainWindow.Editor.ResetBackground(); + mainWindow.Editor.SetBackground(null); formState.BackgroundTime = null; } break; @@ -226,7 +226,7 @@ public class AnnotatorEventHandler( if (mainWindow.LvFiles.SelectedItem == null) return; var mediaInfo = (MediaFileInfo)mainWindow.LvFiles.SelectedItem; - mainWindow.Editor.ResetBackground(); + mainWindow.Editor.SetBackground(null); formState.CurrentMedia = mediaInfo; mainWindow.Title = $"Azaion Annotator - {mediaInfo.Name}"; @@ -262,7 +262,7 @@ public class AnnotatorEventHandler( if (formState.BackgroundTime.HasValue) { //no need to save image, it's already there, just remove background - mainWindow.Editor.ResetBackground(); + mainWindow.Editor.SetBackground(null); formState.BackgroundTime = null; //next item diff --git a/Azaion.Common/Controls/CanvasEditor.cs b/Azaion.Common/Controls/CanvasEditor.cs index c2dd310..15ab798 100644 --- a/Azaion.Common/Controls/CanvasEditor.cs +++ b/Azaion.Common/Controls/CanvasEditor.cs @@ -124,7 +124,7 @@ public class CanvasEditor : Canvas MouseWheel += CanvasWheel; } - public void SetImageSource(ImageSource? source) + public void SetBackground(ImageSource? source) { SetZoom(); _backgroundImage.Source = source; @@ -228,20 +228,20 @@ public class CanvasEditor : Canvas _newAnnotationRect.Height = 0; var width = Math.Abs(endPos.X - _newAnnotationStartPos.X); var height = Math.Abs(endPos.Y - _newAnnotationStartPos.Y); - if (width < MIN_SIZE || height < MIN_SIZE) - return; - - var time = GetTimeFunc(); - var control = CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel + if (width >= MIN_SIZE && height >= MIN_SIZE) { - Width = width, - Height = height, - X = Math.Min(endPos.X, _newAnnotationStartPos.X), - Y = Math.Min(endPos.Y, _newAnnotationStartPos.Y), - Confidence = 1 - }); - control.UpdateLayout(); - CheckLabelBoundaries(control); + var time = GetTimeFunc(); + var control = CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel + { + Width = width, + Height = height, + X = Math.Min(endPos.X, _newAnnotationStartPos.X), + Y = Math.Min(endPos.Y, _newAnnotationStartPos.Y), + Confidence = 1 + }); + control.UpdateLayout(); + CheckLabelBoundaries(control); + } } else if (SelectionState != SelectionState.PanZoomMoving) CheckLabelBoundaries(_curAnn);