Exemplo n.º 1
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            //대부분의 경우 키보드에서 키를 누르면 KeyUp, KeyPress, KeyDown 등의 이벤트들이 발생한다.
            //그러나 Control, Alt, ReturnResult 같은 특수한 키들은 상기된 이벤트들을 발생시기 전에 미리 짜여진, 다른 행동을 취한다.
            //ProcessCmdKey는 해당 폼으로 들어오는 키들을 제일 먼저 인식하고 관련된 키에 대한 프로시저들을 실행하는 메소드인데, 이 함수를 오버라이드 한다.
            if (keyData == Keys.Return)
            {
                Equal.PerformClick();

                return(true); //여기서 return 함으로써 enter키를 누르는 행동이 '버튼을 누르는 등'의 프로시저들 행하지 않고 종료시킨다.
            }

            if (keyData == Keys.Tab)
            {
                foreach (Control ctr in Controls)
                {
                    if (ctr.GetType() == typeof(Button))
                    {
                        ctr.TabStop = true;
                    }
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Exemplo n.º 2
0
        private void OP_click(object sender, EventArgs e)
        {
            if (Op_press == false)
            {
                op_cnt = op_cnt + 1;
                if (op_cnt > 1)
                {
                    Equal.PerformClick();
                    op_cnt = 1;
                    Num    = res;
                }
                else
                {
                    Num = Double.Parse(result.Text);
                }


                Button B = (Button)sender;


                Operation = B.Text;

                Op_press      = true;
                equation.Text = equation.Text + " " + result.Text + " " + Operation;
            }
        }
Exemplo n.º 3
0
        private void Operation_Perf(object sender, EventArgs e)
        {
            if (!_infinityCheck)
            {
                Button output = (Button)sender;

                if (_resultValue != 0)
                {
                    Equal.PerformClick();
                    _operatorPerf    = output.Text;
                    Label_Show.Text  = $"{_firstValue} {_operatorPerf}";
                    _boloperatorPerf = true;
                }
                else if (TxtBox.Text.Length <= 0)
                {
                    TxtBox.Text  = Constants.ZeroValue;
                    _resultValue = 0;
                }
                else
                {
                    _operatorPerf    = output.Text;
                    _firstValue      = double.Parse(TxtBox.Text);
                    Label_Show.Text  = $"{_firstValue} {_operatorPerf}";
                    _boloperatorPerf = true;
                }
            }
            else
            {
                Global_Clr.PerformClick();
            }
        }
Exemplo n.º 4
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.Enter:
                Equal.PerformClick();
                break;

            default:
                Debug.WriteLine(e.KeyCode.ToString());
                ErrorBox.Text = "";
                break;
            }
        }
Exemplo n.º 5
0
        private void operator_click_even(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            if (resV != 0)
            {
                Equal.PerformClick();
                operationP   = button.Text;
                isOperationP = true;
            }
            else
            {
                operationP   = button.Text;
                resV         = double.Parse(textBox1.Text);
                isOperationP = true;
            }
        }
Exemplo n.º 6
0
        private void operator_click(object sender, EventArgs e)
        {
            Button btt = (Button)sender;

            if (ResultVal != 0)
            {
                Equal.PerformClick();
                operator_icon        = btt.Text;
                CurrentOperator.Text = ResultVal + " " + operator_icon;
                isOperationPerformed = true;
            }
            else
            {
                operator_icon        = btt.Text;
                ResultVal            = double.Parse(result.Text);
                CurrentOperator.Text = ResultVal + " " + operator_icon;
                isOperationPerformed = true;
            }
        }
Exemplo n.º 7
0
        private void operation_click(object sender, EventArgs e)
        {
            Button num = (Button)sender;

            if (values != 0)
            {
                Equal.PerformClick();
                operation          = num.Text;
                Result.Text        = values + " " + operation;
                OperationPerformed = true;
            }
            else
            {
                operation          = num.Text;
                values             = Double.Parse(textbox.Text);
                Result.Text        = values + " " + operation;
                OperationPerformed = true;
            }
        }
