Example #1
0
        internal static bool ToolTipIsEnabled(DependencyObject o, TriggerAction triggerAction)
        {
            object tooltipObject = GetToolTip(o);

            if ((tooltipObject != null) && GetIsEnabled(o))
            {
                // determine whether tooltip-on-keyboard-focus is enabled
                bool enableOnKeyboardFocus = true;
                if (triggerAction == TriggerAction.KeyboardFocus)
                {
                    // attached property on owner has first priority
                    bool?propertyValue = GetShowsToolTipOnKeyboardFocus(o);

                    // if that doesn't say, get the value from the ToolTip itself (if any)
                    if (propertyValue == (bool?)null)
                    {
                        ToolTip tooltip = tooltipObject as ToolTip;
                        if (tooltip != null)
                        {
                            propertyValue = tooltip.ShowsToolTipOnKeyboardFocus;
                        }
                    }

                    // the behavior is enabled, unless explicitly told otherwise
                    enableOnKeyboardFocus = (propertyValue != false);
                }

                if ((PopupControlService.IsElementEnabled(o) || GetShowOnDisabled(o)) && enableOnKeyboardFocus)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        private void OnContextMenuClosed(object source, RoutedEventArgs e)
        {
            ContextMenu contextMenu = source as ContextMenu;

            if (contextMenu != null)
            {
                contextMenu.Closed -= new RoutedEventHandler(this.OnContextMenuClosed);
                DependencyObject dependencyObject = (DependencyObject)contextMenu.GetValue(PopupControlService.OwnerProperty);
                if (dependencyObject != null)
                {
                    contextMenu.ClearValue(PopupControlService.OwnerProperty);
                    UIElement target = PopupControlService.GetTarget(dependencyObject);
                    if (target != null && !PopupControlService.IsPresentationSourceNull(target))
                    {
                        object arg_6A_0;
                        if (!(dependencyObject is ContentElement) && !(dependencyObject is UIElement3D))
                        {
                            IInputElement inputElement = target;
                            arg_6A_0 = inputElement;
                        }
                        else
                        {
                            arg_6A_0 = (IInputElement)dependencyObject;
                        }
                        object expr_6A          = arg_6A_0;
                        ContextMenuEventArgs e2 = new ContextMenuEventArgs(expr_6A, false);
                        ((IInputElement)expr_6A).RaiseEvent(e2);
                    }
                }
            }
        }
Example #3
0
        private static UIElement GetTarget(DependencyObject o)
        {
            UIElement uIElement = o as UIElement;

            if (uIElement == null)
            {
                ContentElement contentElement = o as ContentElement;
                if (contentElement != null)
                {
                    DependencyObject dependencyObject = PopupControlService.FindContentElementParent(contentElement);
                    uIElement = (dependencyObject as UIElement);
                    if (uIElement == null)
                    {
                        UIElement3D uIElement3D = dependencyObject as UIElement3D;
                        if (uIElement3D != null)
                        {
                            uIElement = UIElementHelper.GetContainingUIElement2D(uIElement3D);
                        }
                    }
                }
                else
                {
                    UIElement3D uIElement3D2 = o as UIElement3D;
                    if (uIElement3D2 != null)
                    {
                        uIElement = UIElementHelper.GetContainingUIElement2D(uIElement3D2);
                    }
                }
            }
            return(uIElement);
        }
Example #4
0
        // Token: 0x060053F2 RID: 21490 RVA: 0x001745F0 File Offset: 0x001727F0
        private void OnContextMenuClosed(object source, RoutedEventArgs e)
        {
            ContextMenu contextMenu = source as ContextMenu;

            if (contextMenu != null)
            {
                contextMenu.Closed -= this.OnContextMenuClosed;
                DependencyObject dependencyObject = (DependencyObject)contextMenu.GetValue(PopupControlService.OwnerProperty);
                if (dependencyObject != null)
                {
                    contextMenu.ClearValue(PopupControlService.OwnerProperty);
                    UIElement target = PopupControlService.GetTarget(dependencyObject);
                    if (target != null && !PopupControlService.IsPresentationSourceNull(target))
                    {
                        IInputElement inputElement2;
                        if (!(dependencyObject is ContentElement) && !(dependencyObject is UIElement3D))
                        {
                            IInputElement inputElement = target;
                            inputElement2 = inputElement;
                        }
                        else
                        {
                            inputElement2 = (IInputElement)dependencyObject;
                        }
                        IInputElement        inputElement3 = inputElement2;
                        ContextMenuEventArgs e2            = new ContextMenuEventArgs(inputElement3, false);
                        inputElement3.RaiseEvent(e2);
                    }
                }
            }
        }
Example #5
0
        // Token: 0x0600443D RID: 17469 RVA: 0x00136E28 File Offset: 0x00135028
        private static object CoerceHasDropShadow(DependencyObject d, object value)
        {
            ContextMenu contextMenu = (ContextMenu)d;

            if (contextMenu._parentPopup == null || !contextMenu._parentPopup.AllowsTransparency || !SystemParameters.DropShadow)
            {
                return(BooleanBoxes.FalseBox);
            }
            return(PopupControlService.CoerceProperty(d, value, ContextMenuService.HasDropShadowProperty));
        }
Example #6
0
        // Token: 0x06005875 RID: 22645 RVA: 0x001882FC File Offset: 0x001864FC
        private static object CoerceHasDropShadow(DependencyObject d, object value)
        {
            ToolTip toolTip = (ToolTip)d;

            if (toolTip._parentPopup == null || !toolTip._parentPopup.AllowsTransparency || !SystemParameters.DropShadow)
            {
                return(BooleanBoxes.FalseBox);
            }
            return(PopupControlService.CoerceProperty(d, value, ToolTipService.HasDropShadowProperty));
        }
        // Token: 0x06004475 RID: 17525 RVA: 0x001377FC File Offset: 0x001359FC
        internal static bool ContextMenuIsEnabled(DependencyObject o)
        {
            bool   result      = false;
            object contextMenu = ContextMenuService.GetContextMenu(o);

            if (contextMenu != null && ContextMenuService.GetIsEnabled(o) && (PopupControlService.IsElementEnabled(o) || ContextMenuService.GetShowOnDisabled(o)))
            {
                result = true;
            }
            return(result);
        }
        private static bool ToolTipIsEnabled(DependencyObject o)
        {
            if ((GetToolTip(o) != null) && GetIsEnabled(o))
            {
                if (PopupControlService.IsElementEnabled(o) || GetShowOnDisabled(o))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #9
0
        /// <summary>Called when the <see cref="P:System.Windows.Controls.ContentControl.Content" /> property changes. </summary>
        /// <param name="oldContent">The old value of the <see cref="P:System.Windows.Controls.ContentControl.Content" /> property.</param>
        /// <param name="newContent">The new value of the <see cref="P:System.Windows.Controls.ContentControl.Content" /> property.</param>
        // Token: 0x0600588F RID: 22671 RVA: 0x00188508 File Offset: 0x00186708
        protected override void OnContentChanged(object oldContent, object newContent)
        {
            PopupControlService popupControlService = PopupControlService.Current;

            if (this == popupControlService.CurrentToolTip && (bool)base.GetValue(PopupControlService.ServiceOwnedProperty) && newContent is ToolTip)
            {
                popupControlService.OnRaiseToolTipClosingEvent(null, EventArgs.Empty);
                popupControlService.OnRaiseToolTipOpeningEvent(null, EventArgs.Empty);
                return;
            }
            base.OnContentChanged(oldContent, newContent);
        }
Example #10
0
        internal static bool ContextMenuIsEnabled(DependencyObject o)
        {
            bool   contextMenuIsEnabled = false;
            object menu = GetContextMenu(o);

            if ((menu != null) && GetIsEnabled(o))
            {
                if (PopupControlService.IsElementEnabled(o) || GetShowOnDisabled(o))
                {
                    contextMenuIsEnabled = true;
                }
            }

            return(contextMenuIsEnabled);
        }
        // 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);
        }
Example #12
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);
        }
Example #13
0
        internal static object CoerceProperty(DependencyObject o, object value, DependencyProperty dp)
        {
            DependencyObject dependencyObject = (DependencyObject)o.GetValue(PopupControlService.OwnerProperty);

            if (dependencyObject != null)
            {
                bool flag;
                if (dependencyObject.GetValueSource(dp, null, out flag) != BaseValueSourceInternal.Default | flag)
                {
                    return(dependencyObject.GetValue(dp));
                }
                if (dp == ToolTip.PlacementTargetProperty || dp == ContextMenu.PlacementTargetProperty)
                {
                    UIElement target = PopupControlService.GetTarget(dependencyObject);
                    if (target != null)
                    {
                        return(target);
                    }
                }
            }
            return(value);
        }
Example #14
0
        private bool WithinCurrentToolTip(DependencyObject o)
        {
            if (this._currentToolTip == null)
            {
                return(false);
            }
            DependencyObject dependencyObject = o as Visual;

            if (dependencyObject == null)
            {
                ContentElement contentElement = o as ContentElement;
                if (contentElement != null)
                {
                    dependencyObject = PopupControlService.FindContentElementParent(contentElement);
                }
                else
                {
                    dependencyObject = (o as Visual3D);
                }
            }
            return(dependencyObject != null && ((dependencyObject is Visual && ((Visual)dependencyObject).IsDescendantOf(this._currentToolTip)) || (dependencyObject is Visual3D && ((Visual3D)dependencyObject).IsDescendantOf(this._currentToolTip))));
        }
Example #15
0
        protected override void OnContentChanged(object oldContent, object newContent)
        {
            PopupControlService popupControlService = PopupControlService.Current;

            // Whenever the tooltip for a control is not an instance of a ToolTip, the framework creates a wrapper
            // ToolTip instance. Such a ToolTip is tagged ServiceOwned and its Content property is bound to the
            // ToolTipProperty of the Owner element. So while such a ServiceOwned ToolTip is visible if the
            // ToolTipProperty on the Owner changes to be a real ToolTip instance then it causes a crash
            // complaining that the ServiceOwned ToolTip is wrapping another nested ToolTip. The condition here
            // detects this case and merely dismisses the old ToolTip and displays the new ToolTip instead thus
            // avoiding the use of a wrapper ToolTip.

            if (this == popupControlService.CurrentToolTip &&
                (bool)GetValue(PopupControlService.ServiceOwnedProperty) &&
                newContent is ToolTip)
            {
                popupControlService.ReplaceCurrentToolTip();
            }
            else
            {
                base.OnContentChanged(oldContent, newContent);
            }
        }
Example #16
0
 private static object CoerceHorizontalOffset(DependencyObject d, object value)
 {
     return(PopupControlService.CoerceProperty(d, value, ContextMenuService.HorizontalOffsetProperty));
 }
Example #17
0
 private static object CoercePlacement(DependencyObject d, object value)
 {
     return(PopupControlService.CoerceProperty(d, value, ContextMenuService.PlacementProperty));
 }
Example #18
0
 internal FrameworkServices()
 {
     this._keyboardNavigation = new KeyboardNavigation();
     this._popupControlService = new PopupControlService();
 }
Example #19
0
 // Token: 0x0600586F RID: 22639 RVA: 0x00188255 File Offset: 0x00186455
 private static object CoerceVerticalOffset(DependencyObject d, object value)
 {
     return(PopupControlService.CoerceProperty(d, value, ToolTipService.VerticalOffsetProperty));
 }
Example #20
0
 // Token: 0x0600587B RID: 22651 RVA: 0x0018838C File Offset: 0x0018658C
 private static object CoercePlacementRectangle(DependencyObject d, object value)
 {
     return(PopupControlService.CoerceProperty(d, value, ToolTipService.PlacementRectangleProperty));
 }
Example #21
0
 internal FrameworkServices()
 { 
     // STA Requirement are checked in InputManager cctor where InputManager.Current is used in KeyboardNavigation cctor
     _keyboardNavigation = new KeyboardNavigation();
     _popupControlService = new PopupControlService();
 }