private void InspectElementForToolTip(DependencyObject o)
        {
            DependencyObject origObj = o;

            if (LocateNearestToolTip(ref o))
            {
                // Show the ToolTip on "o" or keep the current ToolTip active

                if (o != null)
                {
                    // A ToolTip value was found and is enabled, proceed to firing the event

                    if (LastMouseOverWithToolTip != null)
                    {
                        // If a ToolTip is active, don't show it anymore
                        RaiseToolTipClosingEvent(true /* reset */);
                    }

                    LastChecked = origObj;
                    LastMouseOverWithToolTip = o;

                    bool quickShow = _quickShow; // ResetToolTipTimer may reset _quickShow
                    ResetToolTipTimer();

                    if (quickShow)
                    {
                        _quickShow = false;
                        RaiseToolTipOpeningEvent();
                    }
                    else
                    {
                        ToolTipTimer          = new DispatcherTimer(DispatcherPriority.Normal);
                        ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetInitialShowDelay(o));
                        ToolTipTimer.Tag      = BooleanBoxes.TrueBox; // should open
                        ToolTipTimer.Tick    += new EventHandler(OnRaiseToolTipOpeningEvent);
                        ToolTipTimer.Start();
                    }
                }
            }
            else
            {
                // If a ToolTip is active, don't show it anymore
                RaiseToolTipClosingEvent(true /* reset */);

                // No longer over an item with a tooltip
                LastMouseOverWithToolTip = null;
            }
        }
Пример #2
0
        private void InspectElementForToolTip(DependencyObject o)
        {
            DependencyObject lastChecked = o;

            if (this.LocateNearestToolTip(ref o))
            {
                if (o != null)
                {
                    if (this.LastMouseOverWithToolTip != null)
                    {
                        this.RaiseToolTipClosingEvent(true);
                    }
                    this.LastChecked = lastChecked;
                    this.LastMouseOverWithToolTip = o;
                    bool arg_3E_0 = this._quickShow;
                    this.ResetToolTipTimer();
                    if (arg_3E_0)
                    {
                        this._quickShow = false;
                        this.RaiseToolTipOpeningEvent();
                        return;
                    }
                    this.ToolTipTimer          = new DispatcherTimer(DispatcherPriority.Normal);
                    this.ToolTipTimer.Interval = TimeSpan.FromMilliseconds((double)ToolTipService.GetInitialShowDelay(o));
                    this.ToolTipTimer.Tag      = BooleanBoxes.TrueBox;
                    this.ToolTipTimer.Tick    += new EventHandler(this.OnRaiseToolTipOpeningEvent);
                    this.ToolTipTimer.Start();
                    return;
                }
            }
            else
            {
                this.RaiseToolTipClosingEvent(true);
                this.LastMouseOverWithToolTip = null;
            }
        }
