Use public api to call ShowMsgBox functions & remove useless Core project import

This commit is contained in:
Jack251970 2024-11-27 12:21:34 +08:00
parent 9b75acdf21
commit 534a1117aa
15 changed files with 38 additions and 55 deletions

View file

@ -7,7 +7,6 @@ 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 +100,7 @@ namespace Flow.Launcher.Plugin.Calculator
}
catch (ExternalException)
{
MessageBoxEx.Show("Copy failed, please try later");
Context.API.ShowMsgBox("Copy failed, please try later");
return false;
}
}

View file

@ -11,7 +11,6 @@ using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
using System.Linq;
using Flow.Launcher.Plugin.Explorer.Helper;
using Flow.Launcher.Plugin.Explorer.ViewModels;
using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Explorer
{
@ -174,7 +173,7 @@ namespace Flow.Launcher.Plugin.Explorer
{
try
{
if (MessageBoxEx.Show(
if (Context.API.ShowMsgBox(
string.Format(Context.API.GetTranslation("plugin_explorer_delete_folder_link"), record.FullPath),
string.Empty,
MessageBoxButton.YesNo,

View file

@ -1,5 +1,4 @@
using Droplex;
using Flow.Launcher.Core;
using Flow.Launcher.Plugin.SharedCommands;
using Microsoft.Win32;
using System;
@ -21,7 +20,7 @@ public static class EverythingDownloadHelper
if (string.IsNullOrEmpty(installedLocation))
{
if (MessageBoxEx.Show(
if (api.ShowMsgBox(
string.Format(api.GetTranslation("flowlauncher_plugin_everything_installing_select"), Environment.NewLine),
api.GetTranslation("flowlauncher_plugin_everything_installing_title"),
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
@ -52,7 +51,7 @@ public static class EverythingDownloadHelper
installedLocation = "C:\\Program Files\\Everything\\Everything.exe";
FilesFolders.OpenPath(installedLocation, MessageBoxEx.Show);
FilesFolders.OpenPath(installedLocation, api.ShowMsgBox);
return installedLocation;

View file

@ -5,14 +5,12 @@ using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using Flow.Launcher.Plugin.Explorer.Search.Everything;
using System.Windows.Input;
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
{
@ -124,7 +122,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
return false;
}
}
@ -138,7 +136,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
return false;
}
}
@ -153,7 +151,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_opendir_error"));
return false;
}
}
@ -316,7 +314,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
}
catch (Exception ex)
{
MessageBoxEx.Show(ex.Message, Context.API.GetTranslation("plugin_explorer_openfile_error"));
Context.API.ShowMsgBox(ex.Message, Context.API.GetTranslation("plugin_explorer_openfile_error"));
}
return true;
@ -338,7 +336,7 @@ namespace Flow.Launcher.Plugin.Explorer.Search
private static void OpenFile(string filePath, string workingDir = "", bool asAdmin = false)
{
IncrementEverythingRunCounterIfNeeded(filePath);
FilesFolders.OpenFile(filePath, MessageBoxEx.Show, workingDir, asAdmin);
FilesFolders.OpenFile(filePath, Context.API.ShowMsgBox, workingDir, asAdmin);
}
private static void OpenFolder(string folderPath, string fileNameOrFilePath = null)

View file

@ -1,5 +1,4 @@
#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;
@ -358,7 +357,7 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
private void ShowUnselectedMessage()
{
var warning = Context.API.GetTranslation("plugin_explorer_make_selection_warning");
MessageBoxEx.Show(warning);
Context.API.ShowMsgBox(warning);
}

View file

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

View file

@ -1,5 +1,4 @@
using Flow.Launcher.Core;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.ExternalPlugins;
using Flow.Launcher.Core.Plugin;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Http;
@ -132,7 +131,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
Environment.NewLine);
}
if (MessageBoxEx.Show(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
if (Context.API.ShowMsgBox(message, Context.API.GetTranslation("plugin_pluginsmanager_install_title"),
MessageBoxButton.YesNo) == MessageBoxResult.No)
return;
@ -266,7 +265,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
Environment.NewLine);
}
if (MessageBoxEx.Show(message,
if (Context.API.ShowMsgBox(message,
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
MessageBoxButton.YesNo) != MessageBoxResult.Yes)
{
@ -361,7 +360,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
resultsForUpdate.Count());
}
if (MessageBoxEx.Show(message,
if (Context.API.ShowMsgBox(message,
Context.API.GetTranslation("plugin_pluginsmanager_update_title"),
MessageBoxButton.YesNo) == MessageBoxResult.No)
{
@ -475,7 +474,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
if (Settings.WarnFromUnknownSource)
{
if (!InstallSourceKnown(plugin.UrlDownload)
&& MessageBoxEx.Show(string.Format(
&& Context.API.ShowMsgBox(string.Format(
Context.API.GetTranslation("plugin_pluginsmanager_install_unknown_source_warning"),
Environment.NewLine),
Context.API.GetTranslation(
@ -512,7 +511,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
if (Settings.WarnFromUnknownSource)
{
if (!InstallSourceKnown(plugin.Website)
&& MessageBoxEx.Show(string.Format(
&& Context.API.ShowMsgBox(string.Format(
Context.API.GetTranslation(
"plugin_pluginsmanager_install_unknown_source_warning"),
Environment.NewLine),
@ -649,7 +648,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
Environment.NewLine);
}
if (MessageBoxEx.Show(message,
if (Context.API.ShowMsgBox(message,
Context.API.GetTranslation("plugin_pluginsmanager_uninstall_title"),
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
{

View file

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

View file

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

View file

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

View file

@ -10,7 +10,6 @@ using Flow.Launcher.Plugin.Program.Programs;
using System.ComponentModel;
using System.Windows.Data;
using Flow.Launcher.Plugin.Program.ViewModels;
using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.Program.Views
{
@ -179,7 +178,7 @@ namespace Flow.Launcher.Plugin.Program.Views
if (selectedProgramSource == null)
{
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
MessageBoxEx.Show(msg);
context.API.ShowMsgBox(msg);
}
else
{
@ -284,7 +283,7 @@ namespace Flow.Launcher.Plugin.Program.Views
if (selectedItems.Count == 0)
{
string msg = context.API.GetTranslation("flowlauncher_plugin_program_pls_select_program_source");
MessageBoxEx.Show(msg);
context.API.ShowMsgBox(msg);
return;
}
@ -293,7 +292,7 @@ namespace Flow.Launcher.Plugin.Program.Views
var msg = string.Format(
context.API.GetTranslation("flowlauncher_plugin_program_delete_program_source"));
if (MessageBoxEx.Show(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
if (context.API.ShowMsgBox(msg, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
{
return;
}

View file

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

View file

@ -2,12 +2,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
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;
@ -143,7 +141,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\shutdown.png",
Action = c =>
{
var result = MessageBoxEx.Show(
var result = context.API.ShowMsgBox(
context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_shutdown_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_shutdown_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
@ -163,7 +161,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\restart.png",
Action = c =>
{
var result = MessageBoxEx.Show(
var result = context.API.ShowMsgBox(
context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
@ -183,7 +181,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\restart_advanced.png",
Action = c =>
{
var result = MessageBoxEx.Show(
var result = context.API.ShowMsgBox(
context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_restart_computer_advanced"),
context.API.GetTranslation("flowlauncher_plugin_sys_restart_computer"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
@ -202,7 +200,7 @@ namespace Flow.Launcher.Plugin.Sys
IcoPath = "Images\\logoff.png",
Action = c =>
{
var result = MessageBoxEx.Show(
var result = context.API.ShowMsgBox(
context.API.GetTranslation("flowlauncher_plugin_sys_dlgtext_logoff_computer"),
context.API.GetTranslation("flowlauncher_plugin_sys_log_off"),
MessageBoxButton.YesNo, MessageBoxImage.Warning);
@ -279,7 +277,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)
{
MessageBoxEx.Show($"Error emptying recycle bin, error code: {result}\n" +
context.API.ShowMsgBox($"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);

View file

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

View file

@ -3,7 +3,6 @@ using System.Windows.Controls;
using Flow.Launcher.Core.Plugin;
using System.ComponentModel;
using System.Windows.Data;
using Flow.Launcher.Core;
namespace Flow.Launcher.Plugin.WebSearch
{
@ -37,7 +36,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 = MessageBoxEx.Show(formated, string.Empty, MessageBoxButton.YesNo);
var result = _context.API.ShowMsgBox(formated, string.Empty, MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
var id = _context.CurrentPluginMetadata.ID;