lot of small fixes for dataset explorer

This commit is contained in:
Alex Bezdieniezhnykh
2024-09-16 20:12:05 +03:00
parent 42fdee599e
commit 2236eb7fcb
6 changed files with 94 additions and 59 deletions
+2 -1
View File
@@ -14,5 +14,6 @@ public enum PlaybackControlEnum
TurnOffVolume = 9,
TurnOnVolume = 10,
Previous = 11,
Next = 12
Next = 12,
Close = 13
}
+3 -23
View File
@@ -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)