public static void RestartGame() { var controls = System.Windows.Forms.Form.ActiveForm?.Controls; if (controls == null) { return; } if (!controls.Find(CardButtonName, true).Any()) { SetBestTime(controls); } else { RemoveCardButtons(controls); } ControlsBuilder boardBuilder = new GameBoard(); GameScreen.Instance.Construct(boardBuilder); controls.AddRange(boardBuilder.Controls.ToArray()); StopwatchControl.Restart(); }
private void Timer_Tick(object sender, EventArgs eArgs) { if (_timeLabel != null) { _timeLabel.Text = StopwatchControl.Elapsed().TimespanToTimerString(); } }
private static void SetBestTime(Control.ControlCollection controls) { var lastBestTime = controls.Find(BestTimeLabelName, true).FirstOrDefault(); var elapsed = StopwatchControl.Elapsed(); if (lastBestTime != null && elapsed.CompareTo(lastBestTime.Text.TimerStringToTimestamp()) == -1) { lastBestTime.Text = elapsed.TimespanToTimerString(); } }
public static IStopwatchController CreateController(StopwatchControl stopwatch) { switch (stopwatch.StopwatchType) { case StopwatchType.None: return new DefaultController(stopwatch); default: return new DefaultController(stopwatch); } }
public GameMenu() { controls = new List <Control>(); Timer clock = new Timer(); clock.Start(); clock.Tick += Timer_Tick; StopwatchControl.Start(); }
public void RestoreConfig(StopwatchControl stopwatchControl) { if (stopwatchControl == null) throw new ArgumentNullException("stopwatchControl"); StopwatchConfig config = StopwatchConfigManager.Current.GetConfig(stopwatchControl.ConfigName); if (config != null) { stopwatchControl.ApplyConfig(config); } else { MessageService.ShowError("码表控件没有配置初始化,请先配置初始化。"); } }
public DefaultController(StopwatchControl control) { this.Stopwatch = control; this.serialPort = this.Stopwatch.SerialPort; }
public SHHSController(StopwatchControl control) : base(control) { }