예제 #1
0
        public void OnTimeEvent(object sender, ElapsedEventArgs e)
        {
            Invoke(new Action(() =>
            {
                s -= 1;
                if (s < 0)
                {
                    s = 59;
                    --m;
                }
                txtBoxTimer.Text = string.Format("{0}:{1}", m.ToString().PadLeft(2, '0'), s.ToString().PadLeft(2, '0'));

                if (m == 0 && s == 0)
                {
                    t.Stop();
                    txtBoxTimer.Text      = "00:00";
                    ResultForm resultform = new ResultForm(result);
                    resultform.ShowDialog();
                    this.Close();
                }
            }));
        }
예제 #2
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            RadioButton gbOneItem    = new RadioButton();
            var         radioButtons = gbAnwers.Controls.OfType <RadioButton>();

            foreach (RadioButton radio in radioButtons)
            {
                if (radio.Checked)
                {
                    var ans = radio.Tag as QuestionAnswerClass;
                    result[indexQuest] = ans.IsTrue;
                    indexQuest++;
                    count--;
                    this.progressBar1.Value += 1;

                    if (ans.IsTrue == true)
                    {
                        SoundPlayer soundPlayer = new SoundPlayer(Properties.Resources.win);
                        soundPlayer.Play();
                        if (indexQuest == 1)
                        {
                            lbl1.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 2)
                        {
                            lbl2.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 3)
                        {
                            lbl3.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 4)
                        {
                            lbl4.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 5)
                        {
                            lbl5.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 6)
                        {
                            lbl6.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 7)
                        {
                            lbl7.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 8)
                        {
                            lbl8.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 9)
                        {
                            lbl9.BackColor = Color.Yellow;
                        }
                        if (indexQuest == 10)
                        {
                            lbl10.BackColor = Color.Yellow;
                        }
                    }
                    else
                    {
                        limit++;
                        SoundPlayer soundPlayer1 = new SoundPlayer(Properties.Resources.lose);
                        soundPlayer1.Play();
                        if (indexQuest == 1)
                        {
                            lbl1.BackColor = Color.Red;
                        }
                        if (indexQuest == 2)
                        {
                            lbl2.BackColor = Color.Red;
                        }
                        if (indexQuest == 3)
                        {
                            lbl3.BackColor = Color.Red;
                        }
                        if (indexQuest == 4)
                        {
                            lbl4.BackColor = Color.Red;
                        }
                        if (indexQuest == 5)
                        {
                            lbl5.BackColor = Color.Red;
                        }
                        if (indexQuest == 6)
                        {
                            lbl6.BackColor = Color.Red;
                        }
                        if (indexQuest == 7)
                        {
                            lbl7.BackColor = Color.Red;
                        }
                        if (indexQuest == 8)
                        {
                            lbl8.BackColor = Color.Red;
                        }
                        if (indexQuest == 9)
                        {
                            lbl9.BackColor = Color.Red;
                        }
                        if (indexQuest == 10)
                        {
                            lbl10.BackColor = Color.Red;
                        }
                    }

                    if (limit > 2)
                    {
                        t.Stop();
                        ResultForm resultform = new ResultForm(result);
                        resultform.ShowDialog();
                        this.Close();
                    }
                }
            }

            if (indexQuest < listQuestion.Count)
            {
                ShowFormQuesting();
            }
            else
            {
                t.Stop();
                ResultForm resultform = new ResultForm(result);
                resultform.ShowDialog();
                this.Close();
            }
        }