From 5d8f277aa0e0339e15f2cd59e283e2b701863f26 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Wed, 27 Nov 2024 22:16:52 +0800 Subject: [PATCH] Use image loader to load image --- Flow.Launcher.Core/MessageBoxEx.xaml.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Flow.Launcher.Core/MessageBoxEx.xaml.cs b/Flow.Launcher.Core/MessageBoxEx.xaml.cs index bca20c067..dd1e9a606 100644 --- a/Flow.Launcher.Core/MessageBoxEx.xaml.cs +++ b/Flow.Launcher.Core/MessageBoxEx.xaml.cs @@ -1,8 +1,9 @@ using System; +using System.IO; using System.Windows; using System.Windows.Input; -using System.Windows.Media.Imaging; using Flow.Launcher.Infrastructure; +using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Infrastructure.Logger; namespace Flow.Launcher.Core @@ -142,7 +143,7 @@ namespace Flow.Launcher.Core } } - private static void SetImageOfMessageBox(MessageBoxImage icon) + private static async void SetImageOfMessageBox(MessageBoxImage icon) { switch (icon) { @@ -168,11 +169,11 @@ namespace Flow.Launcher.Core } } - private void SetImage(string imageName) + private async void SetImage(string imageName) { - string uri = Constant.ProgramDirectory + "/Images/" + imageName; - var uriSource = new Uri(uri, UriKind.RelativeOrAbsolute); - Img.Source = new BitmapImage(uriSource); + var imagePath = Path.Combine(Constant.ProgramDirectory, "Images", imageName); + var imageSource = await ImageLoader.LoadAsync(imagePath); + Img.Source = imageSource; } private void KeyEsc_OnPress(object sender, ExecutedRoutedEventArgs e)