Exemplo n.º 1
0
        public static void PaintEventForm1(int width, int height, PaintEventArgs e)
        {
            if (!boardCreated)
            {
                int countRec   = 0;
                int formWidth  = width;
                int formHeight = height;
                int penWidth   = 1;

                Pen myPen = new Pen(new SolidBrush(Color.Black), penWidth);

                for (int i = recHeight; i <= formHeight; i += recHeight) //dessine les lignes horizontales
                {
                    e.Graphics.DrawLine(myPen, 0, i, formWidth, i);
                    countHorizontal++;
                }

                for (int i = recWidth; i <= formWidth; i += recWidth) //dessine les lignes verticales
                {
                    e.Graphics.DrawLine(myPen, i, 0, i, formHeight);
                    countVertical++;
                }

                countRec = countHorizontal * countVertical;

                for (int x = 0; x < countHorizontal; x++) // Récupère les rectangles
                {
                    for (int y = 0; y < countVertical; y++)
                    {
                        Rectangle newRec = new Rectangle(recHeight * y, recWidth * x, recWidth, recHeight);
                        plateauCases[x][y].Rec = newRec;
                    }
                }

                for (int x = 0; x < plateauCases.Length; x++) // Colorie les cases
                {
                    for (int y = 0; y < plateauCases[x].Length; y++)
                    {
                        if (plateauCases[x][y].isBlack)
                        {
                            e.Graphics.FillRectangle(new SolidBrush(Color.Black), plateauCases[x][y].Rec);
                        }
                    }
                }

                boardCreated = true;

                ImagesManager MyImagesM = new ImagesManager(panelMain);

                MyImagesM.createPictureBox();
            }
        }