private void Button_Click(object sender, RoutedEventArgs e) { var button = sender as Button; int digit = -1; if (int.TryParse(button.Content.ToString(), out digit)) { calc.AddDigit(digit); } }
private void Button_Click(object sender, RoutedEventArgs e) { var button = sender as Button; int digit = -1; object tag = (sender as Button).Tag; if (int.TryParse(button.Content.ToString(), out digit)) { calc.AddDigit(digit); } else { switch (tag) { case "decimal": calc.AddDecimalPoint(); break; case "evaluate": calc.Compute(); break; case "addition": calc.AddOperation(Operation.Add); break; case "substraction": calc.AddOperation(Operation.Sub); break; case "multiplication": calc.AddOperation(Operation.Mul); break; case "division": calc.AddOperation(Operation.Div); break; case "degree": calc.AddOperation(Operation.Pow); break; case "reverse": calc.AddOperation(Operation.Drob); break; case "radical": calc.AddOperation(Operation.Sqrt); break; case "Cos": calc.AddOperation(Operation.Cos); break; case "Sin": calc.AddOperation(Operation.Sin); break; case "clear": calc.Clear(); break; case "reset": calc.Reset(); break; case "earse": calc.Earse(); break; } } }
private void Button_Click(object sender, RoutedEventArgs e) { var button = sender as Button; int digit = -1; if (int.TryParse(button.Content.ToString(), out digit)) { calc.AddDigit(digit); } else { switch (button.Tag) { case "plus": calc.AddOperation(CalculatorOperation.Add); break; case "minus": calc.AddOperation(CalculatorOperation.Sub); break; case "multiplication": calc.AddOperation(CalculatorOperation.Mul); break; case "division": calc.AddOperation(CalculatorOperation.Div); break; case "negate": calc.TransformInput(CalculatorTransformation.Negate); break; case "percent": calc.TransformInput(CalculatorTransformation.Percent); break; case "sqr": calc.TransformInput(CalculatorTransformation.Sqr); break; case "sqrt": calc.TransformInput(CalculatorTransformation.Sqrt); break; case "inverse": calc.TransformInput(CalculatorTransformation.Inverse); break; case "point": calc.AddPoint(); break; case "compute": calc.Compute(); break; case "delete": calc.Delete(); break; case "clear": calc.Clear(); break; default: MessageBox.Show(button.Tag?.ToString() ?? ""); break; } } }
private void Button_Click(object sender, RoutedEventArgs e) { int digit = -1; Button b = sender as Button; if (int.TryParse(b.Content.ToString(), out digit)) { calc.AddDigit(digit); } else { switch (b.Tag) { case "div": calc.AddOperation(CalculatorOperation.Div); break; case "mul": calc.AddOperation(CalculatorOperation.Mul); break; case "min": calc.AddOperation(CalculatorOperation.Sub); break; case "pls": calc.AddOperation(CalculatorOperation.Add); break; case "clear": calc.Clear(); break; case "clearall": calc.clearAll(); break; case "compute": calc.Compute(); break; case "dot": calc.AddPoint(); break; case "negate": calc.TransformInput(CalculatorTransformation.Negate); break; case "percent": calc.TransformInput(CalculatorTransformation.Percent); break; case "sqr": calc.TransformInput(CalculatorTransformation.Sqr); break; case "sqrt": calc.TransformInput(CalculatorTransformation.Sqrt); break; case "inverse": calc.TransformInput(CalculatorTransformation.Inverse); break; case "del": calc.RemoveDigit(); break; } } }
private void Button_Click(object sender, RoutedEventArgs e) { string text = (sender as Button).Content.ToString(); string name = (sender as Button).Name; int digit; if (int.TryParse(text, out digit)) { calc.AddDigit(digit); } else { switch (name) { case "dec": calc.AddDecimalPoint(); break; case "evaluate": calc.Compute(); break; case "addition": calc.AddOperation(Operation.Add); break; case "substraction": calc.AddOperation(Operation.Sub); break; case "multiplication": calc.AddOperation(Operation.Mul); break; case "division": calc.AddOperation(Operation.Div); break; case "clear": calc.Clear(); break; case "reset": calc.Reset(); break; case "back": calc.ClearSimbol(); break; case "pow": calc.AddOperation(Operation.Pow); break; case "sqrt": calc.AddOperation(Operation.Sqrt); break; case "log": calc.AddOperation(Operation.Log); break; case "tan": calc.AddOperation(Operation.Tan); break; case "Cos": calc.AddOperation(Operation.Cos); break; case "Sin": calc.AddOperation(Operation.Sin); break; case "inter": calc.AddOperation(Operation.Interest); break; case "sign": calc.Sign(); break; case "exit": this.Close(); break; } } }
private void button_Click(object sender, RoutedEventArgs e) { Button button = sender as Button; int digit = -1; if (int.TryParse(button.Content.ToString(), out digit)) { calc.AddDigit(digit); } else { switch (button.Tag) { case "Add": calc.ProcessBinOp(CalculatorOperations.Add); break; case "Sub": calc.ProcessBinOp(CalculatorOperations.Sub); break; case "Mul": calc.ProcessBinOp(CalculatorOperations.Mul); break; case "Div": calc.ProcessBinOp(CalculatorOperations.Div); break; case "Eq": calc.ProcessBinOp(CalculatorOperations.Eq); break; case "Invert": calc.ProcessUnOp(CalculatorUnOperations.Invert); break; case "Point": calc.AddPoint(); break; case "Reciprocal": calc.ProcessUnOp(CalculatorUnOperations.Reciprocal); break; case "CE": calc.Clear(); break; case "C": calc.ClearAll(); break; case "Percent": calc.ProcessBinOp(CalculatorOperations.Percent); break; case "Sqr": calc.ProcessUnOp(CalculatorUnOperations.Sqr); break; case "Sqrt": calc.ProcessUnOp(CalculatorUnOperations.Sqrt); break; case "Backspace": calc.ProcessUnOp(CalculatorUnOperations.Backspace); break; } } }