diff --git a/Flow.Launcher.Core/Plugin/PluginManager.cs b/Flow.Launcher.Core/Plugin/PluginManager.cs index 4c85fb061..29d91dc8d 100644 --- a/Flow.Launcher.Core/Plugin/PluginManager.cs +++ b/Flow.Launcher.Core/Plugin/PluginManager.cs @@ -205,7 +205,7 @@ namespace Flow.Launcher.Core.Plugin } catch (Exception e) { - Log.Exception(nameof(PluginManager), $"Fail to Init plugin: {pair.Metadata.Name}", e); + Log.Exception(ClassName, $"Fail to Init plugin: {pair.Metadata.Name}", e); pair.Metadata.Disabled = true; failedPlugins.Enqueue(pair); } diff --git a/Flow.Launcher.Core/Resource/InternationalizationManager.cs b/Flow.Launcher.Core/Resource/InternationalizationManager.cs deleted file mode 100644 index 5d718466c..000000000 --- a/Flow.Launcher.Core/Resource/InternationalizationManager.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using CommunityToolkit.Mvvm.DependencyInjection; - -namespace Flow.Launcher.Core.Resource -{ - [Obsolete("InternationalizationManager.Instance is obsolete. Use Ioc.Default.GetRequiredService() instead.")] - public static class InternationalizationManager - { - public static Internationalization Instance - => Ioc.Default.GetRequiredService(); - } -} diff --git a/Flow.Launcher.Core/Updater.cs b/Flow.Launcher.Core/Updater.cs index 20b884b3d..83d4fd9e0 100644 --- a/Flow.Launcher.Core/Updater.cs +++ b/Flow.Launcher.Core/Updater.cs @@ -9,8 +9,6 @@ using System.Text.Json.Serialization; using System.Threading; using System.Threading.Tasks; using System.Windows; -using CommunityToolkit.Mvvm.DependencyInjection; -using Flow.Launcher.Core.Resource; using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Http; @@ -131,7 +129,7 @@ namespace Flow.Launcher.Core await using var jsonStream = await Http.GetStreamAsync(api).ConfigureAwait(false); - var releases = await System.Text.Json.JsonSerializer.DeserializeAsync>(jsonStream).ConfigureAwait(false); + var releases = await JsonSerializer.DeserializeAsync>(jsonStream).ConfigureAwait(false); var latest = releases.Where(r => !r.Prerelease).OrderByDescending(r => r.PublishedAt).First(); var latestUrl = latest.HtmlUrl.Replace("/tag/", "/download/"); @@ -146,10 +144,9 @@ namespace Flow.Launcher.Core return manager; } - private static string NewVersionTips(string version) + private string NewVersionTips(string version) { - var translator = Ioc.Default.GetRequiredService(); - var tips = string.Format(translator.GetTranslation("newVersionTips"), version); + var tips = string.Format(_api.GetTranslation("newVersionTips"), version); return tips; } diff --git a/Flow.Launcher/ActionKeywords.xaml.cs b/Flow.Launcher/ActionKeywords.xaml.cs index d403d4847..ad24f2a76 100644 --- a/Flow.Launcher/ActionKeywords.xaml.cs +++ b/Flow.Launcher/ActionKeywords.xaml.cs @@ -1,8 +1,6 @@ using System.Windows; -using Flow.Launcher.Core.Resource; using Flow.Launcher.Plugin; using Flow.Launcher.ViewModel; -using Flow.Launcher.Core; using System.Linq; using System.Collections.Generic; @@ -10,20 +8,19 @@ namespace Flow.Launcher { public partial class ActionKeywords { - private readonly PluginPair plugin; - private readonly Internationalization translater = InternationalizationManager.Instance; - private readonly PluginViewModel pluginViewModel; + private readonly PluginPair _plugin; + private readonly PluginViewModel _pluginViewModel; public ActionKeywords(PluginViewModel pluginViewModel) { InitializeComponent(); - plugin = pluginViewModel.PluginPair; - this.pluginViewModel = pluginViewModel; + _plugin = pluginViewModel.PluginPair; + _pluginViewModel = pluginViewModel; } private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e) { - tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeparator, plugin.Metadata.ActionKeywords.ToArray()); + tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeparator, _plugin.Metadata.ActionKeywords.ToArray()); tbAction.Focus(); } @@ -34,7 +31,7 @@ namespace Flow.Launcher private void btnDone_OnClick(object sender, RoutedEventArgs _) { - var oldActionKeywords = plugin.Metadata.ActionKeywords; + var oldActionKeywords = _plugin.Metadata.ActionKeywords; var newActionKeywords = tbAction.Text.Split(Query.ActionKeywordSeparator).ToList(); newActionKeywords.RemoveAll(string.IsNullOrEmpty); @@ -48,7 +45,7 @@ namespace Flow.Launcher { if (oldActionKeywords.Count != newActionKeywords.Count) { - ReplaceActionKeyword(plugin.Metadata.ID, removedActionKeywords, addedActionKeywords); + ReplaceActionKeyword(_plugin.Metadata.ID, removedActionKeywords, addedActionKeywords); return; } @@ -58,18 +55,16 @@ namespace Flow.Launcher if (sortedOldActionKeywords.SequenceEqual(sortedNewActionKeywords)) { // User just changes the sequence of action keywords - var msg = translater.GetTranslation("newActionKeywordsSameAsOld"); - MessageBoxEx.Show(msg); + App.API.ShowMsgBox(App.API.GetTranslation("newActionKeywordsSameAsOld")); } else { - ReplaceActionKeyword(plugin.Metadata.ID, removedActionKeywords, addedActionKeywords); + ReplaceActionKeyword(_plugin.Metadata.ID, removedActionKeywords, addedActionKeywords); } } else { - string msg = translater.GetTranslation("newActionKeywordsHasBeenAssigned"); - App.API.ShowMsgBox(msg); + App.API.ShowMsgBox(App.API.GetTranslation("newActionKeywordsHasBeenAssigned")); } } @@ -85,7 +80,7 @@ namespace Flow.Launcher } // Update action keywords text and close window - pluginViewModel.OnActionKeywordsChanged(); + _pluginViewModel.OnActionKeywordsChanged(); Close(); } } diff --git a/Flow.Launcher/App.xaml.cs b/Flow.Launcher/App.xaml.cs index 90fefe0a6..89faa105e 100644 --- a/Flow.Launcher/App.xaml.cs +++ b/Flow.Launcher/App.xaml.cs @@ -343,7 +343,7 @@ namespace Flow.Launcher public void OnSecondAppStarted() { - Ioc.Default.GetRequiredService().Show(); + API.ShowMainWindow(); } #endregion diff --git a/Flow.Launcher/Converters/TextConverter.cs b/Flow.Launcher/Converters/TextConverter.cs index 5f0e1ea82..2c4dad4a9 100644 --- a/Flow.Launcher/Converters/TextConverter.cs +++ b/Flow.Launcher/Converters/TextConverter.cs @@ -1,7 +1,6 @@ using System; using System.Globalization; using System.Windows.Data; -using Flow.Launcher.Core.Resource; using Flow.Launcher.ViewModel; namespace Flow.Launcher.Converters; @@ -23,7 +22,7 @@ public class TextConverter : IValueConverter if (translationKey is null) return id; - return InternationalizationManager.Instance.GetTranslation(translationKey); + return App.API.GetTranslation(translationKey); } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new InvalidOperationException(); diff --git a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs index 53fa173a5..8b193fa1d 100644 --- a/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs +++ b/Flow.Launcher/CustomQueryHotkeySetting.xaml.cs @@ -1,5 +1,4 @@ -using Flow.Launcher.Core.Resource; -using Flow.Launcher.Helper; +using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.UserSettings; using System.Collections.ObjectModel; using System.Linq; @@ -53,14 +52,13 @@ namespace Flow.Launcher Close(); } - public void UpdateItem(CustomPluginHotkey item) { updateCustomHotkey = _settings.CustomPluginHotkeys.FirstOrDefault(o => o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey); if (updateCustomHotkey == null) { - App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey")); + App.API.ShowMsgBox(App.API.GetTranslation("invalidPluginHotkey")); Close(); return; } @@ -68,7 +66,7 @@ namespace Flow.Launcher tbAction.Text = updateCustomHotkey.ActionKeyword; HotkeyControl.SetHotkey(updateCustomHotkey.Hotkey, false); update = true; - lblAdd.Text = InternationalizationManager.Instance.GetTranslation("update"); + lblAdd.Text = App.API.GetTranslation("update"); } private void BtnTestActionKeyword_OnClick(object sender, RoutedEventArgs e) diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs index 416f8e049..ecbdea606 100644 --- a/Flow.Launcher/CustomShortcutSetting.xaml.cs +++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs @@ -1,9 +1,7 @@ -using Flow.Launcher.Core.Resource; -using System; +using System; using System.Windows; using System.Windows.Input; using Flow.Launcher.SettingPages.ViewModels; -using Flow.Launcher.Core; namespace Flow.Launcher { @@ -41,15 +39,15 @@ namespace Flow.Launcher private void BtnAdd_OnClick(object sender, RoutedEventArgs e) { - if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value)) + if (string.IsNullOrEmpty(Key) || string.IsNullOrEmpty(Value)) { - App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("emptyShortcut")); + App.API.ShowMsgBox(App.API.GetTranslation("emptyShortcut")); return; } // Check if key is modified or adding a new one if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key)) { - App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("duplicateShortcut")); + App.API.ShowMsgBox(App.API.GetTranslation("duplicateShortcut")); return; } DialogResult = !update || originalKey != Key || originalValue != Value; diff --git a/Flow.Launcher/Helper/HotKeyMapper.cs b/Flow.Launcher/Helper/HotKeyMapper.cs index 7b2fdfcf4..0771a6074 100644 --- a/Flow.Launcher/Helper/HotKeyMapper.cs +++ b/Flow.Launcher/Helper/HotKeyMapper.cs @@ -3,7 +3,6 @@ using Flow.Launcher.Infrastructure.UserSettings; using System; using NHotkey; using NHotkey.Wpf; -using Flow.Launcher.Core.Resource; using Flow.Launcher.ViewModel; using ChefKeys; using Flow.Launcher.Infrastructure.Logger; @@ -56,9 +55,9 @@ internal static class HotKeyMapper string.Format("|HotkeyMapper.SetWithChefKeys|Error registering hotkey: {0} \nStackTrace:{1}", e.Message, e.StackTrace)); - string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr); - string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle"); - MessageBoxEx.Show(errorMsg, errorMsgTitle); + string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkeyStr); + string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle"); + App.API.ShowMsgBox(errorMsg, errorMsgTitle); } } @@ -82,8 +81,8 @@ internal static class HotKeyMapper e.Message, e.StackTrace, hotkeyStr)); - string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr); - string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle"); + string errorMsg = string.Format(App.API.GetTranslation("registerHotkeyFailed"), hotkeyStr); + string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle"); App.API.ShowMsgBox(errorMsg, errorMsgTitle); } } @@ -107,9 +106,9 @@ internal static class HotKeyMapper string.Format("|HotkeyMapper.RemoveHotkey|Error removing hotkey: {0} \nStackTrace:{1}", e.Message, e.StackTrace)); - string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("unregisterHotkeyFailed"), hotkeyStr); - string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle"); - MessageBoxEx.Show(errorMsg, errorMsgTitle); + string errorMsg = string.Format(App.API.GetTranslation("unregisterHotkeyFailed"), hotkeyStr); + string errorMsgTitle = App.API.GetTranslation("MessageBoxTitle"); + App.API.ShowMsgBox(errorMsg, errorMsgTitle); } } @@ -137,8 +136,8 @@ internal static class HotKeyMapper if (_mainViewModel.ShouldIgnoreHotkeys()) return; - _mainViewModel.Show(); - _mainViewModel.ChangeQueryText(hotkey.ActionKeyword, true); + App.API.ShowMainWindow(); + App.API.ChangeQuery(hotkey.ActionKeyword, true); }); } diff --git a/Flow.Launcher/HotkeyControl.xaml.cs b/Flow.Launcher/HotkeyControl.xaml.cs index 678280bba..8762a934b 100644 --- a/Flow.Launcher/HotkeyControl.xaml.cs +++ b/Flow.Launcher/HotkeyControl.xaml.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using CommunityToolkit.Mvvm.DependencyInjection; -using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Infrastructure.UserSettings; @@ -65,7 +64,6 @@ namespace Flow.Launcher hotkeyControl.RefreshHotkeyInterface(hotkeyControl.Hotkey); } - public static readonly DependencyProperty ChangeHotkeyProperty = DependencyProperty.Register( nameof(ChangeHotkey), typeof(ICommand), @@ -79,7 +77,6 @@ namespace Flow.Launcher set { SetValue(ChangeHotkeyProperty, value); } } - public static readonly DependencyProperty TypeProperty = DependencyProperty.Register( nameof(Type), typeof(HotkeyType), @@ -227,19 +224,18 @@ namespace Flow.Launcher private static bool CheckHotkeyAvailability(HotkeyModel hotkey, bool validateKeyGesture) => hotkey.Validate(validateKeyGesture) && HotKeyMapper.CheckAvailability(hotkey); - public string EmptyHotkey => InternationalizationManager.Instance.GetTranslation("none"); + public string EmptyHotkey => App.API.GetTranslation("none"); public ObservableCollection KeysToDisplay { get; set; } = new(); public HotkeyModel CurrentHotkey { get; private set; } = new(false, false, false, false, Key.None); - public void GetNewHotkey(object sender, RoutedEventArgs e) { - OpenHotkeyDialog(); + _ = OpenHotkeyDialogAsync(); } - private async Task OpenHotkeyDialog() + private async Task OpenHotkeyDialogAsync() { if (!string.IsNullOrEmpty(Hotkey)) { @@ -262,12 +258,11 @@ namespace Flow.Launcher } } - private void SetHotkey(HotkeyModel keyModel, bool triggerValidate = true) { if (triggerValidate) { - bool hotkeyAvailable = false; + bool hotkeyAvailable; // TODO: This is a temporary way to enforce changing only the open flow hotkey to Win, and will be removed by PR #3157 if (keyModel.ToString() == "LWin" || keyModel.ToString() == "RWin") { diff --git a/Flow.Launcher/HotkeyControlDialog.xaml.cs b/Flow.Launcher/HotkeyControlDialog.xaml.cs index 2f8c5eb26..c7af8c5b8 100644 --- a/Flow.Launcher/HotkeyControlDialog.xaml.cs +++ b/Flow.Launcher/HotkeyControlDialog.xaml.cs @@ -5,7 +5,6 @@ using System.Windows; using System.Windows.Input; using ChefKeys; using CommunityToolkit.Mvvm.DependencyInjection; -using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure.Hotkey; using Flow.Launcher.Infrastructure.UserSettings; @@ -34,7 +33,7 @@ public partial class HotkeyControlDialog : ContentDialog public EResultType ResultType { get; private set; } = EResultType.Cancel; public string ResultValue { get; private set; } = string.Empty; - public static string EmptyHotkey => InternationalizationManager.Instance.GetTranslation("none"); + public static string EmptyHotkey => App.API.GetTranslation("none"); private static bool isOpenFlowHotkey; @@ -42,7 +41,7 @@ public partial class HotkeyControlDialog : ContentDialog { WindowTitle = windowTitle switch { - "" or null => InternationalizationManager.Instance.GetTranslation("hotkeyRegTitle"), + "" or null => App.API.GetTranslation("hotkeyRegTitle"), _ => windowTitle }; DefaultHotkey = defaultHotkey; @@ -141,14 +140,14 @@ public partial class HotkeyControlDialog : ContentDialog if (_hotkeySettings.RegisteredHotkeys.FirstOrDefault(v => v.Hotkey == hotkey) is { } registeredHotkeyData) { var description = string.Format( - InternationalizationManager.Instance.GetTranslation(registeredHotkeyData.DescriptionResourceKey), + App.API.GetTranslation(registeredHotkeyData.DescriptionResourceKey), registeredHotkeyData.DescriptionFormatVariables ); Alert.Visibility = Visibility.Visible; if (registeredHotkeyData.RemoveHotkey is not null) { tbMsg.Text = string.Format( - InternationalizationManager.Instance.GetTranslation("hotkeyUnavailableEditable"), + App.API.GetTranslation("hotkeyUnavailableEditable"), description ); SaveBtn.IsEnabled = false; @@ -160,7 +159,7 @@ public partial class HotkeyControlDialog : ContentDialog else { tbMsg.Text = string.Format( - InternationalizationManager.Instance.GetTranslation("hotkeyUnavailableUneditable"), + App.API.GetTranslation("hotkeyUnavailableUneditable"), description ); SaveBtn.IsEnabled = false; @@ -176,7 +175,7 @@ public partial class HotkeyControlDialog : ContentDialog if (!CheckHotkeyAvailability(hotkey.Value, true)) { - tbMsg.Text = InternationalizationManager.Instance.GetTranslation("hotkeyUnavailable"); + tbMsg.Text = App.API.GetTranslation("hotkeyUnavailable"); Alert.Visibility = Visibility.Visible; SaveBtn.IsEnabled = false; SaveBtn.Visibility = Visibility.Visible; diff --git a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs index 880bfd9bc..64f52edff 100644 --- a/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs +++ b/Flow.Launcher/Resources/Pages/WelcomePage1.xaml.cs @@ -17,7 +17,9 @@ namespace Flow.Launcher.Resources.Pages Ioc.Default.GetRequiredService().PageNum = 1; InitializeComponent(); } - private Internationalization _translater => InternationalizationManager.Instance; + + private readonly Internationalization _translater = Ioc.Default.GetRequiredService(); + public List Languages => _translater.LoadAvailableLanguages(); public Settings Settings { get; set; } @@ -30,12 +32,11 @@ namespace Flow.Launcher.Resources.Pages } set { - InternationalizationManager.Instance.ChangeLanguage(value); + _translater.ChangeLanguage(value); - if (InternationalizationManager.Instance.PromptShouldUsePinyin(value)) + if (_translater.PromptShouldUsePinyin(value)) Settings.ShouldUsePinyin = true; } } - } } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs index 35dbab647..069a7cb24 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneGeneralViewModel.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Windows.Forms; -using CommunityToolkit.Mvvm.DependencyInjection; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Core; using Flow.Launcher.Core.Configuration; @@ -19,12 +17,14 @@ public partial class SettingsPaneGeneralViewModel : BaseModel public Settings Settings { get; } private readonly Updater _updater; private readonly IPortable _portable; + private readonly Internationalization _translater; - public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortable portable) + public SettingsPaneGeneralViewModel(Settings settings, Updater updater, IPortable portable, Internationalization translater) { Settings = settings; _updater = updater; _portable = portable; + _translater = translater; UpdateEnumDropdownLocalizations(); } @@ -32,7 +32,6 @@ public partial class SettingsPaneGeneralViewModel : BaseModel public class SearchWindowAlignData : DropdownDataGeneric { } public class SearchPrecisionData : DropdownDataGeneric { } public class LastQueryModeData : DropdownDataGeneric { } - public bool StartFlowLauncherOnSystemStartup { @@ -61,8 +60,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel } catch (Exception e) { - Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"), - e.Message); + App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message); } } } @@ -89,8 +87,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel } catch (Exception e) { - Notification.Show(InternationalizationManager.Instance.GetTranslation("setAutoStartFailed"), - e.Message); + App.API.ShowMsg(App.API.GetTranslation("setAutoStartFailed"), e.Message); } } } @@ -121,7 +118,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel } // This is only required to set at startup. When portable mode enabled/disabled a restart is always required - private bool _portableMode = DataLocation.PortableDataLocationInUse(); + private static bool _portableMode = DataLocation.PortableDataLocationInUse(); public bool PortableMode { @@ -173,9 +170,9 @@ public partial class SettingsPaneGeneralViewModel : BaseModel get => Settings.Language; set { - InternationalizationManager.Instance.ChangeLanguage(value); + _translater.ChangeLanguage(value); - if (InternationalizationManager.Instance.PromptShouldUsePinyin(value)) + if (_translater.PromptShouldUsePinyin(value)) ShouldUsePinyin = true; UpdateEnumDropdownLocalizations(); @@ -188,14 +185,14 @@ public partial class SettingsPaneGeneralViewModel : BaseModel set => Settings.ShouldUsePinyin = value; } - public List Languages => InternationalizationManager.Instance.LoadAvailableLanguages(); + public List Languages => _translater.LoadAvailableLanguages(); public string AlwaysPreviewToolTip => string.Format( - InternationalizationManager.Instance.GetTranslation("AlwaysPreviewToolTip"), + App.API.GetTranslation("AlwaysPreviewToolTip"), Settings.PreviewHotkey ); - private string GetFileFromDialog(string title, string filter = "") + private static string GetFileFromDialog(string title, string filter = "") { var dlg = new OpenFileDialog { @@ -237,7 +234,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel private void SelectPython() { var selectedFile = GetFileFromDialog( - InternationalizationManager.Instance.GetTranslation("selectPythonExecutable"), + App.API.GetTranslation("selectPythonExecutable"), "Python|pythonw.exe" ); @@ -249,7 +246,7 @@ public partial class SettingsPaneGeneralViewModel : BaseModel private void SelectNode() { var selectedFile = GetFileFromDialog( - InternationalizationManager.Instance.GetTranslation("selectNodeExecutable"), + App.API.GetTranslation("selectNodeExecutable"), "node|*.exe" ); diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs index b13aaefe3..7a7c19dd3 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneHotkeyViewModel.cs @@ -1,7 +1,6 @@ using System.Linq; using System.Windows; using CommunityToolkit.Mvvm.Input; -using Flow.Launcher.Core.Resource; using Flow.Launcher.Helper; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Hotkey; @@ -41,15 +40,15 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var item = SelectedCustomPluginHotkey; if (item is null) { - App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); + App.API.ShowMsgBox(App.API.GetTranslation("pleaseSelectAnItem")); return; } var result = App.API.ShowMsgBox( string.Format( - InternationalizationManager.Instance.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey + App.API.GetTranslation("deleteCustomHotkeyWarning"), item.Hotkey ), - InternationalizationManager.Instance.GetTranslation("delete"), + App.API.GetTranslation("delete"), MessageBoxButton.YesNo ); @@ -66,7 +65,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var item = SelectedCustomPluginHotkey; if (item is null) { - App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); + App.API.ShowMsgBox(App.API.GetTranslation("pleaseSelectAnItem")); return; } @@ -87,15 +86,15 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var item = SelectedCustomShortcut; if (item is null) { - App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); + App.API.ShowMsgBox(App.API.GetTranslation("pleaseSelectAnItem")); return; } var result = App.API.ShowMsgBox( string.Format( - InternationalizationManager.Instance.GetTranslation("deleteCustomShortcutWarning"), item.Key, item.Value + App.API.GetTranslation("deleteCustomShortcutWarning"), item.Key, item.Value ), - InternationalizationManager.Instance.GetTranslation("delete"), + App.API.GetTranslation("delete"), MessageBoxButton.YesNo ); @@ -111,7 +110,7 @@ public partial class SettingsPaneHotkeyViewModel : BaseModel var item = SelectedCustomShortcut; if (item is null) { - App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation("pleaseSelectAnItem")); + App.API.ShowMsgBox(App.API.GetTranslation("pleaseSelectAnItem")); return; } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs index e2f9e516c..38a6ef31e 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneProxyViewModel.cs @@ -1,7 +1,6 @@ using System.Net; using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Core; -using Flow.Launcher.Core.Resource; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.Plugin; @@ -22,7 +21,7 @@ public partial class SettingsPaneProxyViewModel : BaseModel private void OnTestProxyClicked() { var message = TestProxy(); - App.API.ShowMsgBox(InternationalizationManager.Instance.GetTranslation(message)); + App.API.ShowMsgBox(App.API.GetTranslation(message)); } private string TestProxy() diff --git a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs index dd7fd13a9..569d489d2 100644 --- a/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs +++ b/Flow.Launcher/SettingPages/Views/SettingsPaneGeneral.xaml.cs @@ -2,6 +2,7 @@ using CommunityToolkit.Mvvm.DependencyInjection; using Flow.Launcher.Core; using Flow.Launcher.Core.Configuration; +using Flow.Launcher.Core.Resource; using Flow.Launcher.Infrastructure.UserSettings; using Flow.Launcher.SettingPages.ViewModels; @@ -18,7 +19,8 @@ public partial class SettingsPaneGeneral var settings = Ioc.Default.GetRequiredService(); var updater = Ioc.Default.GetRequiredService(); var portable = Ioc.Default.GetRequiredService(); - _viewModel = new SettingsPaneGeneralViewModel(settings, updater, portable); + var translater = Ioc.Default.GetRequiredService(); + _viewModel = new SettingsPaneGeneralViewModel(settings, updater, portable, translater); DataContext = _viewModel; InitializeComponent(); } diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 66481cad6..4a6c1d639 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -16,7 +16,6 @@ using CommunityToolkit.Mvvm.Input; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure.Hotkey; -using Flow.Launcher.Infrastructure.Image; using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Storage; using Flow.Launcher.Infrastructure.UserSettings; @@ -275,7 +274,7 @@ namespace Flow.Launcher.ViewModel Hide(); await PluginManager.ReloadDataAsync().ConfigureAwait(false); - Notification.Show(App.API.GetTranslation("success"), + App.API.ShowMsg(App.API.GetTranslation("success"), App.API.GetTranslation("completedSuccessfully")); }