示例#1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.Clear(BackColor);

            using (var pen = new Pen(new SolidBrush(Color.Black)))
            {
                for (int x = 0; x < CellCountX; x++)
                {
                    for (int y = 0; y < CellCountY; y++)
                    {
                        e.Graphics.DrawRectangle(pen, new Rectangle(
                                                     x * CellWidth, y * CellHeight, CellWidth, CellHeight));
                    }
                }
            }

            game.OnDraw(e.Graphics);

            base.OnPaint(e);
        }