fix ui bugs, fix RefreshThumbnails method

This commit is contained in:
Alex Bezdieniezhnykh
2025-04-14 19:43:14 +03:00
parent dd42292eee
commit 1287c13516
5 changed files with 62 additions and 27 deletions
+21 -18
View File
@@ -1,6 +1,7 @@
using System.IO;
using System.Windows;
using System.Windows.Input;
using System.Windows.Threading;
using Azaion.Common.DTO;
using Azaion.Common.DTO.Queue;
using Azaion.Common.Events;
@@ -103,26 +104,28 @@ public class DatasetExplorerEventHandler(
public async Task Handle(AnnotationCreatedEvent notification, CancellationToken cancellationToken)
{
var annotation = notification.Annotation;
var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber;
//TODO: For editing existing need to handle updates
datasetExplorer.AddAnnotationToDict(annotation);
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
datasetExplorer.Dispatcher.Invoke(async () =>
{
var annThumb = new AnnotationThumbnail(annotation);
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
{
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
var ann = datasetExplorer.SelectedAnnotations.FirstOrDefault(x => x.Annotation.Name == annThumb.Annotation.Name);
if (ann != null)
datasetExplorer.SelectedAnnotations.Remove(ann);
}
var annotation = notification.Annotation;
var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber;
datasetExplorer.SelectedAnnotations.Insert(0, annThumb);
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
}
await Task.CompletedTask;
//TODO: For editing existing need to handle updates
datasetExplorer.AddAnnotationToDict(annotation);
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
{
var annThumb = new AnnotationThumbnail(annotation);
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
{
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
var ann = datasetExplorer.SelectedAnnotations.FirstOrDefault(x => x.Annotation.Name == annThumb.Annotation.Name);
if (ann != null)
datasetExplorer.SelectedAnnotations.Remove(ann);
}
datasetExplorer.SelectedAnnotations.Insert(0, annThumb);
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
}
});
}
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)