private void DrawKenGrid(Grid kenGrid) { container.Controls.Clear(); Table tbl = new Table(); container.Controls.Add(tbl); for (int i = 0; i < kenGrid.Dimension; i++) { TableRow row = new TableRow(); tbl.Rows.Add(row); for (int j = 0; j < kenGrid.Dimension; j++) { CellViewModel cellView = new CellViewModel(kenGrid.CellMatrix[i, j]); TableCell cell = new TableCell(); DefineBorder(cell, cellView); row.Cells.Add(cell); KenCell kenCell = (KenCell)LoadControl("KenCell.ascx"); kenCell.ID = "kencell-" + i.ToString() + "-" + j.ToString(); kenCell.Cell = cellView; cell.Controls.Add(kenCell); } } }
internal bool Solve(Grid grid, out Logger log, bool stepByStep = false) { _log = log = new Logger(); _kenKenGrid = grid; if (_kenKenGrid.Solved) return true; Step stepAction = null; while ((stepAction = FindCell()).FoundCell != null) { SolveCell(stepAction); if (stepByStep) return _kenKenGrid.Solved; } return _kenKenGrid.Solved; }
void SaveSession(Grid grid, bool solved, int steps) { Session["grid"] = grid; Session["solved"] = solved; Session["steps"] = steps; }
void LoadSession(out Grid grid, out bool prevSolved, out int steps) { grid = (Grid)Session["grid"]; prevSolved = (bool)Session["solved"]; steps = (int)Session["steps"]; }