private void CountdownTimer_Tick(object sender, EventArgs e)
 {
     countdown--;
     if (countdown <= 0)
     {
         CoverLabel1.Visible = false;
         CoverLabel1.Text    = CoverLabel2.Text = "";
         if (_activeUsers.Length == 2)
         {
             CoverLabel2.Visible = false;
             QM2 = new QuestionMaker(); // creating this here allows the random objects in each QuestionMaker to use different seeds, as they are dependent on time
         }
         CountdownTimer.Stop();
         CountdownTimer.Dispose();
         quizTimer.Start();
         UpdateScreenTimer_Tick(this, EventArgs.Empty);// creates a new question instantly, eliminating the possibility that a button is pressed before the timer ticks, which would cause errors
         UpdateScreenTimer.Start();
         return;
     }
     CoverLabel1.Text = countdown.ToString();
     CoverLabel2.Text = CoverLabel1.Text;
     if (_sfx)
     {
         SystemSounds.Beep.Play();
     }
 }
Пример #2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (countdownTimer != null)
                {
                    countdownTimer.Elapsed -= OnCountdownTimerElapsed;
                    countdownTimer.Dispose();
                    countdownTimer = null;
                }
            }

            base.Dispose(disposing);
        }
Пример #3
0
 private void Game_Init()
 {
     Countdown--;
     if (Countdown == 0) // Если отсчет закончился
     {
         CountdownLabel.Text     = "GO";
         CountdownTimer.Interval = 500; // Ставим интервал 500 мсек на скрытие надписи "GO"
     }
     else if (Countdown == -1)          // Если прошли 500 мсек после окончания отсчета, то удаляем таймер и лейбл
     {
         CountdownLabel.Dispose();
         CountdownTimer.Dispose();
         Game_Start();
     }
     else
     {
         CountdownLabel.Text = Countdown.ToString();
     }
 }
Пример #4
0
 public void Dispose()
 {
     DetachListener();
     _timer?.Dispose();
 }