@@ -9,39 +9,39 @@ namespace Flow.Launcher.ViewModel
9
9
{
10
10
public class PluginViewModel : BaseModel
11
11
{
12
- public PluginPair PluginPair { get ; set ; }
13
-
14
- public ImageSource Image => ImageLoader . Load ( PluginPair . Metadata . IcoPath ) ;
15
- public bool PluginState
12
+ private readonly PluginPair _pluginPair ;
13
+ public PluginPair PluginPair
16
14
{
17
- get { return ! PluginPair . Metadata . Disabled ; }
18
- set
15
+ get => _pluginPair ;
16
+ init
19
17
{
20
- PluginPair . Metadata . Disabled = ! value ;
18
+ _pluginPair = value ;
19
+ value . Metadata . PropertyChanged += ( _ , args ) =>
20
+ {
21
+ if ( args . PropertyName == nameof ( PluginPair . Metadata . AvgQueryTime ) )
22
+ OnPropertyChanged ( nameof ( QueryTime ) ) ;
23
+ } ;
21
24
}
22
25
}
23
26
24
- public Control SettingControl
27
+ public ImageSource Image => ImageLoader . Load ( PluginPair . Metadata . IcoPath ) ;
28
+ public bool PluginState
25
29
{
26
- get
27
- {
28
- if ( PluginPair . Plugin is not ISettingProvider settingProvider )
29
- return new Control ( ) ;
30
-
31
- return settingProvider . CreateSettingPanel ( ) ;
32
- }
30
+ get => ! PluginPair . Metadata . Disabled ;
31
+ set => PluginPair . Metadata . Disabled = ! value ;
33
32
}
34
33
34
+ public Control SettingControl => PluginPair . Plugin is not ISettingProvider settingProvider ? new Control ( ) : settingProvider . CreateSettingPanel ( ) ;
35
+
35
36
public Visibility ActionKeywordsVisibility => PluginPair . Metadata . ActionKeywords . Count == 1 ? Visibility . Visible : Visibility . Collapsed ;
36
- public string InitilizaTime => PluginPair . Metadata . InitTime . ToString ( ) + "ms" ;
37
+ public string InitilizaTime => PluginPair . Metadata . InitTime + "ms" ;
37
38
public string QueryTime => PluginPair . Metadata . AvgQueryTime + "ms" ;
38
39
public string ActionKeywordsText => string . Join ( Query . ActionKeywordSeperater , PluginPair . Metadata . ActionKeywords ) ;
39
40
public int Priority => PluginPair . Metadata . Priority ;
40
41
41
42
public void ChangeActionKeyword ( string newActionKeyword , string oldActionKeyword )
42
43
{
43
44
PluginManager . ReplaceActionKeyword ( PluginPair . Metadata . ID , oldActionKeyword , newActionKeyword ) ;
44
-
45
45
OnPropertyChanged ( nameof ( ActionKeywordsText ) ) ;
46
46
}
47
47
@@ -51,6 +51,7 @@ public void ChangePriority(int newPriority)
51
51
OnPropertyChanged ( nameof ( Priority ) ) ;
52
52
}
53
53
54
- public bool IsActionKeywordRegistered ( string newActionKeyword ) => PluginManager . ActionKeywordRegistered ( newActionKeyword ) ;
54
+ public static bool IsActionKeywordRegistered ( string newActionKeyword ) => PluginManager . ActionKeywordRegistered ( newActionKeyword ) ;
55
55
}
56
- }
56
+
57
+ }
0 commit comments