public void Create(int offset, int length, string message)
        {
            var marker = new ErrorTextMarker(offset, length, message, Colors.Red);

            markers.Add(marker);
            textEditor.TextArea.TextView.Redraw(marker);
        }
        private void TextViewMouseHover(object sender, MouseEventArgs e)
        {
            if (!markers.Any())
            {
                return;
            }

            TextViewPosition?position = textEditor.TextArea.TextView.GetPositionFloor(
                e.GetPosition(textEditor.TextArea.TextView) + textEditor.TextArea.TextView.ScrollOffset);

            if (position.HasValue)
            {
                TextLocation logicalPosition = position.Value.Location;
                int          offset          = textEditor.Document.GetOffset(logicalPosition);

                var             markersAtOffset = markers.FindSegmentsContaining(offset);
                ErrorTextMarker marker          = markersAtOffset.LastOrDefault(m => !string.IsNullOrEmpty(m.Message));

                if (marker != null)
                {
                    if (toolTip == null)
                    {
                        toolTip                 = new ToolTip();
                        toolTip.Closed         += (s2, e2) => toolTip = null;
                        toolTip.PlacementTarget = textEditor;
                        toolTip.Content         = new TextBlock
                        {
                            Text         = marker.Message,
                            TextWrapping = TextWrapping.Wrap
                        };
                        toolTip.IsOpen = true;
                        e.Handled      = true;
                    }
                }
            }
        }
示例#3
0
 public void Create(int offset, int length, string message)
 {
     var marker = new ErrorTextMarker(offset, length, message, Colors.Red);
     markers.Add(marker);
     textEditor.TextArea.TextView.Redraw(marker);
 }