public static Board FromString(string basis) { // Create a new board from an 81-character string that specifies the board's values left-to-right, top-to-bottom var board = new Board(); int i = 0; for (var y = 0; y < Size; y++) { for (var x = 0; x < Size; x++) { if (' ' != basis[i]) { board.SetValue(x, y, basis[i] - '0', Digit.Kind.Given); } i++; } } return board; }
public static Board FromString(string basis) { // Create a new board from an 81-character string that specifies the board's values left-to-right, top-to-bottom var board = new Board(); int i = 0; for (var y = 0; y < Size; y++) { for (var x = 0; x < Size; x++) { if (' ' != basis[i]) { board.SetValue(x, y, basis[i] - '0', Digit.Kind.Given); } i++; } } return(board); }
public bool ChangeSelectedValue(int value, Digit.Kind kind) { var changed = false; // Get the current position _conflictPosition = null; var x = (int)_markerPosition.X; var y = (int)_markerPosition.Y; if (Digit.Unknown == value) { // Clear the digit's value if set if (_board.GetDigit(x, y).ValueKnown) { _board.ClearValue(x, y); changed = true; } } else { try { // Set the cell's value _board.SetValue(x, y, value, kind); changed = true; } catch (InvalidBoardException e) { // Would have created an invalid board; identify the location of the conflict _conflictPosition = new Point(e.X, e.Y); } } // Update the display UpdateDisplay(_board); return(changed); }