Represents adorner for KeyTips. KeyTipAdorners is chained to produce one from another. Detaching root adorner couses detaching all adorners in the chain
Inheritance: System.Windows.Documents.Adorner
示例#1
0
        // Forward to the next element
        private void Forward(UIElement element, bool click)
        {
            this.Log("Forwarding to {0}", element);

            this.Detach();

            if (click)
            {
                //element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                var control = element as IKeyTipedControl;
                control?.OnKeyTipPressed();
            }

            var children = GetVisibleChildren(element);

            if (children.Count == 0)
            {
                this.Terminate();
                return;
            }

            this.childAdorner = ReferenceEquals(GetTopLevelElement(children[0]), GetTopLevelElement(element)) == false
                ? new KeyTipAdorner(children[0], element, this)
                : new KeyTipAdorner(element, element, this);

            // Stop if no further KeyTips can be displayed.
            if (this.childAdorner.keyTips.Any() == false)
            {
                this.Terminate();
                return;
            }

            this.childAdorner.Attach();
        }
示例#2
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();
            }
        }
示例#3
0
        private void Show()
        {
            // Check whether the window is
            // - still present (prevents exceptions when window is closed by system commands)
            // - still active (prevents keytips showing during Alt-Tab'ing)
            if (this.window == null ||
                this.window.IsActive == false)
            {
                this.RestoreFocuses();
                return;
            }

            this.ClearUserInput();

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

            // Special behavior for backstage
            var specialControl = this.GetBackstage()
                                 ?? (DependencyObject)this.GetApplicationMenu();

            if (specialControl != null)
            {
                this.DirectlyForwardToSpecialControl(specialControl);
            }
            else
            {
                this.activeAdornerChain.Attach();
            }
        }
示例#4
0
        void OnWindowKeyDown(object sender, KeyEventArgs e)
        {
            if (e.IsRepeat)
            {
                return;
            }
            timer.Stop();

            if (ribbon.IsCollapsed)
            {
                return;
            }
            if ((e.Key == Key.System) &&
                ((e.SystemKey == Key.LeftAlt) ||
                 (e.SystemKey == Key.RightAlt) ||
                 (e.SystemKey == Key.F10) ||
                 (e.SystemKey == Key.Space)))
            {
                if ((activeAdornerChain == null) || (!activeAdornerChain.IsAdornerChainAlive))
                {
                    activeAdornerChain = null;
                    timer.Start();
                }
                else
                {
                    activeAdornerChain.Terminate(); activeAdornerChain = null;
                }
            }
        }
示例#5
0
        // Forward to the next element
        void Forward(UIElement element, bool click)
        {
            Detach();
            if (click)
            {
                element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                element.UpdateLayout();
            }

            UIElement[] children = LogicalTreeHelper.GetChildren(element)
                                   .Cast <object>()
                                   .Where(x => x is UIElement)
                                   .Cast <UIElement>().ToArray();
            if (children.Length == 0)
            {
                Terminate(); return;
            }

            childAdorner = GetTopLevelElement(children[0]) != GetTopLevelElement(element) ?
                           new KeyTipAdorner(children[0], element, this) :
                           new KeyTipAdorner(element, element, this);

            if (childAdorner.keyTips.Count != 0)
            {
                Detach();
                childAdorner.Attach();
            }
            else
            {
                Terminate();
            }
        }
示例#6
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();
            }
        }
示例#7
0
 private void OnAdornerChainTerminated(object sender, EventArgs e)
 {
     this.activeAdornerChain.Terminated -= this.OnAdornerChainTerminated;
     this.activeAdornerChain             = null;
     this.ClearUserInput();
     this.RestoreFocus();
 }
示例#8
0
        // Forward to the next element
        private void Forward(UIElement element, bool click)
        {
            Detach();
            if (click)
            {
                //element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                var control = element as IKeyTipedControl;
                if (control != null)
                {
                    control.OnKeyTipPressed();
                }
                element.UpdateLayout();
            }

            var children = LogicalTreeHelper.GetChildren(element)
                           .Cast <object>()
                           .Where(x => x is UIElement)
                           .Cast <UIElement>().ToArray();

            if (children.Length == 0)
            {
                Terminate(); return;
            }

            childAdorner = GetTopLevelElement(children[0]) != GetTopLevelElement(element) ?
                           new KeyTipAdorner(children[0], element, this) :
                           new KeyTipAdorner(element, element, this);

            Detach();
            childAdorner.Attach();
        }
