protected void RequestToolTip(Point mousePos)
        {
            if (this.toolTipRectangle.Contains(mousePos))
            {
                if (!this.toolTipActive)
                {
                    base.ResetMouseEventArgs();
                }
                return;
            }
            this.toolTipRectangle = new Rectangle(mousePos.X - 4, mousePos.Y - 4, 8, 8);
            ICSharpCode.TextEditor.TextView textView = this.textView;
            int                     x = mousePos.X - this.textView.DrawingPosition.Left;
            int                     y = mousePos.Y;
            Rectangle               drawingPosition        = this.textView.DrawingPosition;
            TextLocation            logicalPosition        = textView.GetLogicalPosition(x, y - drawingPosition.Top);
            bool                    flag                   = (!this.textView.DrawingPosition.Contains(mousePos) || logicalPosition.Y < 0 ? false : logicalPosition.Y < this.Document.TotalNumberOfLines);
            ToolTipRequestEventArgs toolTipRequestEventArg = new ToolTipRequestEventArgs(mousePos, logicalPosition, flag);

            this.OnToolTipRequest(toolTipRequestEventArg);
            if (!toolTipRequestEventArg.ToolTipShown)
            {
                this.CloseToolTip();
                return;
            }
            this.toolTipActive = true;
            this.SetToolTip(toolTipRequestEventArg.toolTipText, (flag ? logicalPosition.Y + 1 : -1));
        }
        public TextArea(TextEditorControl motherTextEditorControl, TextAreaControl motherTextAreaControl)
        {
            this.motherTextAreaControl   = motherTextAreaControl;
            this.motherTextEditorControl = motherTextEditorControl;
            this.caret                    = new ICSharpCode.TextEditor.Caret(this);
            this.selectionManager         = new ICSharpCode.TextEditor.Document.SelectionManager(this.Document, this);
            this.textAreaClipboardHandler = new TextAreaClipboardHandler(this);
            base.ResizeRedraw             = true;
            base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            base.SetStyle(ControlStyles.Opaque, false);
            base.SetStyle(ControlStyles.ResizeRedraw, true);
            base.SetStyle(ControlStyles.Selectable, true);
            this.textView      = new ICSharpCode.TextEditor.TextView(this);
            this.gutterMargin  = new ICSharpCode.TextEditor.GutterMargin(this);
            this.foldMargin    = new ICSharpCode.TextEditor.FoldMargin(this);
            this.iconBarMargin = new ICSharpCode.TextEditor.IconBarMargin(this);
            List <AbstractMargin> abstractMargins = this.leftMargins;

            AbstractMargin[] abstractMarginArray = new AbstractMargin[] { this.iconBarMargin, this.gutterMargin, this.foldMargin };
            abstractMargins.AddRange(abstractMarginArray);
            this.OptionsChanged();
            (new TextAreaMouseHandler(this)).Attach();
            (new TextAreaDragDropHandler()).Attach(this);
            this.bracketshemes.Add(new BracketHighlightingSheme('{', '}'));
            this.bracketshemes.Add(new BracketHighlightingSheme('(', ')'));
            this.bracketshemes.Add(new BracketHighlightingSheme('[', ']'));
            this.caret.PositionChanged                   += new EventHandler(this.SearchMatchingBracket);
            this.Document.TextContentChanged             += new EventHandler(this.TextContentChanged);
            this.Document.FoldingManager.FoldingsChanged += new EventHandler(this.DocumentFoldingsChanged);
        }
        public void SetCaretToDesiredColumn()
        {
            FoldMarker foldMarker;

            ICSharpCode.TextEditor.Caret    caret    = this.Caret;
            ICSharpCode.TextEditor.TextView textView = this.textView;
            int   line          = this.Caret.Line;
            int   desiredColumn = this.Caret.DesiredColumn;
            Point virtualTop    = this.VirtualTop;

            caret.Position = textView.GetLogicalColumn(line, desiredColumn + virtualTop.X, out foldMarker);
        }
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            if (!this.toolTipRectangle.Contains(e.Location))
            {
                this.toolTipRectangle = Rectangle.Empty;
                if (this.toolTipActive)
                {
                    this.RequestToolTip(e.Location);
                }
            }
            foreach (AbstractMargin leftMargin in this.leftMargins)
            {
                if (!leftMargin.DrawingPosition.Contains(e.X, e.Y))
                {
                    continue;
                }
                this.Cursor = leftMargin.Cursor;
                leftMargin.HandleMouseMove(new Point(e.X, e.Y), e.Button);
                if (this.lastMouseInMargin != leftMargin)
                {
                    if (this.lastMouseInMargin != null)
                    {
                        this.lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                    }
                    this.lastMouseInMargin = leftMargin;
                }
                return;
            }
            if (this.lastMouseInMargin != null)
            {
                this.lastMouseInMargin.HandleMouseLeave(EventArgs.Empty);
                this.lastMouseInMargin = null;
            }
            if (!this.textView.DrawingPosition.Contains(e.X, e.Y))
            {
                this.Cursor = Cursors.Default;
                return;
            }
            ICSharpCode.TextEditor.TextView textView = this.TextView;
            int          x = e.X - this.TextView.DrawingPosition.X;
            int          y = e.Y;
            Rectangle    drawingPosition = this.TextView.DrawingPosition;
            TextLocation logicalPosition = textView.GetLogicalPosition(x, y - drawingPosition.Y);

            if (this.SelectionManager.IsSelected(this.Document.PositionToOffset(logicalPosition)) && Control.MouseButtons == System.Windows.Forms.MouseButtons.None)
            {
                this.Cursor = Cursors.Default;
                return;
            }
            this.Cursor = this.textView.Cursor;
        }