private void Buton_Click(object sender, EventArgs e) { SimpleButton buton = (SimpleButton)sender; if (String.IsNullOrEmpty(buton.Text)) { buton.Text = buton.Name; buton.Refresh(); secimler.Add(buton); } if (secimler.Count == 2) { System.Threading.Thread.Sleep(700); if (secimler[0].Text == secimler[1].Text) { secimler[0].Dispose(); secimler[1].Dispose(); if (grpOyunAlani.Controls.Count == 0) { MessageBox.Show("Oyun Bitti"); timer1.Enabled = false; timer1.Stop(); } } else { secimler[0].Text = null; secimler[1].Text = null; txtHataSayisi.Value += 1; } secimler.Clear(); } }
private void Buton_Click(object sender, EventArgs e) { SimpleButton buton = (SimpleButton)sender; buton.Appearance.BackColor = Color.Green; buton.BorderStyle = BorderStyles.HotFlat; if (string.IsNullOrEmpty(buton.Text)) { buton.Text = buton.Name; //Buton isminin gözükmesi için refresh yaptık.Çok hızlı çalıştığından text görünmeyebiliyor. buton.Refresh(); secimler.Add(buton); } if (secimler.Count == 2) { //Sistemi bekletmek için System.Threading.Thread.Sleep(400); if (secimler[0].Text == secimler[1].Text) { //Butonları silme secimler[0].Dispose(); secimler[1].Dispose(); if (groupOyun.Controls.Count == 0) { MessageBox.Show("Congrulations! Game Over.", "Game Over", MessageBoxButtons.OK, MessageBoxIcon.Information); timer1.Enabled = false; timer1.Stop(); clcHata.Value = 0; } } else { secimler[0].Appearance.BackColor = Color.Red; secimler[0].BorderStyle = BorderStyles.HotFlat; secimler[1].Appearance.BackColor = Color.Red; secimler[1].BorderStyle = BorderStyles.HotFlat; secimler[0].Text = null; secimler[1].Text = null; //Hata sayısı clcHata.Value += 1; } secimler.Clear(); } }