void RestartButton_Click(object sender, EventArgs e) { matched = 0; timePassed = 0; NameBox.Text = ""; StartTimer.Start(); NameBox.Hide(); AskName.Hide(); DisplayVictory.Hide(); SubmitButton.Hide(); Deck deck = new Deck(); PictureBox[] boxes = new PictureBox[] { pictureBox1, pictureBox2, pictureBox3, pictureBox4, pictureBox5, pictureBox6, pictureBox7, pictureBox8, pictureBox9, pictureBox10, pictureBox11, pictureBox12, pictureBox13, pictureBox14, pictureBox15, pictureBox16 }; totalCards = boxes.Count(); foreach (PictureBox pictureBox in boxes) { Card card = deck.Deal(); pictureBox.Image = card.CurrentImage; pictureBox.Tag = card; pictureBox.Show(); } }
public GameForm() { InitializeComponent(); Deck deck = new Deck(); boxes = new PictureBox[] { pictureBox1, pictureBox2, pictureBox3, pictureBox4, pictureBox5, pictureBox6, pictureBox7, pictureBox8, pictureBox9, pictureBox10, pictureBox11, pictureBox12, pictureBox13, pictureBox14, pictureBox15, pictureBox16 }; StartTimer.Start(); totalCards = boxes.Count(); NameBox.Hide(); AskName.Hide(); DisplayVictory.Hide(); SubmitButton.Hide(); foreach (PictureBox pictureBox in boxes) { Card card = deck.Deal(); pictureBox.Image = card.CurrentImage; pictureBox.Tag = card; } }