public void RenderGrid(Grid grid) { Console.SetCursorPosition(GridColPosition, GridRowPosition); this.scene.Clear() .Append(' '); for (int i = 1; i <= GlobalConstants.GridColsCount; i++) { string toAppend = i < 9 ? i.ToString() : i.ToString().Substring(i.ToString().Length - 1); this.scene.Append(toAppend); } this.scene.AppendLine(); for (int row = 0; row < grid.TotalRows; row++) { this.scene.Append((char)(GlobalConstants.MinRowValueOnGridAsciiCode + row)); for (int col = 0; col < grid.TotalCols; col++) { this.scene.Append(grid.GetCell(row, col)); } this.scene.Append(Environment.NewLine); } Console.WriteLine(this.scene.ToString()); this.SetCursorAtInputPosition(); }
/// <summary> /// Updates grid position /// </summary> public void UpdateGrid(Grid grid, Position position) { Console.SetCursorPosition(position.Col + GridColPosition + 1, position.Row + GridRowPosition + 1); Console.Write(grid.GetCell(position.Row, position.Col)); this.SetCursorAtInputPosition(); }