Replace System.Windows.MessageBox with MessageBoxEx

This commit is contained in:
Jack251970 2024-11-25 10:38:43 +08:00
parent c103244e20
commit b30cc4fc38
25 changed files with 108 additions and 85 deletions

View file

@ -96,13 +96,13 @@ namespace Flow.Launcher.Core.Configuration
public void MoveUserDataFolder(string fromLocation, string toLocation) public void MoveUserDataFolder(string fromLocation, string toLocation)
{ {
FilesFolders.CopyAll(fromLocation, toLocation); FilesFolders.CopyAll(fromLocation, toLocation, MessageBoxEx.Show);
VerifyUserDataAfterMove(fromLocation, toLocation); VerifyUserDataAfterMove(fromLocation, toLocation);
} }
public void VerifyUserDataAfterMove(string fromLocation, string toLocation) public void VerifyUserDataAfterMove(string fromLocation, string toLocation)
{ {
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation); FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation, MessageBoxEx.Show);
} }
public void CreateShortcuts() public void CreateShortcuts()
@ -158,13 +158,13 @@ namespace Flow.Launcher.Core.Configuration
// delete it and prompt the user to pick the portable data location // delete it and prompt the user to pick the portable data location
if (File.Exists(roamingDataDeleteFilePath)) if (File.Exists(roamingDataDeleteFilePath))
{ {
FilesFolders.RemoveFolderIfExists(roamingDataDir); FilesFolders.RemoveFolderIfExists(roamingDataDir, MessageBoxEx.Show);
if (MessageBoxEx.Show("Flow Launcher has detected you enabled portable mode, " + if (MessageBoxEx.Show("Flow Launcher has detected you enabled portable mode, " +
"would you like to move it to a different location?", string.Empty, "would you like to move it to a different location?", string.Empty,
MessageBoxType.YesNo) == MessageBoxResult.Yes) MessageBoxType.YesNo) == MessageBoxResult.Yes)
{ {
FilesFolders.OpenPath(Constant.RootDirectory); FilesFolders.OpenPath(Constant.RootDirectory, MessageBoxEx.Show);
Environment.Exit(0); Environment.Exit(0);
} }
@ -173,7 +173,7 @@ namespace Flow.Launcher.Core.Configuration
// delete it and notify the user about it. // delete it and notify the user about it.
else if (File.Exists(portableDataDeleteFilePath)) else if (File.Exists(portableDataDeleteFilePath))
{ {
FilesFolders.RemoveFolderIfExists(portableDataDir); FilesFolders.RemoveFolderIfExists(portableDataDir, MessageBoxEx.Show);
MessageBoxEx.Show("Flow Launcher has detected you disabled portable mode, " + MessageBoxEx.Show("Flow Launcher has detected you disabled portable mode, " +
"the relevant shortcuts and uninstaller entry have been created"); "the relevant shortcuts and uninstaller entry have been created");

View file

@ -6,8 +6,10 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using Flow.Launcher.Core.Resource; using Flow.Launcher.Core.Resource;
using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Core.ExternalPlugins.Environments namespace Flow.Launcher.Core.ExternalPlugins.Environments
{ {
@ -57,7 +59,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
EnvName, EnvName,
Environment.NewLine 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); var msg = string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName);
string selectedFile; string selectedFile;
@ -82,7 +84,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
} }
else else
{ {
MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language)); MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
Log.Error("PluginsLoader", Log.Error("PluginsLoader",
$"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.", $"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.",
$"{Language}Environment"); $"{Language}Environment");
@ -98,7 +100,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
if (expectedPath == currentPath) if (expectedPath == currentPath)
return; return;
FilesFolders.RemoveFolderIfExists(installedDirPath); FilesFolders.RemoveFolderIfExists(installedDirPath, MessageBoxEx.Show);
InstallEnvironment(); InstallEnvironment();

View file

@ -28,7 +28,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
internal override void InstallEnvironment() 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 // 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 // uses Python plugin they need to custom install and use v3.8.9

View file

@ -25,7 +25,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
internal override void InstallEnvironment() internal override void InstallEnvironment()
{ {
FilesFolders.RemoveFolderIfExists(InstallPath); FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait(); DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();

View file

@ -25,7 +25,7 @@ namespace Flow.Launcher.Core.ExternalPlugins.Environments
internal override void InstallEnvironment() internal override void InstallEnvironment()
{ {
FilesFolders.RemoveFolderIfExists(InstallPath); FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait(); DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();

View file

@ -519,7 +519,7 @@ namespace Flow.Launcher.Core.Plugin
var newPluginPath = Path.Combine(installDirectory, folderName); var newPluginPath = Path.Combine(installDirectory, folderName);
FilesFolders.CopyAll(pluginFolderPath, newPluginPath); FilesFolders.CopyAll(pluginFolderPath, newPluginPath, MessageBoxEx.Show);
Directory.Delete(tempFolderPluginPath, true); Directory.Delete(tempFolderPluginPath, true);

View file

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows;
using Flow.Launcher.Core.ExternalPlugins.Environments; using Flow.Launcher.Core.ExternalPlugins.Environments;
#pragma warning disable IDE0005 #pragma warning disable IDE0005
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
@ -11,6 +11,7 @@ using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin; using Flow.Launcher.Plugin;
using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch; using Stopwatch = Flow.Launcher.Infrastructure.Stopwatch;
using MessageBoxImage = Flow.Launcher.Core.MessageBoxEx.MessageBoxImage;
namespace Flow.Launcher.Core.Plugin namespace Flow.Launcher.Core.Plugin
{ {
@ -119,10 +120,10 @@ namespace Flow.Launcher.Core.Plugin
_ = Task.Run(() => _ = Task.Run(() =>
{ {
MessageBox.Show($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" + MessageBoxEx.Show($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
$"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" + $"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" +
$"Please refer to the logs for more information", "", $"Please refer to the logs for more information", "",
MessageBoxButtons.OK, MessageBoxIcon.Warning); MessageBoxButton.OK, MessageBoxImage.Warning);
}); });
} }

View file

@ -69,8 +69,8 @@ namespace Flow.Launcher.Core
if (DataLocation.PortableDataLocationInUse()) if (DataLocation.PortableDataLocationInUse())
{ {
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}"; var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination); FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination, MessageBoxEx.Show);
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination)) if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination, MessageBoxEx.Show))
MessageBoxEx.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"), MessageBoxEx.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
DataLocation.PortableDataPath, DataLocation.PortableDataPath,
targetDestination)); targetDestination));

