Flow.Launcher/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs

65 lines
1.9 KiB
C#
Raw Normal View History

using Flow.Launcher.Infrastructure.Storage;
2020-05-19 12:38:42 +00:00
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.ViewModels;
using Flow.Launcher.Plugin.Explorer.Views;
using System.Collections.Generic;
2021-01-02 14:01:15 +00:00
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace Flow.Launcher.Plugin.Explorer
{
2021-01-02 14:01:15 +00:00
public class Main : ISettingProvider, IAsyncPlugin, ISavable, IContextMenu, IPluginI18n
{
internal PluginInitContext Context { get; set; }
internal Settings Settings;
private SettingsViewModel viewModel;
private IContextMenu contextMenu;
2020-05-25 08:58:04 +00:00
2021-01-02 14:01:15 +00:00
private SearchManager searchManager;
public Control CreateSettingPanel()
{
return new ExplorerSettings(viewModel);
}
2021-01-02 14:01:15 +00:00
public async Task InitAsync(PluginInitContext context)
{
Context = context;
viewModel = new SettingsViewModel(context);
2021-01-02 14:01:15 +00:00
await viewModel.LoadStorage();
Settings = viewModel.Settings;
contextMenu = new ContextMenu(Context, Settings);
2021-01-02 14:01:15 +00:00
searchManager = new SearchManager(Settings, Context);
}
public List<Result> LoadContextMenus(Result selectedResult)
{
return contextMenu.LoadContextMenus(selectedResult);
}
2021-01-02 14:01:15 +00:00
public async Task<List<Result>> QueryAsync(Query query, CancellationToken token)
{
2021-01-02 14:01:15 +00:00
return await searchManager.SearchAsync(query, token);
}
public void Save()
{
viewModel.Save();
}
2020-06-08 10:31:48 +00:00
public string GetTranslatedPluginTitle()
{
return Context.API.GetTranslation("plugin_explorer_plugin_name");
}
public string GetTranslatedPluginDescription()
{
return Context.API.GetTranslation("plugin_explorer_plugin_description");
}
}
}