Exemplo n.º 8
0
        private void Operator_Click(object sender, EventArgs e)
        {
            Button b = (Button)sender;

            if (value != 0)
            {
                Equal.PerformClick();
                operatie_click = true;
                operatie       = b.Text;
                Live.Text      = value + " " + operatie;
            }
            else
            {
                operatie       = b.Text;
                value          = Double.Parse(result.Text);
                operatie_click = true;
                Live.Text      = value + " " + operatie;
            }
        }
Exemplo n.º 9
0
        // 演算子ボタン処理+-*/
        private void operator_click(object sender, EventArgs e)
        {
            Button button = (Button)sender;

            if (resultValue != 0)
            {
                Equal.PerformClick();// =処理と同じ
                operationPerformed    = button.Text;
                currentOperation.Text = resultValue + " " + operationPerformed;
                isoperationPerformed  = true;
            }
            else
            {
                operationPerformed    = button.Text;
                resultValue           = Double.Parse(InputBox_Result.Text);
                currentOperation.Text = resultValue + " " + operationPerformed;
                isoperationPerformed  = true;
            }
        }
Exemplo n.º 10
0
        /*this method is the click event for "+ - * and /" operation */
        private void Arithmitic_click(object sender, EventArgs e)
        {
            Button button_num = (Button)sender;

            if (result_value != 0)
            {
                Equal.PerformClick();
                Operand        = button_num.Text;
                result_value   = double.Parse(textBox1.Text);
                label1.Text    = result_value + " " + Operand;
                Is_enter_value = true;
            }

            else
            {
                Operand        = button_num.Text;
                result_value   = double.Parse(textBox1.Text);
                Is_enter_value = true;
                label1.Text    = result_value + " " + Operand;
            }
        }
Exemplo n.º 11
0
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            //대부분의 경우 키보드에서 키를 누르면 KeyUp, KeyPress, KeyDown 등의 이벤트들이 발생한다.
            //그러나 Control, Alt, ReturnResult 같은 특수한 키들은 상기된 이벤트들을 발생시기 전에 미리 짜여진, 다른 행동을 취한다.
            //ProcessCmdKey는 해당 폼으로 들어오는 키들을 제일 먼저 인식하고 관련된 키에 대한 프로시저들을 실행하는 메소드인데, 이 함수를 오버라이드 한다.
            //Debug.WriteLine(Convert.ToString(keyData));
            if (keyData == Keys.Return)
            {
                Equal.PerformClick();
                return(true); //여기서 return 함으로써 enter키를 누르는 행동이 '버튼을 누르는 등'의 프로시저들 행하지 않고 종료시킨다.
            }
            if (keyData == Keys.Tab)
            {
                foreach (Control ctr in Controls)
                {
                    if (ctr.GetType() == typeof(Button))
                    {
                        ctr.TabStop = true;
                    }
                }
            }

            if (keyData == (Keys.Shift | Keys.D9))
            {
                BracketOpen.PerformClick();
                return(true);
            }

            if (keyData == (Keys.Shift | Keys.D0))
            {
                BracketClose.PerformClick();
                return(true);
            }

            if (keyData == (Keys.Shift | Keys.D5))
            {
                Mod.PerformClick();
                return(true);
            }

            if (keyData == (Keys.Shift | Keys.D6))
            {
                Power.PerformClick();
                return(true);
            }

            if (keyData == (Keys.Shift | Keys.D8))
            {
                Multiply.PerformClick();
                return(true);
            }

            if (keyData == (Keys.OemMinus))
            {
                Minus.PerformClick();
                return(true);
            }

            if (keyData == (Keys.Shift | Keys.Oemplus))
            {
                Plus.PerformClick();
                return(true);
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Exemplo n.º 12
0
        private void Calculator_Keypress(object sender, KeyPressEventArgs e)
        {
            switch (e.KeyChar.ToString())
            {
            case "1":
                butt1.PerformClick(); break;

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

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

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

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

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

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

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

            case "0":
                butt0.PerformClick(); break;

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

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

            case "13":
                Equal.PerformClick(); break;

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

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

            case "x":
                Ori.PerformClick(); break;

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

            case "s":
                Radical.PerformClick(); break;

            case "w":
                Clear_Label.PerformClick(); break;

            case "q":
                Del.PerformClick(); break;

            default:
                break;
            }
        }