Esempio n. 1
0
 public void StartTest()
 {
     timeLeft                      = randomTimeGenerator.Next(100, 500);
     testActive                    = true;
     button1.BackColor             = Color.Violet;
     ButtomCountdownTimer.Interval = 1;
     ButtomCountdownTimer.Start();
     button1.Text = "Click when the button turns green ";
 }
Esempio n. 2
0
        private void ButtomCountdownTimer_Tick(object sender, EventArgs e)
        {
            if (timeLeft > 0)
            {
                timeLeft = timeLeft - 1;
                tooSoon  = true;
            }
            else
            {
                tooSoon = false;
                //button1.Enabled = true;
                ButtomCountdownTimer.Stop();
                button1.BackColor = Color.Green;
                //sum.Value = timeCalc1 + timeCalc2;

                timeLeft = 0;
                stopwatch.Start();
            }
        }
Esempio n. 3
0
        public void EndTest()
        {
            testActive = false;
            testNumber++;
            ButtomCountdownTimer.Stop();
            button1.BackColor = Color.Yellow;
            button1.Text      = "";
            stopwatch.Stop();
            //int elapsedTime = (int));
            decimal reactionTime = stopwatch.ElapsedMilliseconds - 100;

            button1.Text       = reactionTime + "ms" + Environment.NewLine + "Press any key to try again";
            totalReactionTime += (int)reactionTime;
            label1.Text        = testNumber + " RECENT ATTMEPTS (AVERAGE: " + (totalReactionTime / testNumber) + "ms)" + Environment.NewLine;
            label2.Text       += reactionTime + Environment.NewLine;
            stopwatch.Reset();
            //button1.Enabled = true;
            button2.Enabled = true;
        }