public CrossWordSolver(CrossWordTask task) { _globalHistory = new HistoryFrame(); CreateLineProcessors(); Board = new Board(task.ColumnsTasks.Length, task.RowsTasks.Length); _colsLines = ParseColsLines(task).ToArray(); _rowsLines = ParseRowsLines(task).ToArray(); }
private void InitPictureGrid(CrossWordTask task) { _pictureGrid = new PuzzleGrid(task.ColumnsTasks.Length, task.RowsTasks.Length); _pictureGrid.MovingEnabled = true; PicturePanel.Controls.Clear(); PicturePanel.Controls.Add(_pictureGrid); _pictureGrid.Moved += PictureMoved; _pictureGrid.Scaled += PictureScaled; _pictureGrid.HoveredPointChanged += PictureGrid_HoveredPointChanged; _pictureGrid.CellChanged += PictureGrid_CellChanged; }
private CrossWordLine[] ParseRowsLines(CrossWordTask task) { CrossWordLineTask[] rowsTasks = task.RowsTasks; CrossWordLine[] rows = new CrossWordLine[rowsTasks.Length]; for (int rowIndex = 0; rowIndex < rowsTasks.Length; rowIndex++) { Point[] linePoints = Board.GetRow(rowIndex); Group[] groups = rowsTasks[rowIndex].Select(gLen => new Group(gLen)).ToArray(); rows[rowIndex] = new CrossWordLine(groups, linePoints, true, _rowProcessors); } return(rows); }
private IEnumerable <CrossWordLine> ParseColsLines(CrossWordTask task) { CrossWordLineTask[] colsTasks = task.ColumnsTasks; CrossWordLine[] columns = new CrossWordLine[colsTasks.Length]; for (int colIndex = 0; colIndex < colsTasks.Length; colIndex++) { Point[] linePoints = Board.GetColumn(colIndex); Group[] groups = colsTasks[colIndex].Select(gLen => new Group(gLen)).ToArray(); columns[colIndex] = new CrossWordLine(groups, linePoints, false, _columnProcessors); } return(columns); }
private void DisplayRowsTask(CrossWordTask task) { var rows = task.RowsTasks; var gridWidth = rows.Max(r => r.Length); var gridHeight = rows.Length; _rowsTaskGrid = new PuzzleGrid(gridWidth, gridHeight, showVerticalMainLines: false); for (int y = 0; y < gridHeight; y++) { var emptyCount = gridWidth - rows[y].Length; for (int x = 0; x < rows[y].Length; x++) { _rowsTaskGrid.GridCells[emptyCount + x, y] = rows[y][x]; } } RowsPanel.Controls.Clear(); RowsPanel.Controls.Add(_rowsTaskGrid); }
private void DisplayColsTask(CrossWordTask task) { var cols = task.ColumnsTasks; var gridWidth = cols.Length; var gridHeight = cols.Max(c => c.Length); _colsTaskGrid = new PuzzleGrid(gridWidth, gridHeight, showHorizontalMainLines: false); for (int x = 0; x < gridWidth; x++) { var emptyCount = gridHeight - cols[x].Length; for (int y = 0; y < cols[x].Length; y++) { _colsTaskGrid.GridCells[x, emptyCount + y] = cols[x][y]; } } ColsPanel.Controls.Clear(); ColsPanel.Controls.Add(_colsTaskGrid); }
private void DisplayTask(CrossWordTask task) { DisplayColsTask(task); DisplayRowsTask(task); }