예제 #1
0
        /// <summary>
        ///     Finds the nearest element with an enabled tooltip.
        /// </summary>
        /// <param name="o">
        ///     The most "leaf" element to start looking at.
        ///     This element will be replaced with the element that
        ///     contains an active tooltip OR null if the element
        ///     is already in play.
        /// </param>
        /// <param name="triggerAction">
        ///     The user action that triggered this search.
        /// </param>
        /// <param name="showToolTip">
        ///     Whether or not the tooltip found should be shown.
        /// </param>
        /// <returns>True if a tooltip was located.</returns>
        private bool LocateNearestToolTip(ref DependencyObject o, ToolTip.ToolTipTrigger triggerAction, ref bool showToolTip)
        {
            IInputElement element      = o as IInputElement;
            bool          foundToolTip = false;

            showToolTip = false;

            if (element != null)
            {
                FindToolTipEventArgs args = new FindToolTipEventArgs(triggerAction);
                element.RaiseEvent(args);

                foundToolTip = args.Handled;

                if (args.TargetElement != null)
                {
                    // Open this element's ToolTip
                    o           = args.TargetElement;
                    showToolTip = true;
                }
                else if (args.KeepCurrentActive)
                {
                    // Keep the current ToolTip active
                    o           = null;
                    showToolTip = true;
                }
            }

            // Close any existing ToolTips
            return(foundToolTip);
        }
예제 #2
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);
        }
        // Token: 0x060058B7 RID: 22711 RVA: 0x00188DF4 File Offset: 0x00186FF4
        private static bool ToolTipIsEnabled(DependencyObject o, ToolTip.ToolTipTrigger triggerAction)
        {
            object toolTip = ToolTipService.GetToolTip(o);

            if (toolTip != null && ToolTipService.GetIsEnabled(o))
            {
                ToolTip toolTip2 = toolTip as ToolTip;
                bool    flag     = toolTip2 == null || toolTip2.ShouldShowOnKeyboardFocus;
                if ((PopupControlService.IsElementEnabled(o) || ToolTipService.GetShowOnDisabled(o)) && (triggerAction != ToolTip.ToolTipTrigger.KeyboardFocus || flag))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #4
0
        private static bool ToolTipIsEnabled(DependencyObject o, ToolTip.ToolTipTrigger triggerAction)
        {
            object tooltipObject = GetToolTip(o);

            if ((tooltipObject != null) && GetIsEnabled(o))
            {
                // Some tooltips may choose not to show on Keyboard focus, get the ToolTip and query the property,
                // if we are unable to cast to a ToolTip that means a default ToolTip will be used, the default behavior is to show on focus.
                ToolTip tooltip = tooltipObject as ToolTip;
                bool    enableOnKeyboardFocus = tooltip != null ? tooltip.ShouldShowOnKeyboardFocus : true;

                if ((PopupControlService.IsElementEnabled(o) || GetShowOnDisabled(o)) &&
                    (triggerAction != ToolTip.ToolTipTrigger.KeyboardFocus || enableOnKeyboardFocus))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #5
0
        // Token: 0x060053DC RID: 21468 RVA: 0x00173DD8 File Offset: 0x00171FD8
        private bool LocateNearestToolTip(ref DependencyObject o, ToolTip.ToolTipTrigger triggerAction, ref bool showToolTip)
        {
            IInputElement inputElement = o as IInputElement;
            bool          result       = false;

            showToolTip = false;
            if (inputElement != null)
            {
                FindToolTipEventArgs findToolTipEventArgs = new FindToolTipEventArgs(triggerAction);
                inputElement.RaiseEvent(findToolTipEventArgs);
                result = findToolTipEventArgs.Handled;
                if (findToolTipEventArgs.TargetElement != null)
                {
                    o           = findToolTipEventArgs.TargetElement;
                    showToolTip = true;
                }
                else if (findToolTipEventArgs.KeepCurrentActive)
                {
                    o           = null;
                    showToolTip = true;
                }
            }
            return(result);
        }
예제 #6
0
 // Token: 0x060058C2 RID: 22722 RVA: 0x00188E84 File Offset: 0x00187084
 internal FindToolTipEventArgs(ToolTip.ToolTipTrigger triggerAction)
 {
     base.RoutedEvent    = ToolTipService.FindToolTipEvent;
     this._triggerAction = triggerAction;
 }
예제 #7
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);
        }