public void DrawInto(Graphics g) { int cellWidth = Width / puzzle.Size; int cellHeight = Height / puzzle.Size; g.Clear(Color.White); for (int x = 1; x <= puzzle.Size - 1; x++) { g.DrawLine(Pens.Black, new Point(cellWidth * x, 0), new Point(cellWidth * x, Height)); g.DrawLine(Pens.Black, new Point(0, cellHeight * x), new Point(Width, cellHeight * x)); } for (int i = 0; i < puzzle.Size; i++) { for (int j = 0; j < puzzle.Size; j++) { float y = cellHeight * i + cellHeight / 2 - font.Height / 2; float x = cellWidth * j + cellWidth / 2 - font.Size / 2; if (showSolution && puzzle.IsSolution(j, i)) { g.FillRectangle(new SolidBrush(Color.FromArgb(100, Color.Yellow)), new Rectangle(new Point(cellWidth * j, cellHeight * i), new Size(cellWidth, cellHeight))); } g.DrawString(puzzle[i, j].ToString(), font, Brushes.Black, new PointF(x, y)); } } }