44using Flow . Launcher . Infrastructure . Exception ;
55using Flow . Launcher . Infrastructure . UserSettings ;
66using Flow . Launcher . Plugin ;
7+ using Flow . Launcher . ViewModel ;
78
89namespace Flow . Launcher
910{
1011 public partial class ActionKeywords : Window
1112 {
12- private PluginPair _plugin ;
13- private Settings _settings ;
14- private readonly Internationalization _translater = InternationalizationManager . Instance ;
13+ private readonly PluginPair plugin ;
14+ private Settings settings ;
15+ private readonly Internationalization translater = InternationalizationManager . Instance ;
16+ private readonly PluginViewModel pluginViewModel ;
1517
16- public ActionKeywords ( string pluginId , Settings settings )
18+ public ActionKeywords ( string pluginId , Settings settings , PluginViewModel pluginViewModel )
1719 {
1820 InitializeComponent ( ) ;
19- _plugin = PluginManager . GetPluginForId ( pluginId ) ;
20- _settings = settings ;
21- if ( _plugin == null )
21+ plugin = PluginManager . GetPluginForId ( pluginId ) ;
22+ this . settings = settings ;
23+ this . pluginViewModel = pluginViewModel ;
24+ if ( plugin == null )
2225 {
23- MessageBox . Show ( _translater . GetTranslation ( "cannotFindSpecifiedPlugin" ) ) ;
26+ MessageBox . Show ( translater . GetTranslation ( "cannotFindSpecifiedPlugin" ) ) ;
2427 Close ( ) ;
2528 }
2629 }
2730
2831 private void ActionKeyword_OnLoaded ( object sender , RoutedEventArgs e )
2932 {
30- tbOldActionKeyword . Text = string . Join ( Query . ActionKeywordSeperater , _plugin . Metadata . ActionKeywords . ToArray ( ) ) ;
33+ tbOldActionKeyword . Text = string . Join ( Query . ActionKeywordSeperater , plugin . Metadata . ActionKeywords . ToArray ( ) ) ;
3134 tbAction . Focus ( ) ;
3235 }
3336
@@ -38,19 +41,17 @@ private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
3841
3942 private void btnDone_OnClick ( object sender , RoutedEventArgs _ )
4043 {
41- var oldActionKeyword = _plugin . Metadata . ActionKeywords [ 0 ] ;
44+ var oldActionKeyword = plugin . Metadata . ActionKeywords [ 0 ] ;
4245 var newActionKeyword = tbAction . Text . Trim ( ) ;
4346 newActionKeyword = newActionKeyword . Length > 0 ? newActionKeyword : "*" ;
44- if ( ! PluginManager . ActionKeywordRegistered ( newActionKeyword ) )
47+ if ( ! pluginViewModel . IsActionKeywordRegistered ( newActionKeyword ) )
4548 {
46- var id = _plugin . Metadata . ID ;
47- PluginManager . ReplaceActionKeyword ( id , oldActionKeyword , newActionKeyword ) ;
48- MessageBox . Show ( _translater . GetTranslation ( "success" ) ) ;
49+ pluginViewModel . ChangeActionKeyword ( newActionKeyword , oldActionKeyword ) ;
4950 Close ( ) ;
5051 }
5152 else
5253 {
53- string msg = _translater . GetTranslation ( "newActionKeywordsHasBeenAssigned" ) ;
54+ string msg = translater . GetTranslation ( "newActionKeywordsHasBeenAssigned" ) ;
5455 MessageBox . Show ( msg ) ;
5556 }
5657 }
0 commit comments