mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 13:06:31 +00:00
reuse VirtualizingWrapPanel for display Dataset Explorer
This commit is contained in:
@@ -148,9 +148,9 @@ public class YoloLabel : Label
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task<List<YoloLabel>> ReadFromFile(string filename, CancellationToken cancellationToken)
|
||||
public static async Task<List<YoloLabel>> ReadFromFile(string filename)
|
||||
{
|
||||
var str = await File.ReadAllTextAsync(filename, cancellationToken);
|
||||
var str = await File.ReadAllTextAsync(filename);
|
||||
|
||||
return str.Split(Environment.NewLine)
|
||||
.Select(Parse)
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace Azaion.Annotator.DTO;
|
||||
|
||||
public class ThumbnailDto : INotifyPropertyChanged
|
||||
{
|
||||
public string ThumbnailPath { get; set; }
|
||||
public string ImagePath { get; set; }
|
||||
public string LabelPath { get; set; }
|
||||
|
||||
private BitmapImage? _image;
|
||||
public BitmapImage? Image
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_image == null)
|
||||
LoadImageAsync();
|
||||
return _image;
|
||||
}
|
||||
set
|
||||
{
|
||||
_image = value;
|
||||
OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
private async void LoadImageAsync()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var bitmap = new BitmapImage();
|
||||
bitmap.BeginInit();
|
||||
bitmap.UriSource = new Uri(ThumbnailPath);
|
||||
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmap.DecodePixelWidth = 480;
|
||||
bitmap.DecodePixelHeight = 270;
|
||||
bitmap.EndInit();
|
||||
bitmap.Freeze(); // Freeze to make it cross-thread accessible
|
||||
Image = bitmap;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user