From 250627a27adfab53625132066480698e34bbc735 Mon Sep 17 00:00:00 2001 From: Hongtao Zhang Date: Fri, 25 Nov 2022 13:51:07 -0600 Subject: [PATCH] Load large Thumbnail when load full image --- Flow.Launcher.Infrastructure/Image/ImageLoader.cs | 9 +++++---- Flow.Launcher/ViewModel/ResultViewModel.cs | 7 ++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs index 6026316d3..48c984cde 100644 --- a/Flow.Launcher.Infrastructure/Image/ImageLoader.cs +++ b/Flow.Launcher.Infrastructure/Image/ImageLoader.cs @@ -23,6 +23,7 @@ namespace Flow.Launcher.Infrastructure.Image private static readonly bool EnableImageHash = true; public static ImageSource DefaultImage { get; } = new BitmapImage(new Uri(Constant.MissingImgIcon)); public const int SmallIconSize = 32; + public const int FullIconSize = 256; private static readonly string[] ImageExtensions = @@ -217,7 +218,7 @@ namespace Flow.Launcher.Infrastructure.Image else { type = ImageType.File; - image = GetThumbnail(path, ThumbnailOptions.None); + image = GetThumbnail(path, ThumbnailOptions.None, loadFullImage ? FullIconSize : SmallIconSize); } } else @@ -234,12 +235,12 @@ namespace Flow.Launcher.Infrastructure.Image return new ImageResult(image, type); } - private static BitmapSource GetThumbnail(string path, ThumbnailOptions option = ThumbnailOptions.ThumbnailOnly) + private static BitmapSource GetThumbnail(string path, ThumbnailOptions option = ThumbnailOptions.ThumbnailOnly, int size = SmallIconSize) { return WindowsThumbnailProvider.GetThumbnail( path, - Constant.ThumbnailSize, - Constant.ThumbnailSize, + size, + size, option); } diff --git a/Flow.Launcher/ViewModel/ResultViewModel.cs b/Flow.Launcher/ViewModel/ResultViewModel.cs index 25a48204d..fca37a359 100644 --- a/Flow.Launcher/ViewModel/ResultViewModel.cs +++ b/Flow.Launcher/ViewModel/ResultViewModel.cs @@ -199,13 +199,10 @@ namespace Flow.Launcher.ViewModel } - private async ValueTask LoadPreviewImageAsync() + private async Task LoadPreviewImageAsync() { var imagePath = Result.PreviewImage ?? Result.IcoPath; - var loadFullImage = (Path.GetExtension(imagePath) ?? "").Equals(".url", StringComparison.OrdinalIgnoreCase); - // We need to modify the property not field here to trigger the OnPropertyChanged event - //PreviewImage = await Task.Run(() => ImageLoader.Load(imagePath, true)).ConfigureAwait(false); - PreviewImage = await ImageLoader.LoadAsync(imagePath, loadFullImage).ConfigureAwait(false); + PreviewImage = await ImageLoader.LoadAsync(imagePath, true).ConfigureAwait(false); } public Result Result { get; }