View file

@ -21,7 +21,8 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// </summary> /// </summary>
/// <param name="sourcePath"></param> /// <param name="sourcePath"></param>
/// <param name="targetPath"></param> /// <param name="targetPath"></param>
public static void CopyAll(this string sourcePath, string targetPath) /// <param name="messageBoxExShow"></param>
public static void CopyAll(this string sourcePath, string targetPath, Func<string, MessageBoxResult> messageBoxExShow)
{ {
// Get the subdirectories for the specified directory. // Get the subdirectories for the specified directory.
DirectoryInfo dir = new DirectoryInfo(sourcePath); DirectoryInfo dir = new DirectoryInfo(sourcePath);
@ -54,7 +55,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
foreach (DirectoryInfo subdir in dirs) foreach (DirectoryInfo subdir in dirs)
{ {
string temppath = Path.Combine(targetPath, subdir.Name); string temppath = Path.Combine(targetPath, subdir.Name);
CopyAll(subdir.FullName, temppath); CopyAll(subdir.FullName, temppath, messageBoxExShow);
} }
} }
catch (Exception) catch (Exception)
@ -62,7 +63,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG #if DEBUG
throw; throw;
#else #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); RemoveFolderIfExists(targetPath);
#endif #endif
} }
@ -75,8 +76,9 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// </summary> /// </summary>
/// <param name="fromPath"></param> /// <param name="fromPath"></param>
/// <param name="toPath"></param> /// <param name="toPath"></param>
/// <param name="messageBoxExShow"></param>
/// <returns></returns> /// <returns></returns>
public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath) public static bool VerifyBothFolderFilesEqual(this string fromPath, string toPath, Func<string, MessageBoxResult> messageBoxExShow)
{ {
try try
{ {
@ -96,7 +98,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG #if DEBUG
throw; throw;
#else #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; return false;
#endif #endif
} }
@ -107,7 +109,8 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// Deletes a folder if it exists /// Deletes a folder if it exists
/// </summary> /// </summary>
/// <param name="path"></param> /// <param name="path"></param>
public static void RemoveFolderIfExists(this string path) /// <param name="messageBoxExShow"></param>
public static void RemoveFolderIfExists(this string path, Func<string, MessageBoxResult> messageBoxExShow)
{ {
try try
{ {
@ -119,7 +122,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG #if DEBUG
throw; throw;
#else #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 #endif
} }
} }
@ -148,7 +151,8 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// Open a directory window (using the OS's default handler, usually explorer) /// Open a directory window (using the OS's default handler, usually explorer)
/// </summary> /// </summary>
/// <param name="fileOrFolderPath"></param> /// <param name="fileOrFolderPath"></param>
public static void OpenPath(string fileOrFolderPath) /// <param name="messageBoxExShow"></param>
public static void OpenPath(string fileOrFolderPath, Func<string, MessageBoxResult> messageBoxExShow)
{ {
var psi = new ProcessStartInfo var psi = new ProcessStartInfo
{ {
@ -166,7 +170,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG #if DEBUG
throw; throw;
#else #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 #endif
} }
} }
@ -175,9 +179,10 @@ namespace Flow.Launcher.Plugin.SharedCommands
/// Open a file with associated application /// Open a file with associated application
/// </summary> /// </summary>
/// <param name="filePath">File path</param> /// <param name="filePath">File path</param>
/// <param name="messageBoxExShow"></param>
/// <param name="workingDir">Working directory</param> /// <param name="workingDir">Working directory</param>
/// <param name="asAdmin">Open as Administrator</param> /// <param name="asAdmin">Open as Administrator</param>
public static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false) public static void OpenFile(string filePath, Func<string, MessageBoxResult> messageBoxExShow, string workingDir = "", bool asAdmin = false)
{ {
var psi = new ProcessStartInfo var psi = new ProcessStartInfo
{ {
@ -196,7 +201,7 @@ namespace Flow.Launcher.Plugin.SharedCommands
#if DEBUG #if DEBUG
throw; throw;
#else #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 #endif
} }
} }

View file

@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Mages.Core; using Mages.Core;
using Flow.Launcher.Plugin.Calculator.ViewModels; using Flow.Launcher.Plugin.Calculator.ViewModels;
using Flow.Launcher.Plugin.Calculator.Views; using Flow.Launcher.Plugin.Calculator.Views;
using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Calculator namespace Flow.Launcher.Plugin.Calculator
{ {
@ -101,7 +101,7 @@ namespace Flow.Launcher.Plugin.Calculator
} }
catch (ExternalException) catch (ExternalException)
{ {
MessageBox.Show("Copy failed, please try later"); MessageBoxEx.Show("Copy failed, please try later");
return false; return false;
} }
} }

