Exemple #1
0
 private void Clear()
 {
     leftOperand = 0;
     rightOperand = 0;
     operation = Operations.None;
     FormatValue();
 }
Exemple #2
0
 private void Calc(Operations operation)
 {
     Calc();
     this.operation = operation;
     leftOperand = rightOperand;
     rightOperand = 0;
     FormatValue();
 }
Exemple #3
0
        private bool HandleException(Operations op)
        {
            if (op.Equals(Operations.Sqrt) || op.Equals(Operations.Reciprocal))
            {
                Result_Click(this.Result, System.EventArgs.Empty);
                return true;
            }

            return false;
        }
 public void initialize()
 {
     outbox.Text = "";
     bnPlus.IsEnabled = true;
     bnMinus.IsEnabled = true;
     bnMult.IsEnabled = true;
     bnDev.IsEnabled = true;
     bnEq.IsEnabled = false;
     choosedOperation = Operations.None;
 }
Exemple #5
0
 private void Calc()
 {
     try
     {
         switch (operation)
         {
             case Operations.None:
                 leftOperand = rightOperand;
                 break;
             case Operations.Add:
                 leftOperand += rightOperand;
                 break;
             case Operations.Sub:
                 leftOperand -= rightOperand;
                 break;
             case Operations.Mul:
                 leftOperand *= rightOperand;
                 break;
             case Operations.Div:
                 leftOperand /= rightOperand;
                 break;
         }
         rightOperand = leftOperand;
         leftOperand = 0;
         operation = Operations.None;
         FormatValue();
     }catch(Exception ex)
     {
         
     }
 }
        private void Operation_Click(object sender, RoutedEventArgs e)
        {
            if (outbox.Text == "") return;

            a = Convert.ToDouble(outbox.Text);
            outbox.Text = "";
            bnEq.IsEnabled = true;

            switch(((Button)sender).Name)
            {
                case "bnPlus":
                    choosedOperation = Operations.Plus;
                    break;
                case "bnMinus":
                    choosedOperation = Operations.Minus;
                    break;
                case "bnMult":
                    choosedOperation = Operations.Mult;
                    break;
                case "bnDev":
                    choosedOperation = Operations.Devision;
                    break;
            }

            bnPlus.IsEnabled = false;
            bnMinus.IsEnabled = false;
            bnMult.IsEnabled = false;
            bnDev.IsEnabled = false;
        }