예제 #1
0
        private void Boutons_Click(object sender, EventArgs e)
        {
            if (sender is BoutonCavalier)
            {
                BoutonCavalier b = (BoutonCavalier)sender;
                if (cpt == 0)
                {
                    b.BackgroundImage = Image.FromFile(@"images\cavalier.png");
                    cpt++;
                }
                else
                {
                    BoutonCavalier b1 = coups[cpt - 1];
                    b1.BackgroundImage = null;
                    b1.Text            = cpt.ToString();
                    b.BackgroundImage  = Image.FromFile(@"images\cavalier.png");
                    cpt++;
                }

                coups.Add(b);

                for (int x = 2; x < 10; x++)
                {
                    for (int y = 2; y < 10; y++)
                    {
                        plateau[x, y].Enabled = false;
                        if (x % 2 == 0 && y % 2 == 0)
                        {
                            plateau[x, y].BackColor = Color.LightCyan;
                        }
                        else if (x % 2 == 1 && y % 2 == 1)
                        {
                            plateau[x, y].BackColor = Color.LightCyan;
                        }
                        else if (x % 2 == 1 && y % 2 == 0)
                        {
                            plateau[x, y].BackColor = Color.IndianRed;
                        }
                        else if (x % 2 == 0 && y % 2 == 1)
                        {
                            plateau[x, y].BackColor = Color.IndianRed;
                        }
                    }
                }
                for (int depl = 0; depl < 8; depl++)
                {
                    if (b.getX() + depi[depl] >= 2 && b.getY() + depj[depl] >= 2 && b.getX() + depi[depl] < 10 && b.getY() + depj[depl] < 10)
                    {
                        if (plateau[b.getX() + depi[depl], b.getY() + depj[depl]].Text == "")
                        {
                            plateau[b.getX() + depi[depl], b.getY() + depj[depl]].BackColor = Color.CadetBlue;
                            plateau[b.getX() + depi[depl], b.getY() + depj[depl]].Enabled   = true;
                        }
                    }
                }
            }
        }
예제 #2
0
파일: Form2.cs 프로젝트: YoumnaHA/Cavalier
 private void Bouton_Click(object sender, EventArgs e)
 {
     if (sender is BoutonCavalier)
     {
         BoutonCavalier b = (BoutonCavalier)sender;
         grille[i, j]       = 0;
         i                  = b.getX();
         j                  = b.getY();
         grille[i, j]       = 1;
         b.BackgroundImage  = Image.FromFile(@"images\cavalier.png");
         plateau[i, j].Text = "1";
         //b.BackColor = Color.DarkTurquoise;
         b.Enabled = false;
     }
 }