示例#1
0
        void OnMouseHover(MouseEventArgs e)
        {
            ToolTipRequestEventArgs args = new ToolTipRequestEventArgs(editor);
            var pos = editor.GetPositionFromPoint(e.GetPosition(editor));

            args.InDocument = pos.HasValue;

            if (pos.HasValue)
            {
                args.LogicalPosition = new TextLocation(pos.Value.Line, pos.Value.Column);
            }
            else
            {
                return;
            }

            DebuggerService.HandleToolTipRequest(args);

            if (args.ContentToShow != null)
            {
                var contentToShowITooltip = args.ContentToShow as ITooltip;

                if (contentToShowITooltip != null && contentToShowITooltip.ShowAsPopup)
                {
                    if (!(args.ContentToShow is UIElement))
                    {
                        throw new NotSupportedException("Content to show in Popup must be UIElement: " + args.ContentToShow);
                    }
                    if (popup == null)
                    {
                        popup = CreatePopup();
                    }
                    if (TryCloseExistingPopup(false))
                    {
                        // when popup content decides to close, close the popup
                        contentToShowITooltip.Closed += delegate { popup.IsOpen = false; };
                        popup.Child = (UIElement)args.ContentToShow;
                        //ICSharpCode.SharpDevelop.Debugging.DebuggerService.CurrentDebugger.IsProcessRunningChanged
                        SetPopupPosition(popup, e);
                        popup.IsOpen = true;
                    }
                    e.Handled = true;
                }
            }
            else
            {
                // close popup if mouse hovered over empty area
                if (popup != null)
                {
                    e.Handled = true;
                }
                TryCloseExistingPopup(false);
            }
        }