Esempio n. 1
0
        private void MyControl_KeyPress(object sender, KeyPressEventArgs e)
        {
            string _char = e.KeyChar.ToString();

            switch (_char)
            {
            case "\r":

                Lines++;
                _caret.NewLine();
                var point   = new Point(textAreaRect.Left + Constants.TEXTAREAPADDING, _rowHeight * (Lines - 1));
                var newInfo = new LineInfo(string.Empty, point, new SizeF(_fontWidth, _fontHeigth + _lineHeight));
                newInfo.Index = _lineInfos.Count - 1;
                _lineInfos.Add(newInfo);

                break;

            case "\b":
                _caret.StepBack();
                break;

            default:

                _caret.StepForward();
                var editinfo = _lineInfos[_caret.LineIndex];
                editinfo.AddChar(e.KeyChar);
                break;
            }

            Invalidate();
        }