示例#1
0
        // Find key tips on the given element
        private void FindKeyTips(FrameworkElement element, bool hide)
        {
            var children = GetVisibleChildren(element);

            foreach (var child in children)
            {
                var groupBox = child as RibbonGroupBox;

                var keys = KeyTip.GetKeys(child);
                if (keys != null)
                {
                    if (groupBox != null)
                    {
                        this.GenerateAndAddGroupBoxKeyTipInformation(hide, keys, child, groupBox);
                    }
                    else
                    {
                        this.GenerateAndAddRegularKeyTipInformations(keys, child, hide);

                        // Do not search deeper in the tree
                        continue;
                    }
                }

                var innerHide = hide || groupBox?.State == RibbonGroupBoxState.Collapsed;
                this.FindKeyTips(child, innerHide);
            }
        }
示例#2
0
        void Show()
        {
            // Check whether the window is still active
            // (it prevent keytips showing during Alt-Tab'ing)
            if (!window.IsActive)
            {
                RestoreFocuses();
                return;
            }

            activeAdornerChain             = new KeyTipAdorner(ribbon, ribbon, null);
            activeAdornerChain.Terminated += OnAdornerChainTerminated;

            // Special behavior for backstage
            Backstage backstage = ribbon.Menu as Backstage;

            if (backstage != null && backstage.IsOpen)
            {
                string keys = KeyTip.GetKeys(backstage);
                if (!String.IsNullOrEmpty(keys))
                {
                    activeAdornerChain.Forward(KeyTip.GetKeys(backstage), false);
                }
                else
                {
                    activeAdornerChain.Attach();
                }
            }
            else
            {
                activeAdornerChain.Attach();
            }
        }
示例#3
0
        private void Show()
        {
            // Check whether the window is still active
            // (it prevent keytips showing during Alt-Tab'ing)
            if (!this.window.IsActive)
            {
                this.RestoreFocuses();
                return;
            }

            this.currentUserInput = string.Empty;

            this.activeAdornerChain             = new KeyTipAdorner(this.ribbon, this.ribbon, null);
            this.activeAdornerChain.Terminated += this.OnAdornerChainTerminated;

            // Special behavior for backstage
            var backstage = this.ribbon.Menu as Backstage;

            if (backstage != null && backstage.IsOpen)
            {
                var keys = KeyTip.GetKeys(backstage);
                if (!String.IsNullOrEmpty(keys))
                {
                    this.activeAdornerChain.Forward(KeyTip.GetKeys(backstage), false);
                }
                else
                {
                    this.activeAdornerChain.Attach();
                }
            }
            else
            {
                this.activeAdornerChain.Attach();
            }
        }
示例#4
0
        private void DirectlyForwardToSpecialControl(DependencyObject specialControl)
        {
            var keys = KeyTip.GetKeys(specialControl);

            if (string.IsNullOrEmpty(keys) == false)
            {
                this.activeAdornerChain.Forward(keys, false);
            }
            else
            {
                this.activeAdornerChain.Attach();
            }
        }
示例#5
0
        // Find key tips on the given element
        private void FindKeyTips(UIElement element, bool hide)
        {
            this.Log("FindKeyTips");

            var children = LogicalTreeHelper.GetChildren(element);

            foreach (var item in children)
            {
                var child = item as UIElement;

                if (child == null ||
                    child.Visibility != Visibility.Visible)
                {
                    continue;
                }

                var groupBox = child as RibbonGroupBox;

                var keys = KeyTip.GetKeys(child);
                if (keys != null)
                {
                    // Gotcha!
                    var keyTip = new KeyTip
                    {
                        Content    = keys,
                        Visibility = hide
                            ? Visibility.Collapsed
                            : Visibility.Visible
                    };

                    // Add to list & visual
                    // children collections
                    this.keyTips.Add(keyTip);
                    this.AddVisualChild(keyTip);
                    this.associatedElements.Add(child);

                    if (groupBox != null)
                    {
                        if (groupBox.State == RibbonGroupBoxState.Collapsed)
                        {
                            keyTip.Visibility = Visibility.Visible;
                            this.FindKeyTips(child, true);
                            continue;
                        }
                        else
                        {
                            keyTip.Visibility = Visibility.Collapsed;
                        }
                    }
                    else
                    {
                        // Bind IsEnabled property
                        var binding = new Binding("IsEnabled")
                        {
                            Source = child,
                            Mode   = BindingMode.OneWay
                        };
                        keyTip.SetBinding(IsEnabledProperty, binding);
                        continue;
                    }
                }

                if (groupBox != null &&
                    groupBox.State == RibbonGroupBoxState.Collapsed)
                {
                    this.FindKeyTips(child, true);
                }
                else
                {
                    this.FindKeyTips(child, hide);
                }
            }
        }
示例#6
0
        // Find key tips on the given element
        private void FindKeyTips(UIElement element, bool hide)
        {
            this.Log("FindKeyTips");

            IEnumerable children = LogicalTreeHelper.GetChildren(element);

            foreach (object item in children)
            {
                UIElement      child    = item as UIElement;
                RibbonGroupBox groupBox = (child as RibbonGroupBox);
                if (child != null)
                {
                    string keys = KeyTip.GetKeys(child);
                    if (keys != null)
                    {
                        // Gotcha!
                        KeyTip keyTip = new KeyTip
                        {
                            Content    = keys,
                            Visibility = hide
                                                ? Visibility.Collapsed
                                                : Visibility.Visible
                        };

                        // Add to list & visual
                        // children collections
                        keyTips.Add(keyTip);
                        base.AddVisualChild(keyTip);
                        associatedElements.Add(child);

                        if (groupBox != null)
                        {
                            if (groupBox.State == RibbonGroupBoxState.Collapsed)
                            {
                                keyTip.Visibility = Visibility.Visible;
                                FindKeyTips(child, true);
                                continue;
                            }
                            else
                            {
                                keyTip.Visibility = Visibility.Collapsed;
                            }
                        }
                        else
                        {
                            // Bind IsEnabled property
                            Binding binding = new Binding("IsEnabled")
                            {
                                Source = child,
                                Mode   = BindingMode.OneWay
                            };
                            keyTip.SetBinding(UIElement.IsEnabledProperty, binding);
                            continue;
                        }
                    }

                    if ((groupBox != null) &&
                        (groupBox.State == RibbonGroupBoxState.Collapsed))
                    {
                        FindKeyTips(child, true);
                    }
                    else
                    {
                        FindKeyTips(child, hide);
                    }
                }
            }
        }