mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 12:56:30 +00:00
lot of small fixes for dataset explorer
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Media.Imaging;
|
||||
using Azaion.Annotator.Extensions;
|
||||
|
||||
namespace Azaion.Annotator.DTO;
|
||||
|
||||
@@ -16,7 +17,7 @@ public class ThumbnailDto : INotifyPropertyChanged
|
||||
get
|
||||
{
|
||||
if (_image == null)
|
||||
LoadImageAsync();
|
||||
Task.Run(async () => Image = await ThumbnailPath.OpenImage());
|
||||
return _image;
|
||||
}
|
||||
set
|
||||
@@ -26,28 +27,7 @@ public class ThumbnailDto : INotifyPropertyChanged
|
||||
}
|
||||
}
|
||||
|
||||
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 void UpdateImage() => _image = null;
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
protected virtual void OnPropertyChanged([CallerMemberName] string? propertyName = null)
|
||||
|
||||
Reference in New Issue
Block a user