@@ -40,7 +40,7 @@ internal abstract class JsonRPCPlugin : IAsyncPlugin, IContextMenu, ISettingProv
40
40
protected PluginInitContext context ;
41
41
public const string JsonRPC = "JsonRPC" ;
42
42
43
- /// <summary>
43
+ /// <summary=
44
44
/// The language this JsonRPCPlugin support
45
45
/// </summary>
46
46
public abstract string SupportedLanguage { get ; set ; }
@@ -82,7 +82,7 @@ public List<Result> LoadContextMenus(Result selectedResult)
82
82
} ;
83
83
private Dictionary < string , object > Settings { get ; set ; }
84
84
85
- private Dictionary < string , Control > _settingControls = new ( ) ;
85
+ private Dictionary < string , FrameworkElement > _settingControls = new ( ) ;
86
86
87
87
private async Task < List < Result > > DeserializedResultAsync ( Stream output )
88
88
{
@@ -337,6 +337,8 @@ public async Task InitSettingAsync()
337
337
338
338
foreach ( var ( type , attribute ) in _settingsTemplate . Body )
339
339
{
340
+ if ( type == "textBlock" )
341
+ continue ;
340
342
if ( ! Settings . ContainsKey ( attribute . Name ) )
341
343
{
342
344
Settings [ attribute . Name ] = attribute . DefaultValue ;
@@ -376,17 +378,29 @@ public Control CreateSettingPanel()
376
378
Margin = settingControlMargin
377
379
} ;
378
380
379
- Control contentControl ;
381
+ FrameworkElement contentControl ;
380
382
381
383
switch ( type )
382
384
{
385
+ case "textBlock" :
386
+ {
387
+ contentControl = new TextBlock
388
+ {
389
+ Text = attribute . Description . Replace ( "\\ r\\ n" , "\r \n " ) ,
390
+ Margin = settingControlMargin ,
391
+ MaxWidth = 400 ,
392
+ TextWrapping = TextWrapping . WrapWithOverflow
393
+ } ;
394
+ break ;
395
+ }
383
396
case "input" :
384
397
{
385
398
var textBox = new TextBox ( )
386
399
{
387
400
Width = 300 ,
388
401
Text = Settings [ attribute . Name ] as string ?? string . Empty ,
389
- Margin = settingControlMargin
402
+ Margin = settingControlMargin ,
403
+ ToolTip = attribute . Description
390
404
} ;
391
405
textBox . TextChanged += ( _ , _ ) =>
392
406
{
@@ -404,7 +418,8 @@ public Control CreateSettingPanel()
404
418
Margin = settingControlMargin ,
405
419
TextWrapping = TextWrapping . WrapWithOverflow ,
406
420
AcceptsReturn = true ,
407
- Text = Settings [ attribute . Name ] as string ?? string . Empty
421
+ Text = Settings [ attribute . Name ] as string ?? string . Empty ,
422
+ ToolTip = attribute . Description
408
423
} ;
409
424
textBox . TextChanged += ( sender , _ ) =>
410
425
{
@@ -420,7 +435,8 @@ public Control CreateSettingPanel()
420
435
Width = 300 ,
421
436
Margin = settingControlMargin ,
422
437
Password = Settings [ attribute . Name ] as string ?? string . Empty ,
423
- PasswordChar = attribute . passwordChar == default ? '*' : attribute . passwordChar
438
+ PasswordChar = attribute . passwordChar == default ? '*' : attribute . passwordChar ,
439
+ ToolTip = attribute . Description
424
440
} ;
425
441
passwordBox . PasswordChanged += ( sender , _ ) =>
426
442
{
@@ -435,7 +451,8 @@ public Control CreateSettingPanel()
435
451
{
436
452
ItemsSource = attribute . Options ,
437
453
SelectedItem = Settings [ attribute . Name ] ,
438
- Margin = settingControlMargin
454
+ Margin = settingControlMargin ,
455
+ ToolTip = attribute . Description
439
456
} ;
440
457
comboBox . SelectionChanged += ( sender , _ ) =>
441
458
{
@@ -448,7 +465,8 @@ public Control CreateSettingPanel()
448
465
var checkBox = new CheckBox
449
466
{
450
467
IsChecked = Settings [ attribute . Name ] is bool isChecked ? isChecked : bool . Parse ( attribute . DefaultValue ) ,
451
- Margin = settingControlMargin
468
+ Margin = settingControlMargin ,
469
+ ToolTip = attribute . Description
452
470
} ;
453
471
checkBox . Click += ( sender , _ ) =>
454
472
{
@@ -459,7 +477,8 @@ public Control CreateSettingPanel()
459
477
default :
460
478
continue ;
461
479
}
462
- _settingControls [ attribute . Name ] = contentControl ;
480
+ if ( type != "textBlock" )
481
+ _settingControls [ attribute . Name ] = contentControl ;
463
482
panel . Children . Add ( name ) ;
464
483
panel . Children . Add ( contentControl ) ;
465
484
mainPanel . Children . Add ( panel ) ;
0 commit comments