21
21
using ISavable = Flow . Launcher . Plugin . ISavable ;
22
22
using System . IO ;
23
23
using System . Collections . Specialized ;
24
+ using CommunityToolkit . Mvvm . Input ;
24
25
25
26
namespace Flow . Launcher . ViewModel
26
27
{
27
- public class MainViewModel : BaseModel , ISavable
28
+ public partial class MainViewModel : BaseModel , ISavable
28
29
{
29
30
#region Private Fields
30
31
@@ -82,6 +83,7 @@ public MainViewModel(Settings settings)
82
83
_selectedResults = Results ;
83
84
84
85
InitializeKeyCommands ( ) ;
86
+
85
87
RegisterViewUpdate ( ) ;
86
88
RegisterResultsUpdatedEvent ( ) ;
87
89
@@ -154,6 +156,8 @@ private void RegisterResultsUpdatedEvent()
154
156
}
155
157
}
156
158
159
+
160
+
157
161
private void InitializeKeyCommands ( )
158
162
{
159
163
EscCommand = new RelayCommand ( _ =>
@@ -307,7 +311,7 @@ private void InitializeKeyCommands()
307
311
Notification . Show (
308
312
InternationalizationManager . Instance . GetTranslation ( "success" ) ,
309
313
InternationalizationManager . Instance . GetTranslation ( "completedSuccessfully" )
310
- ) ;
314
+ ) ;
311
315
} ) , TaskScheduler . Default )
312
316
. ConfigureAwait ( false ) ;
313
317
} ) ;
@@ -318,9 +322,9 @@ private void InitializeKeyCommands()
318
322
#region ViewModel Properties
319
323
320
324
public ResultsViewModel Results { get ; private set ; }
321
-
325
+
322
326
public ResultsViewModel ContextMenu { get ; private set ; }
323
-
327
+
324
328
public ResultsViewModel History { get ; private set ; }
325
329
326
330
public bool GameModeStatus { get ; set ; }
@@ -336,6 +340,74 @@ public string QueryText
336
340
}
337
341
}
338
342
343
+
344
+ public double Top
345
+ {
346
+ get => _settings . WindowTop ;
347
+ set
348
+ {
349
+ _settings . WindowTop = value ;
350
+ OnPropertyChanged ( ) ;
351
+ }
352
+ }
353
+ public double Left
354
+ {
355
+ get => _settings . WindowLeft ;
356
+ set
357
+ {
358
+ _settings . WindowLeft = value ;
359
+ OnPropertyChanged ( ) ;
360
+ }
361
+ }
362
+
363
+ [ RelayCommand ]
364
+ private void IncreaseWidth ( )
365
+ {
366
+ if ( MainWindowWidth + 100 > 1920 || _settings . WindowSize == 1920 )
367
+ {
368
+ _settings . WindowSize = 1920 ;
369
+ }
370
+ else
371
+ {
372
+ _settings . WindowSize += 100 ;
373
+ Left -= 50 ;
374
+ }
375
+ OnPropertyChanged ( ) ;
376
+ }
377
+
378
+ [ RelayCommand ]
379
+ private void DecreaseWidth ( )
380
+ {
381
+ if ( MainWindowWidth - 100 < 400 || _settings . WindowSize == 400 )
382
+ {
383
+ _settings . WindowSize = 400 ;
384
+ }
385
+ else
386
+ {
387
+ Left += 50 ;
388
+ _settings . WindowSize -= 100 ;
389
+ }
390
+ OnPropertyChanged ( ) ;
391
+ }
392
+
393
+ [ RelayCommand ]
394
+ private void IncreaseMaxResult ( )
395
+ {
396
+ if ( _settings . MaxResultsToShow == 17 )
397
+ return ;
398
+
399
+ _settings . MaxResultsToShow += 1 ;
400
+ }
401
+
402
+ [ RelayCommand ]
403
+ private void DecreaseMaxResult ( )
404
+ {
405
+ if ( _settings . MaxResultsToShow == 2 )
406
+ return ;
407
+
408
+ _settings . MaxResultsToShow -= 1 ;
409
+ }
410
+
339
411
/// <summary>
340
412
/// we need move cursor to end when we manually changed query
341
413
/// but we don't want to move cursor to end when query is updated from TextBox
@@ -411,7 +483,11 @@ private ResultsViewModel SelectedResults
411
483
412
484
public Visibility SearchIconVisibility { get ; set ; }
413
485
414
- public double MainWindowWidth => _settings . WindowSize ;
486
+ public double MainWindowWidth
487
+ {
488
+ get => _settings . WindowSize ;
489
+ set => _settings . WindowSize = value ;
490
+ }
415
491
416
492
public string PluginIconPath { get ; set ; } = null ;
417
493
@@ -592,7 +668,7 @@ private async void QueryResults()
592
668
PluginIconPath = null ;
593
669
SearchIconVisibility = Visibility . Visible ;
594
670
}
595
-
671
+
596
672
597
673
if ( query . ActionKeyword == Plugin . Query . GlobalPluginWildcardSign )
598
674
{
@@ -903,18 +979,18 @@ public void ResultCopy(string stringToCopy)
903
979
904
980
Clipboard . SetFileDropList ( paths ) ;
905
981
App . API . ShowMsg (
906
- App . API . GetTranslation ( "copy" )
907
- + " "
908
- + ( isFile ? App . API . GetTranslation ( "fileTitle" ) : App . API . GetTranslation ( "folderTitle" ) ) ,
982
+ App . API . GetTranslation ( "copy" )
983
+ + " "
984
+ + ( isFile ? App . API . GetTranslation ( "fileTitle" ) : App . API . GetTranslation ( "folderTitle" ) ) ,
909
985
App . API . GetTranslation ( "completedSuccessfully" ) ) ;
910
986
}
911
987
else
912
988
{
913
989
Clipboard . SetDataObject ( copyText . ToString ( ) ) ;
914
990
App . API . ShowMsg (
915
- App . API . GetTranslation ( "copy" )
916
- + " "
917
- + App . API . GetTranslation ( "textTitle" ) ,
991
+ App . API . GetTranslation ( "copy" )
992
+ + " "
993
+ + App . API . GetTranslation ( "textTitle" ) ,
918
994
App . API . GetTranslation ( "completedSuccessfully" ) ) ;
919
995
}
920
996
}
0 commit comments