View file

@ -10,11 +10,9 @@ using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using System.Linq; using System.Linq;
using Flow.Launcher.Plugin.Explorer.Helper; 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.Plugin.Explorer.ViewModels;
using Flow.Launcher.Core;
using MessageBoxImage = Flow.Launcher.Core.MessageBoxEx.MessageBoxImage;
namespace Flow.Launcher.Plugin.Explorer namespace Flow.Launcher.Plugin.Explorer
{ {
@ -177,12 +175,12 @@ namespace Flow.Launcher.Plugin.Explorer
{ {
try try
{ {
if (MessageBox.Show( if (MessageBoxEx.Show(
string.Format(Context.API.GetTranslation("plugin_explorer_delete_folder_link"), record.FullPath), string.Format(Context.API.GetTranslation("plugin_explorer_delete_folder_link"), record.FullPath),
string.Empty, string.Empty,
MessageBoxButton.YesNo, MessageBoxButton.YesNo,
MessageBoxIcon.Warning) MessageBoxImage.Warning)
== DialogResult.No) == MessageBoxResult.No)
return false; return false;
if (isFile) if (isFile)

View file

@ -1,10 +1,13 @@
using Droplex; using Droplex;
using Flow.Launcher.Core;
using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Plugin.SharedCommands;
using Microsoft.Win32; using Microsoft.Win32;
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows;
using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Plugin.Explorer.Search.Everything; namespace Flow.Launcher.Plugin.Explorer.Search.Everything;
@ -19,10 +22,10 @@ public static class EverythingDownloadHelper
if (string.IsNullOrEmpty(installedLocation)) if (string.IsNullOrEmpty(installedLocation))
{ {
if (System.Windows.Forms.MessageBox.Show( if (MessageBoxEx.Show(
string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine), string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine),
api.GetTranslation("flowlauncher_plugin_everything_installing_title"), 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 var dlg = new System.Windows.Forms.OpenFileDialog
{ {
@ -50,7 +53,7 @@ public static class EverythingDownloadHelper
installedLocation = "C:\\Program Files\\Everything\\Everything.exe"; installedLocation = "C:\\Program Files\\Everything\\Everything.exe";
FilesFolders.OpenPath(installedLocation); FilesFolders.OpenPath(installedLocation, MessageBoxEx.Show);
return installedLocation; return installedLocation;

View file

@ -12,6 +12,7 @@ using Path = System.IO.Path;
using System.Windows.Controls; using System.Windows.Controls;
using Flow.Launcher.Plugin.Explorer.Views; using Flow.Launcher.Plugin.Explorer.Views;
using Peter; using Peter;
using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Explorer.Search namespace Flow.Launcher.Plugin.Explorer.Search
{ {
@ -123,7 +124,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
catch (Exception ex) 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; return false;
} }
} }
@ -137,7 +138,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
catch (Exception ex) 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; return false;
} }
} }
@ -152,7 +153,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
catch (Exception ex) 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; return false;
} }
} }
@ -315,7 +316,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
} }
catch (Exception ex) 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; return true;
@ -337,7 +338,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
private static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false) private static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false)
{ {
IncrementEverythingRunCounterIfNeeded(filePath); IncrementEverythingRunCounterIfNeeded(filePath);
FilesFolders.OpenFile(filePath, workingDir, asAdmin); FilesFolders.OpenFile(filePath, MessageBoxEx.Show, workingDir, asAdmin);
} }
private static void OpenFolder(string folderPath, string fileNameOrFilePath = null) private static void OpenFolder(string folderPath, string fileNameOrFilePath = null)

