Example #1
0
        private void CheckForWinner()
        {
            foreach (Control control in tableLayoutPanel1.Controls)
            {
                Label pictureLabel = control as Label;

                if (pictureLabel != null)
                {
                    if (pictureLabel.ForeColor == pictureLabel.BackColor)
                    {
                        return;
                    }
                }
            }

            DialogResult dialogResult = MessageBox.Show("Do you want play again ?",
                                                        "You won in " + winnerTime + " seconds!!!!", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                howLong.Stop();
                this.Hide();
                SecondForm newForm = new SecondForm();
                newForm.ShowDialog();
                this.Close();
            }
            else if (dialogResult == DialogResult.No)
            {
                this.Close();
            }
        }
Example #2
0
        private void ChangeSize_Click(object sender, EventArgs e)
        {
            this.Hide();
            SecondForm newForm = new SecondForm();

            newForm.ShowDialog();
            this.Close();
        }
Example #3
0
        /// <summary>
        /// Picture Click event for game reset.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PictureReset_Click(object sender, EventArgs e)
        {
            this.Hide();
            SecondForm form = new SecondForm();

            form.ShowDialog();
            this.Close();
        }
Example #4
0
        /// <summary>
        /// Check every icon to see if it is matched, by
        /// comparing its foreground color to its background color.
        /// If all of the icons are matched, the player wins.
        /// </summary>
        private void CheckForWinner()
        {
            foreach (Control control in tableLayoutPanel1.Controls)
            {
                Label pictureLabel = control as Label;

                if (pictureLabel != null)
                {
                    if (pictureLabel.ForeColor == pictureLabel.BackColor)
                    {
                        return;
                    }
                }
            }

            /**
             * If the loop didn't return. It didin't find
             * any unmatched icons.
             * That means the user won.A dialog box will appear.
             */
            DialogResult dialogResult = MessageBox.Show("Your time: " + winnerTime +
                                                        " seconds\nYour click: " + clickCount.Text + "\nWrong pair:"
                                                        + wrongPair + "\n\nDo you want play again ?",
                                                        "You won !!! Congratulations !!!!", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                howLong.Stop();
                this.Hide();
                SecondForm newForm = new SecondForm();
                newForm.ShowDialog();
                this.Close();
            }
            else if (dialogResult == DialogResult.No)
            {
                this.Close();
            }
        }