示例#9
0
        private void Show()
        {
            this.timer.Stop();

            // Check whether the window is
            // - still present (prevents exceptions when window is closed by system commands)
            // - still active (prevents keytips showing during Alt-Tab'ing)
            if (this.window == null ||
                this.window.IsActive == false)
            {
                this.RestoreFocus();
                return;
            }

            // Special behavior for backstage, application menu and start screen.
            // If one of those is open we have to forward key tips directly to them.
            var keyTipsTarget = this.GetStartScreen()
                                ?? this.GetBackstage()
                                ?? this.GetApplicationMenu()
                                ?? this.ribbon;

            if (keyTipsTarget == null)
            {
                return;
            }

            this.ClosePopups();

            this.backUpFocusedControl = null;

            // If focus is inside the Ribbon already we don't want to jump around after finishing with KeyTips
            if (UIHelper.GetParent <Ribbon>(Keyboard.FocusedElement as DependencyObject) == null)
            {
                this.backUpFocusedControl = FocusWrapper.GetWrapperForCurrentFocus();
            }

            if (keyTipsTarget is Ribbon targetRibbon &&
                targetRibbon.IsMinimized == false &&
                targetRibbon.SelectedTabIndex >= 0 &&
                targetRibbon.TabControl != null)
            {
                // Focus ribbon
                (this.ribbon.TabControl.ItemContainerGenerator.ContainerFromIndex(this.ribbon.TabControl.SelectedIndex) as UIElement)?.Focus();
            }

            this.ClearUserInput();

            if (this.activeAdornerChain != null)
            {
                this.activeAdornerChain.Terminated -= this.OnAdornerChainTerminated;
            }

            this.activeAdornerChain             = new KeyTipAdorner(keyTipsTarget, keyTipsTarget, null);
            this.activeAdornerChain.Terminated += this.OnAdornerChainTerminated;
            this.activeAdornerChain.Attach();
        }
示例#10
0
        private void ShowDelayed()
        {
            if (this.activeAdornerChain != null)
            {
                this.activeAdornerChain.Terminate();
            }

            this.activeAdornerChain = null;
            this.timer.Start();
        }
示例#11
0
        /// <summary>
        /// Construcotor
        /// </summary>
        /// <param name="adornedElement"></param>
        /// <param name="parentAdorner">Parent adorner or null</param>
        /// <param name="keyTipElementContainer">The element which is container for elements</param>
        public KeyTipAdorner(UIElement adornedElement, UIElement keyTipElementContainer, KeyTipAdorner parentAdorner)
            : base(adornedElement)
        {
            this.parentAdorner = parentAdorner;

            // Try to find supported elements
            FindKeyTips(keyTipElementContainer, false);
            oneOfAssociatedElements = (FrameworkElement)(associatedElements.Count == 0 ? null : associatedElements[0]);

            keyTipPositions = new Point[keyTips.Count];
        }
示例#12
0
 // Window's messages hook up
 IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
 {
     // Mouse clicks in non client area
     if ((msg >= 161) && (msg <= 173))
     {
         if ((activeAdornerChain != null) && (activeAdornerChain.IsAdornerChainAlive))
         {
             activeAdornerChain.Terminate();
             activeAdornerChain = null;
         }
     }
     return(IntPtr.Zero);
 }
示例#13
0
        /// <summary>
        /// Construcotor
        /// </summary>
        /// <param name="adornedElement">Element to adorn.</param>
        /// <param name="parentAdorner">Parent adorner or null.</param>
        /// <param name="keyTipElementContainer">The element which is container for elements.</param>
        public KeyTipAdorner(FrameworkElement adornedElement, FrameworkElement keyTipElementContainer, KeyTipAdorner parentAdorner)
            : base(adornedElement)
        {
            this.parentAdorner = parentAdorner;

            this.keyTipElementContainer = keyTipElementContainer;

            // Try to find supported elements
            this.FindKeyTips(this.keyTipElementContainer, false);
            this.oneOfAssociatedElements = this.keyTipInformations.Count != 0
                    ? this.keyTipInformations[0].AssociatedElement
                    : adornedElement // Maybe here is bug, coz we need keytipped item here...
            ;
        }
