private void Step(int stepCount) { if (stepCount == 0) { return; } UIGameBoard.SuspendLayout(); UIGameBoard.TurnOffHighlighting(); int increment = (stepCount > 0) ? -1 : 1; while (stepCount != 0) { stepCount += increment; if (increment < 0) // moving forward { PuzzleSolution[CurrentStep++].Apply(); } else { PuzzleSolution[--CurrentStep].Undo(); } } UpdateRuleButtons(); UIGameBoard.ResumeLayout(); UIGameBoard.Invalidate(true /*invalidateChildren*/); UIGameBoard.Update(); }
private void ButtonEndEdit_Click(object sender, EventArgs e) { UIGameBoard.Board.EditMode = false; ButtonEditGame.Visible = true; ButtonEndEdit.Visible = false; ButtonSolve.Visible = true; UIGameBoard.Invalidate(true /*invalidateChildren*/); UIGameBoard.Update(); }
public void OnEditModeClick(object sender, MouseEventArgs args) { if (!Cell.Board.EditMode) { return; } UIGameBoard uiBoard = Form1.MainForm.UIGameBoard; if (Cell.Value > 0) { Cell.ClearCellValue(); Cell.Board.RecalculatePencilMarks(); } else { int widthSection = Width / 3; int heightSection = (int)((float)Height / 3.3f); int x = args.X / widthSection; int y = args.Y / heightSection; int option = 3 * y + x + 1; List <int> pencilMarks = Cell.PMSignature.ListOfBits(); if (!Cell.IsPencilmarkSet(option)) { return; } List <Cell> emptyCells = Cell.ShadowedCells .Where(cell => cell.IsPencilmarkSet(option) && cell.PencilMarkCount == 1) .ToList(); if (emptyCells.Count > 0) { List <UICell> emptyUiCells = emptyCells .Select(cell => UiGameBoard.UiCellMatrix[cell.RowIndex, cell.ColIndex]) .ToList(); UiGameBoard.HighlightCells(emptyUiCells, Color.Yellow, 1.0, new List <PMFinding> { new PMFinding(option, PMRole.ChainColor1) }); return; } Cell.Board.SetCellValueAndAffectShadowedCells(Cell.RowIndex, Cell.ColIndex, option, false /*mutable*/); } uiBoard.Invalidate(true /*invalidateChildren*/); uiBoard.Update(); }
private void ButtonEditGame_Click(object sender, EventArgs e) { if (PuzzleSolution != null && CurrentStep > 0) { ButtonUndoAll_Click(null, null); } UIGameBoard.TurnOffHighlighting(); UIGameBoard.Board.EditMode = true; ButtonEditGame.Visible = false; ButtonSolve.Visible = false; ButtonEndEdit.Visible = true; UIGameBoard.Invalidate(true /*invalidateChildren*/); UIGameBoard.Update(); }