Exemplo n.º 1
0
        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();
        }
Exemplo n.º 2
0
        private void OnSolvePuzzle_Click(object sender, EventArgs e)
        {
            bool couldSolve;

            UIGameBoard.SuspendLayout();
            PuzzleSolution = GameSolver.Solve(UIGameBoard.Board, out couldSolve);
            if (!couldSolve)
            {
                new TooHardBox().ShowDialog();
            }

            CurrentStep = PuzzleSolution.Count;
            ButtonUndoAll_Click(null, null);
            ButtonSolve.Visible = false;
            UpdateRuleButtons();
            UIGameBoard.ResumeLayout(true /*performLayout*/);
        }