示例#1
0
 private void DivideButton_Click(object sender, EventArgs e)
 {
     if (first == string.Empty)
     {
         first     = input;
         operation = '/';
         input     = string.Empty;
         label1.Focus();
     }
     else
     {
         second    = input;
         operation = '/';
         label1.Focus();
         EqualsButton.PerformClick();
     }
 }
示例#2
0
        private void operator_click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            if (resultValue != 0)
            {
                EqualsButton.PerformClick();

                operationPerformed         = button.Text;
                isOperationPerformed       = true;
                LabelCurrentOperation.Text = resultValue + " " + operationPerformed; // виводить в label значення + дію
            }
            else
            {
                operationPerformed         = button.Text;
                resultValue                = Double.Parse(TextBox_Result.Text);
                isOperationPerformed       = true;
                LabelCurrentOperation.Text = resultValue + " " + operationPerformed; // виводить в label значення + дію
            }
        }
示例#3
0
 private void MinusButton_Click(object sender, EventArgs e)
 {
     /*first = input;
      * operation = '-';
      * input = string.Empty;
      * label1.Focus();*/
     if (first == string.Empty)
     {
         first     = input;
         operation = '-';
         input     = string.Empty;
         label1.Focus();
     }
     else
     {
         second    = input;
         operation = '-';
         label1.Focus();
         EqualsButton.PerformClick();
     }
 }
示例#4
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;
            }
        }