private void CalculateResult()
        {
            if (state == StateOfCalc.SECTOSET)
            {
                number2 = ParsetoDouble(InsertedValue);
                try
                {
                    switch (operation)
                    {
                    case Operation.ADD:
                        InsertedValue = calcEngine.Addition(number1, number2).Result.ToString();
                        break;

                    case Operation.SUB:
                        InsertedValue = calcEngine.Subtraction(number1, number2).Result.ToString();
                        break;

                    case Operation.MUL:
                        InsertedValue = calcEngine.Multiplication(number1, number2).Result.ToString();
                        break;

                    case Operation.DIV:
                        if (number2.Equals(0))
                        {
                            InsertedValue = "Can't div by ZERO";
                            return;
                        }
                        InsertedValue = calcEngine.Division(number1, number2).Result.ToString();
                        break;
                    }
                    state = StateOfCalc.RESULT;
                }
                catch (Exception e)
                {
                    MessagingCenter.Send(new MessagingCenterAlert
                    {
                        Title   = "Error",
                        Message = e.Message,
                        Cancel  = "OK"
                    }, "message");
                }
            }
        }
Example #2
0
        private void CalculateResult()
        {
            if (state == StateOfCalc.SECTOSET)
            {
                number2 = ParsetoDouble(InsertedValue);
                try
                {
                    switch (operation)
                    {
                    case Operation.ADD:
                        InsertedValue = calcEngine.Addition(number1, number2).Result.ToString();
                        break;

                    case Operation.SUB:
                        InsertedValue = calcEngine.Subtraction(number1, number2).Result.ToString();
                        break;

                    case Operation.MUL:
                        InsertedValue = calcEngine.Multiplication(number1, number2).Result.ToString();
                        break;

                    case Operation.DIV:
                        if (number2.Equals(0))
                        {
                            InsertedValue = "Can't div by ZERO";
                            return;
                        }
                        InsertedValue = calcEngine.Division(number1, number2).Result.ToString();
                        break;
                    }
                    state = StateOfCalc.RESULT;
                }
                catch (Exception e)
                {
                }
            }
        }