mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
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:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user