private static void DrawMatrixTile(Graphics graphics, PaletteTile tile, int tileRow, int tileCol, Rectangle marginBounds, int stepSize, FontFamily fontFamily) { var matrix = new ColorMatrix {Matrix33 = (float) 0.3}; var attributes = new ImageAttributes(); attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); // draw tile /* graphics.DrawImage(tile.Bitmap, new Rectangle(marginBounds.Left + tileCol*stepSize, marginBounds.Top + tileRow*stepSize, stepSize, stepSize), 0, 0, tile.Bitmap.Size.Width, tile.Bitmap.Size.Height, GraphicsUnit.Pixel, attributes);*/ // draw tile id graphics.DrawString(tile.Id.ToString(), new Font(fontFamily, (float)(stepSize * 0.3), FontStyle.Regular), new SolidBrush(Color.Black), new RectangleF(marginBounds.Left + tileCol * stepSize, marginBounds.Top + tileRow * stepSize, stepSize, stepSize)); }
public List<MatrixPrintInfo> PreparePrints(IReadOnlyList<IReadOnlyList<PaletteTile>> tiles) { var newMatrix = true; var rowInd = 0; var currentRow = 0; var currentColumn = 0; var matrixStartRow = 0; var matrixStartColumn = 0; var matrixRow = 0; var matrixCol = 0; PaletteTile[,] paletteTiles = null; var result = new List<MatrixPrintInfo>(); while (true) { var tileRow = tiles[currentRow]; if (newMatrix) { var rowCount = Math.Min(_matrixSize, tiles.Count - currentRow); var colCount = Math.Min(_matrixSize, tileRow.Count - currentColumn); paletteTiles = new PaletteTile[rowCount, colCount]; result.Add(new MatrixPrintInfo() { MatrixRow = matrixRow, MatrixCol = matrixCol, MatrixPrint = paletteTiles }); rowInd = 0; matrixStartRow = currentRow; matrixStartColumn = currentColumn; newMatrix = false; } var colInd = 0; while (currentColumn < Math.Min(_matrixSize + matrixStartColumn, tileRow.Count)) { paletteTiles[rowInd, colInd] = tiles[currentRow][currentColumn]; colInd++; currentColumn++; } if (AllTilesProccessed(tiles, currentRow, currentColumn, tileRow)) { break; } rowInd++; // row is procced for matrix if (MatrixRowsFilled(tiles, rowInd, currentRow)) { newMatrix = true; // if not all colums, then make if (AnyColumnLeftUnProccessed(currentColumn, tileRow)) { currentRow = matrixStartRow; matrixCol++; } else { currentColumn = 0; matrixRow++; matrixCol = 0; } } else { currentRow++; currentColumn = matrixStartColumn; } } return result; }