mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:06:30 +00:00
fixed bugs with queue handling. At least most of them
This commit is contained in:
@@ -417,7 +417,8 @@ public partial class Annotator
|
||||
mediaFile.HasAnnotations = labelsDict.ContainsKey(mediaFile.FName);
|
||||
|
||||
AllMediaFiles = new ObservableCollection<MediaFileInfo>(allFiles);
|
||||
MediaFilesDict = AllMediaFiles.ToDictionary(x => x.FName);
|
||||
MediaFilesDict = AllMediaFiles.GroupBy(x => x.Name)
|
||||
.ToDictionary(gr => gr.Key, gr => gr.First());
|
||||
LvFiles.ItemsSource = AllMediaFiles;
|
||||
DataContext = this;
|
||||
}
|
||||
@@ -463,7 +464,7 @@ public partial class Annotator
|
||||
{
|
||||
Title = "Open Video folder",
|
||||
IsFolderPicker = true,
|
||||
InitialDirectory = Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)
|
||||
InitialDirectory = Path.GetDirectoryName(_appConfig.DirectoriesConfig.VideosDirectory)
|
||||
};
|
||||
var dialogResult = dlg.ShowDialog();
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Azaion.Annotator.DTO;
|
||||
using Azaion.Common;
|
||||
using Azaion.Common.DTO;
|
||||
@@ -276,31 +277,42 @@ public class AnnotatorEventHandler(
|
||||
mainWindow.AddAnnotation(annotation);
|
||||
}
|
||||
|
||||
public async Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
||||
public Task Handle(AnnotationsDeletedEvent notification, CancellationToken cancellationToken)
|
||||
{
|
||||
var namesSet = notification.AnnotationNames.ToHashSet();
|
||||
|
||||
var remainAnnotations = formState.AnnotationResults
|
||||
.Where(x => !namesSet.Contains(x.Annotation?.Name ?? "")).ToList();
|
||||
formState.AnnotationResults.Clear();
|
||||
foreach (var ann in remainAnnotations)
|
||||
formState.AnnotationResults.Add(ann);
|
||||
|
||||
var timedAnnsToRemove = mainWindow.TimedAnnotations
|
||||
.Where(x => namesSet.Contains(x.Value.Name))
|
||||
.Select(x => x.Value).ToList();
|
||||
mainWindow.TimedAnnotations.Remove(timedAnnsToRemove);
|
||||
|
||||
if (formState.AnnotationResults.Count == 0)
|
||||
try
|
||||
{
|
||||
var media = mainWindow.AllMediaFiles.FirstOrDefault(x => x.Name == formState.CurrentMedia?.Name);
|
||||
if (media != null)
|
||||
mainWindow.Dispatcher.Invoke(() =>
|
||||
{
|
||||
media.HasAnnotations = false;
|
||||
mainWindow.LvFiles.Items.Refresh();
|
||||
}
|
||||
var namesSet = notification.AnnotationNames.ToHashSet();
|
||||
|
||||
var remainAnnotations = formState.AnnotationResults
|
||||
.Where(x => !namesSet.Contains(x.Annotation?.Name ?? "")).ToList();
|
||||
formState.AnnotationResults.Clear();
|
||||
foreach (var ann in remainAnnotations)
|
||||
formState.AnnotationResults.Add(ann);
|
||||
|
||||
var timedAnnsToRemove = mainWindow.TimedAnnotations
|
||||
.Where(x => namesSet.Contains(x.Value.Name))
|
||||
.Select(x => x.Value).ToList();
|
||||
mainWindow.TimedAnnotations.Remove(timedAnnsToRemove);
|
||||
|
||||
if (formState.AnnotationResults.Count == 0)
|
||||
{
|
||||
var media = mainWindow.AllMediaFiles.FirstOrDefault(x => x.Name == formState.CurrentMedia?.Name);
|
||||
if (media != null)
|
||||
{
|
||||
media.HasAnnotations = false;
|
||||
mainWindow.LvFiles.Items.Refresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
catch (Exception e)
|
||||
{
|
||||
logger.LogError(e, e.Message);
|
||||
throw;
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(AnnotationAddedEvent e, CancellationToken cancellationToken)
|
||||
|
||||
Reference in New Issue
Block a user