mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 16:46:31 +00:00
small fixes, renames
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user