示例#14
0
        /// <summary>
        /// Construcotor
        /// </summary>
        /// <param name="adornedElement"></param>
        /// <param name="parentAdorner">Parent adorner or null</param>
        /// <param name="keyTipElementContainer">The element which is container for elements</param>
        public KeyTipAdorner(UIElement adornedElement, UIElement keyTipElementContainer, KeyTipAdorner parentAdorner)
            : base(adornedElement)
        {
            this.parentAdorner = parentAdorner;

            // Try to find supported elements
            FindKeyTips(keyTipElementContainer, false);
            oneOfAssociatedElements = (FrameworkElement)(associatedElements.Count != 0 ?
                                                         associatedElements[0] :
                                                         adornedElement // Maybe here is bug, coz we need keytipped item here...
                                                         );

            keyTipPositions = new Point[keyTips.Count];
        }
示例#15
0
        /// <summary>
        /// Construcotor
        /// </summary>
        /// <param name="adornedElement"></param>
        /// <param name="parentAdorner">Parent adorner or null</param>
        /// <param name="keyTipElementContainer">The element which is container for elements</param>
        public KeyTipAdorner(UIElement adornedElement, UIElement keyTipElementContainer, KeyTipAdorner parentAdorner)
            : base(adornedElement)
        {
            this.parentAdorner = parentAdorner;

            this.keyTipElementContainer = keyTipElementContainer;

            // Try to find supported elements
            FindKeyTips(this.keyTipElementContainer, false);
            oneOfAssociatedElements = (FrameworkElement)(associatedElements.Count != 0 ?
                associatedElements[0] :
                adornedElement // Maybe here is bug, coz we need keytipped item here...
                );

            keyTipPositions = new Point[keyTips.Count];
        }
示例#16
0
        // Window's messages hook up
        IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            // We must terminate the keytip's adorner chain if:
            // - mouse clicks in non client area
            // - the window is deactivated
            if (((msg >= 161) && (msg <= 173)) || msg == NativeMethods.WM_NCACTIVATE)
            {
                if ((activeAdornerChain != null) && (activeAdornerChain.IsAdornerChainAlive))
                {
                    activeAdornerChain.Terminate();
                    activeAdornerChain = null;
                }
            }

            return(IntPtr.Zero);
        }
示例#17
0
        private void OnAdornerChainTerminated(object sender, KeyTipPressedResult e)
        {
            this.activeAdornerChain.Terminated -= this.OnAdornerChainTerminated;
            this.activeAdornerChain             = null;
            this.ClearUserInput();

            if (e.PressedElementOpenedPopup == false)
            {
                this.ClosePopups();
            }

            if (e.PressedElementAquiredFocus == false)
            {
                this.RestoreFocus();
            }
        }
示例#18
0
        /// <summary>
        /// Construcotor
        /// </summary>
        /// <param name="adornedElement"></param>
        /// <param name="parentAdorner">Parent adorner or null</param>
        /// <param name="keyTipElementContainer">The element which is container for elements</param>
        public KeyTipAdorner(UIElement adornedElement, UIElement keyTipElementContainer, KeyTipAdorner parentAdorner)
            : base(adornedElement)
        {
            this.parentAdorner = parentAdorner;

            this.keyTipElementContainer = keyTipElementContainer;

            // Try to find supported elements
            this.FindKeyTips(this.keyTipElementContainer, false);
            this.oneOfAssociatedElements = (FrameworkElement)(this.associatedElements.Count != 0
                    ? this.associatedElements[0]
                    : adornedElement // Maybe here is bug, coz we need keytipped item here...
                                                              );

            this.keyTipPositions      = new Point[this.keyTips.Count];
            this.backupedVisibilities = new Visibility[this.keyTips.Count];
        }
