From b30cc4fc384efd3483b7992fd18745f94fadad4f Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Mon, 25 Nov 2024 10:38:43 +0800
Subject: [PATCH] Replace System.Windows.MessageBox with MessageBoxEx
---
Flow.Launcher.Core/Configuration/Portable.cs | 10 +++----
.../Environments/AbstractPluginEnvironment.cs | 8 ++++--
.../Environments/PythonEnvironment.cs | 2 +-
.../Environments/TypeScriptEnvironment.cs | 2 +-
.../Environments/TypeScriptV2Environment.cs | 2 +-
Flow.Launcher.Core/Plugin/PluginManager.cs | 2 +-
Flow.Launcher.Core/Plugin/PluginsLoader.cs | 7 +++--
Flow.Launcher.Core/Updater.cs | 4 +--
.../SharedCommands/FilesFolders.cs | 27 ++++++++++--------
.../Flow.Launcher.Plugin.Calculator/Main.cs | 4 +--
.../ContextMenu.cs | 12 ++++----
.../Everything/EverythingDownloadHelper.cs | 9 ++++--
.../Search/ResultManager.cs | 11 ++++----
.../ViewModels/SettingsViewModel.cs | 4 +--
.../Views/ActionKeywordSetting.xaml.cs | 9 +++---
.../PluginsManager.cs | 28 ++++++++++---------
.../AddProgramSource.xaml.cs | 3 +-
.../Flow.Launcher.Plugin.Program.csproj | 1 +
.../ProgramSuffixes.xaml.cs | 5 ++--
.../Views/ProgramSetting.xaml.cs | 8 ++++--
.../Flow.Launcher.Plugin.Sys.csproj | 1 +
Plugins/Flow.Launcher.Plugin.Sys/Main.cs | 13 +++++----
.../SearchSourceSetting.xaml.cs | 13 +++++----
.../SearchSourceViewModel.cs | 2 +-
.../SettingsControl.xaml.cs | 6 ++--
25 files changed, 108 insertions(+), 85 deletions(-)
diff --git a/Flow.Launcher.Core/Configuration/Portable.cs b/Flow.Launcher.Core/Configuration/Portable.cs
index 544cf2509..2a1db10e7 100644
--- a/Flow.Launcher.Core/Configuration/Portable.cs
+++ b/Flow.Launcher.Core/Configuration/Portable.cs
@@ -96,13 +96,13 @@ namespace Flow.Launcher.Core.Configuration
public void MoveUserDataFolder(string fromLocation, string toLocation)
{
- FilesFolders.CopyAll(fromLocation, toLocation);
+ FilesFolders.CopyAll(fromLocation, toLocation, MessageBoxEx.Show);
VerifyUserDataAfterMove(fromLocation, toLocation);
}
public void VerifyUserDataAfterMove(string fromLocation, string toLocation)
{
- FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation);
+ FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation, MessageBoxEx.Show);
}
public void CreateShortcuts()
@@ -158,13 +158,13 @@ namespace Flow.Launcher.Core.Configuration
// delete it and prompt the user to pick the portable data location
if (File.Exists(roamingDataDeleteFilePath))
{
- FilesFolders.RemoveFolderIfExists(roamingDataDir);
+ FilesFolders.RemoveFolderIfExists(roamingDataDir, MessageBoxEx.Show);
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)
{
- FilesFolders.OpenPath(Constant.RootDirectory);
+ FilesFolders.OpenPath(Constant.RootDirectory, MessageBoxEx.Show);
Environment.Exit(0);
}
@@ -173,7 +173,7 @@ namespace Flow.Launcher.Core.Configuration
// delete it and notify the user about it.
else if (File.Exists(portableDataDeleteFilePath))
{
- FilesFolders.RemoveFolderIfExists(portableDataDir);
+ FilesFolders.RemoveFolderIfExists(portableDataDir, MessageBoxEx.Show);
MessageBoxEx.Show("Flow Launcher has detected you disabled portable mode, " +
"the relevant shortcuts and uninstaller entry have been created");
diff --git a/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs b/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs
index 30e812c6f..433df6f97 100644
--- a/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs
+++ b/Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs
@@ -6,8 +6,10 @@ 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
{
@@ -57,7 +59,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
EnvName,
Environment.NewLine
);
- if (MessageBox.Show(noRuntimeMessage, string.Empty, MessageBoxButtons.YesNo) == DialogResult.No)
+ if (MessageBoxEx.Show(noRuntimeMessage, string.Empty, MessageBoxType.YesNo) == MessageBoxResult.No)
{
var msg = string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName);
string selectedFile;
@@ -82,7 +84,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
}
else
{
- MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
+ MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
Log.Error("PluginsLoader",
$"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.",
$"{Language}Environment");
@@ -98,7 +100,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
if (expectedPath == currentPath)
return;
- FilesFolders.RemoveFolderIfExists(installedDirPath);
+ FilesFolders.RemoveFolderIfExists(installedDirPath, MessageBoxEx.Show);
InstallEnvironment();
diff --git a/Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs b/Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs
index 5676e12f5..96c29646e 100644
--- a/Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs
+++ b/Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs
@@ -28,7 +28,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
internal override void InstallEnvironment()
{
- FilesFolders.RemoveFolderIfExists(InstallPath);
+ FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
// Python 3.11.4 is no longer Windows 7 compatible. If user is on Win 7 and
// uses Python plugin they need to custom install and use v3.8.9
diff --git a/Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs b/Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs
index 70341f711..0d6f109e0 100644
--- a/Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs
+++ b/Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs
@@ -25,7 +25,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
internal override void InstallEnvironment()
{
- FilesFolders.RemoveFolderIfExists(InstallPath);
+ FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();
diff --git a/Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs b/Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs
index 11ed94d3f..582a4407c 100644
--- a/Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs
+++ b/Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs
@@ -25,7 +25,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
internal override void InstallEnvironment()
{
- FilesFolders.RemoveFolderIfExists(InstallPath);
+ FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();
diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs
index 91cb36a0e..5c4eaa1da 100644
--- a/Flow.Launcher.Core/Plugin/PluginManager.cs
+++ b/Flow.Launcher.Core/Plugin/PluginManager.cs
@@ -519,7 +519,7 @@ namespace Flow.Launcher.Core.Plugin
var newPluginPath = Path.Combine(installDirectory, folderName);
- FilesFolders.CopyAll(pluginFolderPath, newPluginPath);
+ FilesFolders.CopyAll(pluginFolderPath, newPluginPath, MessageBoxEx.Show);
Directory.Delete(tempFolderPluginPath, true);
diff --git a/Flow.Launcher.Core/Plugin/PluginsLoader.cs b/Flow.Launcher.Core/Plugin/PluginsLoader.cs
index 0f2e4f996..495d25e1b 100644
--- a/Flow.Launcher.Core/Plugin/PluginsLoader.cs
+++ b/Flow.Launcher.Core/Plugin/PluginsLoader.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
-using System.Windows.Forms;
+using System.Windows;
using Flow.Launcher.Core.ExternalPlugins.Environments;
#pragma warning disable IDE0005
using Flow.Launcher.Infrastructure.Logger;
@@ -11,6 +11,7 @@ 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
{
@@ -119,10 +120,10 @@ namespace Flow.Launcher.Core.Plugin
_ = Task.Run(() =>
{
- MessageBox.Show($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
+ MessageBoxEx.Show($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
$"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" +
$"Please refer to the logs for more information", "",
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
+ MessageBoxButton.OK, MessageBoxImage.Warning);
});
}
diff --git a/Flow.Launcher.Core/Updater.cs b/Flow.Launcher.Core/Updater.cs
index 34545c771..5a980c5e2 100644
--- a/Flow.Launcher.Core/Updater.cs
+++ b/Flow.Launcher.Core/Updater.cs
@@ -69,8 +69,8 @@ namespace Flow.Launcher.Core
if (DataLocation.PortableDataLocationInUse())
{
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
- FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination);
- if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination))
+ FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination, MessageBoxEx.Show);
+ if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination, MessageBoxEx.Show))
MessageBoxEx.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
DataLocation.PortableDataPath,
targetDestination));
diff --git a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
index dd8c4b112..fb2578e6d 100644
--- a/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
+++ b/Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs
@@ -21,7 +21,8 @@ namespace Flow.Launcher.Plugin.SharedCommands
///
///
///
- public static void CopyAll(this string sourcePath, string targetPath)
+ ///
+ public static void CopyAll(this string sourcePath, string targetPath, Func messageBoxExShow)
{
// Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourcePath);
@@ -54,7 +55,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
foreach (DirectoryInfo subdir in dirs)
{
string temppath = Path.Combine(targetPath, subdir.Name);
- CopyAll(subdir.FullName, temppath);
+ CopyAll(subdir.FullName, temppath, messageBoxExShow);
}
}
catch (Exception)
@@ -62,7 +63,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG
throw;
#else
- MessageBox.Show(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath));
+ messageBoxExShow(string.Format("Copying path {0} has failed, it will now be deleted for consistency", targetPath));
RemoveFolderIfExists(targetPath);
#endif
}
@@ -75,8 +76,9 @@ namespace Flow.Launcher.Plugin.SharedCommands
///
///
///
+ ///
///
- public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath)
+ public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath, Func messageBoxExShow)
{
try
{
@@ -96,7 +98,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG
throw;
#else
- MessageBox.Show(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath));
+ messageBoxExShow(string.Format("Unable to verify folders and files between {0} and {1}", fromPath, toPath));
return false;
#endif
}
@@ -107,7 +109,8 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// Deletes a folder if it exists
///
///
- public static void RemoveFolderIfExists(this string path)
+ ///
+ public static void RemoveFolderIfExists(this string path, Func messageBoxExShow)
{
try
{
@@ -119,7 +122,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG
throw;
#else
- MessageBox.Show(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path));
+ messageBoxExShow(string.Format("Not able to delete folder {0}, please go to the location and manually delete it", path));
#endif
}
}
@@ -148,7 +151,8 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// Open a directory window (using the OS's default handler, usually explorer)
///
///
- public static void OpenPath(string fileOrFolderPath)
+ ///
+ public static void OpenPath(string fileOrFolderPath, Func messageBoxExShow)
{
var psi = new ProcessStartInfo
{
@@ -166,7 +170,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG
throw;
#else
- MessageBox.Show(string.Format("Unable to open the path {0}, please check if it exists", fileOrFolderPath));
+ messageBoxExShow(string.Format("Unable to open the path {0}, please check if it exists", fileOrFolderPath));
#endif
}
}
@@ -175,9 +179,10 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// Open a file with associated application
///
/// File path
+ ///
/// Working directory
/// Open as Administrator
- public static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false)
+ public static void OpenFile(string filePath, Func messageBoxExShow, string workingDir = "", bool asAdmin = false)
{
var psi = new ProcessStartInfo
{
@@ -196,7 +201,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG
throw;
#else
- MessageBox.Show(string.Format("Unable to open the path {0}, please check if it exists", filePath));
+ messageBoxExShow(string.Format("Unable to open the path {0}, please check if it exists", filePath));
#endif
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
index 5077e6061..54a6f7a44 100644
--- a/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Calculator/Main.cs
@@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.Globalization;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
-using System.Windows;
using System.Windows.Controls;
using Mages.Core;
using Flow.Launcher.Plugin.Calculator.ViewModels;
using Flow.Launcher.Plugin.Calculator.Views;
+using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Calculator
{
@@ -101,7 +101,7 @@ namespace Flow.Launcher.Plugin.Calculator
}
catch (ExternalException)
{
- MessageBox.Show("Copy failed, please try later");
+ MessageBoxEx.Show("Copy failed, please try later");
return false;
}
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs
index f061ca183..8c40cac9a 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/ContextMenu.cs
@@ -10,11 +10,9 @@ using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using System.Linq;
using Flow.Launcher.Plugin.Explorer.Helper;
-using MessageBox = System.Windows.Forms.MessageBox;
-using MessageBoxIcon = System.Windows.Forms.MessageBoxIcon;
-using MessageBoxButton = System.Windows.Forms.MessageBoxButtons;
-using DialogResult = System.Windows.Forms.DialogResult;
using Flow.Launcher.Plugin.Explorer.ViewModels;
+using Flow.Launcher.Core;
+using MessageBoxImage = Flow.Launcher.Core.MessageBoxEx.MessageBoxImage;
namespace Flow.Launcher.Plugin.Explorer
{
@@ -177,12 +175,12 @@ namespace Flow.Launcher.Plugin.Explorer
{
try
{
- if (MessageBox.Show(
+ if (MessageBoxEx.Show(
string.Format(Context.API.GetTranslation("plugin_explorer_delete_folder_link"), record.FullPath),
string.Empty,
MessageBoxButton.YesNo,
- MessageBoxIcon.Warning)
- == DialogResult.No)
+ MessageBoxImage.Warning)
+ == MessageBoxResult.No)
return false;
if (isFile)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs
index ef923632d..b890e6e18 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingDownloadHelper.cs
@@ -1,10 +1,13 @@
using Droplex;
+using Flow.Launcher.Core;
using Flow.Launcher.Plugin.SharedCommands;
using Microsoft.Win32;
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using System.Windows;
+using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Plugin.Explorer.Search.Everything;
@@ -19,10 +22,10 @@ public static class EverythingDownloadHelper
if (string.IsNullOrEmpty(installedLocation))
{
- if (System.Windows.Forms.MessageBox.Show(
+ if (MessageBoxEx.Show(
string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine),
api.GetTranslation("flowlauncher_plugin_everything_installing_title"),
- System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
+ MessageBoxType.YesNo) == MessageBoxResult.Yes)
{
var dlg = new System.Windows.Forms.OpenFileDialog
{
@@ -50,7 +53,7 @@ public static class EverythingDownloadHelper
installedLocation = "C:\\Program Files\\Everything\\Everything.exe";
- FilesFolders.OpenPath(installedLocation);
+ FilesFolders.OpenPath(installedLocation, MessageBoxEx.Show);
return installedLocation;
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
index 1e7555a8d..bffe75c29 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/ResultManager.cs
@@ -12,6 +12,7 @@ using Path = System.IO.Path;
using System.Windows.Controls;
using Flow.Launcher.Plugin.Explorer.Views;
using Peter;
+using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Explorer.Search
{
@@ -123,7 +124,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
+ MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
return false;
}
}
@@ -137,7 +138,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
+ MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
return false;
}
}
@@ -152,7 +153,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
+ MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
return false;
}
}
@@ -315,7 +316,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
- MessageBox.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_openfile_error"));
+ MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_openfile_error"));
}
return true;
@@ -337,7 +338,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
private static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false)
{
IncrementEverythingRunCounterIfNeeded(filePath);
- FilesFolders.OpenFile(filePath, workingDir, asAdmin);
+ FilesFolders.OpenFile(filePath, MessageBoxEx.Show, workingDir, asAdmin);
}
private static void OpenFolder(string folderPath, string fileNameOrFilePath = null)
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
index 309f7a6f7..49b4a9fa2 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs
@@ -1,4 +1,5 @@
#nullable enable
+using Flow.Launcher.Core;
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
using Flow.Launcher.Plugin.Explorer.Search.Everything.Exceptions;
@@ -14,7 +15,6 @@ using System.Linq;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Input;
-using MessageBox = System.Windows.Forms.MessageBox;
namespace Flow.Launcher.Plugin.Explorer.ViewModels
{
@@ -358,7 +358,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
private void ShowUnselectedMessage()
{
var warning = Context.API.GetTranslation("plugin_explorer_make_selection_warning");
- MessageBox.Show(warning);
+ MessageBoxEx.Show(warning);
}
diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
index 9e86ce4b4..fdfe1638a 100644
--- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ActionKeywordSetting.xaml.cs
@@ -1,8 +1,9 @@
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Input;
+using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Explorer.Views
{
@@ -62,10 +63,10 @@ namespace Flow.Launcher.Plugin.Explorer.Views
switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled)
{
case (Settings.ActionKeyword.FileContentSearchActionKeyword, true):
- MessageBox.Show(api.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
+ MessageBoxEx.Show(api.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
return;
case (Settings.ActionKeyword.QuickAccessActionKeyword, true):
- MessageBox.Show(api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid"));
+ MessageBoxEx.Show(api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid"));
return;
}
@@ -77,7 +78,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
}
// The keyword is not valid, so show message
- MessageBox.Show(api.GetTranslation("newActionKeywordsHasBeenAssigned"));
+ MessageBoxEx.Show(api.GetTranslation("newActionKeywordsHasBeenAssigned"));
}
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs
index 2d71329b4..fcba3ebee 100644
--- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs
+++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs
@@ -1,4 +1,5 @@
-using Flow.Launcher.Core.ExternalPlugins;
+using Flow.Launcher.Core;
+using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Http;
@@ -12,6 +13,7 @@ using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
+using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Plugin.PluginsManager
{
@@ -131,8 +133,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
Environment.NewLine);
}
- if (MessageBox.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
- MessageBoxButton.YesNo) == MessageBoxResult.No)
+ if (MessageBoxEx.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
+ MessageBoxType.YesNo) == MessageBoxResult.No)
return;
// at minimum should provide a name, but handle plugin that is not downloaded from plugins manifest and is a url download
@@ -265,9 +267,9 @@ namespace Flow.Launcher.Plugin.PluginsManager
Environment.NewLine);
}
- if (MessageBox.Show(message,
+ if (MessageBoxEx.Show(message,
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
- MessageBoxButton.YesNo) != MessageBoxResult.Yes)
+ MessageBoxType.YesNo) != MessageBoxResult.Yes)
{
return false;
}
@@ -360,9 +362,9 @@ namespace Flow.Launcher.Plugin.PluginsManager
resultsForUpdate.Count());
}
- if (MessageBox.Show(message,
+ if (MessageBoxEx.Show(message,
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
- MessageBoxButton.YesNo) == MessageBoxResult.No)
+ MessageBoxType.YesNo) == MessageBoxResult.No)
{
return false;
}
@@ -474,12 +476,12 @@ namespace Flow.Launcher.Plugin.PluginsManager
if (Settings.WarnFromUnknownSource)
{
if (!InstallSourceKnown(plugin.UrlDownload)
- && MessageBox.Show(string.Format(
+ && MessageBoxEx.Show(string.Format(
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
Environment.NewLine),
Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning_title"),
- MessageBoxButton.YesNo) == MessageBoxResult.No)
+ MessageBoxType.YesNo) == MessageBoxResult.No)
return false;
}
@@ -511,13 +513,13 @@ namespace Flow.Launcher.Plugin.PluginsManager
if (Settings.WarnFromUnknownSource)
{
if (!InstallSourceKnown(plugin.Website)
- && MessageBox.Show(string.Format(
+ && MessageBoxEx.Show(string.Format(
Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning"),
Environment.NewLine),
Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning_title"),
- MessageBoxButton.YesNo) == MessageBoxResult.No)
+ MessageBoxType.YesNo) == MessageBoxResult.No)
return false;
}
@@ -648,9 +650,9 @@ namespace Flow.Launcher.Plugin.PluginsManager
Environment.NewLine);
}
- if (MessageBox.Show(message,
+ if (MessageBoxEx.Show(message,
Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"),
- MessageBoxButton.YesNo) == MessageBoxResult.Yes)
+ MessageBoxType.YesNo) == MessageBoxResult.Yes)
{
Application.Current.MainWindow.Hide();
Uninstall(x.Metadata);
diff --git a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
index be8b768bd..fef16cb33 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/AddProgramSource.xaml.cs
@@ -1,4 +1,5 @@
using System.Windows;
+using Flow.Launcher.Core;
using Flow.Launcher.Plugin.Program.ViewModels;
namespace Flow.Launcher.Plugin.Program
@@ -32,7 +33,7 @@ namespace Flow.Launcher.Plugin.Program
var (modified, msg) = ViewModel.AddOrUpdate();
if (modified == false && msg != null)
{
- MessageBox.Show(msg); // Invalid
+ MessageBoxEx.Show(msg); // Invalid
return;
}
DialogResult = modified;
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
index 4d88eef2c..68363c1fa 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Program/Flow.Launcher.Plugin.Program.csproj
@@ -54,6 +54,7 @@
+
diff --git a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs
index 31565c8b0..af1df8e71 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/ProgramSuffixes.xaml.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Windows;
+using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Program
{
@@ -39,14 +40,14 @@ namespace Flow.Launcher.Plugin.Program
if (suffixes.Length == 0 && UseCustomSuffixes)
{
string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty");
- MessageBox.Show(warning);
+ MessageBoxEx.Show(warning);
return;
}
if (protocols.Length == 0 && UseCustomProtocols)
{
string warning = context.API.GetTranslation("flowlauncher_plugin_protocols_cannot_empty");
- MessageBox.Show(warning);
+ MessageBoxEx.Show(warning);
return;
}
diff --git a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs
index 7570d6b4d..e85b7534e 100644
--- a/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.Program/Views/ProgramSetting.xaml.cs
@@ -10,6 +10,8 @@ using Flow.Launcher.Plugin.Program.Programs;
using System.ComponentModel;
using System.Windows.Data;
using Flow.Launcher.Plugin.Program.ViewModels;
+using Flow.Launcher.Core;
+using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Plugin.Program.Views
{
@@ -178,7 +180,7 @@ namespace Flow.Launcher.Plugin.Program.Views
if (selectedProgramSource == null)
{
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
- MessageBox.Show(msg);
+ MessageBoxEx.Show(msg);
}
else
{
@@ -283,7 +285,7 @@ namespace Flow.Launcher.Plugin.Program.Views
if (selectedItems.Count == 0)
{
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
- MessageBox.Show(msg);
+ MessageBoxEx.Show(msg);
return;
}
@@ -292,7 +294,7 @@ namespace Flow.Launcher.Plugin.Program.Views
var msg = string.Format(
context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source"));
- if (MessageBox.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
+ if (MessageBoxEx.Show(msg, string.Empty, MessageBoxType.YesNo) == MessageBoxResult.No)
{
return;
}
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj b/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj
index b797b3cf4..4e804e82c 100644
--- a/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj
+++ b/Plugins/Flow.Launcher.Plugin.Sys/Flow.Launcher.Plugin.Sys.csproj
@@ -37,6 +37,7 @@
+
diff --git a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
index 1ec07915d..72f3639ff 100644
--- a/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
+++ b/Plugins/Flow.Launcher.Plugin.Sys/Main.cs
@@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Forms;
using System.Windows.Interop;
+using Flow.Launcher.Core;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;
@@ -14,7 +15,7 @@ using Flow.Launcher.Plugin.SharedCommands;
using Application = System.Windows.Application;
using Control = System.Windows.Controls.Control;
using FormsApplication = System.Windows.Forms.Application;
-using MessageBox = System.Windows.MessageBox;
+using MessageBoxImage = Flow.Launcher.Core.MessageBoxEx.MessageBoxImage;
namespace Flow.Launcher.Plugin.Sys
{
@@ -143,7 +144,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\shutdown.png",
Action = c =>
{
- var result = MessageBox.Show(
+ var result = MessageBoxEx.Show(
context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_shutdown_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
@@ -163,7 +164,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\restart.png",
Action = c =>
{
- var result = MessageBox.Show(
+ var result = MessageBoxEx.Show(
context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
@@ -183,7 +184,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\restart_advanced.png",
Action = c =>
{
- var result = MessageBox.Show(
+ var result = MessageBoxEx.Show(
context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer_advanced"),
context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
@@ -202,7 +203,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\logoff.png",
Action = c =>
{
- var result = MessageBox.Show(
+ var result = MessageBoxEx.Show(
context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_logoff_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_log_off"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
@@ -279,7 +280,7 @@ namespace Flow.Launcher.Plugin.Sys
var result = SHEmptyRecycleBin(new WindowInteropHelper(Application.Current.MainWindow).Handle, 0);
if (result != (uint) HRESULT.S_OK && result != (uint) 0x8000FFFF)
{
- MessageBox.Show($"Error emptying recycle bin, error code: {result}\n" +
+ MessageBoxEx.Show($"Error emptying recycle bin, error code: {result}\n" +
"please refer to https://msdn.microsoft.com/en-us/library/windows/desktop/aa378137",
"Error",
MessageBoxButton.OK, MessageBoxImage.Error);
diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs
index 60863ee82..8336f4b9a 100644
--- a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceSetting.xaml.cs
@@ -2,6 +2,7 @@
using System.Windows;
using Microsoft.Win32;
using Flow.Launcher.Core.Plugin;
+using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.WebSearch
{
@@ -55,17 +56,17 @@ namespace Flow.Launcher.Plugin.WebSearch
if (string.IsNullOrEmpty(_searchSource.Title))
{
var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_title");
- MessageBox.Show(warning);
+ MessageBoxEx.Show(warning);
}
else if (string.IsNullOrEmpty(_searchSource.Url))
{
var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_url");
- MessageBox.Show(warning);
+ MessageBoxEx.Show(warning);
}
else if (string.IsNullOrEmpty(_searchSource.ActionKeyword))
{
var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_action_keyword");
- MessageBox.Show(warning);
+ MessageBoxEx.Show(warning);
}
else if (_action == Action.Add)
{
@@ -92,7 +93,7 @@ namespace Flow.Launcher.Plugin.WebSearch
else
{
var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned");
- MessageBox.Show(warning);
+ MessageBoxEx.Show(warning);
}
}
@@ -113,7 +114,7 @@ namespace Flow.Launcher.Plugin.WebSearch
else
{
var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned");
- MessageBox.Show(warning);
+ MessageBoxEx.Show(warning);
}
if (!string.IsNullOrEmpty(selectedNewIconImageFullPath))
@@ -138,7 +139,7 @@ namespace Flow.Launcher.Plugin.WebSearch
if (!string.IsNullOrEmpty(selectedNewIconImageFullPath))
{
if (_viewModel.ShouldProvideHint(selectedNewIconImageFullPath))
- MessageBox.Show(_api.GetTranslation("flowlauncher_plugin_websearch_iconpath_hint"));
+ MessageBoxEx.Show(_api.GetTranslation("flowlauncher_plugin_websearch_iconpath_hint"));
imgPreviewIcon.Source = await _viewModel.LoadPreviewIconAsync(selectedNewIconImageFullPath);
}
diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SearchSourceViewModel.cs
index 105e7dd68..0495772d5 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
- MessageBox.Show(string.Format("Copying the selected image file to {0} has failed, changes will now be reverted", destinationFileNameFullPath));
+ Flow.Launcher.Core.MessageBoxEx.Show(string.Format("Copying the selected image file to {0} has failed, changes will now be reverted", destinationFileNameFullPath));
UpdateIconAttributes(selectedSearchSource, fullPathToOriginalImage);
#endif
}
diff --git a/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs b/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs
index 7caa5beb3..7e4edf653 100644
--- a/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs
+++ b/Plugins/Flow.Launcher.Plugin.WebSearch/SettingsControl.xaml.cs
@@ -1,8 +1,10 @@
-using System.Windows;
+using System.Windows;
using System.Windows.Controls;
using Flow.Launcher.Core.Plugin;
using System.ComponentModel;
using System.Windows.Data;
+using Flow.Launcher.Core;
+using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Plugin.WebSearch
{
@@ -36,7 +38,7 @@ namespace Flow.Launcher.Plugin.WebSearch
var warning = _context.API.GetTranslation("flowlauncher_plugin_websearch_delete_warning");
var formated = string.Format(warning, selected.Title);
- var result = MessageBox.Show(formated, string.Empty, MessageBoxButton.YesNo);
+ var result = MessageBoxEx.Show(formated, string.Empty, MessageBoxType.YesNo);
if (result == MessageBoxResult.Yes)
{
var id = _context.CurrentPluginMetadata.ID;