private void MouseHover(object sender, MouseEventArgs e)
        {
            var pos        = TextEditor.TextArea.TextView.GetPositionFloor(e.GetPosition(TextEditor.TextArea.TextView) + TextEditor.TextArea.TextView.ScrollOffset);
            var inDocument = pos.HasValue;

            if (inDocument)
            {
                var logicalPosition = pos.Value.Location;
                var offset          = TextEditor.Document.GetOffset(logicalPosition);

                var        markersAtOffset   = _textMarkerService.GetMarkersAtOffset(offset);
                TextMarker markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);

                if (markerWithToolTip != null)
                {
                    if (_toolTip == null)
                    {
                        _toolTip                 = new ToolTip();
                        _toolTip.Closed         += ToolTipClosed;
                        _toolTip.PlacementTarget = this;
                        _toolTip.Content         = new TextBlock
                        {
                            Text         = markerWithToolTip.ToolTip,
                            TextWrapping = TextWrapping.Wrap
                        };
                        _toolTip.IsOpen = true;
                        e.Handled       = true;
                    }
                }
            }
        }
Пример #2
0
        private void ToolTipMouseHover(object sender, MouseEventArgs e)
        {
            var  pos        = this.TextArea.TextView.GetPositionFloor(e.GetPosition(this.TextArea.TextView) + this.TextArea.TextView.ScrollOffset);
            bool inDocument = pos.HasValue;

            if (inDocument)
            {
                TextLocation logicalPosition = pos.Value.Location;
                int          offset          = this.Document.GetOffset(logicalPosition);

                var         markersAtOffset   = textMarkerService.GetMarkersAtOffset(offset);
                ITextMarker markerWithToolTip = markersAtOffset.FirstOrDefault(marker => marker.ToolTip != null);

                var ast_node = ParseInfo?.AstNodeAtOffset(offset);

                if (markerWithToolTip != null || ast_node != null)
                {
                    if (toolTip == null)
                    {
                        var toolTipText = "";
                        if (markerWithToolTip != null && markerWithToolTip.ToolTip != null)
                        {
                            toolTipText += (string)markerWithToolTip.ToolTip;
                        }
                        if (ast_node != null)
                        {
                            toolTipText += ast_node.ToString();
                        }

                        toolTip                 = new ToolTip();
                        toolTip.Closed         += ToolTipClosed;
                        toolTip.PlacementTarget = this;
                        toolTip.Content         = new TextBlock
                        {
                            Text         = toolTipText,
                            TextWrapping = TextWrapping.Wrap
                        };
                        toolTip.IsOpen = true;
                        e.Handled      = true;
                    }
                }
            }
        }