remove fix, todo: test

This commit is contained in:
Alex Bezdieniezhnykh
2025-01-03 18:32:56 +02:00
parent 9aebfd787b
commit ae2c62350a
19 changed files with 353 additions and 245 deletions
+15 -16
View File
@@ -34,13 +34,13 @@ public class CanvasEditor : Canvas
public static readonly DependencyProperty GetTimeFuncProp =
DependencyProperty.Register(
nameof(GetTimeFunc),
typeof(Func<TimeSpan?>),
typeof(Func<TimeSpan>),
typeof(CanvasEditor),
new PropertyMetadata(null));
public Func<TimeSpan?> GetTimeFunc
public Func<TimeSpan> GetTimeFunc
{
get => (Func<TimeSpan?>)GetValue(GetTimeFuncProp);
get => (Func<TimeSpan>)GetValue(GetTimeFuncProp);
set => SetValue(GetTimeFuncProp, value);
}
@@ -154,7 +154,7 @@ public class CanvasEditor : Canvas
private void CanvasMouseUp(object sender, MouseButtonEventArgs e)
{
if (SelectionState == SelectionState.NewAnnCreating)
CreateAnnotation(e.GetPosition(this));
CreateDetectionControl(e.GetPosition(this));
SelectionState = SelectionState.None;
e.Handled = true;
@@ -291,7 +291,7 @@ public class CanvasEditor : Canvas
SetTop(_newAnnotationRect, currentPos.Y);
}
private void CreateAnnotation(Point endPos)
private void CreateDetectionControl(Point endPos)
{
_newAnnotationRect.Width = 0;
_newAnnotationRect.Height = 0;
@@ -301,7 +301,7 @@ public class CanvasEditor : Canvas
return;
var time = GetTimeFunc();
CreateAnnotation(CurrentAnnClass, time, new CanvasLabel
CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel
{
Width = width,
Height = height,
@@ -310,20 +310,20 @@ public class CanvasEditor : Canvas
});
}
public DetectionControl CreateAnnotation(DetectionClass annClass, TimeSpan? time, CanvasLabel canvasLabel)
public DetectionControl CreateDetectionControl(DetectionClass annClass, TimeSpan time, CanvasLabel canvasLabel)
{
var annotationControl = new DetectionControl(annClass, time, AnnotationResizeStart, canvasLabel.Probability)
var detectionControl = new DetectionControl(annClass, time, AnnotationResizeStart, canvasLabel.Probability)
{
Width = canvasLabel.Width,
Height = canvasLabel.Height
};
annotationControl.MouseDown += AnnotationPositionStart;
SetLeft(annotationControl, canvasLabel.X );
SetTop(annotationControl, canvasLabel.Y);
Children.Add(annotationControl);
CurrentDetections.Add(annotationControl);
detectionControl.MouseDown += AnnotationPositionStart;
SetLeft(detectionControl, canvasLabel.X );
SetTop(detectionControl, canvasLabel.Y);
Children.Add(detectionControl);
CurrentDetections.Add(detectionControl);
_newAnnotationRect.Fill = new SolidColorBrush(annClass.Color);
return annotationControl;
return detectionControl;
}
#endregion
@@ -355,8 +355,7 @@ public class CanvasEditor : Canvas
public void ClearExpiredAnnotations(TimeSpan time)
{
var expiredAnns = CurrentDetections.Where(x =>
x.Time.HasValue &&
Math.Abs((time - x.Time.Value).TotalMilliseconds) > _viewThreshold.TotalMilliseconds)
Math.Abs((time - x.Time).TotalMilliseconds) > _viewThreshold.TotalMilliseconds)
.ToList();
RemoveAnnotations(expiredAnns);
}