示例#19
0
        private void OnWindowKeyUp(object sender, KeyEventArgs e)
        {
            if (this.ribbon.IsCollapsed)
            {
                return;
            }

            if ((e.Key == Key.System) &&
                ((e.SystemKey == Key.LeftAlt) ||
                 (e.SystemKey == Key.RightAlt) ||
                 (e.SystemKey == Key.F10) ||
                 (e.SystemKey == Key.Space)))
            {
                this.currentUserInput = string.Empty;

                e.Handled = true;

                if (this.timer.IsEnabled)
                {
                    this.timer.Stop();
                    this.backUpFocusedElement = Keyboard.FocusedElement;

                    // Focus ribbon
                    this.ribbon.Focusable = true;
                    //this.ribbon.Focus();

                    this.Show();
                }
                else if (this.activeAdornerChain != null && this.activeAdornerChain.IsAdornerChainAlive)
                {
                    // Focus ribbon
                    this.backUpFocusedElement = Keyboard.FocusedElement;
                    this.ribbon.Focusable     = true;
                    //this.ribbon.Focus();

                    this.activeAdornerChain.Terminate();
                    this.activeAdornerChain = null;
                }
            }
            else
            {
                this.timer.Stop();
            }
        }
示例#20
0
        private void Show()
        {
            this.timer.Stop();

            // Check whether the window is
            // - still present (prevents exceptions when window is closed by system commands)
            // - still active (prevents keytips showing during Alt-Tab'ing)
            if (this.window == null ||
                this.window.IsActive == false)
            {
                this.RestoreFocus();
                return;
            }

            this.ClosePopups();

            // If focus is inside the Ribbon already we don't want to jump around after finishing with KeyTips
            if (UIHelper.GetParent <Ribbon>(Keyboard.FocusedElement as DependencyObject) == null)
            {
                this.backUpFocusedControl = FocusWrapper.GetWrapperForCurrentFocus();
            }

            // Focus ribbon
            this.ribbon.SelectedTabItem?.Focus();

            this.ClearUserInput();

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

            // Special behavior for backstage
            var specialControl = this.GetBackstage()
                                 ?? this.GetApplicationMenu()
                                 ?? this.GetStartScreen();

            if (specialControl != null)
            {
                this.DirectlyForwardToSpecialControl(specialControl);
            }
            else
            {
                this.activeAdornerChain.Attach();
            }
        }
示例#21
0
        // Forward to the next element
        private void Forward(UIElement element, bool click)
        {
            this.Log("Forwarding");

            this.Detach();

            if (click)
            {
                //element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                var control = element as IKeyTipedControl;
                if (control != null)
                {
                    control.OnKeyTipPressed();
                }
            }

            var children = LogicalTreeHelper.GetChildren(element)
                           .OfType <UIElement>()
                           .ToArray();

            if (children.Length == 0)
            {
                this.Terminate();
                return;
            }

            this.childAdorner = ReferenceEquals(GetTopLevelElement(children[0]), GetTopLevelElement(element)) == false
                ? new KeyTipAdorner(children[0], element, this)
                : new KeyTipAdorner(element, element, this);

            // Stop if no further KeyTips can be displayed.
            if (!this.childAdorner.keyTips.Any())
            {
                this.Terminate();
                return;
            }

            this.Detach();
            this.childAdorner.Attach();
        }
示例#22
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;

            if (ribbon.IsBackstageOpen)
            {
                activeAdornerChain.Forward(Ribbon.Localization.BackstageButtonKeyTip, false);
            }
            else
            {
                activeAdornerChain.Attach();
            }
        }
