コード例 #1
0
        private void EqualsButton_Click(object sender, RoutedEventArgs e)
        {
            if (!calculation.IsEvaluable)
            {
                ResultDisplay.Text = "No operator defined, try again!";
                return;
            }

            if (string.IsNullOrEmpty(number))
            {
                ResultDisplay.Text = "There is nothing to compute.";
                return;
            }

            calculation.SecondNumber = Int32.Parse(number);
            number = string.Empty;

            double result = calculation.GetResult();

            if (calculation.Operator.Equals(ArithmeticOperator.Division) && result == -1)
            {
                ResultDisplay.Text = "Can not divide by zero";
            }
            else
            {
                ResultDisplay.Text = result.ToString();
            }

            calculation.Clean();
            cleanMessageDisplay = true;
        }