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)); }
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; }