示例#23
0
        // Forward to the next element
        private void Forward(string keys, FrameworkElement element, bool click)
        {
            this.LogTrace("Forwarding keys \"{0}\" to element \"{1}\".", keys, GetControlLogText(element));

            this.Detach();
            KeyTipPressedResult keyTipPressedResult = KeyTipPressedResult.Empty;

            if (click)
            {
                this.LogTrace("Invoking click.");

                var control = element as IKeyTipedControl;
                keyTipPressedResult = control?.OnKeyTipPressed() ?? KeyTipPressedResult.Empty;
            }

            var children = GetVisibleChildren(element);

            if (children.Count == 0)
            {
                this.Terminate(keyTipPressedResult);
                return;
            }

            // Panels aren't good elements to adorn. For example, trying to display KeyTips on MenuItems in SplitButton fails if using a panel.
            var validChild = children.FirstOrDefault(x => x is Panel == false) ?? children[0];

            this.childAdorner = ReferenceEquals(GetTopLevelElement(validChild), GetTopLevelElement(element)) == false
                ? new KeyTipAdorner(validChild, element, this)
                : new KeyTipAdorner(element, element, this);

            // Stop if no further KeyTips can be displayed.
            if (this.childAdorner.keyTipInformations.Any() == false)
            {
                this.Terminate(keyTipPressedResult);
                return;
            }

            this.childAdorner.Attach();
        }
示例#24
0
        private void OnWindowKeyDown(object sender, KeyEventArgs e)
        {
            if (e.IsRepeat)
            {
                return;
            }

            if (this.ribbon.IsCollapsed)
            {
                return;
            }

            if (IsShowOrHideKey(e))
            {
                if (this.activeAdornerChain == null
                    || this.activeAdornerChain.IsAdornerChainAlive == false
                    || this.activeAdornerChain.AreAnyKeyTipsVisible == false)
                {
                    this.ShowDelayed();
                }
                else if (this.activeAdornerChain != null
                    && this.activeAdornerChain.IsAdornerChainAlive)
                {
                    // Focus ribbon
                    this.backUpFocusedElement = Keyboard.FocusedElement;
                    this.ribbon.Focusable = true;
                    //this.ribbon.Focus();

                    this.activeAdornerChain.Terminate();
                    this.activeAdornerChain = null;
                }
                else
                {
                    this.ClearUserInput();
                }
            }
            else if (e.Key == Key.Escape
                && this.activeAdornerChain != null)
            {
                this.activeAdornerChain.ActiveKeyTipAdorner.Back();
            }
            else
            {
                // Should we show the keytips and immediately react to key?
                if (e.Key != Key.System
                    || e.SystemKey == Key.Escape
                    || e.KeyboardDevice.Modifiers != ModifierKeys.Alt)
                {
                    return;
                }

                if (this.activeAdornerChain == null
                    || this.activeAdornerChain.IsAdornerChainAlive == false
                    || this.activeAdornerChain.AreAnyKeyTipsVisible == false)
                {
                    this.ShowImmediatly();
                }

                if (this.activeAdornerChain == null)
                {
                    return;
                }

                this.currentUserInput += keyConverter.ConvertToString(e.SystemKey);

                if (this.activeAdornerChain.ActiveKeyTipAdorner.Forward(this.currentUserInput, true))
                {
                    this.ClearUserInput();
                    e.Handled = true;
                }
            }
        }
