using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace go01 { public partial class Form1 : Form { enum CouleurVoulue { Red, Green, Blue, Black, LAST } CouleurVoulue[,] tableauCouleur = new CouleurVoulue[19,19]; List pboxList = new List(); Goban g; public Form1() { InitializeComponent(); g = new Goban(this, pictureBox1,25, "Adri", "Pauline"); /*for(int i = 0; i<19*19; i++) { pboxList.Add(new PictureBox()); pboxList[i].Location = new Point((i%19)*(pictureBox1.Width / 19), (i/19)*(pictureBox1.Height / 19)); pboxList[i].Width = pictureBox1.Width / 19; pboxList[i].Height = pictureBox1.Height / 19; pboxList[i].BackColor = Color.FromName(CouleurVoulue.Red.ToString()); tableauCouleur[i % 19, i / 19] = CouleurVoulue.Red; pboxList[i].Name = (i%19).ToString()+";"+ (i / 19).ToString(); pboxList[i].Click += new System.EventHandler(this.pictureBox1_Click); pictureBox1.Controls.Add(pboxList[i]); }*/ } private void pictureBox1_Click(object sender, EventArgs e) { String[] xy = ((PictureBox)sender).Name.Split(';'); if (++tableauCouleur[int.Parse(xy[0]), int.Parse(xy[1])] == CouleurVoulue.LAST) tableauCouleur[int.Parse(xy[0]), int.Parse(xy[1])] = CouleurVoulue.Red; ((PictureBox)sender).BackColor = Color.FromName((tableauCouleur[int.Parse(xy[0]),int.Parse(xy[1])]).ToString()); Console.WriteLine(((PictureBox)sender).Name); } } }