void OnToolTipRequest(object sender, ToolTipRequestEventArgs e) { if (e.ToolTipShown) return; Point mousepos = e.MousePosition; FoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y); if (marker != null && marker.IsFolded) { StringBuilder sb = new StringBuilder(marker.InnerText); // max 10 lines int endLines = 0; for (int i = 0; i < sb.Length; ++i) { if (sb[i] == '\n') { ++endLines; if (endLines >= 10) { sb.Remove(i + 1, sb.Length - i - 1); sb.Append(Environment.NewLine); sb.Append("..."); break; } } } sb.Replace("\t", " "); e.ShowToolTip(sb.ToString()); return; } List<TextMarker> markers = textArea.Document.MarkerStrategy.GetMarkers(e.LogicalPosition); foreach (TextMarker tm in markers) { if (tm.ToolTip != null) { e.ShowToolTip(tm.ToolTip.Replace("\t", " ")); return; } } }
protected virtual void OnToolTipRequest(ToolTipRequestEventArgs e) { if (ToolTipRequest != null) { ToolTipRequest(this, e); } }
protected void RequestToolTip(Point mousePos) { if (toolTipRectangle.Contains(mousePos)) { if (!toolTipActive) { ResetMouseEventArgs(); } return; } //Console.WriteLine("Request tooltip for " + mousePos); toolTipRectangle = new Rectangle(mousePos.X - 4, mousePos.Y - 4, 8, 8); TextLocation logicPos = textView.GetLogicalPosition(mousePos.X - textView.DrawingPosition.Left, mousePos.Y - textView.DrawingPosition.Top); bool inDocument = textView.DrawingPosition.Contains(mousePos) && logicPos.Y >= 0 && logicPos.Y < Document.TotalNumberOfLines; ToolTipRequestEventArgs args = new ToolTipRequestEventArgs(mousePos, logicPos, inDocument); OnToolTipRequest(args); if (args.ToolTipShown) { //Console.WriteLine("Set tooltip to " + args.toolTipText); toolTipActive = true; SetToolTip(args.toolTipText, inDocument ? logicPos.Y + 1 : -1); } else { CloseToolTip(); } }
void OnToolTipRequest(object sender, ToolTipRequestEventArgs e) { if (e.ToolTipShown) { return; } Point mousepos = e.MousePosition; FoldMarker marker = textArea.TextView.GetFoldMarkerFromPosition(mousepos.X - textArea.TextView.DrawingPosition.X, mousepos.Y - textArea.TextView.DrawingPosition.Y); if (marker != null && marker.IsFolded) { StringBuilder sb = new StringBuilder(marker.InnerText); // max 10 lines int endLines = 0; for (int i = 0; i < sb.Length; ++i) { if (sb[i] == '\n') { ++endLines; if (endLines >= 10) { sb.Remove(i + 1, sb.Length - i - 1); sb.Append(Environment.NewLine); sb.Append("..."); break; } } } sb.Replace("\t", " "); e.ShowToolTip(sb.ToString()); return; } List <TextMarker> markers = textArea.Document.MarkerStrategy.GetMarkers(e.LogicalPosition); foreach (TextMarker tm in markers) { if (tm.ToolTip != null) { e.ShowToolTip(tm.ToolTip.Replace("\t", " ")); return; } } }
private void OnToolTipRequest(object sender, ToolTipRequestEventArgs e) { if (e.InDocument == false || e.ToolTipShown == true) { return; } int offset = mEditor.Document.PositionToOffset(e.LogicalPosition); LineSegment line = mEditor.Document.GetLineSegmentForOffset(offset); TextWord word = line.GetWord(e.LogicalPosition.Column); if (word == null) { return; } string lineText = word.Word; if (lineText.Length > 0) { if (TextArea.ToolTipWnd == null) { } e.ShowToolTip(lineText); } }