public PicrossBoard(PicrossBoard copySource) { Puzzle = copySource.Puzzle; RowCount = Puzzle.RowCount; ColumnCount = Puzzle.ColumnCount; Matrix = new PicrossCell[RowCount, ColumnCount]; for (int rowIndex = 0; rowIndex < RowCount; rowIndex++) { for (int columnIndex = 0; columnIndex < ColumnCount; columnIndex++) { PicrossCell otherCell = copySource.Matrix[rowIndex, columnIndex]; Matrix[rowIndex, columnIndex] = new PicrossCell() { State = otherCell.State, Row = rowIndex, Column = columnIndex }; } } Columns = CopyColumns(copySource); Rows = CopyRows(copySource); ActiveLines = (new[] { Columns, Rows }).SelectMany(collection => collection); }
public PicrossLine(PicrossLine copySource) { Cells = new PicrossCell[copySource.Length]; for (int i = 0; i < Length; i++) { Cells[i] = new PicrossCell() { State = copySource.Cells[i].State }; } }
public PicrossLine(int length, PicrossCellState state) { var cells = new PicrossCell[length]; for (int i = 0; i < length; i++) { cells[i] = new PicrossCell() { State = state }; } Cells = cells; }
public PicrossLine(IEnumerable <PicrossCellState> cellStates) { Cells = new PicrossCell[cellStates.Count()]; int i = 0; foreach (var cellState in cellStates) { Cells[i] = new PicrossCell() { State = cellState }; i++; } }
public void Copy(PicrossBoard source) { if (Puzzle != source.Puzzle) { throw new ArgumentException(); } for (int rowIndex = 0; rowIndex < RowCount; rowIndex++) { for (int columnIndex = 0; columnIndex < ColumnCount; columnIndex++) { PicrossCell otherCell = source.Matrix[rowIndex, columnIndex]; Matrix[rowIndex, columnIndex].State = otherCell.State; } } }
public PicrossBoard(PicrossPuzzle puzzle) { Puzzle = puzzle; RowCount = Puzzle.RowCount; ColumnCount = Puzzle.ColumnCount; Matrix = new PicrossCell[RowCount, ColumnCount]; for (int rowIndex = 0; rowIndex < RowCount; rowIndex++) { for (int columnIndex = 0; columnIndex < ColumnCount; columnIndex++) { Matrix[rowIndex, columnIndex] = new PicrossCell() { Row = rowIndex, Column = columnIndex }; } } Columns = GatherColumns(); Rows = GatherRows(); ActiveLines = (new[] { Columns, Rows }).SelectMany(collection => collection); }