Пример #3
0
        /// <summary>
        /// Inspects the given element in search of an enabled tooltip, depending on the user
        /// action triggering this search this method will result in the tooltip showing for
        /// the first time, closing, or remaining open if the tooltip was already showing.
        /// </summary>
        /// <param name="o">The element to be inspected.</param>
        /// <param name="triggerAction">The user action that triggered this search.</param>
        /// <returns>True if the method found a tooltip and acted upon it.</returns>
        /// <remarks>
        /// Mouse only shows the tooltip the first time it moves over an element, as long as the mouse keeps moving inside that element, the tooltip stays.
        /// When the keyboard focus lands on an element with a tooltip the tooltip shows unless it was already being shown by the mouse.
        /// If the user presses the keyboard shortcut while focusing an element with a tooltip, the tooltip state will toggle from open to closed or viceversa.
        /// </remarks>
        private bool InspectElementForToolTip(DependencyObject o, ToolTip.ToolTipTrigger triggerAction)
        {
            DependencyObject origObj      = o;
            bool             foundToolTip = false;
            bool             showToolTip  = false;

            bool fromKeyboard = triggerAction == ToolTip.ToolTipTrigger.KeyboardFocus ||
                                triggerAction == ToolTip.ToolTipTrigger.KeyboardShortcut;

            foundToolTip = LocateNearestToolTip(ref o, triggerAction, ref showToolTip);

            if (showToolTip)
            {
                // Show the ToolTip on "o" or keep the current ToolTip active

                if (o != null)
                {
                    // A ToolTip value was found and is enabled, proceed to firing the event

                    if (LastObjectWithToolTip != null)
                    {
                        // If a ToolTip is active, don't show it anymore
                        RaiseToolTipClosingEvent(true /* reset */);
                        LastMouseOverWithToolTip = null;
                    }

                    LastChecked           = origObj;
                    LastObjectWithToolTip = o;
                    if (!fromKeyboard)
                    {
                        LastMouseOverWithToolTip = o;
                    }

                    // When showing tooltips from keyboard focus, do not allow quickshow.
                    // A user tabbing through elements quickly doesn't need to see all the tooltips, only when it has settled on an element.
                    bool quickShow = fromKeyboard ? false : _quickShow; // ResetToolTipTimer may reset _quickShow
                    ResetToolTipTimer();

                    if (quickShow)
                    {
                        _quickShow = false;
                        RaiseToolTipOpeningEvent(fromKeyboard);
                    }
                    else
                    {
                        ToolTipTimer          = new DispatcherTimer(DispatcherPriority.Normal);
                        ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetInitialShowDelay(o));
                        ToolTipTimer.Tag      = BooleanBoxes.TrueBox; // should open
                        ToolTipTimer.Tick    += new EventHandler((s, e) => { RaiseToolTipOpeningEvent(fromKeyboard); });
                        ToolTipTimer.Start();
                    }
                }
            }
            // If we are moving focus to an element that does not have a tooltip,
            // and the mouse is still on a tooltip element, keep showing the tooltip under the mouse.
            else if (LastMouseOverWithToolTip == null || triggerAction != ToolTip.ToolTipTrigger.KeyboardFocus)
            {
                // If a ToolTip is active, don't show it anymore
                RaiseToolTipClosingEvent(true /* reset */);

                //Only cleanup the LasMouseOverWithToolTip property if it is the mouse that is moving away.
                if (triggerAction == ToolTip.ToolTipTrigger.Mouse)
                {
                    // No longer over an item with a tooltip
                    LastMouseOverWithToolTip = null;
                }

                LastObjectWithToolTip = null;
            }

            return(foundToolTip);
        }
Пример #4
0
        // Token: 0x060053DB RID: 21467 RVA: 0x00173CAC File Offset: 0x00171EAC
        private bool InspectElementForToolTip(DependencyObject o, ToolTip.ToolTipTrigger triggerAction)
        {
            DependencyObject lastChecked  = o;
            bool             flag         = false;
            bool             fromKeyboard = triggerAction == ToolTip.ToolTipTrigger.KeyboardFocus || triggerAction == ToolTip.ToolTipTrigger.KeyboardShortcut;
            bool             result       = this.LocateNearestToolTip(ref o, triggerAction, ref flag);

            if (flag)
            {
                if (o != null)
                {
                    if (this.LastObjectWithToolTip != null)
                    {
                        this.RaiseToolTipClosingEvent(true);
                        this.LastMouseOverWithToolTip = null;
                    }
                    this.LastChecked           = lastChecked;
                    this.LastObjectWithToolTip = o;
                    if (!fromKeyboard)
                    {
                        this.LastMouseOverWithToolTip = o;
                    }
                    bool flag2 = !fromKeyboard && this._quickShow;
                    this.ResetToolTipTimer();
                    if (flag2)
                    {
                        this._quickShow = false;
                        this.RaiseToolTipOpeningEvent(fromKeyboard);
                    }
                    else
                    {
                        this.ToolTipTimer          = new DispatcherTimer(DispatcherPriority.Normal);
                        this.ToolTipTimer.Interval = TimeSpan.FromMilliseconds((double)ToolTipService.GetInitialShowDelay(o));
                        this.ToolTipTimer.Tag      = BooleanBoxes.TrueBox;
                        this.ToolTipTimer.Tick    += delegate(object s, EventArgs e)
                        {
                            this.RaiseToolTipOpeningEvent(fromKeyboard);
                        };
                        this.ToolTipTimer.Start();
                    }
                }
            }
            else if (this.LastMouseOverWithToolTip == null || triggerAction != ToolTip.ToolTipTrigger.KeyboardFocus)
            {
                this.RaiseToolTipClosingEvent(true);
                if (triggerAction == ToolTip.ToolTipTrigger.Mouse)
                {
                    this.LastMouseOverWithToolTip = null;
                }
                this.LastObjectWithToolTip = null;
            }
            return(result);
        }