// 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(); }
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(); } }
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(); } }
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; } } }
// 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(); } }
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(); } }
private void OnAdornerChainTerminated(object sender, EventArgs e) { this.activeAdornerChain.Terminated -= this.OnAdornerChainTerminated; this.activeAdornerChain = null; this.ClearUserInput(); this.RestoreFocus(); }
// 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 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(); }
private void ShowDelayed() { if (this.activeAdornerChain != null) { this.activeAdornerChain.Terminate(); } this.activeAdornerChain = null; this.timer.Start(); }
/// <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]; }
// 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">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... ; }
/// <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]; }
/// <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]; }
// 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); }
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(); } }
/// <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]; }
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(); } }
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(); } }
// 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(); }
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(); } }
// 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(); }
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; } } }
// 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; }
// 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(); }
// 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(); }
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; } } }
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(); }
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(); }
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; } } } } }