small fixes, renames

This commit is contained in:
Alex Bezdieniezhnykh
2025-01-15 16:41:42 +02:00
parent ae2c62350a
commit 1bc1d81fde
16 changed files with 234 additions and 181 deletions
+36 -3
View File
@@ -10,9 +10,11 @@ namespace Azaion.Dataset;
public class DatasetExplorerEventHandler(
DatasetExplorer datasetExplorer,
AnnotationService annotationService)
: INotificationHandler<KeyEvent>,
INotificationHandler<DatasetExplorerControlEvent>
AnnotationService annotationService) :
INotificationHandler<KeyEvent>,
INotificationHandler<DatasetExplorerControlEvent>,
INotificationHandler<AnnotationCreatedEvent>,
INotificationHandler<AnnotationsDeletedEvent>
{
private readonly Dictionary<Key, PlaybackControlEnum> _keysControlEnumDict = new()
{
@@ -83,4 +85,35 @@ public class DatasetExplorerEventHandler(
break;
}
}
public async Task Handle(AnnotationCreatedEvent notification, CancellationToken cancellationToken)
{
var annotation = notification.Annotation;
var selectedClass = ((DetectionClass?)datasetExplorer.LvClasses.SelectedItem)?.Id;
if (selectedClass == null)
return;
//TODO: For editing existing need to handle updates
datasetExplorer.AddAnnotationToDict(annotation);
if (annotation.Classes.Contains(selectedClass.Value))
{
var annThumb = new AnnotationThumbnail(annotation);
datasetExplorer.SelectedAnnotations.Add(annThumb);
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
}
}
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
{
var names = notification.Annotations.Select(x => x.Name).ToList();
var annThumbs = datasetExplorer.SelectedAnnotationDict
.Where(x => names.Contains(x.Key))
.Select(x => x.Value)
.ToList();
foreach (var annThumb in annThumbs)
{
datasetExplorer.SelectedAnnotations.Remove(annThumb);
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
}
}
}