fix editing non-timed annotations

This commit is contained in:
Alex Bezdieniezhnykh
2024-09-20 09:23:12 +03:00
parent 2236eb7fcb
commit 742f1ffee9
10 changed files with 218 additions and 119 deletions
+8 -5
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);
}
@@ -310,7 +310,7 @@ public class CanvasEditor : Canvas
});
}
public AnnotationControl CreateAnnotation(AnnotationClass annClass, TimeSpan time, CanvasLabel canvasLabel)
public AnnotationControl CreateAnnotation(AnnotationClass annClass, TimeSpan? time, CanvasLabel canvasLabel)
{
var annotationControl = new AnnotationControl(annClass, time, AnnotationResizeStart)
{
@@ -354,7 +354,10 @@ public class CanvasEditor : Canvas
public void ClearExpiredAnnotations(TimeSpan time)
{
var expiredAnns = CurrentAnns.Where(x => Math.Abs((time - x.Time).TotalMilliseconds) > _viewThreshold.TotalMilliseconds).ToList();
var expiredAnns = CurrentAnns.Where(x =>
x.Time.HasValue &&
Math.Abs((time - x.Time.Value).TotalMilliseconds) > _viewThreshold.TotalMilliseconds)
.ToList();
RemoveAnnotations(expiredAnns);
}
}