public ONIPlannerSubControl GetCellAt(UInt16 x, UInt16 y) { if (x > CellGrid.GetLength(0)) { throw new ArgumentOutOfRangeException("X", x, "X value given is higher than the number of columns!"); } if (y > CellGrid.GetLength(1)) { throw new ArgumentOutOfRangeException("Y", y, "Y value given is higher than the number of rows!"); } return(CellGrid[x, y]); }
public void ReformatCellGrid(UInt16 newWidth, UInt16 newHeight, bool forceRedraw) { ONIPlannerSubControl[,] newGrid = new ONIPlannerSubControl[newWidth, newHeight]; if (newWidth == CellGrid.GetLength(0) && newHeight == CellGrid.GetLength(1)) { return; } if (CellGrid == null) { newGrid.Initialize(); } else { for (int x = 0; x < newWidth; x++) { for (int y = 0; y < newHeight; y++) { if (CellGrid.GetLength(0) > newWidth || CellGrid.GetLength(1) > newHeight) { newGrid[x, y] = new ONIPlannerSubControl(); } else { newGrid[x, y] = CellGrid[x, y]; } } } } CellGrid = newGrid; if (forceRedraw) { for (int x = 0; x < newWidth; x++) { for (int y = 0; y < newHeight; y++) { CellGrid[x, y].NeedsRedraw = true; CellGrid[x, y].Refresh(); } } } }