@@ -81,12 +81,22 @@ public static string Usage
81
81
/// </summary>
82
82
public bool PromptOnExit { get ; private set ; }
83
83
84
+ /// <summary>
85
+ /// Gets a value indicating whether to keep the computer awake while the timer is running.
86
+ /// </summary>
87
+ public bool DoNotKeepComputerAwake { get ; private set ; }
88
+
84
89
/// <summary>
85
90
/// Gets a value indicating whether an icon for the app should be visible in the notification area of the
86
91
/// taskbar.
87
92
/// </summary>
88
93
public bool ShowInNotificationArea { get ; private set ; }
89
94
95
+ /// <summary>
96
+ /// Gets a value indicating whether to show the time elapsed rather than the time left.
97
+ /// </summary>
98
+ public bool ShowTimeElapsed { get ; private set ; }
99
+
90
100
/// <summary>
91
101
/// Gets a value indicating whether to loop the timer continuously.
92
102
/// </summary>
@@ -103,6 +113,11 @@ public static string Usage
103
113
/// </summary>
104
114
public bool CloseWhenExpired { get ; private set ; }
105
115
116
+ /// <summary>
117
+ /// Gets a value indicating whether Windows should be shut down when the timer expires.
118
+ /// </summary>
119
+ public bool ShutDownWhenExpired { get ; private set ; }
120
+
106
121
/// <summary>
107
122
/// Gets the color of the timer progress bar.
108
123
/// </summary>
@@ -119,6 +134,11 @@ public static string Usage
119
134
/// </summary>
120
135
public bool LoopSound { get ; private set ; }
121
136
137
+ /// <summary>
138
+ /// Gets a value indicating whether all saved timers should be opened when the application starts.
139
+ /// </summary>
140
+ public bool OpenSavedTimers { get ; private set ; }
141
+
122
142
/// <summary>
123
143
/// Gets a value that indicates whether the timer window is restored, minimized, or maximized.
124
144
/// </summary>
@@ -189,9 +209,12 @@ public TimerOptions GetTimerOptions()
189
209
Title = this . Title ,
190
210
AlwaysOnTop = this . AlwaysOnTop ,
191
211
PromptOnExit = this . PromptOnExit ,
212
+ DoNotKeepComputerAwake = this . DoNotKeepComputerAwake ,
213
+ ShowTimeElapsed = this . ShowTimeElapsed ,
192
214
LoopTimer = this . LoopTimer ,
193
215
PopUpWhenExpired = this . PopUpWhenExpired ,
194
216
CloseWhenExpired = this . CloseWhenExpired ,
217
+ ShutDownWhenExpired = this . ShutDownWhenExpired ,
195
218
Color = this . Color ,
196
219
Sound = this . Sound ,
197
220
LoopSound = this . LoopSound ,
@@ -231,13 +254,17 @@ private static CommandLineArguments GetArgumentsFromMostRecentOptions()
231
254
AlwaysOnTop = options . AlwaysOnTop ,
232
255
IsFullScreen = windowSize . IsFullScreen ,
233
256
PromptOnExit = options . PromptOnExit ,
257
+ DoNotKeepComputerAwake = options . DoNotKeepComputerAwake ,
258
+ ShowTimeElapsed = options . ShowTimeElapsed ,
234
259
ShowInNotificationArea = Settings . Default . ShowInNotificationArea ,
235
260
LoopTimer = options . LoopTimer ,
236
261
PopUpWhenExpired = options . PopUpWhenExpired ,
237
262
CloseWhenExpired = options . CloseWhenExpired ,
263
+ ShutDownWhenExpired = options . ShutDownWhenExpired ,
238
264
Color = options . Color ,
239
265
Sound = options . Sound ,
240
266
LoopSound = options . LoopSound ,
267
+ OpenSavedTimers = Settings . Default . OpenSavedTimersOnStartup ,
241
268
WindowState = windowSize . WindowState != WindowState . Minimized ? windowSize . WindowState : windowSize . RestoreWindowState ,
242
269
RestoreWindowState = windowSize . RestoreWindowState ,
243
270
WindowBounds = windowSize . RestoreBounds
@@ -262,13 +289,17 @@ private static CommandLineArguments GetArgumentsFromFactoryDefaults()
262
289
AlwaysOnTop = defaultOptions . AlwaysOnTop ,
263
290
IsFullScreen = defaultOptions . WindowSize . IsFullScreen ,
264
291
PromptOnExit = defaultOptions . PromptOnExit ,
292
+ DoNotKeepComputerAwake = defaultOptions . DoNotKeepComputerAwake ,
293
+ ShowTimeElapsed = defaultOptions . ShowTimeElapsed ,
265
294
ShowInNotificationArea = false ,
266
295
LoopTimer = defaultOptions . LoopTimer ,
267
296
PopUpWhenExpired = defaultOptions . PopUpWhenExpired ,
268
297
CloseWhenExpired = defaultOptions . CloseWhenExpired ,
298
+ ShutDownWhenExpired = defaultOptions . ShutDownWhenExpired ,
269
299
Color = defaultOptions . Color ,
270
300
Sound = defaultOptions . Sound ,
271
301
LoopSound = defaultOptions . LoopSound ,
302
+ OpenSavedTimers = false ,
272
303
WindowState = defaultOptions . WindowSize . WindowState ,
273
304
RestoreWindowState = defaultOptions . WindowSize . RestoreWindowState ,
274
305
WindowBounds = defaultWindowBoundsWithLocation
@@ -355,6 +386,32 @@ private static CommandLineArguments GetCommandLineArguments(IEnumerable<string>
355
386
argumentsBasedOnFactoryDefaults . PromptOnExit = promptOnExit ;
356
387
break ;
357
388
389
+ case "--do-not-keep-awake" :
390
+ case "-k" :
391
+ ThrowIfDuplicateSwitch ( specifiedSwitches , "--do-not-keep-awake" ) ;
392
+
393
+ bool doNotKeepComputerAwake = GetBoolValue (
394
+ arg ,
395
+ remainingArgs ,
396
+ argumentsBasedOnMostRecentOptions . DoNotKeepComputerAwake ) ;
397
+
398
+ argumentsBasedOnMostRecentOptions . DoNotKeepComputerAwake = doNotKeepComputerAwake ;
399
+ argumentsBasedOnFactoryDefaults . DoNotKeepComputerAwake = doNotKeepComputerAwake ;
400
+ break ;
401
+
402
+ case "--show-time-elapsed" :
403
+ case "-u" :
404
+ ThrowIfDuplicateSwitch ( specifiedSwitches , "--show-time-elapsed" ) ;
405
+
406
+ bool showTimeElapsed = GetBoolValue (
407
+ arg ,
408
+ remainingArgs ,
409
+ argumentsBasedOnMostRecentOptions . ShowTimeElapsed ) ;
410
+
411
+ argumentsBasedOnMostRecentOptions . ShowTimeElapsed = showTimeElapsed ;
412
+ argumentsBasedOnFactoryDefaults . ShowTimeElapsed = showTimeElapsed ;
413
+ break ;
414
+
358
415
case "--show-in-notification-area" :
359
416
case "-n" :
360
417
ThrowIfDuplicateSwitch ( specifiedSwitches , "--show-in-notification-area" ) ;
@@ -407,6 +464,18 @@ private static CommandLineArguments GetCommandLineArguments(IEnumerable<string>
407
464
argumentsBasedOnFactoryDefaults . CloseWhenExpired = closeWhenExpired ;
408
465
break ;
409
466
467
+ case "--shut-down-when-expired" :
468
+ case "-x" :
469
+ ThrowIfDuplicateSwitch ( specifiedSwitches , "--shut-down-when-expired" ) ;
470
+
471
+ bool shutDownWhenExpired = GetBoolValue (
472
+ arg ,
473
+ remainingArgs ) ;
474
+
475
+ argumentsBasedOnMostRecentOptions . ShutDownWhenExpired = shutDownWhenExpired ;
476
+ argumentsBasedOnFactoryDefaults . ShutDownWhenExpired = shutDownWhenExpired ;
477
+ break ;
478
+
410
479
case "--color" :
411
480
case "-c" :
412
481
ThrowIfDuplicateSwitch ( specifiedSwitches , "--color" ) ;
@@ -446,6 +515,19 @@ private static CommandLineArguments GetCommandLineArguments(IEnumerable<string>
446
515
argumentsBasedOnFactoryDefaults . LoopSound = loopSound ;
447
516
break ;
448
517
518
+ case "--open-saved-timers" :
519
+ case "-v" :
520
+ ThrowIfDuplicateSwitch ( specifiedSwitches , "--open-saved-timers" ) ;
521
+
522
+ bool openSavedTimers = GetBoolValue (
523
+ arg ,
524
+ remainingArgs ,
525
+ argumentsBasedOnMostRecentOptions . OpenSavedTimers ) ;
526
+
527
+ argumentsBasedOnMostRecentOptions . OpenSavedTimers = openSavedTimers ;
528
+ argumentsBasedOnFactoryDefaults . OpenSavedTimers = openSavedTimers ;
529
+ break ;
530
+
449
531
case "--window-bounds" :
450
532
case "-b" :
451
533
ThrowIfDuplicateSwitch ( specifiedSwitches , "--window-bounds" ) ;
@@ -556,6 +638,38 @@ private static string GetRequiredValue(string arg, Queue<string> remainingArgs)
556
638
return value ;
557
639
}
558
640
641
+ /// <summary>
642
+ /// Returns the next <see cref="bool"/> value in <paramref name="remainingArgs"/>, or throws an exception if
643
+ /// <paramref name="remainingArgs"/> is empty or the next argument is not "on" or "off".
644
+ /// </summary>
645
+ /// <param name="arg">The name of the argument for which the value is to be returned.</param>
646
+ /// <param name="remainingArgs">The unparsed arguments.</param>
647
+ /// <returns>The next <see cref="bool"/> value in <paramref name="remainingArgs"/>.</returns>
648
+ /// <exception cref="ParseException">If <paramref name="remainingArgs"/> is empty or the next argument is not
649
+ /// "on" or "off".</exception>
650
+ private static bool GetBoolValue ( string arg , Queue < string > remainingArgs )
651
+ {
652
+ string value = GetRequiredValue ( arg , remainingArgs ) ;
653
+
654
+ switch ( value )
655
+ {
656
+ case "on" :
657
+ return true ;
658
+
659
+ case "off" :
660
+ return false ;
661
+
662
+ default :
663
+ string message = string . Format (
664
+ Resources . ResourceManager . GetEffectiveProvider ( ) ,
665
+ Resources . CommandLineArgumentsParseExceptionInvalidValueForSwitchFormatString ,
666
+ arg ,
667
+ value ) ;
668
+
669
+ throw new ParseException ( message ) ;
670
+ }
671
+ }
672
+
559
673
/// <summary>
560
674
/// Returns the next <see cref="bool"/> value in <paramref name="remainingArgs"/>, or throws an exception if
561
675
/// <paramref name="remainingArgs"/> is empty or the next argument is not "on", "off", or "last".
0 commit comments