From 897fd7aabac08c098546af7a80cc3ca4d90c86c8 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Tue, 26 Nov 2024 21:31:13 +0800 Subject: [PATCH] Replace Flow.Launcher.Core.MessageBoxType & MessageBoxImage with System.Windows.MessageBoxButton & MessageBoxImage Remove useless warning file --- Flow.Launcher.Core/Configuration/Portable.cs | 3 +- .../Environments/AbstractPluginEnvironment.cs | 4 +- Flow.Launcher.Core/MessageBoxEx.xaml.cs | 49 ++---------------- Flow.Launcher.Core/Plugin/PluginsLoader.cs | 1 - .../Resource/Internationalization.cs | 3 +- Flow.Launcher.Core/Updater.cs | 3 +- Flow.Launcher/Images/warning.png | Bin 738 -> 0 bytes .../ViewModels/SettingsPaneAboutViewModel.cs | 3 +- .../ViewModels/SettingsPaneHotkeyViewModel.cs | 5 +- .../ContextMenu.cs | 1 - .../Everything/EverythingDownloadHelper.cs | 3 +- .../PluginsManager.cs | 13 +++-- .../Views/ProgramSetting.xaml.cs | 3 +- Plugins/Flow.Launcher.Plugin.Sys/Main.cs | 1 - .../SettingsControl.xaml.cs | 3 +- 15 files changed, 20 insertions(+), 75 deletions(-) delete mode 100644 Flow.Launcher/Images/warning.png diff --git a/Flow.Launcher.Core/Configuration/Portable.cs b/Flow.Launcher.Core/Configuration/Portable.cs index 2a1db10e7..d7c73fb46 100644 --- a/Flow.Launcher.Core/Configuration/Portable.cs +++ b/Flow.Launcher.Core/Configuration/Portable.cs @@ -9,7 +9,6 @@ using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin.SharedCommands; using System.Linq; -using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Core.Configuration { @@ -162,7 +161,7 @@ namespace Flow.Launcher.Core.Configuration if (MessageBoxEx.Show("Flow Launcher has detected you enabled portable mode, " + "would you like to move it to a different location?", string.Empty, - MessageBoxType.YesNo) == MessageBoxResult.Yes) + MessageBoxButton.YesNo) == MessageBoxResult.Yes) { FilesFolders.OpenPath(Constant.RootDirectory, MessageBoxEx.Show); diff --git a/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs b/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs index 433df6f97..6d41e2383 100644 --- a/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs +++ b/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs @@ -4,12 +4,10 @@ using Flow.Launcher.Plugin; using Flow.Launcher.Plugin.SharedCommands; using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Windows; using System.Windows.Forms; using Flow.Launcher.Core.Resource; -using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Core.ExternalPlugins.Environments { @@ -59,7 +57,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments EnvName, Environment.NewLine ); - if (MessageBoxEx.Show(noRuntimeMessage, string.Empty, MessageBoxType.YesNo) == MessageBoxResult.No) + if (MessageBoxEx.Show(noRuntimeMessage, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No) { var msg = string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName); string selectedFile; diff --git a/Flow.Launcher.Core/MessageBoxEx.xaml.cs b/Flow.Launcher.Core/MessageBoxEx.xaml.cs index 1a986be4c..b87302ca5 100644 --- a/Flow.Launcher.Core/MessageBoxEx.xaml.cs +++ b/Flow.Launcher.Core/MessageBoxEx.xaml.cs @@ -13,25 +13,6 @@ namespace Flow.Launcher.Core InitializeComponent(); } - public enum MessageBoxType - { - ConfirmationWithYesNo = 0, - ConfirmationWithYesNoCancel, - YesNo, - Information, - Error, - Warning - } - - public enum MessageBoxImage - { - Warning = 0, - Question, - Information, - Error, - None - } - static MessageBoxEx msgBox; static MessageBoxResult _result = MessageBoxResult.No; @@ -49,31 +30,9 @@ namespace Flow.Launcher.Core } /// 3 parameter - public static MessageBoxResult Show(string messageBoxText, string title, MessageBoxType type) + public static MessageBoxResult Show(string messageBoxText, string title, MessageBoxButton type) { - switch (type) - { - case MessageBoxType.ConfirmationWithYesNo: - return Show(messageBoxText, title, MessageBoxButton.YesNo, - MessageBoxImage.Question); - case MessageBoxType.YesNo: - return Show(messageBoxText, title, MessageBoxButton.YesNo, - MessageBoxImage.Question); - case MessageBoxType.ConfirmationWithYesNoCancel: - return Show(messageBoxText, title, MessageBoxButton.YesNoCancel, - MessageBoxImage.Question); - case MessageBoxType.Information: - return Show(messageBoxText, title, MessageBoxButton.OK, - MessageBoxImage.Information); - case MessageBoxType.Error: - return Show(messageBoxText, title, MessageBoxButton.OK, - MessageBoxImage.Error); - case MessageBoxType.Warning: - return Show(messageBoxText, title, MessageBoxButton.OK, - MessageBoxImage.Warning); - default: - return MessageBoxResult.No; - } + return Show(messageBoxText, title, type, MessageBoxImage.None); } // 4 parameter, Final Display Message. @@ -144,8 +103,8 @@ namespace Flow.Launcher.Core { switch (image) { - case MessageBoxImage.Warning: - msgBox.SetImage("Warning.png"); + case MessageBoxImage.Exclamation: + msgBox.SetImage("Exclamation.png"); msgBox.Img.Visibility = Visibility.Visible; break; case MessageBoxImage.Question: diff --git a/Flow.Launcher.Core/Plugin/PluginsLoader.cs b/Flow.Launcher.Core/Plugin/PluginsLoader.cs index 495d25e1b..7973c66ba 100644 --- a/Flow.Launcher.Core/Plugin/PluginsLoader.cs +++ b/Flow.Launcher.Core/Plugin/PluginsLoader.cs @@ -11,7 +11,6 @@ using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; -using MessageBoxImage = Flow.Launcher.Core.MessageBoxEx.MessageBoxImage; namespace Flow.Launcher.Core.Plugin { diff --git a/Flow.Launcher.Core/Resource/Internationalization.cs b/Flow.Launcher.Core/Resource/Internationalization.cs index e634dc9dd..1505e84f8 100644 --- a/Flow.Launcher.Core/Resource/Internationalization.cs +++ b/Flow.Launcher.Core/Resource/Internationalization.cs @@ -11,7 +11,6 @@ using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using System.Globalization; using System.Threading.Tasks; -using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Core.Resource { @@ -125,7 +124,7 @@ namespace Flow.Launcher.Core.Resource // "Do you want to search with pinyin?" string text = languageToSet == AvailableLanguages.Chinese ? "是否启用拼音搜索?" : "是否啓用拼音搜索?" ; - if (MessageBoxEx.Show(text, string.Empty, MessageBoxType.YesNo) == MessageBoxResult.No) + if (MessageBoxEx.Show(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No) return false; return true; diff --git a/Flow.Launcher.Core/Updater.cs b/Flow.Launcher.Core/Updater.cs index 5a980c5e2..b92d86568 100644 --- a/Flow.Launcher.Core/Updater.cs +++ b/Flow.Launcher.Core/Updater.cs @@ -17,7 +17,6 @@ using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; using System.Text.Json.Serialization; using System.Threading; -using static Flow.Launcher.Core.MessageBoxEx; namespace Flow.Launcher.Core { @@ -84,7 +83,7 @@ namespace Flow.Launcher.Core Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}"); - if (MessageBoxEx.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxType.YesNo) == MessageBoxResult.Yes) + if (MessageBoxEx.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes) { UpdateManager.RestartApp(Constant.ApplicationFileName); } diff --git a/Flow.Launcher/Images/warning.png b/Flow.Launcher/Images/warning.png deleted file mode 100644 index 8d29625ee731a16a1c29ecc6cd5f505a449f0069..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 738 zcmV<80v-K{P)kh?ZJ9v_+5#4%NNw-R79O38FZ;HlsS!NjIyLIO)*2?WT0erCr?W zAm}1V5NRF6h=V;_^CTCMc)5G;_x^+?a5uhtclZ7Le(yf_IKq%0H01e_0UUJ)vkqh( zu&h9~gwhHqD#vF*x%KG0Xf2X|@Yb@}iI?}K1EPW=C|?6nu>&BQ5Wl9$N7FS#e*mia zmjK=RKWytMEgUQjJV3N`a=D$vpsldog}O@!=N%A1p#p-J7*Zf0FZ2f%Ky2kp5Y%~b z(~jJ4pXLq&R}fA+Ac8^-gehq_fjW8N^uPg#YW@L0%dB98GR=oiSaTJVoOGZ^o2q0E zwdw{SQJX3XH(Ip@NYm!c<=KA(XNn6 zfCH^s0m!uZ@Wpw2sGpJpw9i^<)eb(3?9)N*X^#C}#Ot+D}B+KjIc;|^$Ql?A}jrh0*E%+Sy( z4}hUfjd;wdJgq7LxY~@TYV3|+y?QPhUR>D2$X{^4U zh=y-m{fxQG-^>6MT1^Ge)uvfG=2ep2YC3>L^_j8w(L6f8Tt