Esempio n. 1
0
        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 "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.AddOperation(Operation.Sign);
                    break;
                }
            }
        }