コード例 #1
0
        public void RenderBlocks(Graphics g, int totalClientWidth, int totalClientHeight, Game _game)
        {
            var cellSize    = (totalClientHeight - 100) / NumberOfCellsHigh;
            var totalWidth  = cellSize * NumberOfCellsWide;
            var totalHeight = cellSize * NumberOfCellsHigh;

            var x1 = (totalClientWidth - totalWidth) / 2;
            var y1 = (totalClientHeight - 100) - totalHeight;

            g.TranslateTransform(x1, y1);

            for (int row = 0; row < NumberOfCellsHigh; row++)
            {
                for (int column = 0; column < NumberOfCellsWide; column++)
                {
                    if (_game.CellColour(column, row) != Cell.Empty)
                    {
                        var colour = CellColourToBrush(_game.CellColour(column, row));

                        g.FillRectangle(colour, (column * cellSize) + 1, ((NumberOfCellsHigh - row - 1) * cellSize) + 1, cellSize - 2, cellSize - 2);
                    }
                }
            }

            g.ResetTransform();
        }