@@ -14,7 +14,7 @@ namespace Cosmic.NET.WPF
1414{
1515 public class MainWindowVM : ReactiveObject
1616 {
17- private const double ThrottleDelay = 0.5 ;
17+ private readonly TimeSpan ThrottleDelay = TimeSpan . FromMilliseconds ( 500 ) ;
1818
1919 private const string HNoughtPos = "H-nought must be positive." ;
2020 private const string HNoughtNum = "H-nought must be a number." ;
@@ -24,17 +24,17 @@ public class MainWindowVM : ReactiveObject
2424 private const string ZNotNeg = "The redshift must be at least 0." ;
2525 private const string ZNum = "The redshift must be a number." ;
2626
27- private readonly List < string > _activeErrors = new List < string > ( ) ;
27+ private readonly List < string > _activeErrors = new ( ) ;
2828
2929 public enum FileType
3030 {
3131 Txt ,
3232 Csv
3333 }
3434
35- public Interaction < string , Unit > ParseError { get ; }
36- public Interaction < string , FileInfo > GetFileToOpen { get ; }
37- public Interaction < string , Tuple < FileInfo , FileType > > GetFileToSave { get ; }
35+ public Interaction < string , Unit > ParseError { get ; } = new ( ) ;
36+ public Interaction < string , FileInfo > GetFileToOpen { get ; } = new ( ) ;
37+ public Interaction < string , Tuple < FileInfo , FileType > > GetFileToSave { get ; } = new ( ) ;
3838
3939 /// <summary>
4040 /// Copy the single-redshift output to the clipboard.
@@ -51,10 +51,6 @@ public enum FileType
5151
5252 public MainWindowVM ( )
5353 {
54- ParseError = new Interaction < string , Unit > ( ) ;
55- GetFileToOpen = new Interaction < string , FileInfo > ( ) ;
56- GetFileToSave = new Interaction < string , Tuple < FileInfo , FileType > > ( ) ;
57-
5854 CopyOutputToClipboard = ReactiveCommand . CreateFromTask (
5955 CopyOutput ,
6056 this . WhenAnyValue ( x => x . CosmoText , t => ! string . IsNullOrEmpty ( t ) ) ) ;
@@ -75,7 +71,7 @@ public MainWindowVM()
7571 RedshiftText = Redshift . ToString ( CultureInfo . InvariantCulture ) ;
7672
7773 this . WhenAnyValue ( x => x . HNoughtText )
78- . Throttle ( TimeSpan . FromSeconds ( ThrottleDelay ) )
74+ . Throttle ( ThrottleDelay )
7975 . Subscribe ( h =>
8076 {
8177 if ( string . IsNullOrWhiteSpace ( h ) ) return ;
@@ -96,7 +92,7 @@ public MainWindowVM()
9692
9793
9894 this . WhenAnyValue ( x => x . OmegaMatterText )
99- . Throttle ( TimeSpan . FromSeconds ( ThrottleDelay ) )
95+ . Throttle ( ThrottleDelay )
10096 . Subscribe ( om =>
10197 {
10298 if ( string . IsNullOrWhiteSpace ( om ) ) return ;
@@ -116,7 +112,7 @@ public MainWindowVM()
116112 } ) ;
117113
118114 this . WhenAnyValue ( x => x . OmegaLambdaText )
119- . Throttle ( TimeSpan . FromSeconds ( ThrottleDelay ) )
115+ . Throttle ( ThrottleDelay )
120116 . Subscribe ( ol =>
121117 {
122118 if ( string . IsNullOrWhiteSpace ( ol ) ) return ;
@@ -130,7 +126,7 @@ public MainWindowVM()
130126 } ) ;
131127
132128 this . WhenAnyValue ( x => x . RedshiftText )
133- . Throttle ( TimeSpan . FromSeconds ( ThrottleDelay ) )
129+ . Throttle ( ThrottleDelay )
134130 . Subscribe ( z =>
135131 {
136132 if ( string . IsNullOrWhiteSpace ( z ) ) return ;
0 commit comments