private void paintBoard(Panel panel, DBoard db) { BufferedGraphics myBuffer; BufferedGraphicsContext currentContext; currentContext = BufferedGraphicsManager.Current; myBuffer = currentContext.Allocate(panel.CreateGraphics(), panel.DisplayRectangle); Graphics G = myBuffer.Graphics; int size = db.size; #region painting the board // Painting the board itself G.DrawImage(panel.BackgroundImage, new Point(0, 0)); using (var p = new Pen(Color.Black, 1)) { for (int i = 0; i < size; i++) { int x1 = Constants.CellSize; int y1 = Constants.CellSize + i * Constants.CellSize; int x2 = size * Constants.CellSize; int y2 = y1; G.DrawLine(p, new Point(x1, y1), new Point(x2, y2)); } for (int i = 0; i < size; i++) { int x1 = Constants.CellSize + i * Constants.CellSize; int y1 = Constants.CellSize; int x2 = x1; int y2 = size * Constants.CellSize; G.DrawLine(p, new Point(x1, y1), new Point(x2, y2)); } } if (size == 19) { using (var p = new SolidBrush(Color.Black)) { int[] dotx = { 4, 10, 16, 4, 10, 16, 4, 10, 16 }; int[] doty = { 4, 4, 4, 10, 10, 10, 16, 16, 16 }; for (int i = 0; i < dotx.Length; i++) { int x0 = Constants.CellSize * dotx[i]; int y0 = Constants.CellSize * doty[i]; G.FillEllipse(p, x0 - 3, y0 - 3, 6, 6); } } } #endregion // Painting the stones DrawStone(G, db.blackStones, new Bitmap(TestGUI.Properties.Resources._24)); DrawStone(G, db.whiteStones, new Bitmap(TestGUI.Properties.Resources._24_2)); MarkStonePosition(G, db.blackEst, Color.Blue, Color.White); MarkStonePosition(G, db.whiteEst, Color.Red, Color.Black); myBuffer.Render(); myBuffer.Render(panel.CreateGraphics()); }
private void Form1_Load(object sender, EventArgs e) { board[0] = new DBoard(19); board[1] = new DBoard(9); }