Flow.Launcher/Plugins/Flow.Launcher.Plugin.Explorer/Main.cs
2020-06-08 14:20:22 +10:00

53 lines
1.4 KiB
C#

using Flow.Launcher.Infrastructure.Storage;
using Flow.Launcher.Plugin.Explorer.Search;
using Flow.Launcher.Plugin.Explorer.ViewModels;
using Flow.Launcher.Plugin.Explorer.Views;
using System.Collections.Generic;
using System.Windows.Controls;
namespace Flow.Launcher.Plugin.Explorer
{
public class Main : ISettingProvider, IPlugin, ISavable, IContextMenu //, IPluginI18n <=== do later
{
internal PluginInitContext Context { get; set; }
internal Settings Settings;
private SettingsViewModel viewModel;
private IContextMenu contextMenu;
public Control CreateSettingPanel()
{
return new ExplorerSettings(viewModel);
}
public void Init(PluginInitContext context)
{
Context = context;
viewModel = new SettingsViewModel(context);
Settings = viewModel.Settings;
contextMenu = new ContextMenu(Context, Settings);
}
public List<Result> LoadContextMenus(Result selectedResult)
{
return contextMenu.LoadContextMenus(selectedResult);
}
public List<Result> Query(Query query)
{
var results = new List<Result>();
if (string.IsNullOrEmpty(query.Search))
return results;
return new SearchManager(Settings, Context).Search(query);
}
public void Save()
{
viewModel.Save();
}
}
}