protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
 {
     if (keyData == Keys.F5)
     {
         CompileBtn.PerformClick();
         return(true);
     }
     if (keyData == Keys.F6)
     {
         ClearBtn.PerformClick();
         return(true);
     }
     return(base.ProcessCmdKey(ref msg, keyData));
 }
Beispiel #2
0
 // Division After Checking Our Boolean State.
 public void Divide(string displayValue)
 {
     float.TryParse(displayValue.Trim(), out currentValue);
     // Using Try-Catch For DivideByZeroException
     try{
         if (changeOperand2 == false)
         {
             // Explicitly Throwing Error If Denominator Is Zero.
             if (operand2 != 0)
             {
                 LabelEqu.Text = operand1.ToString() + " / " + operand2.ToString() + " = ";
                 operand1      = currentValue / operand2;
             }
             else
             {
                 throw new DivideByZeroException();
             }
         }
         else
         {
             if (currentValue != 0)
             {
                 operand2       = currentValue;
                 LabelEqu.Text  = operand1.ToString() + " / " + operand2.ToString() + " = ";
                 operand1       = operand1 / currentValue;
                 changeOperand2 = false;
             }
             else
             {
                 throw new DivideByZeroException();
             }
         }
     }
     catch (DivideByZeroException)
     {
         // Resetting Everything And Displaying Error.
         ClearBtn.PerformClick();
         LabelEqu.Text = "ERR";
         // Adding It To Our History.
         vh.addHistory = LabelEqu.Text;
     }
 }
Beispiel #3
0
        // Zorgen dat het toetsenbord gebruikt kan worden
        private void NumPadInput(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar.ToString())
            {
            case "0":
                ZeroBtn.PerformClick();
                break;

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

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

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

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

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

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

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

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

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

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

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

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

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

            case ",":
                DecimalBtn.PerformClick();
                break;

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

            case "c":
                ClearBtn.PerformClick();
                break;

            // Twee keer op de "c" toets op het toetsenbord klikken voor een All Clear
            case "c" + "c":
                AllClearBtn.PerformClick();
                break;

            default:
                break;
            }

            // De "Enter" toets op het toetsenbord de functie van de "=" toets toewijzen
            if (e.KeyChar == (char)Keys.Enter)
            {
                EqualBtn.PerformClick();
            }
        }