public CalculatorViewModel(CalculatorModel calculator) { _calc = calculator; NumberCommand = new RelayCommand(param => { _calc.Number(Convert.ToInt32(param)); UpdateDisplay(); }, param => _calc.CanDoNumber()); PlusCommand = new RelayCommand(param => { _calc.Plus(); UpdateDisplay(); }, param => _calc.CanDoOperator()); MinusCommand = new RelayCommand(param => { _calc.Minus(); UpdateDisplay(); }, param => _calc.CanDoOperator()); TimesCommand = new RelayCommand(param => { _calc.Times(); UpdateDisplay(); }, param => _calc.CanDoOperator()); OverCommand = new RelayCommand(param => { _calc.Over(); UpdateDisplay(); }, param => _calc.CanDoOperator()); EqualsCommand = new RelayCommand(param => { _calc.Equals(); UpdateDisplay(); }, param => _calc.CanDoEquals()); ClearCommand = new RelayCommand(param => { _calc.Clear(); UpdateDisplay(); }, param => _calc.CanDoClear()); }
public void ShowResult() { var resultValue = CalculatorModel.GetResult(); ShowNumber(resultValue); CalculatorModel.Clear(); NumberBuilder.NewNumber(); NumberBuilder.Append(resultValue.ToString()); }
private void ClearAllButtonClick(object sender, RoutedEventArgs e) { NumberBuilder.NewNumber(); CalculatorModel.Clear(); ShowNumber(CalculatorModel.DEFAULT_START_VALUE); }