Exemple #1
0
        private void InsertNumber(NumberViewModel numberViewModel)
        {
            int index = Numbers.IndexOf(Numbers.FirstOrDefault(vm => vm.Value > numberViewModel.Value));

            if (index == -1)
            {
                Numbers.Add(numberViewModel);
            }
            else
            {
                Numbers.Insert(index, numberViewModel);
            }
        }
Exemple #2
0
        private void Push(Number number)
        {
            model.Push(number);

            Numbers.Remove(Numbers.FirstOrDefault(vm => vm.Model == number.Operand1));
            Numbers.Remove(Numbers.FirstOrDefault(vm => vm.Model == number.Operand2));

            ClearSelection();

            NumberViewModel resultViewModel = new NumberViewModel(number, Numbers.Count == 0 && number.Value == TargetValue, CreationSource.Result);

            resultViewModel.IsSelected = Numbers.Count > 0;

            InsertNumber(resultViewModel);

            RaiseNumbersChanged();

            if (model.IsSolved)
            {
                RaiseSolved();
            }
        }
Exemple #3
0
 public Number Calculate(NumberViewModel a, NumberViewModel b)
 {
     return(calculation(a.Model, b.Model));
 }