@@ -49,12 +49,6 @@ public SettingWindowViewModel(Updater updater, IPortable portable)
49
49
break ;
50
50
}
51
51
} ;
52
- int tmp = 0 ;
53
- TimeFormatIndex = ( tmp = TimeFormatList . FindIndex ( x => x . Equals ( Settings . TimeFormat ) ) ) >= 0 ? tmp : 0 ;
54
- DateFormatIndex = ( tmp = DateFormatList . FindIndex ( x => x . Equals ( Settings . DateFormat ) ) ) >= 0 ? tmp : 0 ;
55
- // TODO: CurrentCulture may not equal to settings.language when this is constructed
56
- TimeFormatDisplayList = TimeFormatList . Select ( x => DateTime . Now . ToString ( x , CultureInfo . CurrentCulture ) ) . ToList ( ) ;
57
- DateFormatDisplayList = DateFormatList . Select ( x => DateTime . Now . ToString ( x , CultureInfo . CurrentCulture ) ) . ToList ( ) ;
58
52
}
59
53
60
54
public Settings Settings { get ; set ; }
@@ -164,7 +158,10 @@ private List<LastQueryMode> InitLastQueryModes()
164
158
{
165
159
var key = $ "LastQuery{ e } ";
166
160
var display = _translater . GetTranslation ( key ) ;
167
- var m = new LastQueryMode { Display = display , Value = e , } ;
161
+ var m = new LastQueryMode
162
+ {
163
+ Display = display , Value = e ,
164
+ } ;
168
165
modes . Add ( m ) ;
169
166
}
170
167
return modes ;
@@ -355,7 +352,6 @@ internal void DisplayPluginQuery(string queryToDisplay, PluginPair plugin, int a
355
352
App . API . ShowMainWindow ( ) ;
356
353
}
357
354
358
-
359
355
#endregion
360
356
361
357
#region theme
@@ -420,8 +416,7 @@ public List<ColorScheme> ColorSchemes
420
416
var display = _translater . GetTranslation ( key ) ;
421
417
var m = new ColorScheme
422
418
{
423
- Display = display ,
424
- Value = e ,
419
+ Display = display , Value = e ,
425
420
} ;
426
421
modes . Add ( m ) ;
427
422
}
@@ -445,14 +440,17 @@ public List<SearchWindowPosition> SearchWindowPositions
445
440
{
446
441
var key = $ "SearchWindowPosition{ e } ";
447
442
var display = _translater . GetTranslation ( key ) ;
448
- var m = new SearchWindowPosition { Display = display , Value = e , } ;
443
+ var m = new SearchWindowPosition
444
+ {
445
+ Display = display , Value = e ,
446
+ } ;
449
447
modes . Add ( m ) ;
450
448
}
451
449
return modes ;
452
450
}
453
451
}
454
452
455
- public List < string > TimeFormatList { get ; set ; } = new List < string > ( )
453
+ public List < string > TimeFormatList { get ; } = new ( )
456
454
{
457
455
"h:mm" ,
458
456
"hh:mm" ,
@@ -464,7 +462,7 @@ public List<SearchWindowPosition> SearchWindowPositions
464
462
"hh:mm tt"
465
463
} ;
466
464
467
- public List < string > DateFormatList { get ; set ; } = new List < string > ( )
465
+ public List < string > DateFormatList { get ; } = new ( )
468
466
{
469
467
"MM'/'dd dddd" ,
470
468
"MM'/'dd ddd" ,
@@ -482,65 +480,30 @@ public List<SearchWindowPosition> SearchWindowPositions
482
480
"dd', 'MMMM"
483
481
} ;
484
482
485
- private int timeFormatIndex = 0 ;
486
- public int TimeFormatIndex
483
+ public string TimeFormat
487
484
{
488
- get => timeFormatIndex ;
485
+ get { return Settings . TimeFormat ; }
489
486
set
490
487
{
491
- if ( value != - 1 )
492
- {
493
- timeFormatIndex = value ;
494
- Settings . TimeFormat = TimeFormatList [ value ] ;
495
- ClockText = DateTime . Now . ToString ( Settings . TimeFormat , CultureInfo . CurrentCulture ) ;
496
- }
488
+ Settings . TimeFormat = value ;
489
+ OnPropertyChanged ( ) ;
497
490
}
498
491
}
499
492
500
- private int dateFormatIndex = 0 ;
501
- public int DateFormatIndex
493
+ public string DateFormat
502
494
{
503
- get => dateFormatIndex ;
504
- set
505
- {
506
- if ( value != - 1 )
507
- {
508
- dateFormatIndex = value ;
509
- Settings . DateFormat = DateFormatList [ value ] ;
510
- DateText = DateTime . Now . ToString ( Settings . DateFormat , CultureInfo . CurrentCulture ) ;
511
- }
495
+ get { return Settings . DateFormat ; }
496
+ set
497
+ {
498
+ Settings . DateFormat = value ;
499
+ OnPropertyChanged ( ) ;
512
500
}
513
501
}
514
502
515
503
public string ClockText { get ; private set ; }
516
504
517
505
public string DateText { get ; private set ; }
518
506
519
- public List < string > TimeFormatDisplayList { get ; set ; } = null ;
520
-
521
- public List < string > DateFormatDisplayList { get ; set ; } = null ;
522
-
523
- public void UpdateDateDisplayList ( )
524
- {
525
- for ( int i = 0 ; i < DateFormatList . Count ; ++ i )
526
- {
527
- DateFormatDisplayList [ i ] = DateTime . Now . ToString ( DateFormatList [ i ] , CultureInfo . CurrentCulture ) ;
528
- }
529
- // TODO: CurrentCulture may not equal to settings.language
530
- // Cross thread issue?
531
- DateText = DateTime . Now . ToString ( Settings . DateFormat , CultureInfo . CurrentCulture ) ;
532
- }
533
-
534
- public void UpdateTimeDisplayList ( )
535
- {
536
- for ( int i = 0 ; i < TimeFormatList . Count ; ++ i )
537
- {
538
- TimeFormatDisplayList [ i ] = DateTime . Now . ToString ( TimeFormatList [ i ] , CultureInfo . CurrentCulture ) ;
539
- }
540
- // TODO: CurrentCulture may not equal to settings.language
541
- // Cross thread issue?
542
- ClockText = DateTime . Now . ToString ( Settings . TimeFormat , CultureInfo . CurrentCulture ) ;
543
- }
544
507
545
508
public double WindowWidthSize
546
509
{
@@ -783,7 +746,7 @@ public void DeleteSelectedCustomShortcut()
783
746
784
747
string deleteWarning = string . Format (
785
748
InternationalizationManager . Instance . GetTranslation ( "deleteCustomShortcutWarning" ) ,
786
- item . Key , item . Value ) ;
749
+ item . Key , item . Value ) ;
787
750
if ( MessageBox . Show ( deleteWarning , InternationalizationManager . Instance . GetTranslation ( "delete" ) ,
788
751
MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
789
752
{
@@ -864,19 +827,22 @@ public string CheckLogFolder
864
827
internal void ClearLogFolder ( )
865
828
{
866
829
var directory = new DirectoryInfo (
867
- Path . Combine (
868
- DataLocation . DataDirectory ( ) ,
869
- Constant . Logs ,
870
- Constant . Version ) ) ;
830
+ Path . Combine (
831
+ DataLocation . DataDirectory ( ) ,
832
+ Constant . Logs ,
833
+ Constant . Version ) ) ;
871
834
872
835
directory . EnumerateFiles ( )
873
- . ToList ( )
874
- . ForEach ( x => x . Delete ( ) ) ;
836
+ . ToList ( )
837
+ . ForEach ( x => x . Delete ( ) ) ;
875
838
}
876
839
internal string FormatBytes ( long bytes )
877
840
{
878
841
const int scale = 1024 ;
879
- string [ ] orders = new string [ ] { "GB" , "MB" , "KB" , "Bytes" } ;
842
+ string [ ] orders = new string [ ]
843
+ {
844
+ "GB" , "MB" , "KB" , "Bytes"
845
+ } ;
880
846
long max = ( long ) Math . Pow ( scale , orders . Length - 1 ) ;
881
847
882
848
foreach ( string order in orders )
@@ -888,6 +854,7 @@ internal string FormatBytes(long bytes)
888
854
}
889
855
return "0 Bytes" ;
890
856
}
857
+
891
858
#endregion
892
859
}
893
860
}
0 commit comments