示例#25
0
        // Window's messages hook up
        private IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            // We must terminate the keytip's adorner chain if:
            // - mouse clicks in non client area
            // - the window is deactivated
            if (((msg >= 161) && (msg <= 173)) || msg == Constants.WM_NCACTIVATE)
            {
                if (this.activeAdornerChain != null
                    && this.activeAdornerChain.IsAdornerChainAlive)
                {
                    this.activeAdornerChain.Terminate();
                    this.activeAdornerChain = null;
                }
            }

            return IntPtr.Zero;
        }
        // Forward to the next element
        void Forward(UIElement element, bool click)
        {
            Detach();
            if (click)
            {
                element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                element.UpdateLayout();
            }

            UIElement[] children = LogicalTreeHelper.GetChildren(element)
                .Cast<object>()
                .Where(x => x is UIElement)
                .Cast<UIElement>().ToArray();
            if (children.Length == 0) { Terminate(); return; }
                    
            childAdorner = GetTopLevelElement(children[0]) != GetTopLevelElement(element) ? 
                new KeyTipAdorner(children[0], element, this) :
                new KeyTipAdorner(element, element, this);

            if (childAdorner.keyTips.Count != 0)
            {
                Detach();
                childAdorner.Attach();
            }
            else
            {
                Terminate();
            }
        }
 // Window's messages hook up
 IntPtr WindowProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
 {
     // Mouse clicks in non client area
     if ((msg >= 161) && (msg <= 173))
     {
         if ((activeAdornerChain != null) && (activeAdornerChain.IsAdornerChainAlive))
         {
             activeAdornerChain.Terminate();
             activeAdornerChain = null;
         }
     }
     return IntPtr.Zero;
 }
        /// <summary>
        /// Construcotor
        /// </summary>
        /// <param name="adornedElement"></param>
        /// <param name="parentAdorner">Parent adorner or null</param>
        /// <param name="keyTipElementContainer">The element which is container for elements</param>
        public KeyTipAdorner(UIElement adornedElement, UIElement keyTipElementContainer, KeyTipAdorner parentAdorner)
            : base(adornedElement)
        {
            this.parentAdorner = parentAdorner;

            // Try to find supported elements
            FindKeyTips(keyTipElementContainer, false);
            oneOfAssociatedElements = (FrameworkElement)(associatedElements.Count == 0 ? null : associatedElements[0]);

            keyTipPositions = new Point[keyTips.Count];
        }
        // Forward to the next element
        private void Forward(UIElement element, bool click)
        {
            this.Log("Forwarding to {0}", element);

            this.Detach();

            if (click)
            {
                //element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                var control = element as IKeyTipedControl;
                if (control != null)
                {
                    control.OnKeyTipPressed();
                }
            }

            var children = GetVisibleChildren(element);

            if (children.Length == 0)
            {
                this.Terminate();
                return;
            }

            this.childAdorner = ReferenceEquals(GetTopLevelElement(children[0]), GetTopLevelElement(element)) == false
                ? new KeyTipAdorner(children[0], element, this)
                : new KeyTipAdorner(element, element, this);

            // Stop if no further KeyTips can be displayed.
            if (this.childAdorner.keyTips.Any() == false)
            {
                this.Terminate();
                return;
            }

            this.childAdorner.Attach();
        }
示例#30
0
        private void OnWindowKeyDown(object sender, KeyEventArgs e)
        {
            if (e.IsRepeat)
            {
                return;
            }

            if (this.ribbon.IsCollapsed)
            {
                return;
            }

            if (IsShowOrHideKey(e))
            {
                if (this.activeAdornerChain == null ||
                    this.activeAdornerChain.IsAdornerChainAlive == false ||
                    this.activeAdornerChain.AreAnyKeyTipsVisible == false)
                {
                    this.ShowDelayed();
                }
                else if (this.activeAdornerChain != null &&
                         this.activeAdornerChain.IsAdornerChainAlive)
                {
                    // Focus ribbon
                    this.backUpFocusedElement = Keyboard.FocusedElement;
                    this.ribbon.Focusable     = true;
                    //this.ribbon.Focus();

                    this.activeAdornerChain.Terminate();
                    this.activeAdornerChain = null;
                }
                else
                {
                    this.ClearUserInput();
                }
            }
            else if (e.Key == Key.Escape &&
                     this.activeAdornerChain != null)
            {
                this.activeAdornerChain.ActiveKeyTipAdorner.Back();
            }
            else
            {
                // Should we show the keytips and immediately react to key?
                if (e.Key != Key.System ||
                    e.SystemKey == Key.Escape ||
                    e.KeyboardDevice.Modifiers != ModifierKeys.Alt)
                {
                    return;
                }

                if (this.activeAdornerChain == null ||
                    this.activeAdornerChain.IsAdornerChainAlive == false ||
                    this.activeAdornerChain.AreAnyKeyTipsVisible == false)
                {
                    this.ShowImmediatly();
                }

                if (this.activeAdornerChain == null)
                {
                    return;
                }

                this.currentUserInput += keyConverter.ConvertToString(e.SystemKey);

                if (this.activeAdornerChain.ActiveKeyTipAdorner.Forward(this.currentUserInput, true))
                {
                    this.ClearUserInput();
                    e.Handled = true;
                }
            }
        }
