From c3c6126bab91b1e61fa951f8cf8a2dd902f81a19 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 21:57:17 +0800 Subject: [PATCH] Fix xaml convert issue and use icon loader for PluginActivationIcon --- Flow.Launcher/MainWindow.xaml | 2 +- Flow.Launcher/ViewModel/MainViewModel.cs | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index b9ad97534..f5fd729d4 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -308,7 +308,7 @@ VerticalAlignment="Center" Panel.ZIndex="2" RenderOptions.BitmapScalingMode="HighQuality" - Source="{Binding PluginIconPath}" + Source="{Binding PluginIconSource}" Stretch="Uniform" Style="{DynamicResource PluginActivationIcon}" /> diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index f07d5c6dd..7b96e0cf3 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -23,6 +23,8 @@ using CommunityToolkit.Mvvm.Input; using System.Globalization; using System.Windows.Input; using System.ComponentModel; +using Flow.Launcher.Infrastructure.Image; +using System.Windows.Media; namespace Flow.Launcher.ViewModel { @@ -722,6 +724,8 @@ namespace Flow.Launcher.ViewModel set => Settings.ResultSubItemFontSize = value; } + public ImageSource PluginIconSource { get; private set; } = null; + public string PluginIconPath { get; set; } = null; public string OpenResultCommandModifiers => Settings.OpenResultModifiers; @@ -1066,6 +1070,7 @@ namespace Flow.Launcher.ViewModel Results.Clear(); Results.Visibility = Visibility.Collapsed; PluginIconPath = null; + PluginIconSource = null; SearchIconVisibility = Visibility.Visible; return; } @@ -1099,11 +1104,13 @@ namespace Flow.Launcher.ViewModel if (plugins.Count == 1) { PluginIconPath = plugins.Single().Metadata.IcoPath; + PluginIconSource = await ImageLoader.LoadAsync(PluginIconPath); SearchIconVisibility = Visibility.Hidden; } else { PluginIconPath = null; + PluginIconSource = null; SearchIconVisibility = Visibility.Visible; } @@ -1467,6 +1474,8 @@ namespace Flow.Launcher.ViewModel { Log.Debug("MainViewModel", $"Error in UpdateResultView: {ex.Message}"); } + + } #endregion