Example #1
0
 /// <summary>
 /// Increment the pass counter.
 /// </summary>
 /// <returns>The new value of the pass counter.</returns>
 public int DoNewPass()
 {
     CurrentPass++;
     SymbolManager.DefineGlobal("CURRENT_PASS", CurrentPass + 1);
     PassChanged?.Invoke(this, new EventArgs());
     PassNeeded = false;
     return(CurrentPass);
 }
Example #2
0
        private void ComputeNumbers()
        {
            _puzzleSolver = new PuzzleSolver(GetDigits())
            {
                StartValue = GetStart(),
                EndValue   = GetEnd()
            };
            _puzzleSolver.CompletedValue += delegate(object?sender, CompletedValueArgs e)
            {
                var answer = _answers.FirstOrDefault(an => an.Number == e.Value);
                if (answer is null)
                {
                    return;
                }

                InvokeOnMainThread(() => answer.AddEquation(e.Equation));
            };
            _puzzleSolver.FinishedComputing += delegate(object?sender, EventArgs e)
            {
                CancelAnyComputations();
            };
            _puzzleSolver.EquationsComputed += delegate(object?sender, int equationsComputed)
            {
                InvokeOnMainThread(() => NumberEquationComputed?.Invoke(this, equationsComputed));
            };
            _puzzleSolver.CurrentPass += delegate(object?sender, int pass)
            {
                InvokeOnMainThread(() => PassChanged?.Invoke(this, pass));
            };
            _puzzleSolver.CurrentGroupCombination += delegate(object?sender, List <string> currentGroupCombination)
            {
                InvokeOnMainThread(() => CurrentGroupingEquations?.Invoke(this, currentGroupCombination));
            };

            _puzzleSolver.Solve();
        }