mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 14:36:31 +00:00
make right annotation list more vivid
fix creation new anns bug
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Windows.Media;
|
||||
using Azaion.Annotator.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Azaion.Annotator.DTO;
|
||||
@@ -23,38 +24,44 @@ public class AnnotationResult
|
||||
//For XAML Form
|
||||
public string TimeStr => $"{Time:h\\:mm\\:ss}";
|
||||
|
||||
private List<int>? _detectionClasses = null!;
|
||||
|
||||
//For Form
|
||||
[JsonIgnore]
|
||||
//For XAML Form
|
||||
public string ClassName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Detections.Count == 0)
|
||||
return "";
|
||||
_detectionClasses ??= Detections.Select(x => x.ClassNumber).Distinct().ToList();
|
||||
|
||||
var groups = Detections.Select(x => x.ClassNumber).GroupBy(x => x).ToList();
|
||||
return groups.Count > 1
|
||||
? string.Join(",", groups.Select(x => x.Key + 1))
|
||||
: _config.AnnotationClassesDict[groups.FirstOrDefault().Key].Name;
|
||||
return _detectionClasses.Count > 1
|
||||
? string.Join(", ", _detectionClasses.Select(x => _config.AnnotationClassesDict[x].ShortName))
|
||||
: _config.AnnotationClassesDict[_detectionClasses.FirstOrDefault()].Name;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[JsonIgnore]
|
||||
//For XAML Form
|
||||
public Color ClassColor
|
||||
public Color ClassColor1 => GetAnnotationClass(0);
|
||||
[JsonIgnore]
|
||||
public Color ClassColor2 => GetAnnotationClass(1);
|
||||
[JsonIgnore]
|
||||
public Color ClassColor3 => GetAnnotationClass(2);
|
||||
[JsonIgnore]
|
||||
public Color ClassColor4 => GetAnnotationClass(3);
|
||||
|
||||
private Color GetAnnotationClass(int colorNumber)
|
||||
{
|
||||
get
|
||||
{
|
||||
var defaultColor = (Color)ColorConverter.ConvertFromString("#404040");
|
||||
if (Detections.Count == 0)
|
||||
return defaultColor;
|
||||
if (Detections.Count == 0)
|
||||
return (-1).ToColor();
|
||||
|
||||
var groups = Detections.Select(x => x.ClassNumber).GroupBy(x => x).ToList();
|
||||
_detectionClasses ??= Detections.Select(x => x.ClassNumber).Distinct().ToList();
|
||||
|
||||
return groups.Count > 1
|
||||
? defaultColor
|
||||
: _config.AnnotationClassesDict[groups.FirstOrDefault().Key].Color;
|
||||
}
|
||||
return colorNumber >= _detectionClasses.Count
|
||||
? _config.AnnotationClassesDict[_detectionClasses.LastOrDefault()].Color
|
||||
: _config.AnnotationClassesDict[_detectionClasses[colorNumber]].Color;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user