// used to enable keys to interact with the program
        private void Zaculator_KeyDown(object sender, KeyEventArgs e)
        {
            Button b = new Button();

            switch (e.KeyCode)
            {
            case Keys.NumPad1:
            {
                b.Text = "1";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad2:
            {
                b.Text = "2";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad3:
            {
                b.Text = "3";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad4:
            {
                b.Text = "4";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad5:
            {
                b.Text = "5";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad6:
            {
                b.Text = "6";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad7:
            {
                b.Text = "7";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad8:
            {
                b.Text = "8";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad9:
            {
                b.Text = "9";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.NumPad0:
            {
                b.Text = "0";
                buttonNum_Click(b, null);
                break;
            }

            case Keys.Decimal:
            {
                functions.AddDecimal();
                display.Text = functions.entry;
                break;
            }

            case Keys.Add:
            {
                b.Text = "+";
                operatorClick(b, null);
                break;
            }

            case Keys.Subtract:
            {
                b.Text = "-";
                operatorClick(b, null);
                break;
            }

            case Keys.Multiply:
            {
                b.Text = "*";
                operatorClick(b, null);
                break;
            }

            case Keys.Divide:
            {
                b.Text = "/";
                operatorClick(b, null);
                break;
            }

            case Keys.Back:
            {
                functions.Backspace();
                display.Text = functions.entry;
                break;
            }

            case Keys.Enter:
            {
                functions.Equals();
                display.Text = functions.entry;
                break;
            }
            }
        }
Esempio n. 2
0
 // adds a decimal
 private void buttonDecimal_Click(object sender, EventArgs e)
 {
     functions.AddDecimal();
     display.Text = functions.Entry;
     buttonEquals.Focus();
 }