Example #1
0
 private void ChangeValue(dynamic calculator, Operations operation)
 {
     dynamic addvalue = null;
     if (CurrentVal.Text != "Write your Value:")
     {
         if (state.CalcEnum == CalcEnum.IntCalc)
         {
             addvalue = new Real<int>(int.Parse(CurrentVal.Text));
         }
         if (state.CalcEnum == CalcEnum.FloatCalc)
         {
             addvalue = new Real<double>(double.Parse(CurrentVal.Text));
         }
         if (state.CalcEnum == CalcEnum.ComCalc)
         {
             addvalue = new Complecs(CurrentVal.Text);
         }
         switch (operation)
         {
             case Operations.Add:
                 calculator.Add(addvalue);
                 break;
             case Operations.Remove:
                 calculator.Remove(addvalue);
                 break;
             case Operations.Divide:
                 calculator.Divide(addvalue);
                 break;
             case Operations.Multiply:
                 calculator.Multiply(addvalue);
                 break;
             case Operations.Clear:
                 calculator.Clear(addvalue);
                 break;
             case Operations.Sqrt:
                 try
                 {
                     calculator.Sqrt(addvalue);
                 }
                 catch (Exception)
                 {
                     MessageBox.Show("Eror: Divide at 0");
                 }
                 break;
             case Operations.Modul:
                 calculator.Modul(addvalue);
                 break;
         }
     }
     else
     {
         MessageBox.Show("Write Value!!!!");
     }
 }