示例#31
0
        private void OnWindowKeyUp(object sender, KeyEventArgs e)               
        {
            if (this.ribbon.IsCollapsed)
            {
                return;
            }

            if ((e.Key == Key.System) &&
                ((e.SystemKey == Key.LeftAlt) ||
                 (e.SystemKey == Key.RightAlt) ||
                 (e.SystemKey == Key.F10) ||
                 (e.SystemKey == Key.Space)))
            {
                this.currentUserInput = string.Empty;

                e.Handled = true;

                if (this.timer.IsEnabled)
                {
                    this.timer.Stop();
                    this.backUpFocusedElement = Keyboard.FocusedElement;

                    // Focus ribbon
                    this.ribbon.Focusable = true;
                    //this.ribbon.Focus();

                    this.Show();
                }
                else if (this.activeAdornerChain != null && this.activeAdornerChain.IsAdornerChainAlive)
                {
                    // Focus ribbon
                    this.backUpFocusedElement = Keyboard.FocusedElement;
                    this.ribbon.Focusable = true;
                    //this.ribbon.Focus();

                    this.activeAdornerChain.Terminate();
                    this.activeAdornerChain = null;
                }
            }
            else
            {
                this.timer.Stop();
            }
        }
示例#32
0
        // Forward to the next element
        private void Forward(UIElement element, bool click)
        {
            Detach();
            if (click)
            {
                //element.RaiseEvent(new RoutedEventArgs(Button.ClickEvent, null));
                var control = element as IKeyTipedControl;
                if (control != null) control.OnKeyTipPressed();
                element.UpdateLayout();
            }

            var children = LogicalTreeHelper.GetChildren(element)
                .Cast<object>()
                .Where(x => x is UIElement)
                .Cast<UIElement>().ToArray();
            if (children.Length == 0) { Terminate(); return; }

            childAdorner = GetTopLevelElement(children[0]) != GetTopLevelElement(element) ?
                new KeyTipAdorner(children[0], element, this) :
                new KeyTipAdorner(element, element, this);

            Detach();
            childAdorner.Attach();
        }
 private void OnAdornerChainTerminated(object sender, EventArgs e)
 {
     this.activeAdornerChain.Terminated -= this.OnAdornerChainTerminated;
     this.activeAdornerChain = null;
     this.ClearUserInput();
     this.RestoreFocus();
 }
示例#34
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();
            }
        }
示例#35
0
        void OnWindowKeyDown(object sender, KeyEventArgs e)
        {
            if (e.IsRepeat) return;
            timer.Stop();

            if (ribbon.IsCollapsed) return;
            if ((e.Key == Key.System) &&
                ((e.SystemKey == Key.LeftAlt) ||
                (e.SystemKey == Key.RightAlt) ||
                (e.SystemKey == Key.F10) ||
                (e.SystemKey == Key.Space)))
            {
                if ((activeAdornerChain == null) || (!activeAdornerChain.IsAdornerChainAlive))
                {
                    activeAdornerChain = null;
                    timer.Start();
                }
                else { activeAdornerChain.Terminate(); activeAdornerChain = null; }
            }
        }
示例#36
0
        private void ShowDelayed()
        {
            if (this.activeAdornerChain != null)
            {
                this.activeAdornerChain.Terminate();
            }

            this.activeAdornerChain = null;
            this.timer.Start();
        }
        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;

            if (ribbon.IsBackstageOpen) activeAdornerChain.Forward(Ribbon.Localization.BackstageButtonKeyTip, false);
            else activeAdornerChain.Attach();
        }
示例#38
0
        private void Show()
        {
            // Check whether the window is 
            // - still present (prevents exceptions when window is closed by system commands)
            // - still active (prevents keytips showing during Alt-Tab'ing)
            if (this.window == null
                || this.window.IsActive == false)
            {
                this.RestoreFocuses();
                return;
            }

            this.ClearUserInput();

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

            // Special behavior for backstage
            var specialControl = this.GetBackstage()
                ?? (DependencyObject)this.GetApplicationMenu();

            if (specialControl != null)
            {
                this.DirectlyForwardToSpecialControl(specialControl);
            }
            else
            {
                this.activeAdornerChain.Attach();
            }
        }
示例#39
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();
        }
