/// <summary> /// Initializes a new instance of the <see cref="Timer"/> class. /// </summary> /// <param name="timerInfo">A <see cref="TimerInfo"/> representing the state of the <see /// cref="Timer"/>.</param> public Timer(TimerInfo timerInfo) : base(timerInfo) { this.timerStart = TimerStart.FromTimerStartInfo(timerInfo.TimerStart); this.options = TimerOptions.FromTimerOptionsInfo(timerInfo.Options) ?? new TimerOptions(); this.UpdateHourglassTimer(); }
/// <summary> /// Returns a <see cref="TimerOptionsInfo"/> for the specified <see cref="TimerOptions"/>. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> /// <returns>A <see cref="TimerOptionsInfo"/> for the specified <see cref="TimerOptions"/>.</returns> public static TimerOptionsInfo FromTimerOptions(TimerOptions options) { if (options == null) { return null; } return options.ToTimerOptionsInfo(); }
/// <summary> /// Initializes a new instance of the <see cref="Timer"/> class. /// </summary> /// <param name="options">Configuration data for this timer.</param> public Timer(TimerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.timerStart = null; this.options = TimerOptions.FromTimerOptions(options); this.UpdateHourglassTimer(); }
/// <summary> /// Sets all of the options from another instance of the <see cref="TimerOptions"/> class. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> public void Set(TimerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.title = options.title; this.alwaysOnTop = options.alwaysOnTop; this.loopTimer = options.loopTimer; this.popUpWhenExpired = options.popUpWhenExpired; this.closeWhenExpired = options.closeWhenExpired; this.color = options.color; this.sound = options.sound; this.loopSound = options.loopSound; this.windowSize = WindowSize.FromWindowSize(options.WindowSize); }
/// <summary> /// Updates the <see cref="MostRecentOptions"/> from the currently opened <see cref="TimerWindow"/>s. /// </summary> private void UpdateMostRecentOptions() { if (Application.Current == null) { return; } // Get the options most recently shown to the user from a window that is still open var q = from window in Application.Current.Windows.OfType<TimerWindow>() where window.IsVisible orderby window.Menu.LastShowed descending select window.Options; this.mostRecentOptions = TimerOptions.FromTimerOptions(q.FirstOrDefault()) ?? this.mostRecentOptions; // Never save a title this.mostRecentOptions.Title = string.Empty; }
/// <summary> /// Sets all of the options from another instance of the <see cref="TimerOptions"/> class. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> public void Set(TimerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.title = options.title; this.alwaysOnTop = options.alwaysOnTop; this.promptOnExit = options.promptOnExit; this.showProgressInTaskbar = options.showProgressInTaskbar; this.doNotKeepComputerAwake = options.doNotKeepComputerAwake; this.showTimeElapsed = options.showTimeElapsed; this.loopTimer = options.loopTimer; this.popUpWhenExpired = options.popUpWhenExpired; this.closeWhenExpired = options.closeWhenExpired; this.shutDownWhenExpired = options.shutDownWhenExpired; //this.theme = options.theme; this.sound = options.sound; this.loopSound = options.loopSound; this.windowTitleMode = options.windowTitleMode; this.windowSize = WindowSize.FromWindowSize(options.WindowSize); this.lockInterface = options.lockInterface; this.OnPropertyChanged( "Title", "AlwaysOnTop", "PromptOnExit", "ShowProgressInTaskbar", "DoNotKeepComputerAwake", "ShowTimeElapsed", "LoopTimer", "PopUpWhenExpired", "CloseWhenExpired", "ShutDownWhenExpired", "Theme", "Sound", "LoopSound", "WindowTitleMode", "WindowSize", "LockInterface"); }
/// <summary> /// Sets all of the options from another instance of the <see cref="TimerOptions"/> class. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> public void Set(TimerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.title = options.title; this.alwaysOnTop = options.alwaysOnTop; this.promptOnExit = options.promptOnExit; this.doNotKeepComputerAwake = options.doNotKeepComputerAwake; this.showTimeElapsed = options.showTimeElapsed; this.loopTimer = options.loopTimer; this.popUpWhenExpired = options.popUpWhenExpired; this.closeWhenExpired = options.closeWhenExpired; this.shutDownWhenExpired = options.shutDownWhenExpired; this.theme = options.theme; this.sound = options.sound; this.loopSound = options.loopSound; this.windowTitleMode = options.windowTitleMode; this.windowSize = WindowSize.FromWindowSize(options.WindowSize); this.OnPropertyChanged( "Title", "AlwaysOnTop", "PromptOnExit", "DoNotKeepComputerAwake", "ShowTimeElapsed", "LoopTimer", "PopUpWhenExpired", "CloseWhenExpired", "ShutDownWhenExpired", "Theme", "Sound", "LoopSound", "WindowTitleMode", "WindowSize"); }
/// <summary> /// Sets all of the options from another instance of the <see cref="TimerOptions"/> class. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> public void Set(TimerOptions options) { if (options == null) { throw new ArgumentNullException("options"); } this.title = options.title; this.alwaysOnTop = options.alwaysOnTop; this.promptOnExit = options.promptOnExit; this.doNotKeepComputerAwake = options.doNotKeepComputerAwake; this.showTimeElapsed = options.showTimeElapsed; this.loopTimer = options.loopTimer; this.popUpWhenExpired = options.popUpWhenExpired; this.closeWhenExpired = options.closeWhenExpired; this.shutDownWhenExpired = options.shutDownWhenExpired; this.color = options.color; this.sound = options.sound; this.loopSound = options.loopSound; this.windowSize = WindowSize.FromWindowSize(options.WindowSize); }
/// <summary> /// Returns a <see cref="TimerOptions"/> for the specified <see cref="TimerOptions"/>, or <c>null</c> if the /// specified <see cref="TimerOptions"/> is <c>null</c>. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> /// <returns>A <see cref="TimerOptions"/> for the specified <see cref="TimerOptions"/>, or <c>null</c> if the /// specified <see cref="TimerOptions"/> is <c>null</c>.</returns> public static TimerOptions FromTimerOptions(TimerOptions options) { return options != null ? new TimerOptions(options) : null; }
/// <summary> /// Initializes a new instance of the <see cref="TimerOptions"/> class from another instance of the <see /// cref="TimerOptions"/> class. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> public TimerOptions(TimerOptions options) { this.Set(options); }
/// <summary> /// Returns a <see cref="TimerOptions"/> for the specified <see cref="TimerOptions"/>, or <c>null</c> if the /// specified <see cref="TimerOptions"/> is <c>null</c>. /// </summary> /// <param name="options">A <see cref="TimerOptions"/>.</param> /// <returns>A <see cref="TimerOptions"/> for the specified <see cref="TimerOptions"/>, or <c>null</c> if the /// specified <see cref="TimerOptions"/> is <c>null</c>.</returns> public static TimerOptions FromTimerOptions(TimerOptions options) { return(options != null ? new TimerOptions(options) : null); }
/// <summary> /// Returns an <see cref="CommandLineArguments"/> instance based on the factory default settings. /// </summary> /// <returns>An <see cref="CommandLineArguments"/> instance based on the factory default settings.</returns> private static CommandLineArguments GetArgumentsFromFactoryDefaults() { TimerOptions defaultOptions = new TimerOptions(); WindowSize mostRecentWindowSize = GetMostRecentWindowSize(); Rect defaultWindowBounds = defaultOptions.WindowSize.RestoreBounds; Rect defaultWindowBoundsWithLocation = mostRecentWindowSize.RestoreBounds.Merge(defaultWindowBounds); return new CommandLineArguments { Title = defaultOptions.Title, AlwaysOnTop = defaultOptions.AlwaysOnTop, IsFullScreen = defaultOptions.WindowSize.IsFullScreen, PromptOnExit = defaultOptions.PromptOnExit, DoNotKeepComputerAwake = defaultOptions.DoNotKeepComputerAwake, ShowTimeElapsed = defaultOptions.ShowTimeElapsed, ShowInNotificationArea = false, LoopTimer = defaultOptions.LoopTimer, PopUpWhenExpired = defaultOptions.PopUpWhenExpired, CloseWhenExpired = defaultOptions.CloseWhenExpired, ShutDownWhenExpired = defaultOptions.ShutDownWhenExpired, Color = defaultOptions.Color, Sound = defaultOptions.Sound, LoopSound = defaultOptions.LoopSound, OpenSavedTimers = false, WindowState = defaultOptions.WindowSize.WindowState, RestoreWindowState = defaultOptions.WindowSize.RestoreWindowState, WindowBounds = defaultWindowBoundsWithLocation }; }
/// <summary> /// Initializes the class. /// </summary> public override void Initialize() { this.mostRecentOptions = Settings.Default.MostRecentOptions ?? new TimerOptions(); }