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-01-05 22:41:17 +08:00
|
|
|
|
using Wox.Core.UserSettings;
|
2015-11-09 11:20:02 +08:00
|
|
|
|
using Wox.Infrastructure.Exception;
|
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;
|
2014-07-04 12:08:37 +08:00
|
|
|
|
|
2015-11-05 06:49:40 +08:00
|
|
|
|
public ActionKeywords(string pluginId)
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
2015-11-09 11:20:02 +08:00
|
|
|
|
_plugin = PluginManager.GetPluginForId(pluginId);
|
|
|
|
|
if (_plugin == null)
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.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();
|
|
|
|
|
try
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
2015-11-09 11:20:02 +08:00
|
|
|
|
// update in-memory data
|
|
|
|
|
PluginManager.UpdateActionKeywordForPlugin(_plugin, oldActionKeyword, newActionKeyword);
|
2014-07-04 12:08:37 +08:00
|
|
|
|
}
|
2015-11-09 11:20:02 +08:00
|
|
|
|
catch (WoxPluginException e)
|
2014-07-04 12:08:37 +08:00
|
|
|
|
{
|
2015-11-09 11:20:02 +08:00
|
|
|
|
MessageBox.Show(e.Message);
|
2014-07-04 12:08:37 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2015-11-09 11:20:02 +08:00
|
|
|
|
// update persistant data
|
|
|
|
|
UserSettingStorage.Instance.UpdateActionKeyword(_plugin.Metadata);
|
2014-07-04 12:08:37 +08:00
|
|
|
|
|
2015-01-21 23:00:56 +08:00
|
|
|
|
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
|
2014-07-04 12:08:37 +08:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|