remove fix, todo: test

This commit is contained in:
Alex Bezdieniezhnykh
2025-01-03 18:32:56 +02:00
parent 9aebfd787b
commit ae2c62350a
19 changed files with 353 additions and 245 deletions
@@ -1,9 +0,0 @@
using Azaion.Common.Database;
using MediatR;
namespace Azaion.Common.DTO;
public class AnnotationCreatedEvent(Annotation annotation) : INotification
{
public Annotation Annotation { get; } = annotation;
}
+33 -21
View File
@@ -1,40 +1,52 @@
using System.Windows.Media;
using Azaion.Common.Database;
using Azaion.Common.Extensions;
using Newtonsoft.Json;
namespace Azaion.Common.DTO;
public class AnnotationResult
{
[JsonProperty(PropertyName = "f")]
public string Image { get; set; } = null!;
public Annotation Annotation { get; set; }
[JsonProperty(PropertyName = "t")]
public TimeSpan Time { get; set; }
public string ImagePath { get; set; }
public string TimeStr { get; set; }
public double Lat { get; set; }
public double Lon { get; set; }
public List<Detection> Detections { get; set; } = new();
public string ClassName { get; set; }
#region For XAML Form
public Color ClassColor0 { get; set; }
public Color ClassColor1 { get; set; }
public Color ClassColor2 { get; set; }
public Color ClassColor3 { get; set; }
[JsonIgnore]
public string TimeStr => $"{Time:h\\:mm\\:ss}";
[JsonIgnore]
public string ClassName { get; set; } = null!;
public AnnotationResult(Dictionary<int, DetectionClass> allDetectionClasses, Annotation annotation)
{
Annotation = annotation;
var detections = annotation.Detections.ToList();
[JsonIgnore]
public Color ClassColor0 { get; set; }
Color GetAnnotationClass(List<int> detectionClasses, int colorNumber)
{
if (detections.Count == 0)
return (-1).ToColor();
[JsonIgnore]
public Color ClassColor1 { get; set; }
return colorNumber >= detectionClasses.Count
? allDetectionClasses[detectionClasses.LastOrDefault()].Color
: allDetectionClasses[detectionClasses[colorNumber]].Color;
}
[JsonIgnore]
public Color ClassColor2 { get; set; }
TimeStr = $"{annotation.Time:h\\:mm\\:ss}";
ImagePath = annotation.ImagePath;
[JsonIgnore]
public Color ClassColor3 { get; set; }
var detectionClasses = detections.Select(x => x.ClassNumber).Distinct().ToList();
#endregion
ClassName = detectionClasses.Count > 1
? string.Join(", ", detectionClasses.Select(x => allDetectionClasses[x].ShortName))
: allDetectionClasses[detectionClasses.FirstOrDefault()].Name;
ClassColor0 = GetAnnotationClass(detectionClasses, 0);
ClassColor1 = GetAnnotationClass(detectionClasses, 1);
ClassColor2 = GetAnnotationClass(detectionClasses, 2);
ClassColor3 = GetAnnotationClass(detectionClasses, 3);
}
}
@@ -7,7 +7,7 @@ using Azaion.Common.Extensions;
namespace Azaion.Common.DTO;
public class AnnotationImageView(Annotation annotation) : INotifyPropertyChanged
public class AnnotationThumbnail(Annotation annotation) : INotifyPropertyChanged
{
public Annotation Annotation { get; set; } = annotation;
@@ -30,13 +30,6 @@ public class AnnotationImageView(Annotation annotation) : INotifyPropertyChanged
public string ImageName => Path.GetFileName(Annotation.ImagePath);
public bool IsSeed => Annotation.AnnotationStatus == AnnotationStatus.Created;
public void Delete()
{
File.Delete(Annotation.ImagePath);
File.Delete(Annotation.LabelPath);
File.Delete(Annotation.ThumbPath);
}
public event PropertyChangedEventHandler? PropertyChanged;
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
{
@@ -1,13 +0,0 @@
using MediatR;
namespace Azaion.Common.DTO;
public class AnnotatorControlEvent(PlaybackControlEnum playbackControlEnum) : INotification
{
public PlaybackControlEnum PlaybackControl { get; set; } = playbackControlEnum;
}
public class DatasetExplorerControlEvent(PlaybackControlEnum playbackControlEnum) : INotification
{
public PlaybackControlEnum PlaybackControl { get; set; } = playbackControlEnum;
}
-11
View File
@@ -1,11 +0,0 @@
using System.Windows.Input;
using MediatR;
namespace Azaion.Common.DTO;
public class KeyEvent(object sender, KeyEventArgs args, WindowEnum windowEnum) : INotification
{
public object Sender { get; set; } = sender;
public KeyEventArgs Args { get; set; } = args;
public WindowEnum WindowEnum { get; } = windowEnum;
}