mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Add try catch to encounter dllnotfound issue and move warning string to resource
This commit is contained in:
parent
acc7d5171b
commit
22bc292aa9
5 changed files with 53 additions and 61 deletions
|
|
@ -90,6 +90,7 @@
|
||||||
<system:String x:Key="plugin_explorer_show_contextmenu_title">Show Windows Context Menu</system:String>
|
<system:String x:Key="plugin_explorer_show_contextmenu_title">Show Windows Context Menu</system:String>
|
||||||
|
|
||||||
<!-- Everything -->
|
<!-- Everything -->
|
||||||
|
<system:String x:Key="flowlauncher_plugin_everything_sdk_issue">Everything SDK Loaded Fail</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_everything_is_not_running">Warning: Everything service is not running</system:String>
|
<system:String x:Key="flowlauncher_plugin_everything_is_not_running">Warning: Everything service is not running</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_everything_query_error">Error while querying Everything</system:String>
|
<system:String x:Key="flowlauncher_plugin_everything_query_error">Error while querying Everything</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_everything_sort_by">Sort By</system:String>
|
<system:String x:Key="flowlauncher_plugin_everything_sort_by">Sort By</system:String>
|
||||||
|
|
@ -110,6 +111,7 @@
|
||||||
<system:String x:Key="flowlauncher_plugin_everything_sort_by_descending">↓</system:String>
|
<system:String x:Key="flowlauncher_plugin_everything_sort_by_descending">↓</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_everything_nonfastsort_warning">Warning: This is not a Fast Sort option, searches may be slow</system:String>
|
<system:String x:Key="flowlauncher_plugin_everything_nonfastsort_warning">Warning: This is not a Fast Sort option, searches may be slow</system:String>
|
||||||
|
|
||||||
|
<system:String x:Key="flowlauncher_plugin_everything_click_to_launch_or_install">Click to Launch or Install Everything</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_everything_installing_title">Everything Installation</system:String>
|
<system:String x:Key="flowlauncher_plugin_everything_installing_title">Everything Installation</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_everything_installing_subtitle">Installing Everything service. Please wait...</system:String>
|
<system:String x:Key="flowlauncher_plugin_everything_installing_subtitle">Installing Everything service. Please wait...</system:String>
|
||||||
<system:String x:Key="flowlauncher_plugin_everything_installationsuccess_subtitle">Successfully installed Everything service</system:String>
|
<system:String x:Key="flowlauncher_plugin_everything_installationsuccess_subtitle">Successfully installed Everything service</system:String>
|
||||||
|
|
|
||||||
|
|
@ -91,11 +91,17 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
|
||||||
|
|
||||||
public static async ValueTask<bool> IsEverythingRunningAsync(CancellationToken token = default)
|
public static async ValueTask<bool> IsEverythingRunningAsync(CancellationToken token = default)
|
||||||
{
|
{
|
||||||
await _semaphore.WaitAsync(token);
|
try
|
||||||
EverythingApiDllImport.Everything_GetMajorVersion();
|
{
|
||||||
var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError;
|
await _semaphore.WaitAsync(token);
|
||||||
_semaphore.Release();
|
EverythingApiDllImport.Everything_GetMajorVersion();
|
||||||
return result;
|
var result = EverythingApiDllImport.Everything_GetLastError() != StateCode.IPCError;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_semaphore.Release();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -24,26 +24,40 @@ namespace Flow.Launcher.Plugin.Explorer.Search.Everything
|
||||||
|
|
||||||
private async ValueTask ThrowIfEverythingNotAvailableAsync(CancellationToken token = default)
|
private async ValueTask ThrowIfEverythingNotAvailableAsync(CancellationToken token = default)
|
||||||
{
|
{
|
||||||
if (!await EverythingApi.IsEverythingRunningAsync(token))
|
try
|
||||||
throw new EngineNotAvailableException(
|
{
|
||||||
Enum.GetName(Settings.IndexSearchEngineOption.Everything),
|
if (!await EverythingApi.IsEverythingRunningAsync(token))
|
||||||
"Click to Open or Download Everything",
|
throw new EngineNotAvailableException(
|
||||||
"Everything is not running.",
|
Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
|
||||||
async _ =>
|
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);
|
ErrorIcon = Constants.EverythingErrorImagePath
|
||||||
if (installedPath == null)
|
};
|
||||||
{
|
}
|
||||||
Main.Context.API.ShowMsgError("Unable to find Everything.exe");
|
catch (DllNotFoundException e)
|
||||||
return false;
|
{
|
||||||
}
|
throw new EngineNotAvailableException(
|
||||||
Settings.EverythingInstalledPath = installedPath;
|
Enum.GetName(Settings.IndexSearchEngineOption.Everything)!,
|
||||||
Process.Start(installedPath, "-startup");
|
"Please check whether your system is x86 or x64",
|
||||||
return true;
|
Main.Context.API.GetTranslation("flowlauncher_plugin_everything_sdk_issue"))
|
||||||
})
|
|
||||||
{
|
{
|
||||||
ErrorIcon = Constants.EverythingErrorImagePath
|
ErrorIcon = Constants.GeneralSearchErrorImagePath
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private async ValueTask<bool> 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<SearchResult> SearchAsync(string search, [EnumeratorCancellation] CancellationToken token)
|
public async IAsyncEnumerable<SearchResult> SearchAsync(string search, [EnumeratorCancellation] CancellationToken token)
|
||||||
|
|
|
||||||
|
|
@ -369,6 +369,10 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
||||||
// update the message to let user know in the settings panel.
|
// update the message to let user know in the settings panel.
|
||||||
return Visibility.Visible;
|
return Visibility.Visible;
|
||||||
}
|
}
|
||||||
|
catch (DllNotFoundException)
|
||||||
|
{
|
||||||
|
return Visibility.Collapsed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public string SortOptionWarningMessage
|
public string SortOptionWarningMessage
|
||||||
|
|
@ -386,6 +390,10 @@ namespace Flow.Launcher.Plugin.Explorer.ViewModels
|
||||||
{
|
{
|
||||||
return Context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running");
|
return Context.API.GetTranslation("flowlauncher_plugin_everything_is_not_running");
|
||||||
}
|
}
|
||||||
|
catch (DllNotFoundException)
|
||||||
|
{
|
||||||
|
return Context.API.GetTranslation("flowlauncher_plugin_everything_sdk_issue");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,14 @@
|
||||||
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
using Flow.Launcher.Plugin.Explorer.Search.QuickAccessLinks;
|
||||||
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
using Flow.Launcher.Plugin.Explorer.ViewModels;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using DataFormats = System.Windows.DataFormats;
|
using DataFormats = System.Windows.DataFormats;
|
||||||
using DragDropEffects = System.Windows.DragDropEffects;
|
using DragDropEffects = System.Windows.DragDropEffects;
|
||||||
using DragEventArgs = System.Windows.DragEventArgs;
|
using DragEventArgs = System.Windows.DragEventArgs;
|
||||||
using ListView = System.Windows.Controls.ListView;
|
|
||||||
using MessageBox = System.Windows.MessageBox;
|
|
||||||
|
|
||||||
namespace Flow.Launcher.Plugin.Explorer.Views
|
namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
{
|
{
|
||||||
|
|
@ -92,38 +86,6 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
tbFastSortWarning.Text = viewModel.SortOptionWarningMessage;
|
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)
|
private void LbxAccessLinks_OnDrop(object sender, DragEventArgs e)
|
||||||
{
|
{
|
||||||
AccessLinkDragDrop("QuickAccessLink", e);
|
AccessLinkDragDrop("QuickAccessLink", e);
|
||||||
|
|
@ -133,4 +95,4 @@ namespace Flow.Launcher.Plugin.Explorer.Views
|
||||||
AccessLinkDragDrop("IndexSearchExcludedPath", e);
|
AccessLinkDragDrop("IndexSearchExcludedPath", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue