2016-01-06 14:45:08 +08:00
|
|
|
|
using System.Windows;
|
2014-12-26 19:36:43 +08:00
|
|
|
|
using Wox.Core.Plugin;
|
2016-01-08 04:04:37 +08:00
|
|
|
|
using Wox.Core.Resource;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
using Wox.Infrastructure.Exception;
|
2016-06-19 23:18:43 +08:00
|
|
|
|
using Wox.Infrastructure.UserSettings;
|
2014-07-04 12:08:37 +08:00
|
|
|
|
using Wox.Plugin;
|
|
|
|
|
|
|
|
|
|
namespace Wox
|
|
|
|
|
{
|
2015-11-05 06:49:40 +08:00
|
|
|
|
public partial class ActionKeywords : Window
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
2015-11-09 11:20:02 +08:00
|
|
|
|
private PluginPair _plugin;
|
2016-04-21 08:53:21 +08:00
|
|
|
|
private Settings _settings;
|
2016-06-21 07:14:32 +08:00
|
|
|
|
private readonly Internationalization _translater = InternationalizationManager.Instance;
|
2014-07-04 12:08:37 +08:00
|
|
|
|
|
2016-04-21 08:53:21 +08:00
|
|
|
|
public ActionKeywords(string pluginId, Settings settings)
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2015-11-09 11:20:02 +08:00
|
|
|
|
_plugin = PluginManager.GetPluginForId(pluginId);
|
2016-03-28 10:09:57 +08:00
|
|
|
|
_settings = settings;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
if (_plugin == null)
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
2016-06-21 07:14:32 +08:00
|
|
|
|
MessageBox.Show(_translater.GetTranslation("cannotFindSpecifiedPlugin"));
|
2014-07-04 12:08:37 +08:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ActionKeyword_OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
2015-11-09 11:20:02 +08:00
|
|
|
|
tbOldActionKeyword.Text = string.Join(Query.ActionKeywordSeperater, _plugin.Metadata.ActionKeywords.ToArray());
|
2014-07-04 12:08:37 +08:00
|
|
|
|
tbAction.Focus();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-09 11:20:02 +08:00
|
|
|
|
private void btnDone_OnClick(object sender, RoutedEventArgs _)
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
2015-11-09 11:20:02 +08:00
|
|
|
|
var oldActionKeyword = _plugin.Metadata.ActionKeywords[0];
|
|
|
|
|
var newActionKeyword = tbAction.Text.Trim();
|
2017-10-21 15:39:39 +08:00
|
|
|
|
newActionKeyword = newActionKeyword.Length > 0 ? newActionKeyword : "*";
|
2016-06-21 07:14:32 +08:00
|
|
|
|
if (!PluginManager.ActionKeywordRegistered(newActionKeyword))
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
2016-06-21 07:14:32 +08:00
|
|
|
|
var id = _plugin.Metadata.ID;
|
|
|
|
|
PluginManager.ReplaceActionKeyword(id, oldActionKeyword, newActionKeyword);
|
2019-08-21 18:18:20 +08:00
|
|
|
|
MessageBox.Show(_translater.GetTranslation("success"));
|
2016-06-21 07:14:32 +08:00
|
|
|
|
Close();
|
2014-07-04 12:08:37 +08:00
|
|
|
|
}
|
2016-06-21 07:14:32 +08:00
|
|
|
|
else
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
2016-06-21 07:14:32 +08:00
|
|
|
|
string msg = _translater.GetTranslation("newActionKeywordsHasBeenAssigned");
|
|
|
|
|
MessageBox.Show(msg);
|
2014-07-04 12:08:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|