private void CalcExecute() { //1. производим вычисление ИЛИ выходим if (_binaryOperation.IsReadyForCalc()) //операция готова к вычислению { VibrateButton(); //1. произвести вычисление try { registerOperand = _binaryOperation.GetResult(); //2. вывести результат на дисплей Display = _formatService.FormatResult(registerOperand.Value); Expression = _binaryOperation.GetOperationExpression(); //3. очистить операцию _binaryOperation.Clear(); //4. устанавливаем первый операнд равный результату вычисления _binaryOperation.SetOperand(new Operand(registerOperand.Value, null)); } catch (DivideByZeroException ex) { Display = ex.Message; //3. очистить операцию _binaryOperation.Clear(); Expression = _binaryOperation.GetOperationExpression(); } //5. устанавливаем флаги canBackSpace = false; canChangeSign = false; mustClearDisplay = true; } //else //{ // //1. // _binaryOperation.SetOperand(decimal.Parse(Display, CultureInfo.CurrentCulture)); // //2 // decimal? result = _binaryOperation.Result(); // //2. вывести результат на дисплей // Display = result.ToString(); // //3. очистить операцию // _binaryOperation.Clear(); // //4. устанавливаем первый операнд равный результату вычисления // _binaryOperation.SetOperand(decimal.Parse(Display, CultureInfo.CurrentCulture)); // //5. устанавливаем флаги // isBackSpaceApplicable = false; // mustClearDisplay = true; //} }
private void SetDefaultExecute() { Settings.GrouppingDigits = true; Settings.RoundAccuracy = 2; Settings.Rounding = false; Settings.Vibration = true; GroupingDigits = Settings.GrouppingDigits; RoundAccuracy = Settings.RoundAccuracy; Rounding = Settings.Rounding; VibrateButtons = Settings.Vibration; Sample = _formatService.FormatResult(sampleValue); }
public SettingsPageViewModel(INavigationService navigationService, FormatService formatService, ConstantsPurchasingService purchasingService, IPageDialogService dialogService) : base(navigationService) { _navigationService = navigationService; _formatService = formatService; _purchasingService = purchasingService; _dialogService = dialogService; SetDefaultCommang = new DelegateCommand(SetDefaultExecute); SaveCommand = new DelegateCommand(SaveExecute); PurchaseCommand = new DelegateCommand(PurchaseExecute, PurchaseCanExecute); Sample = _formatService.FormatResult(sampleValue); }