Esempio n. 1
0
 /// <summary>
 /// Clears the output window or console text (if <see cref="IsWritingToConsole"/>) or log file (if <see cref="LogFile"/> not null).
 /// </summary>
 public static void Clear()
 {
     if (LogFile != null)
     {
         _ClearToLogFile();
     }
     else if (IsWritingToConsole)
     {
         try { Console.Clear(); } catch { }                 //exception if redirected, it is documented
     }
     else if (QM2.UseQM2)
     {
         QM2.Clear();
     }
     else
     {
         _ClearToOutputServer();
     }
 }
        private void UpdateScreenTimer_Tick(object sender, EventArgs e)
        {
            TimeLabel.Text = String.Format("{0:00}:{1:00}:{2:000}", quizTimer.Elapsed.Minutes, quizTimer.Elapsed.Seconds, quizTimer.Elapsed.Milliseconds);
            if (car1.X % (Track1.Width / 10) == 0 && car1.Speed != 0) // (if the car has reached a question point and isn't already stopped)
            {
                Q1 = QM1.RandomQuestion();
                Q1.ShuffleAns();
                QuestionLabel1.Text = Q1.QuestionText;
                for (int i = 0; i < 4; i++)
                {
                    Q1AnsLabels[i].Text = Q1.Answers[i];
                }
                CoverLabel1.Visible = false;
                car1.Speed          = 0;
                questionTimer1.Restart();
            }
            if (questionTimer1.Elapsed.Seconds >= 15)
            {
                questionTimer1.Reset();
                CoverLabel1.Text      = "TOO SLOW";
                CoverLabel1.ForeColor = Color.Red;
                car1.X    += 1;
                car1.Speed = 1;
                CoverLabel1.Show();
                questionTimer1.Stop();
                TPQList1.Add(questionTimer1.Elapsed.Seconds);
            }
            if (car1.X >= Track1.Width)
            {
                if (_activeUsers.Length == 2)
                {
                    End(_activeUsers[0], _activeUsers[1]);
                }
                else
                {
                    End();
                }
            }
            car1.Draw();
            wheel1.RotateImage(car1.Speed);
            if (_activeUsers.Length == 2) // I originally had try-catch blocks to handle 1 player, but this seemed to be taxing on the computer as exceptions were thrown every 50ms
            {
                if (car2.X % (Track2.Width / 10) == 0 && car2.Speed != 0)
                {
                    Q2 = QM2.RandomQuestion();
                    Q2.ShuffleAns();
                    QuestionLabel2.Text = Q2.QuestionText;
                    for (int i = 0; i < 4; i++)
                    {
                        Q2AnsLabels[i].Text = Q2.Answers[i];
                    }
                    CoverLabel2.Visible = false;
                    car2.Speed          = 0;
                    questionTimer2.Restart();
                }
                if (questionTimer2.Elapsed.Seconds >= 15)
                {
                    questionTimer2.Reset();
                    CoverLabel2.Text      = "TOO SLOW";
                    CoverLabel2.ForeColor = Color.Red;
                    car2.X    += 1;
                    car2.Speed = 1;
                    CoverLabel2.Show();
                    TPQList2.Add(questionTimer2.Elapsed.Seconds);
                }
                if (car2.X >= Track2.Width)
                {
                    End(_activeUsers[1], _activeUsers[0]);
                }

                car2.Draw();
                wheel2.RotateImage(car2.Speed);
            }
        }