Table of Contents

Class NonogramBuilder

Namespace
NonoSharp
Assembly
NonoSharp.dll

Builder class to create a custom Nonogram puzzle, and can at the final stage be obtained as a NonogramAPI instance or be saved to a file.

public class NonogramBuilder
Inheritance
NonogramBuilder
Inherited Members

Constructors

NonogramBuilder(int, int, string?)

Creates a new PuzzleBuilder instance with a width of width and a height of height.

public NonogramBuilder(int width, int height, string? title = null)

Parameters

width int

Width for the puzzle to create with this PuzzleBuilder

height int

Height for the puzzle to create with this PuzzleBuilder

title string

Optional title to give the puzzle

Exceptions

ArgumentOutOfRangeException

Thrown when width or height is non-positive (<= 0)

Properties

Height

Height of the puzzle that is being created

public int Height { get; }

Property Value

int

Title

Title of the puzzle. A null value means this puzzle has no title

public string? Title { get; set; }

Property Value

string

Width

Height of the grid that is being created

public int Width { get; }

Property Value

int

Methods

EmptyCell(CellPosition)

Marks the cell at position as expected to be empty in the solution.

public void EmptyCell(CellPosition position)

Parameters

position CellPosition

Position of cell to mark as empty

Exceptions

ArgumentOutOfRangeException

Thrown when x or y are less than 0 or are greater or equal to Width or Height respectively

EmptyCell(int, int)

Marks the cell at (x, y) as expected to be empty in the solution.

public void EmptyCell(int x, int y)

Parameters

x int

x-coordinate of cell to mark as empty

y int

y-coordinate of cell to mark as empty

Exceptions

ArgumentOutOfRangeException

Thrown when x or y are less than 0 or are greater or equal to Width or Height respectively

FillCell(CellPosition)

Marks the cell at position as expected to be filled in the solution.

public void FillCell(CellPosition position)

Parameters

position CellPosition

Position of cell to fill

Exceptions

ArgumentOutOfRangeException

Thrown when x or y are less than 0 or are greater or equal to Width or Height respectively

FillCell(int, int)

Marks the cell at (x, y) as expected to be filled in the solution.

public void FillCell(int x, int y)

Parameters

x int

x-coordinate of cell to fill

y int

y-coordinate of cell to fill

Exceptions

ArgumentOutOfRangeException

Thrown when x or y are less than 0 or are greater or equal to Width or Height respectively

GetNonogramAPI()

Converts this puzzle into a playable NonogramAPI.

public NonogramAPI GetNonogramAPI()

Returns

NonogramAPI

Exceptions

PuzzleNotSolvableException

Thrown when the built puzzle is not uniquely solvable

GetNonogramAPIAsync()

Converts this puzzle into a playable NonogramAPI asynchronously.

public Task<NonogramAPI> GetNonogramAPIAsync()

Returns

Task<NonogramAPI>

Exceptions

PuzzleNotSolvableException

Thrown when the built puzzle is not uniquely solvable

IsCellEmpty(CellPosition)

Checks if Cell at position is expected to be empty in the solution.

public bool IsCellEmpty(CellPosition position)

Parameters

position CellPosition

CellPosition to check

Returns

bool

True if the cell is expected to be empty, false otherwise

Exceptions

ArgumentOutOfRangeException

Thrown when the coordinates of position are not within the puzzle bounds

IsCellEmpty(int, int)

Checks if Cell at (x, y) is expected to be empty in the solution.

public bool IsCellEmpty(int x, int y)

Parameters

x int

x-coordinate of cell to check

y int

y-coordinate of cell to check

Returns

bool

True if the cell is expected to be empty, false otherwise

Exceptions

ArgumentOutOfRangeException

Thrown when x or y is not within the puzzle bounds

IsCellFilled(CellPosition)

Checks if Cell at position is expected to be filled in the solution.

public bool IsCellFilled(CellPosition position)

Parameters

position CellPosition

CellPosition to check

Returns

bool

True if the cell is expected to be filled, false otherwise

Exceptions

ArgumentOutOfRangeException

Thrown when the coordinates of position are not within the puzzle bounds

IsCellFilled(int, int)

Checks if Cell at (x, y) is expected to be filled in the solution.

public bool IsCellFilled(int x, int y)

Parameters

x int

x-coordinate of cell to check

y int

y-coordinate of cell to check

Returns

bool

True if the cell is expected to be filled, false otherwise

Exceptions

ArgumentOutOfRangeException

Thrown when x or y is not within the puzzle bounds

IsSolvable()

Determines whether the built puzzle is uniquely solvable.

public bool IsSolvable()

Returns

bool

True if it is uniquely solvable, false otherwise

IsSolvableAsync()

Determines whether the built puzzle is uniquely solvable.

public Task<bool> IsSolvableAsync()

Returns

Task<bool>

True if it is uniquely solvable, false otherwise

SaveAsFile(string)

Saves the built puzzle at path. Specifically, the expected solution and dimension are stored. The puzzle must be uniquely solvable.

public void SaveAsFile(string path)

Parameters

path string

The path to save the puzzle to

Exceptions

PuzzleSerializationFailedException

Thrown when serialization fails. For example, when the given title is too long, or an I/O exception occurs. Usually, there is an inner exception giving more details.

PuzzleSavingFailedException

Thrown when saving files fails, e.g. because of an I/O Exception. See the inner exception for more details

PuzzleNotSolvableException

Thrown when the built puzzle is not uniquely solvable

SaveAsFileAsync(string)

Saves this puzzle asynchronously at path. Specifically, the expected solution and dimension are stored.

public Task SaveAsFileAsync(string path)

Parameters

path string

The path to save the puzzle to

Returns

Task

Exceptions

PuzzleSerializationFailedException

Thrown when serialization fails. For example, when the given title is too long, or an I/O exception occurs. Usually, there is an inner exception giving more details.

PuzzleSavingFailedException

Thrown when saving files fails, e.g. because of an I/O Exception. See the inner exception for more details

PuzzleNotSolvableException

Thrown when the built puzzle is not uniquely solvable

SetDimensions(int, int)

Sets the dimensions of this PuzzleBuilder. This is done by adding new empty cells to the right and bottom. Cannot shrink the puzzle.

public void SetDimensions(int newWidth, int newHeight)

Parameters

newWidth int

New width for the puzzle

newHeight int

New height for the puzzle

Exceptions

OverflowException

When newWidth * newHeight causes overflow

ArgumentOutOfRangeException

newWidth or newHeight are less than their respective old value