示例#40
0
        private void OnWindowKeyDown(object sender, KeyEventArgs e)
        {
            if (e.IsRepeat)
            {
                return;
            }

            if (this.ribbon.IsCollapsed)
            {
                return;
            }

            if ((e.Key == Key.System) &&
                ((e.SystemKey == Key.LeftAlt) ||
                 (e.SystemKey == Key.RightAlt) ||
                 (e.SystemKey == Key.F10) ||
                 (e.SystemKey == Key.Space)))
            {
                if (this.activeAdornerChain == null || (!this.activeAdornerChain.IsAdornerChainAlive || !this.activeAdornerChain.AreAnyKeyTipsVisible))
                {
                    if (this.activeAdornerChain != null)
                    {
                        this.activeAdornerChain.Terminate();
                    }

                    this.activeAdornerChain = null;
                    this.timer.Start();
                }
                else
                {
                    this.currentUserInput = string.Empty;
                }
            }
            else if (e.Key == Key.Escape)
            {
                if (this.activeAdornerChain != null)
                {
                    this.activeAdornerChain.ActiveKeyTipAdorner.Back();
                }
            }
            else
            {
                if (e.Key == Key.System &&
                    e.SystemKey != Key.Escape &&
                    e.KeyboardDevice.Modifiers == ModifierKeys.Alt)
                {
                    if (this.activeAdornerChain == null || (!this.activeAdornerChain.IsAdornerChainAlive || !this.activeAdornerChain.AreAnyKeyTipsVisible))
                    {
                        this.timer.Stop();
                        this.backUpFocusedElement = Keyboard.FocusedElement;

                        // Focus ribbon
                        this.ribbon.Focusable = true;
                        //this.ribbon.Focus();

                        this.Show();
                    }

                    if (this.activeAdornerChain != null)
                    {
                        this.currentUserInput += this.keyConverter.ConvertToString(e.SystemKey);

                        if (this.activeAdornerChain.ActiveKeyTipAdorner.Forward(this.currentUserInput, true))
                        {
                            this.currentUserInput = string.Empty;
                            e.Handled             = true;
                        }
                    }
                }
            }
        }
示例#41
0
        private void OnWindowKeyDown(object sender, KeyEventArgs e)
        {
            if (e.IsRepeat)
            {
                return;
            }

            if (this.ribbon.IsCollapsed)
            {
                return;
            }

            if ((e.Key == Key.System) &&
                ((e.SystemKey == Key.LeftAlt) ||
                (e.SystemKey == Key.RightAlt) ||
                (e.SystemKey == Key.F10) ||
                (e.SystemKey == Key.Space)))
            {
                if (this.activeAdornerChain == null || (!this.activeAdornerChain.IsAdornerChainAlive || !this.activeAdornerChain.AreAnyKeyTipsVisible))
                {
                    if (this.activeAdornerChain != null)
                    {
                        this.activeAdornerChain.Terminate();
                    }

                    this.activeAdornerChain = null;
                    this.timer.Start();
                }
                else
                {
                    this.currentUserInput = string.Empty;
                }
            }
            else if (e.Key == Key.Escape)
            {
                if (this.activeAdornerChain != null)
                {
                    this.activeAdornerChain.ActiveKeyTipAdorner.Back();
                }
            }
            else
            {
                if (e.Key == Key.System
                    && e.SystemKey != Key.Escape
                    && e.KeyboardDevice.Modifiers == ModifierKeys.Alt)
                {
                    if (this.activeAdornerChain == null || (!this.activeAdornerChain.IsAdornerChainAlive || !this.activeAdornerChain.AreAnyKeyTipsVisible))
                    {
                        this.timer.Stop();
                        this.backUpFocusedElement = Keyboard.FocusedElement;

                        // Focus ribbon
                        this.ribbon.Focusable = true;
                        //this.ribbon.Focus();

                        this.Show();
                    }

                    if (this.activeAdornerChain != null)
                    {
                        this.currentUserInput += this.keyConverter.ConvertToString(e.SystemKey);

                        if (this.activeAdornerChain.ActiveKeyTipAdorner.Forward(this.currentUserInput, true))
                        {
                            this.currentUserInput = string.Empty;
                            e.Handled = true;
                        }
                    }
                }
            }
        }