예제 #1
0
        private void btnEquals_Click(object sender, RoutedEventArgs e)
        {
            double newNumber;

            if (double.TryParse(LblResult.Content.ToString(), out newNumber))
            {
                switch (_selectedOperator)
                {
                case Operation.Add:
                    _result = _calculations.Add(_lastNumber, newNumber);
                    break;

                case Operation.Subtract:
                    _result = _calculations.Subtract(_lastNumber, newNumber);
                    break;

                case Operation.Multiply:
                    _result = _calculations.Multiply(_lastNumber, newNumber);
                    break;

                case Operation.Divide:
                    _result = _calculations.Divide(_lastNumber, newNumber);
                    break;
                }

                LblResult.Content = _result;
            }
        }