mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Integrate calculator settings
Save & load settings when plugin is in use & specify user control.
This commit is contained in:
parent
3d3d9435dc
commit
570c1d9a5f
1 changed files with 26 additions and 1 deletions
|
|
@ -2,11 +2,15 @@ using System.Collections.Generic;
|
|||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using Mages.Core;
|
||||
using Wox.Infrastructure.Storage;
|
||||
using Wox.Plugin.Caculator.ViewModels;
|
||||
using Wox.Plugin.Caculator.Views;
|
||||
|
||||
namespace Wox.Plugin.Caculator
|
||||
{
|
||||
public class Main : IPlugin, IPluginI18n
|
||||
public class Main : IPlugin, IPluginI18n, ISavable, ISettingProvider
|
||||
{
|
||||
private static readonly Regex RegValidExpressChar = new Regex(
|
||||
@"^(" +
|
||||
|
|
@ -21,11 +25,22 @@ namespace Wox.Plugin.Caculator
|
|||
private static readonly Engine MagesEngine;
|
||||
private PluginInitContext Context { get; set; }
|
||||
|
||||
private static Settings _settings;
|
||||
private static SettingsViewModel _viewModel;
|
||||
|
||||
static Main()
|
||||
{
|
||||
MagesEngine = new Engine();
|
||||
}
|
||||
|
||||
public void Init(PluginInitContext context)
|
||||
{
|
||||
Context = context;
|
||||
|
||||
_viewModel = new SettingsViewModel();
|
||||
_settings = _viewModel.Settings;
|
||||
}
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
{
|
||||
// Don't affect when user only input "e" or "i" keyword
|
||||
|
|
@ -115,5 +130,15 @@ namespace Wox.Plugin.Caculator
|
|||
{
|
||||
return Context.API.GetTranslation("wox_plugin_caculator_plugin_description");
|
||||
}
|
||||
|
||||
public Control CreateSettingPanel()
|
||||
{
|
||||
return new CalculatorSettings(_viewModel);
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
_viewModel.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue