示例#1
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();
            }
        }
示例#2
0
        /// <summary>
        /// Terminate whole key tip's adorner chain
        /// </summary>
        public void Terminate(KeyTipPressedResult keyTipPressedResult)
        {
            if (this.terminated)
            {
                return;
            }

            this.terminated = true;

            this.Detach();

            this.parentAdorner?.Terminate(keyTipPressedResult);

            this.childAdorner?.Terminate(keyTipPressedResult);

            this.Terminated?.Invoke(this, keyTipPressedResult);

            this.LogDebug("Termination");
        }
示例#3
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();
        }