public void Agfigur_Click(object sender, EventArgs e) { ClickSayi++; Button buttonn = sender as Button; foreach (var item in Saski.AgFigur.Figurr) { if (item.btn.Location == buttonn.Location && ClickSayi == 1) { foreach (var item2 in Saski.Damalar.Damalarr) { if (item.Id == item2.Id) { Agdas = item; item2.Status = false; Black = false; White = true; } } item.Status = false; buttonn.Hide(); } } }
public Form1() { InitializeComponent(); this.Height = (btnHeight * 8) + 40; this.Width = (btnWitdh * 8) + 17; for (int i = 1; i <= 8; i++) { f = false; LeftLoc = 0; for (int j = 1; j <= 8; j++) { if (i <= 3) { if (i % 2 == 0) { if (j % 2 != 0) { Qarafigur = new Button(); f = true; Qarafigur.Width = 30; Qarafigur.Click += new EventHandler(this.Qarafigur_Click); Qarafigur.Height = 30; Qarafigur.Location = new Point(LeftLoc + 15, TopLoc + 15); Qarafigur.BackColor = Color.Green; this.Controls.Add(Qarafigur); var Figur = new QaraFigur(IdFigur, a, Qarafigur); } } else { if (j % 2 == 0) { Qarafigur = new Button(); f = true; Qarafigur.Width = 30; Qarafigur.Height = 30; Qarafigur.Click += new EventHandler(this.Qarafigur_Click); Qarafigur.Location = new Point(LeftLoc + 15, TopLoc + 15); Qarafigur.BackColor = Color.Green; this.Controls.Add(Qarafigur); var Figur = new QaraFigur(IdFigur, a, Qarafigur); } } } if (i >= 6) { if (i % 2 == 0) { if (j % 2 != 0) { Agfigur = new Button(); f = true; Agfigur.Width = 30; Agfigur.Height = 30; Agfigur.Click += new EventHandler(this.Agfigur_Click); Agfigur.Location = new Point(LeftLoc + 15, TopLoc + 15); Agfigur.BackColor = Color.Red; this.Controls.Add(Agfigur); var Figur = new AgFigur(IdFigur, a, Agfigur); } } else { if (j % 2 == 0) { Agfigur = new Button(); f = true; Agfigur.Width = 30; Agfigur.Height = 30; Agfigur.Click += new EventHandler(this.Agfigur_Click); Agfigur.Location = new Point(LeftLoc + 15, TopLoc + 15); Agfigur.BackColor = Color.Red; var Figur = new AgFigur(IdFigur, a, Agfigur); this.Controls.Add(Agfigur); } } } btn = new Button(); btn.Width = btnWitdh; btn.Height = btnHeight; btn.Location = new Point(LeftLoc, TopLoc); btn.Click += new EventHandler(this.btn_Click); btn.FlatStyle = FlatStyle.Flat; btn.FlatAppearance.BorderColor = Color.Gray; btn.FlatAppearance.BorderSize = 1; Controls.Add(btn); var Dama = new Damalar(IdDama, f, btn); IdDama++; IdFigur++; Count++; if (i % 2 != 0) { if (j % 2 == 0) { btn.BackColor = Color.Black; btn.ForeColor = Color.White; } } else { if (j % 2 != 0) { btn.BackColor = Color.Black; btn.ForeColor = Color.White; } } LeftLoc += btnWitdh; } TopLoc += 60; } }