Esempio n. 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            Lvl3_6x6 f = new Lvl3_6x6(0);

            //this.Hide();
            f.Show();
        }
        /// <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()
        {
            // Go through all of the labels in the TableLayoutPanel,
            // checking each one to see if its icon is matched.
            foreach (Control control in tableLayoutPanel1.Controls)
            {
                Label iconLabel = control as Label;

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

            // If the loop didn’t return, it didn't find
            // any unmatched icons.
            // That means the user won. Show a message and close the form.
            MessageBox.Show("LEVEL-2 PASSED! You matched all the icons!", "Congratulations!");

            Menu m = new Menu();

            int[] a     = m.readScoreFile();
            bool  check = false;

            for (int j = 0; j < 5; j++)
            {
                if ((i > a[j]) && (check == false))
                {
                    a[j]  = i;
                    check = true;
                }
            }
            m.writeScoreFile(a);

            Lvl3_6x6 f = new Lvl3_6x6(i);

            //this.Hide();
            f.Show();
            Close();
        }