From 3af296e4d7a4452f62c5ec3e7a9a20acdf772ab7 Mon Sep 17 00:00:00 2001 From: Vic <10308169+VictoriousRaptor@users.noreply.github.com> Date: Fri, 28 Oct 2022 16:36:44 +0800 Subject: [PATCH] Try to get 44x44 logo --- .../Programs/UWP.cs | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs index 075ffbaf6..3d8b6a2f0 100644 --- a/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs +++ b/Plugins/Flow.Launcher.Plugin.Program/Programs/UWP.cs @@ -618,10 +618,10 @@ namespace Flow.Launcher.Plugin.Program.Programs var extension = Path.GetExtension(path); if (extension != null) { - if (File.Exists(path)) - { - return path; // shortcut, avoid enumerating files - } + //if (File.Exists(path)) + //{ + // return path; // shortcut, avoid enumerating files + //} var logoNamePrefix = Path.GetFileNameWithoutExtension(uri); // e.g Square44x44 var logoDir = Path.GetDirectoryName(path); // e.g ..\..\Assets @@ -639,10 +639,26 @@ namespace Flow.Launcher.Plugin.Program.Programs // Just ignore all qualifiers // select like logo.[xxx_yyy].png // https://learn.microsoft.com/en-us/windows/uwp/app-resources/tailor-resources-lang-scale-contrast - var selected = files.FirstOrDefault(file => + var logos = files.Where(file => Path.GetFileName(file).StartsWith(logoNamePrefix) && extension == Path.GetExtension(file) ); + var selected = logos.FirstOrDefault(); + + foreach(var logo in logos) + { + + var imageStream = File.OpenRead(logo); + var decoder = BitmapDecoder.Create(imageStream, BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.None); + var height = decoder.Frames[0].PixelHeight; + var width = decoder.Frames[0].PixelWidth; + if(height == 44 && width == 44) + { + selected = logo; + break; + } + } + if (!string.IsNullOrEmpty(selected)) { return selected;