コード例 #1
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (_readOnly)
            {
                return;
            }
            hideSelectorList();
            //common keys
            bool bCommonKey = false;

            if (!this.IsStringSelected)
            {
                MathNode node;
                switch (e.KeyChar)
                {
                case '+':
                    bCommonKey = true;
                    node       = mathExp.AddMathNode(typeof(PlusNode));
                    mathExp.ClearFocus();
                    mathExp.SetFocus(node[1]);
                    break;

                case '-':
                    bCommonKey = true;
                    node       = mathExp.AddMathNode(typeof(MinusNode));
                    mathExp.ClearFocus();
                    mathExp.SetFocus(node[1]);
                    break;

                case '*':
                    bCommonKey = true;
                    node       = mathExp.AddMathNode(typeof(MultiplyNode));
                    mathExp.ClearFocus();
                    mathExp.SetFocus(node[1]);
                    break;

                case '/':
                    bCommonKey = true;
                    node       = mathExp.AddMathNode(typeof(DivNode));
                    mathExp.ClearFocus();
                    mathExp.SetFocus(node[1]);
                    break;
                }
            }
            if (!bCommonKey)
            {
                mathExp.UpdateSelected(new string(new char[] { e.KeyChar }));
            }
            this.Refresh();
            RefreshVariableMap();
            _changed = true;
        }