4
4
using System . Windows ;
5
5
using System . Windows . Controls ;
6
6
using System . Windows . Documents ;
7
- using System . Windows . Forms ;
8
7
using Flow . Launcher . Infrastructure . Storage ;
9
8
using Flow . Launcher . Plugin ;
10
- using CheckBox = System . Windows . Controls . CheckBox ;
11
- using ComboBox = System . Windows . Controls . ComboBox ;
12
- using Control = System . Windows . Controls . Control ;
13
- using Orientation = System . Windows . Controls . Orientation ;
14
- using TextBox = System . Windows . Controls . TextBox ;
15
- using UserControl = System . Windows . Controls . UserControl ;
16
9
17
10
#nullable enable
18
11
@@ -34,7 +27,7 @@ public class JsonRPCPluginSettings
34
27
// TODO: Move to resource
35
28
private static readonly Thickness settingControlMargin = new ( 0 , 9 , 18 , 9 ) ;
36
29
private static readonly Thickness settingCheckboxMargin = new ( 0 , 9 , 9 , 9 ) ;
37
- private static readonly Thickness settingPanelMargin = ( Thickness ) System . Windows . Application . Current . FindResource ( "SettingPanelMargin" ) ;
30
+ private static readonly Thickness settingPanelMargin = ( Thickness ) Application . Current . FindResource ( "SettingPanelMargin" ) ;
38
31
39
32
public async Task InitializeAsync ( )
40
33
{
@@ -64,7 +57,9 @@ public async Task InitializeAsync()
64
57
public void UpdateSettings ( IReadOnlyDictionary < string , object > settings )
65
58
{
66
59
if ( settings == null || settings . Count == 0 )
60
+ {
67
61
return ;
62
+ }
68
63
69
64
foreach ( var ( key , value ) in settings )
70
65
{
@@ -174,7 +169,7 @@ public void Save()
174
169
Text = attributes . Description ,
175
170
FontSize = 12 ,
176
171
VerticalAlignment = VerticalAlignment . Center ,
177
- Margin = new ( 0 , 2 , 0 , 0 ) , // TODO: Use resource
172
+ Margin = new ( 0 , 2 , 0 , 0 ) ,
178
173
TextWrapping = TextWrapping . WrapWithOverflow
179
174
} ;
180
175
desc . SetResourceReference ( TextBlock . ForegroundProperty , "Color04B" ) ; // for theme change
@@ -196,7 +191,7 @@ public void Save()
196
191
{
197
192
Text = attributes . Description ? . Replace ( "\\ r\\ n" , "\r \n " ) ?? string . Empty ,
198
193
Padding = new Thickness ( 0 , 0 , 0 , 0 ) ,
199
- HorizontalAlignment = System . Windows . HorizontalAlignment . Left ,
194
+ HorizontalAlignment = HorizontalAlignment . Left ,
200
195
TextAlignment = TextAlignment . Left ,
201
196
TextWrapping = TextWrapping . Wrap
202
197
} ;
@@ -209,7 +204,7 @@ public void Save()
209
204
{
210
205
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
211
206
Margin = settingControlMargin ,
212
- HorizontalAlignment = System . Windows . HorizontalAlignment . Stretch ,
207
+ HorizontalAlignment = HorizontalAlignment . Stretch ,
213
208
ToolTip = attributes . Description
214
209
} ;
215
210
@@ -229,7 +224,7 @@ public void Save()
229
224
{
230
225
Margin = new Thickness ( 10 , 0 , 0 , 0 ) ,
231
226
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
232
- HorizontalAlignment = System . Windows . HorizontalAlignment . Stretch ,
227
+ HorizontalAlignment = HorizontalAlignment . Stretch ,
233
228
ToolTip = attributes . Description
234
229
} ;
235
230
@@ -238,25 +233,29 @@ public void Save()
238
233
Settings [ attributes . Name ] = textBox . Text ;
239
234
} ;
240
235
241
- var Btn = new System . Windows . Controls . Button ( )
236
+ var Btn = new Button ( )
242
237
{
243
238
Margin = new Thickness ( 10 , 0 , 0 , 0 ) , Content = "Browse"
244
239
} ;
245
240
246
241
Btn . Click += ( _ , _ ) =>
247
242
{
248
- using CommonDialog dialog = type switch
243
+ using System . Windows . Forms . CommonDialog dialog = type switch
249
244
{
250
- "inputWithFolderBtn" => new FolderBrowserDialog ( ) ,
251
- _ => new OpenFileDialog ( ) ,
245
+ "inputWithFolderBtn" => new System . Windows . Forms . FolderBrowserDialog ( ) ,
246
+ _ => new System . Windows . Forms . OpenFileDialog ( ) ,
252
247
} ;
253
- if ( dialog . ShowDialog ( ) != DialogResult . OK ) return ;
248
+
249
+ if ( dialog . ShowDialog ( ) != System . Windows . Forms . DialogResult . OK )
250
+ {
251
+ return ;
252
+ }
254
253
255
254
var path = dialog switch
256
255
{
257
- FolderBrowserDialog folderDialog => folderDialog . SelectedPath ,
258
- OpenFileDialog fileDialog => fileDialog . FileName ,
259
- _ => string . Empty
256
+ System . Windows . Forms . FolderBrowserDialog folderDialog => folderDialog . SelectedPath ,
257
+ System . Windows . Forms . OpenFileDialog fileDialog => fileDialog . FileName ,
258
+ _ => throw new System . NotImplementedException ( )
260
259
} ;
261
260
textBox . Text = path ;
262
261
Settings [ attributes . Name ] = path ;
@@ -280,7 +279,7 @@ public void Save()
280
279
VerticalAlignment = VerticalAlignment . Center ,
281
280
TextWrapping = TextWrapping . WrapWithOverflow ,
282
281
AcceptsReturn = true ,
283
- HorizontalAlignment = System . Windows . HorizontalAlignment . Stretch ,
282
+ HorizontalAlignment = HorizontalAlignment . Stretch ,
284
283
Text = Settings [ attributes . Name ] as string ?? string . Empty ,
285
284
ToolTip = attributes . Description
286
285
} ;
@@ -301,7 +300,7 @@ public void Save()
301
300
Margin = settingControlMargin ,
302
301
Password = Settings [ attributes . Name ] as string ?? string . Empty ,
303
302
PasswordChar = attributes . passwordChar == default ? '*' : attributes . passwordChar ,
304
- HorizontalAlignment = System . Windows . HorizontalAlignment . Stretch ,
303
+ HorizontalAlignment = HorizontalAlignment . Stretch ,
305
304
ToolTip = attributes . Description
306
305
} ;
307
306
@@ -321,7 +320,7 @@ public void Save()
321
320
ItemsSource = attributes . Options ,
322
321
SelectedItem = Settings [ attributes . Name ] ,
323
322
Margin = settingControlMargin ,
324
- HorizontalAlignment = System . Windows . HorizontalAlignment . Right ,
323
+ HorizontalAlignment = HorizontalAlignment . Right ,
325
324
ToolTip = attributes . Description
326
325
} ;
327
326
@@ -335,49 +334,55 @@ public void Save()
335
334
break ;
336
335
}
337
336
case "checkbox" :
338
- var checkBox = new CheckBox
339
337
{
340
- IsChecked =
338
+ var checkBox = new CheckBox
339
+ {
340
+ IsChecked =
341
341
Settings [ attributes . Name ] is bool isChecked
342
342
? isChecked
343
343
: bool . Parse ( attributes . DefaultValue ) ,
344
- Margin = settingCheckboxMargin ,
345
- HorizontalAlignment = System . Windows . HorizontalAlignment . Right ,
346
- ToolTip = attributes . Description
347
- } ;
344
+ Margin = settingCheckboxMargin ,
345
+ HorizontalAlignment = HorizontalAlignment . Right ,
346
+ ToolTip = attributes . Description
347
+ } ;
348
348
349
- checkBox . Click += ( sender , _ ) =>
350
- {
351
- Settings [ attributes . Name ] = ( ( CheckBox ) sender ) . IsChecked ! ;
352
- } ;
349
+ checkBox . Click += ( sender , _ ) =>
350
+ {
351
+ Settings [ attributes . Name ] = ( ( CheckBox ) sender ) . IsChecked ! ;
352
+ } ;
353
353
354
- contentControl = checkBox ;
354
+ contentControl = checkBox ;
355
355
356
- break ;
356
+ break ;
357
+ }
357
358
case "hyperlink" :
358
- var hyperlink = new Hyperlink { ToolTip = attributes . Description , NavigateUri = attributes . url } ;
359
-
360
- var linkbtn = new System . Windows . Controls . Button
361
359
{
362
- HorizontalAlignment = System . Windows . HorizontalAlignment . Right ,
363
- Margin = settingControlMargin ,
364
- Content = attributes . urlLabel
365
- } ;
360
+ var hyperlink = new Hyperlink { ToolTip = attributes . Description , NavigateUri = attributes . url } ;
366
361
367
- contentControl = linkbtn ;
362
+ var linkbtn = new Button
363
+ {
364
+ HorizontalAlignment = HorizontalAlignment . Right ,
365
+ Margin = settingControlMargin ,
366
+ Content = attributes . urlLabel
367
+ } ;
368
+
369
+ contentControl = linkbtn ;
368
370
369
- break ;
370
- case "seperator" : // TODO: Support seperator
371
- // TODO: Use style for Seperator
372
- contentControl = new Separator
371
+ break ;
372
+ }
373
+ case "seperator" :
373
374
{
374
- VerticalAlignment = VerticalAlignment . Top ,
375
- Margin = new ( - 70 , 13.5 , - 18 , 13.5 ) ,
376
- Height = 1
377
- } ;
378
- contentControl . SetResourceReference ( Separator . BackgroundProperty , "Color03B" ) ;
375
+ // TODO: Move to resource
376
+ contentControl = new Separator
377
+ {
378
+ VerticalAlignment = VerticalAlignment . Top ,
379
+ Margin = new ( - 70 , 13.5 , - 18 , 13.5 ) ,
380
+ Height = 1
381
+ } ;
382
+ contentControl . SetResourceReference ( Separator . BackgroundProperty , "Color03B" ) ;
379
383
380
- break ;
384
+ break ;
385
+ }
381
386
default :
382
387
continue ;
383
388
}
0 commit comments