View file

@ -1,4 +1,5 @@
#nullable enable #nullable enable
using Flow.Launcher.Core;
using Flow.Launcher.Plugin.Explorer.Search; using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.Search.Everything; using Flow.Launcher.Plugin.Explorer.Search.Everything;
using Flow.Launcher.Plugin.Explorer.Search.Everything.Exceptions; using Flow.Launcher.Plugin.Explorer.Search.Everything.Exceptions;
@ -14,7 +15,6 @@ using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Input; using System.Windows.Input;
using MessageBox = System.Windows.Forms.MessageBox;
namespace Flow.Launcher.Plugin.Explorer.ViewModels namespace Flow.Launcher.Plugin.Explorer.ViewModels
{ {
@ -358,7 +358,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
private void ShowUnselectedMessage() private void ShowUnselectedMessage()
{ {
var warning = Context.API.GetTranslation("plugin_explorer_make_selection_warning"); var warning = Context.API.GetTranslation("plugin_explorer_make_selection_warning");
MessageBox.Show(warning); MessageBoxEx.Show(warning);
} }

View file

@ -1,8 +1,9 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Explorer.Views namespace Flow.Launcher.Plugin.Explorer.Views
{ {
@ -62,10 +63,10 @@ namespace Flow.Launcher.Plugin.Explorer.Views
switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled) switch (CurrentActionKeyword.KeywordProperty, KeywordEnabled)
{ {
case (Settings.ActionKeyword.FileContentSearchActionKeyword, true): case (Settings.ActionKeyword.FileContentSearchActionKeyword, true):
MessageBox.Show(api.GetTranslation("plugin_explorer_globalActionKeywordInvalid")); MessageBoxEx.Show(api.GetTranslation("plugin_explorer_globalActionKeywordInvalid"));
return; return;
case (Settings.ActionKeyword.QuickAccessActionKeyword, true): case (Settings.ActionKeyword.QuickAccessActionKeyword, true):
MessageBox.Show(api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid")); MessageBoxEx.Show(api.GetTranslation("plugin_explorer_quickaccess_globalActionKeywordInvalid"));
return; return;
} }
@ -77,7 +78,7 @@ namespace Flow.Launcher.Plugin.Explorer.Views
} }
// The keyword is not valid, so show message // 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) private void BtnCancel_OnClick(object sender, RoutedEventArgs e)

View file

@ -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.Core.Plugin;
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Http; using Flow.Launcher.Infrastructure.Http;
@ -12,6 +13,7 @@ using System.Net.Http;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Plugin.PluginsManager namespace Flow.Launcher.Plugin.PluginsManager
{ {
@ -131,8 +133,8 @@ namespace Flow.Launcher.Plugin.PluginsManager
Environment.NewLine); Environment.NewLine);
} }
if (MessageBox.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"), if (MessageBoxEx.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
MessageBoxButton.YesNo) == MessageBoxResult.No) MessageBoxType.YesNo) == MessageBoxResult.No)
return; return;
// at minimum should provide a name, but handle plugin that is not downloaded from plugins manifest and is a url download // 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); Environment.NewLine);
} }
if (MessageBox.Show(message, if (MessageBoxEx.Show(message,
Context.API.GetTranslation("plugin_pluginsmanager_update_title"), Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
MessageBoxButton.YesNo) != MessageBoxResult.Yes) MessageBoxType.YesNo) != MessageBoxResult.Yes)
{ {
return false; return false;
} }
@ -360,9 +362,9 @@ namespace Flow.Launcher.Plugin.PluginsManager
resultsForUpdate.Count()); resultsForUpdate.Count());
} }
if (MessageBox.Show(message, if (MessageBoxEx.Show(message,
Context.API.GetTranslation("plugin_pluginsmanager_update_title"), Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
MessageBoxButton.YesNo) == MessageBoxResult.No) MessageBoxType.YesNo) == MessageBoxResult.No)
{ {
return false; return false;
} }
@ -474,12 +476,12 @@ namespace Flow.Launcher.Plugin.PluginsManager
if (Settings.WarnFromUnknownSource) if (Settings.WarnFromUnknownSource)
{ {
if (!InstallSourceKnown(plugin.UrlDownload) if (!InstallSourceKnown(plugin.UrlDownload)
&& MessageBox.Show(string.Format( && MessageBoxEx.Show(string.Format(
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"), Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
Environment.NewLine), Environment.NewLine),
Context.API.GetTranslation( Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning_title"), "plugin_pluginsmanager_install_unknown_source_warning_title"),
MessageBoxButton.YesNo) == MessageBoxResult.No) MessageBoxType.YesNo) == MessageBoxResult.No)
return false; return false;
} }
@ -511,13 +513,13 @@ namespace Flow.Launcher.Plugin.PluginsManager
if (Settings.WarnFromUnknownSource) if (Settings.WarnFromUnknownSource)
{ {
if (!InstallSourceKnown(plugin.Website) if (!InstallSourceKnown(plugin.Website)
&& MessageBox.Show(string.Format( && MessageBoxEx.Show(string.Format(
Context.API.GetTranslation( Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning"), "plugin_pluginsmanager_install_unknown_source_warning"),
Environment.NewLine), Environment.NewLine),
Context.API.GetTranslation( Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning_title"), "plugin_pluginsmanager_install_unknown_source_warning_title"),
MessageBoxButton.YesNo) == MessageBoxResult.No) MessageBoxType.YesNo) == MessageBoxResult.No)
return false; return false;
} }
@ -648,9 +650,9 @@ namespace Flow.Launcher.Plugin.PluginsManager
Environment.NewLine); Environment.NewLine);
} }
if (MessageBox.Show(message, if (MessageBoxEx.Show(message,
Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"), Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"),
MessageBoxButton.YesNo) == MessageBoxResult.Yes) MessageBoxType.YesNo) == MessageBoxResult.Yes)
{ {
Application.Current.MainWindow.Hide(); Application.Current.MainWindow.Hide();
Uninstall(x.Metadata); Uninstall(x.Metadata);

View file

@ -1,4 +1,5 @@
using System.Windows; using System.Windows;
using Flow.Launcher.Core;
using Flow.Launcher.Plugin.Program.ViewModels; using Flow.Launcher.Plugin.Program.ViewModels;
namespace Flow.Launcher.Plugin.Program namespace Flow.Launcher.Plugin.Program
@ -32,7 +33,7 @@ namespace Flow.Launcher.Plugin.Program
var (modified, msg) = ViewModel.AddOrUpdate(); var (modified, msg) = ViewModel.AddOrUpdate();
if (modified == false && msg != null) if (modified == false && msg != null)
{ {
MessageBox.Show(msg); // Invalid MessageBoxEx.Show(msg); // Invalid
return; return;
} }
DialogResult = modified; DialogResult = modified;

View file

@ -54,6 +54,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" /> <ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" /> <ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup> </ItemGroup>

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows; using System.Windows;
using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Program namespace Flow.Launcher.Plugin.Program
{ {
@ -39,14 +40,14 @@ namespace Flow.Launcher.Plugin.Program
if (suffixes.Length == 0 && UseCustomSuffixes) if (suffixes.Length == 0 && UseCustomSuffixes)
{ {
string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty"); string warning = context.API.GetTranslation("flowlauncher_plugin_program_suffixes_cannot_empty");
MessageBox.Show(warning); MessageBoxEx.Show(warning);
return; return;
} }
if (protocols.Length == 0 && UseCustomProtocols) if (protocols.Length == 0 && UseCustomProtocols)
{ {
string warning = context.API.GetTranslation("flowlauncher_plugin_protocols_cannot_empty"); string warning = context.API.GetTranslation("flowlauncher_plugin_protocols_cannot_empty");
MessageBox.Show(warning); MessageBoxEx.Show(warning);
return; return;
} }

View file

@ -10,6 +10,8 @@ using Flow.Launcher.Plugin.Program.Programs;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Data; using System.Windows.Data;
using Flow.Launcher.Plugin.Program.ViewModels; using Flow.Launcher.Plugin.Program.ViewModels;
using Flow.Launcher.Core;
using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Plugin.Program.Views namespace Flow.Launcher.Plugin.Program.Views
{ {
@ -178,7 +180,7 @@ namespace Flow.Launcher.Plugin.Program.Views
if (selectedProgramSource == null) if (selectedProgramSource == null)
{ {
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source"); string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
MessageBox.Show(msg); MessageBoxEx.Show(msg);
} }
else else
{ {
@ -283,7 +285,7 @@ namespace Flow.Launcher.Plugin.Program.Views
if (selectedItems.Count == 0) if (selectedItems.Count == 0)
{ {
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source"); string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
MessageBox.Show(msg); MessageBoxEx.Show(msg);
return; return;
} }
@ -292,7 +294,7 @@ namespace Flow.Launcher.Plugin.Program.Views
var msg = string.Format( var msg = string.Format(
context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source")); 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; return;
} }

View file

@ -37,6 +37,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" /> <ProjectReference Include="..\..\Flow.Launcher.Infrastructure\Flow.Launcher.Infrastructure.csproj" />
<ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" /> <ProjectReference Include="..\..\Flow.Launcher.Plugin\Flow.Launcher.Plugin.csproj" />
</ItemGroup> </ItemGroup>

View file

@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
using System.Windows; using System.Windows;
using System.Windows.Forms; using System.Windows.Forms;
using System.Windows.Interop; using System.Windows.Interop;
using Flow.Launcher.Core;
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Infrastructure.UserSettings;
@ -14,7 +15,7 @@ using Flow.Launcher.Plugin.SharedCommands;
using Application = System.Windows.Application; using Application = System.Windows.Application;
using Control = System.Windows.Controls.Control; using Control = System.Windows.Controls.Control;
using FormsApplication = System.Windows.Forms.Application; using FormsApplication = System.Windows.Forms.Application;
using MessageBox = System.Windows.MessageBox; using MessageBoxImage = Flow.Launcher.Core.MessageBoxEx.MessageBoxImage;
namespace Flow.Launcher.Plugin.Sys namespace Flow.Launcher.Plugin.Sys
{ {
@ -143,7 +144,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\shutdown.png", IcoPath = "Images\\shutdown.png",
Action = c => 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_dlgtext_shutdown_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"), context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning); MessageBoxButton.YesNo, MessageBoxImage.Warning);
@ -163,7 +164,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\restart.png", IcoPath = "Images\\restart.png",
Action = c => 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_dlgtext_restart_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"), context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning); MessageBoxButton.YesNo, MessageBoxImage.Warning);
@ -183,7 +184,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\restart_advanced.png", IcoPath = "Images\\restart_advanced.png",
Action = c => 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_dlgtext_restart_computer_advanced"),
context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"), context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning); MessageBoxButton.YesNo, MessageBoxImage.Warning);
@ -202,7 +203,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\logoff.png", IcoPath = "Images\\logoff.png",
Action = c => 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_dlgtext_logoff_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_log_off"), context.API.GetTranslation("flowlauncher_plugin_sys_log_off"),
MessageBoxButton.YesNo, MessageBoxImage.Warning); MessageBoxButton.YesNo, MessageBoxImage.Warning);
@ -279,7 +280,7 @@ namespace Flow.Launcher.Plugin.Sys
var result = SHEmptyRecycleBin(new WindowInteropHelper(Application.Current.MainWindow).Handle, 0); var result = SHEmptyRecycleBin(new WindowInteropHelper(Application.Current.MainWindow).Handle, 0);
if (result != (uint) HRESULT.S_OK && result != (uint) 0x8000FFFF) 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", "please refer to https://msdn.microsoft.com/en-us/library/windows/desktop/aa378137",
"Error", "Error",
MessageBoxButton.OK, MessageBoxImage.Error); MessageBoxButton.OK, MessageBoxImage.Error);

View file

@ -2,6 +2,7 @@
using System.Windows; using System.Windows;
using Microsoft.Win32; using Microsoft.Win32;
using Flow.Launcher.Core.Plugin; using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.WebSearch namespace Flow.Launcher.Plugin.WebSearch
{ {
@ -55,17 +56,17 @@ namespace Flow.Launcher.Plugin.WebSearch
if (string.IsNullOrEmpty(_searchSource.Title)) if (string.IsNullOrEmpty(_searchSource.Title))
{ {
var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_title"); var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_title");
MessageBox.Show(warning); MessageBoxEx.Show(warning);
} }
else if (string.IsNullOrEmpty(_searchSource.Url)) else if (string.IsNullOrEmpty(_searchSource.Url))
{ {
var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_url"); var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_url");
MessageBox.Show(warning); MessageBoxEx.Show(warning);
} }
else if (string.IsNullOrEmpty(_searchSource.ActionKeyword)) else if (string.IsNullOrEmpty(_searchSource.ActionKeyword))
{ {
var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_action_keyword"); var warning = _api.GetTranslation("flowlauncher_plugin_websearch_input_action_keyword");
MessageBox.Show(warning); MessageBoxEx.Show(warning);
} }
else if (_action == Action.Add) else if (_action == Action.Add)
{ {
@ -92,7 +93,7 @@ namespace Flow.Launcher.Plugin.WebSearch
else else
{ {
var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned"); var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned");
MessageBox.Show(warning); MessageBoxEx.Show(warning);
} }
} }
@ -113,7 +114,7 @@ namespace Flow.Launcher.Plugin.WebSearch
else else
{ {
var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned"); var warning = _api.GetTranslation("newActionKeywordsHasBeenAssigned");
MessageBox.Show(warning); MessageBoxEx.Show(warning);
} }
if (!string.IsNullOrEmpty(selectedNewIconImageFullPath)) if (!string.IsNullOrEmpty(selectedNewIconImageFullPath))
@ -138,7 +139,7 @@ namespace Flow.Launcher.Plugin.WebSearch
if (!string.IsNullOrEmpty(selectedNewIconImageFullPath)) if (!string.IsNullOrEmpty(selectedNewIconImageFullPath))
{ {
if (_viewModel.ShouldProvideHint(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); imgPreviewIcon.Source = await _viewModel.LoadPreviewIconAsync(selectedNewIconImageFullPath);
} }

View file

@ -41,7 +41,7 @@ namespace Flow.Launcher.Plugin.WebSearch
#if DEBUG #if DEBUG
throw; throw;
#else #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); UpdateIconAttributes(selectedSearchSource, fullPathToOriginalImage);
#endif #endif
} }

View file

@ -1,8 +1,10 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using Flow.Launcher.Core.Plugin; using Flow.Launcher.Core.Plugin;
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Data; using System.Windows.Data;
using Flow.Launcher.Core;
using static Flow.Launcher.Core.MessageBoxEx;
namespace Flow.Launcher.Plugin.WebSearch 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 warning = _context.API.GetTranslation("flowlauncher_plugin_websearch_delete_warning");
var formated = string.Format(warning, selected.Title); 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) if (result == MessageBoxResult.Yes)
{ {
var id = _context.CurrentPluginMetadata.ID; var id = _context.CurrentPluginMetadata.ID;