private void OperandBtnCommandExecute(OperandCommandParameter commandParameter) { if (_calculatorStorageService.LastUserInteractionType == UserInteractionType.EqualBtnPressed) { NumberTextBoxValue = default(int).ToString(); SeriesOfComputerTextBoxValue = string.Empty; } if (_calculatorStorageService.LastUserInteractionType == UserInteractionType.AnsBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.EFunctionBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.ModOperatorBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.FactOperatorBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.SquareOfXNumberBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.RightParenthesisBtnPressed) { string mulOperatorText = Operators.GetOperatorText(OperatorType.Multiplication); _calculatorStorageService.AddOperatorToStack(mulOperatorText, OperatorType.Multiplication); SeriesOfComputerTextBoxValue = $"{SeriesOfComputerTextBoxValue.Trim()} {mulOperatorText}"; } if (NumberTextBoxValue.IsOnlyZeroValue()) { NumberTextBoxValue = commandParameter.OperandValue.ToString(); } else { NumberTextBoxValue += commandParameter.OperandValue.ToString(); } _calculatorStorageService.SetLastUserInteractionType(commandParameter.UserInteractionType); }
private void CommaBtnCommandExecute(OperationCommandParameter commandParameter) { if (_calculatorStorageService.LastUserInteractionType == UserInteractionType.AnsBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.EqualBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.EFunctionBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.ModOperatorBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.FactOperatorBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.SquareOfXNumberBtnPressed || _calculatorStorageService.LastUserInteractionType == UserInteractionType.RightParenthesisBtnPressed) { OperandBtnCommand.Execute(new OperandCommandParameter(UserInteractionType.OperandBtnPressed, default)); } if (!NumberTextBoxValue.Contains(commandParameter.OperationText)) { NumberTextBoxValue += commandParameter.OperationText; } _calculatorStorageService.SetLastUserInteractionType(commandParameter.UserInteractionType); }
public void DelBtnCommandExecute(OperationCommandParameter commandParameter) { if (_calculatorStorageService.LastUserInteractionType != UserInteractionType.AnsBtnPressed && _calculatorStorageService.LastUserInteractionType != UserInteractionType.EqualBtnPressed && _calculatorStorageService.LastUserInteractionType != UserInteractionType.EFunctionBtnPressed && _calculatorStorageService.LastUserInteractionType != UserInteractionType.ModOperatorBtnPressed && _calculatorStorageService.LastUserInteractionType != UserInteractionType.FactOperatorBtnPressed && _calculatorStorageService.LastUserInteractionType != UserInteractionType.SquareOfXNumberBtnPressed && _calculatorStorageService.LastUserInteractionType != UserInteractionType.RightParenthesisBtnPressed) { if (!NumberTextBoxValue.IsOnlyZeroValue()) { NumberTextBoxValue = NumberTextBoxValue.RemoveLast(); if (NumberTextBoxValue.Length == 0) { NumberTextBoxValue = default(int).ToString(); } } _calculatorStorageService.SetLastUserInteractionType(commandParameter.UserInteractionType); } }