Files
annotations/Azaion.Common/DTO/AnnotationImageView.cs
T
Alex Bezdieniezhnykh 48c9ccbfda add db WIP 2, 80%
refactor, renames
2024-12-24 06:07:13 +02:00

38 lines
1.1 KiB
C#

using System.ComponentModel;
using System.IO;
using System.Runtime.CompilerServices;
using System.Windows.Media.Imaging;
using Azaion.Common.Extensions;
namespace Azaion.Common.DTO;
public class AnnotationImageView(Annotation annotation) : INotifyPropertyChanged
{
public Annotation Annotation { get; set; } = annotation;
private BitmapImage? _thumbnail;
public BitmapImage? Thumbnail
{
get
{
if (_thumbnail == null)
Task.Run(async () => Thumbnail = await Annotation.ThumbPath.OpenImage());
return _thumbnail;
}
private set => _thumbnail = value;
}
public string ImageName => Path.GetFileName(Annotation.ImagePath);
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)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}