mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 21:46:30 +00:00
4780e8c61c
fix schema migrator for enums
70 lines
2.0 KiB
C#
70 lines
2.0 KiB
C#
using System.Windows.Media;
|
|
using Azaion.Common.DTO;
|
|
using Azaion.Common.Extensions;
|
|
|
|
namespace Azaion.Common.Controls
|
|
{
|
|
public partial class DetectionLabelPanel
|
|
{
|
|
private AffiliationEnum _affiliation = AffiliationEnum.None;
|
|
|
|
public AffiliationEnum Affiliation
|
|
{
|
|
get => _affiliation;
|
|
set
|
|
{
|
|
_affiliation = value;
|
|
UpdateAffiliationImage();
|
|
}
|
|
}
|
|
|
|
private DetectionClass _detectionClass = new();
|
|
public DetectionClass DetectionClass {
|
|
get => _detectionClass;
|
|
set
|
|
{
|
|
_detectionClass = value;
|
|
SetClassName();
|
|
}
|
|
}
|
|
|
|
private double _confidence;
|
|
public double Confidence
|
|
{
|
|
get => _confidence;
|
|
set
|
|
{
|
|
_confidence = value;
|
|
SetClassName();
|
|
}
|
|
}
|
|
|
|
private void SetClassName()
|
|
{
|
|
DetectionClassName.Content = _confidence >= 0.995 ? _detectionClass.UIName : $"{_detectionClass.UIName}: {_confidence * 100:F0}%";
|
|
DetectionGrid.Background = new SolidColorBrush(_detectionClass.Color.ToConfidenceColor(_confidence));
|
|
}
|
|
|
|
public DetectionLabelPanel()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private string _detectionLabelText(string detectionClassName) =>
|
|
_confidence >= 0.98 ? detectionClassName : $"{detectionClassName}: {_confidence * 100:F0}%";
|
|
|
|
private void UpdateAffiliationImage()
|
|
{
|
|
if (_affiliation == AffiliationEnum.None)
|
|
{
|
|
AffiliationImage.Source = null;
|
|
return;
|
|
}
|
|
|
|
if (TryFindResource(_affiliation.ToString()) is DrawingImage drawingImage)
|
|
AffiliationImage.Source = drawingImage;
|
|
else
|
|
AffiliationImage.Source = null;
|
|
}
|
|
}
|
|
} |