コード例 #1
0
        private void radioButton4_CheckedChanged(object sender, EventArgs e)
        {
            if (button1.Text == "11" && radioButton4.Checked == true)
            {
                radioButton4.BackColor = Color.Gold;
                button1.Enabled        = true;

                if (button1.Text == "11" && radioButton4.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            if (button1.Text == "8" && radioButton4.Checked == true)
            {
                radioButton4.BackColor = Color.Gold;
                button1.Enabled        = true;

                if (button1.Text == "8" && radioButton4.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            if (button1.Text == "7" && radioButton4.Checked == true)
            {
                radioButton4.BackColor = Color.Gold;
                button1.Enabled        = true;

                if (button1.Text == "7" && radioButton4.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            //----------------------------------------Incorrect answer------------------------------//

            if ((button1.Text == "1" || button1.Text == "2" || button1.Text == "3" || button1.Text == "4" || button1.Text == "5" || button1.Text == "6" ||
                 button1.Text == "9" || button1.Text == "10" || button1.Text == "12" || button1.Text == "13" || button1.Text == "14" || button1.Text == "15" || button1.Text == "16"))
            {
                radioButton4.BackColor = Color.Red;
                pictureBox5.Image      = imageList1.Images[8];
                MessageBox.Show("You loose");
                //button1.Enabled = true;
                //button1.Text = "Start again";
                iSlide = 0;

                DialogResult dialog6 = MessageBox.Show("You loose", "Exit", MessageBoxButtons.OKCancel);
                if (dialog6 == DialogResult.OK)
                {
                    this.Hide();
                    Form begin = new Begin();
                    begin.ShowDialog();
                }
                else
                {
                    this.Close();
                }
            }
        }
コード例 #2
0
        private void radioButton3_CheckedChanged(object sender, EventArgs e)
        {
            if (button1.Text == "14" && radioButton3.Checked == true)
            {
                radioButton3.BackColor = Color.Gold;
                button1.Enabled        = true;

                if (button1.Text == "14" && radioButton3.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            if (button1.Text == "13" && radioButton3.Checked == true)
            {
                radioButton3.BackColor = Color.Gold;
                button1.Enabled        = true;

                if (button1.Text == "13" && radioButton3.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            if (button1.Text == "12" && radioButton3.Checked == true)
            {
                radioButton3.BackColor = Color.Gold;
                button1.Enabled        = true;

                if (button1.Text == "12" && radioButton3.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            if (button1.Text == "9" && radioButton3.Checked == true)
            {
                radioButton3.BackColor = Color.Gold;
                button1.Enabled        = true;

                if (button1.Text == "9" && radioButton3.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            if (button1.Text == "5" && radioButton3.Checked == true)
            {
                radioButton3.BackColor = Color.Gold;
                button1.Enabled        = true;
                MessageBox.Show("You won 1 thousand");

                DialogResult dialog = MessageBox.Show("You can now quit and go home with your cash or you can continue", "Exit", MessageBoxButtons.YesNo);
                if (dialog == DialogResult.Yes)
                {
                    Application.Restart();
                }

                if (button1.Text == "5" && radioButton3.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            if (button1.Text == "2" && radioButton3.Checked == true)
            {
                radioButton3.BackColor = Color.Gold;
                button1.Enabled        = true;

                if (button1.Text == "2" && radioButton3.Checked == true)
                {
                    label2.Text = "Score: " + score;
                    score++;
                }
                else
                {
                    score = 0;
                }
            }

            //-----------------------------Incorrect Answer---------------------------------\\

            if ((button1.Text == "1" || button1.Text == "3" || button1.Text == "4" || button1.Text == "6" || button1.Text == "7" || button1.Text == "8" ||
                 button1.Text == "10" || button1.Text == "11" || button1.Text == "15"))
            {
                radioButton3.BackColor = Color.Red;
                pictureBox5.Image      = imageList1.Images[8];
                iSlide = 0;
                MessageBox.Show("You loose");
                //button1.Enabled = true;
                //button1.Text = "Start again";

                DialogResult dialog5 = MessageBox.Show("You loose", "Exit", MessageBoxButtons.OKCancel);
                if (dialog5 == DialogResult.OK)
                {
                    this.Hide();
                    Form begin = new Begin();
                    begin.ShowDialog();
                }
                else
                {
                    this.Close();
                }
            }
        }