diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml index 079dbbfd2..4a6ada4fa 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Languages/en.xaml @@ -90,6 +90,7 @@ Show Windows Context Menu + Everything SDK Loaded Fail Warning: Everything service is not running Error while querying Everything Sort By @@ -110,6 +111,7 @@ Warning: This is not a Fast Sort option, searches may be slow + Click to Launch or Install Everything Everything Installation Installing Everything service. Please wait... Successfully installed Everything service diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs index cd3183e7b..966ef7602 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingAPI.cs @@ -91,11 +91,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything public static async ValueTask IsEverythingRunningAsync(CancellationToken token = default) { - await _semaphore.WaitAsync(token); - EverythingApiDllImport.Everything_GetMajorVersion(); - var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError; - _semaphore.Release(); - return result; + try + { + await _semaphore.WaitAsync(token); + EverythingApiDllImport.Everything_GetMajorVersion(); + var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError; + return result; + } + finally + { + _semaphore.Release(); + } } /// diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs index fd977edbe..26d755e4e 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Search/Everything/EverythingSearchManager.cs @@ -24,26 +24,40 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything private async ValueTask ThrowIfEverythingNotAvailableAsync(CancellationToken token = default) { - if (!await EverythingApi.IsEverythingRunningAsync(token)) - throw new EngineNotAvailableException( - Enum.GetName(Settings.IndexSearchEngineOption.Everything), - "Click to Open or Download Everything", - "Everything is not running.", - async _ => + try + { + if (!await EverythingApi.IsEverythingRunningAsync(token)) + throw new EngineNotAvailableException( + Enum.GetName(Settings.IndexSearchEngineOption.Everything)!, + Main.Context.API.GetTranslation("flowlauncher_plugin_everything_click_to_launch_or_install"), + Main.Context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running"), + ClickToInstallEverything) { - var installedPath = await EverythingDownloadHelper.PromptDownloadIfNotInstallAsync(Settings.EverythingInstalledPath, Main.Context.API); - if (installedPath == null) - { - Main.Context.API.ShowMsgError("Unable to find Everything.exe"); - return false; - } - Settings.EverythingInstalledPath = installedPath; - Process.Start(installedPath, "-startup"); - return true; - }) + ErrorIcon = Constants.EverythingErrorImagePath + }; + } + catch (DllNotFoundException e) + { + throw new EngineNotAvailableException( + Enum.GetName(Settings.IndexSearchEngineOption.Everything)!, + "Please check whether your system is x86 or x64", + Main.Context.API.GetTranslation("flowlauncher_plugin_everything_sdk_issue")) { - ErrorIcon = Constants.EverythingErrorImagePath + ErrorIcon = Constants.GeneralSearchErrorImagePath }; + } + } + private async ValueTask ClickToInstallEverything(ActionContext _) + { + var installedPath = await EverythingDownloadHelper.PromptDownloadIfNotInstallAsync(Settings.EverythingInstalledPath, Main.Context.API); + if (installedPath == null) + { + Main.Context.API.ShowMsgError("Unable to find Everything.exe"); + return false; + } + Settings.EverythingInstalledPath = installedPath; + Process.Start(installedPath, "-startup"); + return true; } public async IAsyncEnumerable SearchAsync(string search, [EnumeratorCancellation] CancellationToken token) diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs index 0fca0f018..7d96587f8 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/ViewModels/SettingsViewModel.cs @@ -369,6 +369,10 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels // update the message to let user know in the settings panel. return Visibility.Visible; } + catch (DllNotFoundException) + { + return Visibility.Collapsed; + } } } public string SortOptionWarningMessage @@ -386,6 +390,10 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels { return Context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running"); } + catch (DllNotFoundException) + { + return Context.API.GetTranslation("flowlauncher_plugin_everything_sdk_issue"); + } } } diff --git a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs index facdd8308..d0483ea8d 100644 --- a/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs +++ b/Plugins/Flow.Launcher.Plugin.Explorer/Views/ExplorerSettings.xaml.cs @@ -1,20 +1,14 @@ using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks; using Flow.Launcher.Plugin.Explorer.ViewModels; -using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using System.Windows; using System.Windows.Controls; -using System.Windows.Forms; -using System.Windows.Input; -using System.Windows.Media; using DataFormats = System.Windows.DataFormats; using DragDropEffects = System.Windows.DragDropEffects; using DragEventArgs = System.Windows.DragEventArgs; -using ListView = System.Windows.Controls.ListView; -using MessageBox = System.Windows.MessageBox; namespace Flow.Launcher.Plugin.Explorer.Views { @@ -92,38 +86,6 @@ namespace Flow.Launcher.Plugin.Explorer.Views tbFastSortWarning.Text = viewModel.SortOptionWarningMessage; } } - private void SettingExpander_OnExpanded(object sender, RoutedEventArgs e) - { - if (sender is not Expander expander) - return; - - var parentContainer = VisualTreeHelper.GetParent(expander); - - if (parentContainer is not StackPanel stackPanel) - return; - - foreach (UIElement child in stackPanel.Children) - { - if (child != expander) - child.Visibility = Visibility.Collapsed; - } - } - private void SettingExpander_OnCollapsed(object sender, RoutedEventArgs e) - { - if (sender is not Expander expander) - return; - - var parentContainer = VisualTreeHelper.GetParent(expander); - - if (parentContainer is not StackPanel stackPanel) - return; - - foreach (UIElement child in stackPanel.Children) - { - if (child != expander) - child.Visibility = Visibility.Visible; - } - } private void LbxAccessLinks_OnDrop(object sender, DragEventArgs e) { AccessLinkDragDrop("QuickAccessLink", e); @@ -133,4 +95,4 @@ namespace Flow.Launcher.Plugin.Explorer.Views AccessLinkDragDrop("IndexSearchExcludedPath", e); } } -} \ No newline at end of file +}