private void KeyDownRibbon(KeyEventArgs e)
{
ViewBase newView = null;
switch (e.KeyData)
{
case Keys.Tab | Keys.Shift:
case Keys.Left:
// Get the previous focus item for the currently selected page
newView = Ribbon.GroupsArea.ViewGroups.GetPreviousFocusItem(Target);
// Got to the actual tab header
if (newView == null)
newView = Ribbon.TabsArea.LayoutTabs.GetViewForRibbonTab(Ribbon.SelectedTab);
break;
case Keys.Tab:
case Keys.Right:
// Get the next focus item for the currently selected page
newView = Ribbon.GroupsArea.ViewGroups.GetNextFocusItem(Target);
// Move across to any far defined buttons
if (newView == null)
newView = Ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Far);
// Move across to any inherit defined buttons
if (newView == null)
newView = Ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Inherit);
// Rotate around to application button
if (newView == null)
{
if (Ribbon.TabsArea.LayoutAppButton.Visible)
newView = Ribbon.TabsArea.LayoutAppButton.AppButton;
else if (Ribbon.TabsArea.LayoutAppTab.Visible)
newView = Ribbon.TabsArea.LayoutAppTab.AppTab;
}
break;
case Keys.Space:
case Keys.Enter:
// Exit keyboard mode when you click the button spec
Ribbon.KillKeyboardMode();
// Generate a click event
OnClick(new MouseEventArgs(MouseButtons.Left, 1, 0, 0, 0));
break;
}
// If we have a new view to focus and it is not ourself...
if ((newView != null) && (newView != Target))
{
// If the new view is a tab then select that tab unless in minimized mode
if ((newView is ViewDrawRibbonTab) && !Ribbon.RealMinimizedMode)
Ribbon.SelectedTab = ((ViewDrawRibbonTab)newView).RibbonTab;
// Finally we switch focus to new view
Ribbon.FocusView = newView;
}
}