示例#1
0
        /// <summary>
        /// Shows a tooltip for the specified control.
        /// </summary>
        /// <param name="control">The control.</param>
        private static void ShowToolTip(Control control)
        {
            if (control != null && control.IsVisible && control.GetVisualRoot() != null)
            {
                var cp = (control.GetVisualRoot() as IInputRoot)?.MouseDevice?.GetPosition(control);

                if (cp.HasValue && control.IsVisible && new Rect(control.Bounds.Size).Contains(cp.Value))
                {
                    var position = control.PointToScreen(cp.Value) + new Vector(0, 22);

                    if (s_popup == null)
                    {
                        s_popup         = new PopupRoot();
                        s_popup.Content = new ToolTip();
                    }
                    else
                    {
                        ((ISetLogicalParent)s_popup).SetParent(null);
                    }

                    ((ISetLogicalParent)s_popup).SetParent(control);
                    ((ToolTip)s_popup.Content).Content = GetTip(control);
                    s_popup.Position = position;
                    s_popup.Show();

                    s_current = control;
                }
            }
        }
示例#2
0
        private void Open(Control control)
        {
            Close();

            _popup = new PopupRoot {
                Content = this
            };
            ((ISetLogicalParent)_popup).SetParent(control);
            _popup.Position = Popup.GetPosition(control, GetPlacement(control), _popup,
                                                GetHorizontalOffset(control), GetVerticalOffset(control));
            _popup.Show();
        }
示例#3
0
        /// <summary>
        /// Shows a tooltip for the specified control.
        /// </summary>
        /// <param name="control">The control.</param>
        private static void ShowToolTip(Control control)
        {
            if (control != null && control.IsVisible && control.GetVisualRoot() != null)
            {
                if (s_popup != null)
                {
                    throw new AvaloniaInternalException("Previous ToolTip not disposed.");
                }
                var cp       = (control.GetVisualRoot() as IInputRoot)?.MouseDevice?.GetPosition(control);
                var position = control.PointToScreen(cp ?? new Point(0, 0)) + new Vector(0, 22);

                s_popup = new PopupRoot();
                ((ISetLogicalParent)s_popup).SetParent(control);
                s_popup.Content = new ToolTip {
                    Content = GetTip(control)
                };
                s_popup.Position = position;
                s_popup.Show();

                s_current = control;
            }
        }
示例#4
0
        /// <summary>
        /// Shows a tooltip for the specified control.
        /// </summary>
        /// <param name="control">The control.</param>
        private static void ShowToolTip(Control control)
        {
            if (control != null)
            {
                if (s_popup == null)
                {
                    s_popup = new PopupRoot
                    {
                        Content = new ToolTip(),
                    };

                    ((ISetLogicalParent)s_popup).SetParent(control);
                }

                var cp       = MouseDevice.Instance?.GetPosition(control);
                var position = control.PointToScreen(cp ?? new Point(0, 0)) + new Vector(0, 22);

                ((ToolTip)s_popup.Content).Content = GetTip(control);
                s_popup.Position = position;
                s_popup.Show();

                s_current = control;
            }
        }