MVVM refactoring for web search plugin, part 1

1. #486
2. fix #778 #763 #742
3. MVVM refactoring
4. remove IMultipleActionKeywords interface, use PluginManager directly
This commit is contained in:
bao-qian
2016-06-21 00:14:32 +01:00
parent 3efeb4a0a6
commit 6e13440f1f
30 changed files with 495 additions and 518 deletions

View File

@@ -11,6 +11,7 @@ namespace Wox
{
private PluginPair _plugin;
private Settings _settings;
private readonly Internationalization _translater = InternationalizationManager.Instance;
public ActionKeywords(string pluginId, Settings settings)
{
@@ -19,7 +20,7 @@ namespace Wox
_settings = settings;
if (_plugin == null)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("cannotFindSpecifiedPlugin"));
MessageBox.Show(_translater.GetTranslation("cannotFindSpecifiedPlugin"));
Close();
}
}
@@ -39,21 +40,18 @@ namespace Wox
{
var oldActionKeyword = _plugin.Metadata.ActionKeywords[0];
var newActionKeyword = tbAction.Text.Trim();
try
if (!PluginManager.ActionKeywordRegistered(newActionKeyword))
{
// update in-memory data
PluginManager.UpdateActionKeywordForPlugin(_plugin, oldActionKeyword, newActionKeyword);
var id = _plugin.Metadata.ID;
PluginManager.ReplaceActionKeyword(id, oldActionKeyword, newActionKeyword);
MessageBox.Show(_translater.GetTranslation("succeed"));
Close();
}
catch (WoxPluginException e)
else
{
MessageBox.Show(e.Message);
return;
string msg = _translater.GetTranslation("newActionKeywordsHasBeenAssigned");
MessageBox.Show(msg);
}
// update persistant data
_settings.PluginSettings.UpdateActionKeyword(_plugin.Metadata);
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("succeed"));
Close();
}
}
}