コード例 #1
0
        private void RibbonTab_KeyDown(object sender, KeyEventArgs e)
        {
            e.Handled = HandleKeyTipKeyPress(e.Key);
            if (e.Handled)
            {
                _ribbon.IsCollapsedPopupOpen = false;
            }

            KeyTip.SetShowChildKeyTipKeys(this, false);
            KeyDown -= RibbonTab_KeyDown;
        }
コード例 #2
0
        public void ActivateKeyTips(Ribbon ribbon, IKeyTipHandler prev)
        {
            _ribbon = ribbon;
            _prev   = prev;
            foreach (RibbonGroupBox g in Groups)
            {
                Debug.WriteLine("GROUP KEYS: " + KeyTip.GetKeyTipKeys(g));
            }

            Focus();
            KeyTip.SetShowChildKeyTipKeys(this, true);
            KeyDown += RibbonTab_KeyDown;
        }
コード例 #3
0
        public bool HandleKeyTipKeyPress(Key key)
        {
            bool retVal = false;

            foreach (RibbonGroupBox g in Groups)
            {
                if (KeyTip.HasKeyTipKey(g, key))
                {
                    g.Command?.Execute(g.CommandParameter);
                    (Parent as Ribbon).Close();
                    retVal = true;
                    break;
                }
                else
                {
                    foreach (Control c in g.Items)
                    {
                        if (KeyTip.HasKeyTipKey(c, key))
                        {
                            if (c is IKeyTipHandler hdlr)
                            {
                                hdlr.ActivateKeyTips(_ribbon, this);
                                Debug.WriteLine("Group handled " + key.ToString() + " for IKeyTipHandler");
                            }
                            else
                            {
                                if ((c is Button btn) && (btn.Command != null))
                                {
                                    btn.Command.Execute(btn.CommandParameter);
                                }
                                else
                                {
                                    c.RaiseEvent(new RoutedEventArgs(Button.ClickEvent));
                                }
                                _ribbon.Close();
                                retVal = true;
                            }
                            break;
                        }
                    }
                    if (retVal)
                    {
                        break;
                    }
                }
コード例 #4
0
        static RibbonTab()
        {
            KeyTip.ShowChildKeyTipKeysProperty.Changed.AddClassHandler <RibbonTab>(new Action <RibbonTab, AvaloniaPropertyChangedEventArgs>((sender, args) =>
            {
                if ((bool)args.NewValue)
                {
                    foreach (RibbonGroupBox g in sender.Groups)
                    {
                        if ((g.Command != null) && KeyTip.HasKeyTipKeys(g))
                        {
                            KeyTip.GetKeyTip(g).IsOpen = true;
                        }

                        foreach (Control c in g.Items)
                        {
                            if (KeyTip.HasKeyTipKeys(c))
                            {
                                KeyTip.GetKeyTip(c).IsOpen = true;
                            }
                        }
                    }
                }
                else
                {
                    foreach (RibbonGroupBox g in sender.Groups)
                    {
                        KeyTip.GetKeyTip(g).IsOpen = false;

                        foreach (Control c in g.Items)
                        {
                            KeyTip.GetKeyTip(c).IsOpen = false;
                        }
                    }
                }
            }));
        }
コード例 #5
0
 public RibbonTab()
 {
     LostFocus += (sneder, args) => KeyTip.SetShowChildKeyTipKeys(this, false);
 }