Ejemplo n.º 1
0
        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;
            //}
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }