From 676a5b1590a93969a5cfde5aa2eec6d46103a73f Mon Sep 17 00:00:00 2001 From: Jeremy Date: Sat, 7 Dec 2024 22:21:08 +1100 Subject: [PATCH] add defaults to MessageBoxEx Show & update WebSearch to use api call --- Flow.Launcher.Core/MessageBoxEx.xaml.cs | 31 +++++-------------- Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 2 +- .../Flow.Launcher.Plugin.WebSearch/Main.cs | 2 +- .../SearchSourceViewModel.cs | 2 +- 4 files changed, 10 insertions(+), 27 deletions(-) diff --git a/Flow.Launcher.Core/MessageBoxEx.xaml.cs b/Flow.Launcher.Core/MessageBoxEx.xaml.cs index cdccb2c00..a01b5f68d 100644 --- a/Flow.Launcher.Core/MessageBoxEx.xaml.cs +++ b/Flow.Launcher.Core/MessageBoxEx.xaml.cs @@ -22,32 +22,15 @@ namespace Flow.Launcher.Core InitializeComponent(); } - /// 1 parameter public static MessageBoxResult Show(string messageBoxText) - { - return Show(messageBoxText, string.Empty, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - } + => Show(messageBoxText, string.Empty, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - // 2 parameter - public static MessageBoxResult Show(string messageBoxText, string caption) - { - return Show(messageBoxText, caption, MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK); - } - - /// 3 parameter - public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button) - { - return Show(messageBoxText, caption, button, MessageBoxImage.None, MessageBoxResult.OK); - } - - // 4 parameter - public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon) - { - return Show(messageBoxText, caption, button, icon, MessageBoxResult.OK); - } - - // 5 parameter, Final Display Message. - public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult defaultResult) + public static MessageBoxResult Show( + string messageBoxText, + string caption = "", + MessageBoxButton button = MessageBoxButton.OK, + MessageBoxImage icon = MessageBoxImage.None, + MessageBoxResult defaultResult = MessageBoxResult.OK) { if (!Application.Current.Dispatcher.CheckAccess()) { diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs index 282bb6e43..1e36f3adc 100644 --- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs +++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs @@ -301,7 +301,7 @@ namespace Flow.Launcher.Plugin public void ReQuery(bool reselect = true); /// - /// Displays a message box like + /// Displays a standardised Flow message box. /// /// The message of the message box. /// The caption of the message box. diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs index 39aa1738f..9b52db5a8 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/Main.cs @@ -13,7 +13,7 @@ namespace Flow.Launcher.Plugin.WebSearch { public class Main : IAsyncPlugin, ISettingProvider, IPluginI18n, IResultUpdated { - private PluginInitContext _context; + internal static PluginInitContext _context; private Settings _settings; private SettingsViewModel _viewModel; diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs index 0495772d5..9c5e81cb5 100644 --- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs @@ -41,7 +41,7 @@ namespace Flow.Launcher.Plugin.WebSearch #if DEBUG throw; #else - Flow.Launcher.Core.MessageBoxEx.Show(string.Format("Copying the selected image file to {0} has failed, changes will now be reverted", destinationFileNameFullPath)); + Main._context.API.ShowMsgBox(string.Format("Copying the selected image file to {0} has failed, changes will now be reverted", destinationFileNameFullPath)); UpdateIconAttributes(selectedSearchSource, fullPathToOriginalImage); #endif }