/// <summary> /// Invoked when the <see cref="TimerWindow"/> is laid out, rendered, and ready for interaction. /// </summary> /// <param name="sender">The <see cref="TimerWindow"/>.</param> /// <param name="e">The event data.</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Deal with any input or timer set in the constructor if (this.timerStartToStartOnLoad != null) { this.Show(this.timerStartToStartOnLoad); } else if (this.Options.LockInterface) { // If the interface is locked but no timer input was specified, there is nothing the user can do or // should be able to do other than close the window, so pretend that the timer expired immediately this.Show(TimerStart.Zero, false /* remember */); } else if (this.timerToResumeOnLoad != null) { this.Show(this.timerToResumeOnLoad); } this.timerStartToStartOnLoad = null; this.timerToResumeOnLoad = null; // Minimize to notification area if required if (this.WindowState == WindowState.Minimized && Settings.Default.ShowInNotificationArea) { //this.MinimizeToNotificationArea(); } }
private void TimerStart_Tick(object sender, EventArgs e) { TimerStart.Interval = 100; if (second == 0 && minute >= 1) { minute--; second = 60; } if (second == 0 && minute == 0) { TimerStart.Stop(); GameOver(sender, e); return; } second--; if (minute >= 10) { lblMinute.Text = "" + minute; } else { lblMinute.Text = "0" + minute; } if (second >= 10) { lblSecond.Text = "" + second; } else { lblSecond.Text = "0" + second; } }
private void btnChoiLai_Click(object sender, EventArgs e) { txtTyping.Text = ""; txtTyping.Enabled = true; txtTyping.Focus(); TimerStart.Start(); }
private void btnStart_Click(object sender, EventArgs e) { btnStart.Visible = false; btnChoiLai.Visible = true; txtTyping.Enabled = true; txtTyping.Focus(); TimerStart.Start(); }
/// <summary> /// Returns a <see cref="TimerStartInfo"/> for a <see cref="TimerStart"/>. /// </summary> /// <param name="timerStart">A <see cref="TimerStart"/>.</param> /// <returns>The <see cref="TimerStartInfo"/> for the <see cref="TimerStart"/>.</returns> public static TimerStartInfo FromTimerStart(TimerStart timerStart) { if (timerStart == null) { return(null); } return(timerStart.ToTimerStartInfo()); }
private void btnStart_Click(object sender, EventArgs e) { txtTypingTest.Enabled = true; frmTypingTest_Load_KePreviewTrue(sender, e); txtTypingTest.Focus(); btnStart.Visible = false; btnChoiLai.Visible = true; TimerStart.Start(); }
private void TimerStart_Tick(object sender, EventArgs e) { Count = Count + 0.1; Opacity = Count; if (Count >= 1) { TimerStart.Stop(); EventsTimer.Start(); } }
private void btnChoiLai_Click(object sender, EventArgs e) { second = 60; length = 0; dem = 0; lblMinute.Text = "01"; lblSecond.Text = "00"; txtTyping.Text = ""; txtTyping.Enabled = true; txtTyping.Focus(); TimerStart.Start(); }
private void dCredits_Load(object sender, EventArgs e) { while (Ligne != null) { Ligne = sr.ReadLine(); Texte += Ligne + "\n"; } TabAffiche = Texte.Split('\n'); TimerStart.Start(); TimerDeplacementTexte.Start(); }
/// <summary> /// Adds a <see cref="TimerStart"/> to the list of recent <see cref="TimerStart"/> objects. /// </summary> /// <param name="timerStart">A <see cref="TimerStart"/>.</param> public void Add(TimerStart timerStart) { // Remove all equivalent objects this.timerStarts.RemoveAll(e => e.ToString() == timerStart.ToString()); // Add the object to the top of the list this.timerStarts.Insert(0, timerStart); // Limit the number of objects in the list while (this.timerStarts.Count > Capacity) { this.timerStarts.RemoveAt(this.timerStarts.Count - 1); } }
/// <summary> /// Invoked when the <see cref="StartCommand"/> is executed. /// </summary> /// <param name="sender">The <see cref="TimerWindow"/>.</param> /// <param name="e">The event data.</param> private void StartCommandExecuted(object sender, ExecutedRoutedEventArgs e) { TimerStart timerStart = TimerStart.FromString(timerValue); if (timerStart == null) { //this.BeginValidationErrorAnimation(); return; } // If the interface was previously locked, unlock it when a new timer is started this.Options.LockInterface = false; this.Show(timerStart); //this.StartButton.Unfocus(); }
/// <summary> /// Returns the <see cref="TimerStart"/> value corresponding to the concatenation of all <paramref /// name="remainingArgs"/>, or throws an exception if the concatenation of all <paramref name="remainingArgs"/> /// is not a valid representation of a <see cref="TimerStart"/>. /// </summary> /// <param name="remainingArgs">The unparsed arguments.</param> /// <returns>The <see cref="TimerStart"/> value corresponding to the concatenation of all <paramref /// name="remainingArgs"/></returns> /// <exception cref="ParseException">If the concatenation of all <paramref name="remainingArgs"/> is not a /// valid representation of a <see cref="TimerStart"/>.</exception> private static TimerStart GetTimerStartValue(IEnumerable <string> remainingArgs) { string value = string.Join(" ", remainingArgs); TimerStart timerStart = TimerStart.FromString(value); if (timerStart == null) { string message = string.Format( Resources.ResourceManager.GetEffectiveProvider(), Resources.CommandLineArgumentsParseExceptionInvalidTimerInputFormatString, value); throw new ParseException(message); } return(timerStart); }
private void TimerStart_Tick(object sender, EventArgs e) { TimerStart.Interval = 1000; lblMinute.Text = "00"; second--; lblSecond.Text = "" + second; if (second == 0) { TimerStart.Stop(); btnChoiLai.Visible = true; string[] Test = txtTest.Text.Trim().Split(' '); string[] Typing = txtTyping.Text.Split(' '); string s = txtTyping.Text; foreach (char c in s) { if (c == ' ') { length++; } } for (int i = 0; i <= length; i++) { if (Test[i] == Typing[i]) { dem++; } } MessageBox.Show("Bạn đã đúng số câu là " + dem, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); btnStart.Visible = false; txtTyping.Enabled = false; btnChoiLai.Visible = true; txtTyping.Text = ""; second = 60; length = 0; dem = 0; lblMinute.Text = "01"; lblSecond.Text = "00"; } }
/// <summary> /// Invoked when a recent <see cref="TimerStart"/> <see cref="MenuItem"/> is clicked. /// </summary> /// <param name="sender">The <see cref="MenuItem"/> where the event handler is attached.</param> /// <param name="e">The event data.</param> private void RecentInputMenuItemClick(object sender, RoutedEventArgs e) { MenuItem menuItem = (MenuItem)sender; TimerStart timerStart = (TimerStart)menuItem.Tag; TimerWindow window; if (this.timerWindow.Timer.State == TimerState.Stopped || this.timerWindow.Timer.State == TimerState.Expired) { window = this.timerWindow; } else { window = new TimerWindow(); window.Options.Set(this.timerWindow.Options); window.RestoreFromWindow(this.timerWindow); } window.Show(timerStart); }
/// <summary> /// Opens the <see cref="TimerWindow"/> if it is not already open and displays a new timer started with the /// specified <see cref="TimerStart"/>. /// </summary> /// <param name="timerStart">A <see cref="TimerStart"/>.</param> /// <param name="remember">A value indicating whether to remember the <see cref="TimerStart"/> as a recent /// input.</param> public void Show(TimerStart timerStart, bool remember = true) { // Keep track of the input //this.LastTimerStart = timerStart; // Start a new timer Timer newTimer = new Timer(this.Options); if (!newTimer.Start(timerStart)) { // The user has started a timer that expired in the past if (this.Options.LockInterface) { // If the interface is locked, there is nothing the user can do or should be able to do other than // close the window, so pretend that the timer expired immediately this.Show(TimerStart.Zero, false /* remember */); return; } else { // Otherwise, assume the user made an error and display a validation error animation this.Show(); this.SwitchToInputMode(); // this.BeginValidationErrorAnimation(); return; } } TimerManager.Instance.Add(newTimer); if (remember) { TimerStartManager.Instance.Add(timerStart); } // Show the window this.Show(newTimer); }
/// <summary> /// Initializes a new instance of the <see cref="TimerWindow"/> class. /// </summary> /// <param name="timerStart">The <see cref="TimerStart"/> to start when the window loads, or <c>null</c> if no /// <see cref="TimerStart"/> is to be started.</param> public TimerWindow(TimerStart timerStart) : this() { this.timerStartToStartOnLoad = timerStart; }
private void FadeIn() { TimerStart.Start(); }
/// <summary> /// Parses command-line arguments. /// </summary> /// <param name="args">The command-line arguments.</param> /// <returns>The parsed command-line arguments.</returns> /// <exception cref="ParseException">If the command-line arguments could not be parsed.</exception> private static CommandLineArguments GetCommandLineArguments(IEnumerable <string> args) { CommandLineArguments argumentsBasedOnMostRecentOptions = GetArgumentsFromMostRecentOptions(); CommandLineArguments argumentsBasedOnFactoryDefaults = GetArgumentsFromFactoryDefaults(); bool useFactoryDefaults = false; HashSet <string> specifiedSwitches = new HashSet <string>(); Queue <string> remainingArgs = new Queue <string>(args); while (remainingArgs.Count > 0) { string arg = remainingArgs.Dequeue(); switch (arg) { case "--title": case "-t": ThrowIfDuplicateSwitch(specifiedSwitches, "--title"); string title = GetRequiredValue(arg, remainingArgs); argumentsBasedOnMostRecentOptions.Title = title; argumentsBasedOnFactoryDefaults.Title = title; break; case "--always-on-top": case "-a": ThrowIfDuplicateSwitch(specifiedSwitches, "--always-on-top"); bool alwaysOnTop = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.AlwaysOnTop); argumentsBasedOnMostRecentOptions.AlwaysOnTop = alwaysOnTop; argumentsBasedOnFactoryDefaults.AlwaysOnTop = alwaysOnTop; break; case "--full-screen": case "-f": ThrowIfDuplicateSwitch(specifiedSwitches, "--full-screen"); bool isFullScreen = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.IsFullScreen); argumentsBasedOnMostRecentOptions.IsFullScreen = isFullScreen; argumentsBasedOnFactoryDefaults.IsFullScreen = isFullScreen; break; case "--prompt-on-exit": case "-o": ThrowIfDuplicateSwitch(specifiedSwitches, "--prompt-on-exit"); bool promptOnExit = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.PromptOnExit); argumentsBasedOnMostRecentOptions.PromptOnExit = promptOnExit; argumentsBasedOnFactoryDefaults.PromptOnExit = promptOnExit; break; case "--do-not-keep-awake": case "-k": ThrowIfDuplicateSwitch(specifiedSwitches, "--do-not-keep-awake"); bool doNotKeepComputerAwake = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.DoNotKeepComputerAwake); argumentsBasedOnMostRecentOptions.DoNotKeepComputerAwake = doNotKeepComputerAwake; argumentsBasedOnFactoryDefaults.DoNotKeepComputerAwake = doNotKeepComputerAwake; break; case "--show-time-elapsed": case "-u": ThrowIfDuplicateSwitch(specifiedSwitches, "--show-time-elapsed"); bool showTimeElapsed = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.ShowTimeElapsed); argumentsBasedOnMostRecentOptions.ShowTimeElapsed = showTimeElapsed; argumentsBasedOnFactoryDefaults.ShowTimeElapsed = showTimeElapsed; break; case "--show-in-notification-area": case "-n": ThrowIfDuplicateSwitch(specifiedSwitches, "--show-in-notification-area"); bool showInNotificationArea = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.ShowInNotificationArea); argumentsBasedOnMostRecentOptions.ShowInNotificationArea = showInNotificationArea; argumentsBasedOnFactoryDefaults.ShowInNotificationArea = showInNotificationArea; break; case "--loop-timer": case "-l": ThrowIfDuplicateSwitch(specifiedSwitches, "--loop-timer"); bool loopTimer = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.LoopTimer); argumentsBasedOnMostRecentOptions.LoopTimer = loopTimer; argumentsBasedOnFactoryDefaults.LoopTimer = loopTimer; break; case "--pop-up-when-expired": case "-p": ThrowIfDuplicateSwitch(specifiedSwitches, "--pop-up-when-expired"); bool popUpWhenExpired = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.PopUpWhenExpired); argumentsBasedOnMostRecentOptions.PopUpWhenExpired = popUpWhenExpired; argumentsBasedOnFactoryDefaults.PopUpWhenExpired = popUpWhenExpired; break; case "--close-when-expired": case "-e": ThrowIfDuplicateSwitch(specifiedSwitches, "--close-when-expired"); bool closeWhenExpired = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.CloseWhenExpired); argumentsBasedOnMostRecentOptions.CloseWhenExpired = closeWhenExpired; argumentsBasedOnFactoryDefaults.CloseWhenExpired = closeWhenExpired; break; case "--shut-down-when-expired": case "-x": ThrowIfDuplicateSwitch(specifiedSwitches, "--shut-down-when-expired"); bool shutDownWhenExpired = GetBoolValue( arg, remainingArgs); argumentsBasedOnMostRecentOptions.ShutDownWhenExpired = shutDownWhenExpired; argumentsBasedOnFactoryDefaults.ShutDownWhenExpired = shutDownWhenExpired; break; case "--theme": case "-m": ThrowIfDuplicateSwitch(specifiedSwitches, "--theme"); Theme theme = GetThemeValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.Theme); argumentsBasedOnMostRecentOptions.Theme = theme; argumentsBasedOnFactoryDefaults.Theme = theme; break; case "--sound": case "-s": ThrowIfDuplicateSwitch(specifiedSwitches, "--sound"); Sound sound = GetSoundValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.Sound); argumentsBasedOnMostRecentOptions.Sound = sound; argumentsBasedOnFactoryDefaults.Sound = sound; break; case "--loop-sound": case "-r": ThrowIfDuplicateSwitch(specifiedSwitches, "--loop-sound"); bool loopSound = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.LoopSound); argumentsBasedOnMostRecentOptions.LoopSound = loopSound; argumentsBasedOnFactoryDefaults.LoopSound = loopSound; break; case "--open-saved-timers": case "-v": ThrowIfDuplicateSwitch(specifiedSwitches, "--open-saved-timers"); bool openSavedTimers = GetBoolValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.OpenSavedTimers); argumentsBasedOnMostRecentOptions.OpenSavedTimers = openSavedTimers; argumentsBasedOnFactoryDefaults.OpenSavedTimers = openSavedTimers; break; case "--window-title": case "-i": ThrowIfDuplicateSwitch(specifiedSwitches, "--window-title"); WindowTitleMode windowTitleMode = GetWindowTitleModeValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.WindowTitleMode); argumentsBasedOnMostRecentOptions.WindowTitleMode = windowTitleMode; argumentsBasedOnFactoryDefaults.WindowTitleMode = windowTitleMode; break; case "--window-state": case "-w": ThrowIfDuplicateSwitch(specifiedSwitches, "--window-state"); WindowState windowState = GetWindowStateValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.WindowState); argumentsBasedOnMostRecentOptions.WindowState = windowState; argumentsBasedOnFactoryDefaults.WindowState = windowState; break; case "--window-bounds": case "-b": ThrowIfDuplicateSwitch(specifiedSwitches, "--window-bounds"); Rect windowBounds = GetRectValue( arg, remainingArgs, argumentsBasedOnMostRecentOptions.WindowBounds); argumentsBasedOnMostRecentOptions.WindowBounds = argumentsBasedOnMostRecentOptions.WindowBounds.Merge(windowBounds); argumentsBasedOnFactoryDefaults.WindowBounds = argumentsBasedOnFactoryDefaults.WindowBounds.Merge(windowBounds); break; case "--use-factory-defaults": case "-d": ThrowIfDuplicateSwitch(specifiedSwitches, "--use-factory-defaults"); useFactoryDefaults = true; break; case "--help": case "-h": case "-?": ThrowIfDuplicateSwitch(specifiedSwitches, "--help"); argumentsBasedOnMostRecentOptions.ShouldShowUsage = true; argumentsBasedOnFactoryDefaults.ShouldShowUsage = true; break; default: if (IsSwitch(arg)) { string message = string.Format( Resources.ResourceManager.GetEffectiveProvider(), Resources.CommandLineArgumentsParseExceptionUnrecognizedSwitchFormatString, arg); throw new ParseException(message); } List <string> inputArgs = remainingArgs.ToList(); inputArgs.Insert(0, arg); remainingArgs.Clear(); TimerStart timerStart = GetTimerStartValue(inputArgs); argumentsBasedOnMostRecentOptions.TimerStart = timerStart; argumentsBasedOnFactoryDefaults.TimerStart = timerStart; break; } } return(useFactoryDefaults ? argumentsBasedOnFactoryDefaults : argumentsBasedOnMostRecentOptions); }
private void AnimationEnd(object sender, EventArgs e) { DeleteEgg?.Invoke(sender, e); TimerStart?.Invoke(this, e); }
public void StartGame() { TimerStart?.Invoke(this, new EventArgs()); }