Esempio n. 1
0
        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)Keys.Escape)
            {
                result.Text      = "0";
                value            = 0;
                lblEquation.Text = "";
            }

            switch (e.KeyChar.ToString())
            {
            case "0":
                zero.PerformClick();
                break;

            case "1":
                one.PerformClick();
                break;

            case "2":
                two.PerformClick();
                break;

            case "3":
                three.PerformClick();
                break;

            case "4":
                four.PerformClick();
                break;

            case "5":
                five.PerformClick();
                break;

            case "6":
                six.PerformClick();
                break;

            case "7":
                seven.PerformClick();
                break;

            case "8":
                eight.PerformClick();
                break;

            case "9":
                nine.PerformClick();
                break;

            case "+":
                add.PerformClick();
                break;

            case "-":
                minus.PerformClick();
                break;

            case "×":
                multiply.PerformClick();
                break;

            case "*":
                multiply.PerformClick();
                break;

            case "/":
                divide.PerformClick();
                break;

            case "=":
                btnEqual.PerformClick();
                break;

            case "√":
                SquareRoot.PerformClick();
                break;

            case "←":
                backspace.PerformClick();
                break;

            case "¹/×":
                reciprocal.PerformClick();
                break;

            case ".":
                dec.PerformClick();
                break;

            case "ײ":
                Squared.PerformClick();
                break;

            default:
                break;
            }
            if (e.KeyChar == (char)Keys.Back)
            {
                backspace.PerformClick();
            }
            if (e.KeyChar == (char)Keys.Enter)
            {
                btnEqual.PerformClick();
            }
        }