Ejemplo n.º 1
0
        // Calculator_KeyPress: Checks for user input through KeyPresses and performs
        // the corresponding Click-event for the appropriate button.
        // Pre: -
        // Post: The KeyPress-event has been handled and, if there's a match, the appropriate
        // buttons Click-event has been fired.
        private void Calculator_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar)
            {
            case '1': OneButton.PerformClick(); break;

            case '2': TwoButton.PerformClick(); break;

            case '3': ThreeButton.PerformClick(); break;

            case '4': FourButton.PerformClick(); break;

            case '5': FiveButton.PerformClick(); break;

            case '6': SixButton.PerformClick(); break;

            case '7': SevenButton.PerformClick(); break;

            case '8': EightButton.PerformClick(); break;

            case '9': NineButton.PerformClick(); break;

            case '0': ZeroButton.PerformClick(); break;

            case '/': DivideButton.PerformClick(); break;

            case '*': MultiplyButton.PerformClick(); break;

            case '-': SubtractButton.PerformClick(); break;

            case '+': AddButton.PerformClick(); break;

            case ',': CommaButton.PerformClick(); break;

            case 'C': ClearButton.PerformClick(); break;

            case 'c': ClearButton.PerformClick(); break;
            }
            e.Handled = true;
        }
Ejemplo n.º 2
0
        private void DoorForm_updated_KeyDown(object sender, KeyEventArgs e)
        {
            //one
            if (e.KeyCode.Equals(Keys.NumPad1))
            {
                oneButton.PerformClick();
            }

            //two
            if (e.KeyCode.Equals(Keys.NumPad2))
            {
                twoButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.NumPad3))
            {
                threeButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.NumPad4))
            {
                fourButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.NumPad5))
            {
                fiveButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.NumPad6))
            {
                sixButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.NumPad7))
            {
                sevenButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.NumPad8))
            {
                eightButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.NumPad9))
            {
                nineButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.NumPad0))
            {
                ZeroButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.Multiply))
            {
                ScreenLabel.Enabled = true;
                starButton.PerformClick();
            }

            if (e.KeyCode.Equals(Keys.Back))
            {
                DeleteButton.PerformClick();
            }
            if (e.KeyCode.Equals(Keys.Delete))
            {
                ClearAllButton.PerformClick();
            }
        }
Ejemplo n.º 3
0
        private void Form1_KeyPress(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar.ToString())
            {
            case ("0"):
                ZeroButton.PerformClick();
                break;

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

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

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

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

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

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

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

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

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

            case ("\r"):
                EqualsButton.PerformClick();
                break;

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

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

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

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

            case ("+"):
                PlusButton.PerformClick();
                break;
            }
        }