public void KeyDown(Control c, KeyEventArgs e)
{
ViewBase newView = null;
KryptonRibbon ribbon = (KryptonRibbon)c;
switch (e.KeyData)
{
case Keys.Tab:
case Keys.Right:
// Ask the ribbon to get use the first view for the qat
newView = ribbon.GetFirstQATView();
// Get the first near edge button (the last near button is the leftmost one!)
if (newView == null)
newView = ribbon.TabsArea.ButtonSpecManager.GetLastVisibleViewButton(PaletteRelativeEdgeAlign.Near);
if (newView == null)
{
if ((e.KeyData == Keys.Tab) && (ribbon.SelectedTab != null))
{
// Get the currently selected tab page
newView = ribbon.TabsArea.LayoutTabs.GetViewForRibbonTab(ribbon.SelectedTab);
}
else
{
// Get the first visible tab page
newView = ribbon.TabsArea.LayoutTabs.GetViewForFirstRibbonTab();
}
}
// 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);
break;
case Keys.Tab | Keys.Shift:
case Keys.Left:
// Move across to any far defined buttons
newView = ribbon.TabsArea.ButtonSpecManager.GetLastVisibleViewButton(PaletteRelativeEdgeAlign.Far);
// Move across to any inherit defined buttons
if (newView == null)
newView = ribbon.TabsArea.ButtonSpecManager.GetLastVisibleViewButton(PaletteRelativeEdgeAlign.Inherit);
if (newView == null)
{
if (e.KeyData != Keys.Left)
{
// Get the last control on the selected tab
newView = ribbon.GroupsArea.ViewGroups.GetLastFocusItem();
// Get the currently selected tab page
if (newView == null)
{
if (ribbon.SelectedTab != null)
newView = ribbon.TabsArea.LayoutTabs.GetViewForRibbonTab(ribbon.SelectedTab);
else
newView = ribbon.TabsArea.LayoutTabs.GetViewForLastRibbonTab();
}
}
else
{
// Get the last visible tab page
newView = ribbon.TabsArea.LayoutTabs.GetViewForLastRibbonTab();
}
}
// Get the last near edge button (the first near button is the rightmost one!)
if (newView == null)
newView = ribbon.TabsArea.ButtonSpecManager.GetFirstVisibleViewButton(PaletteRelativeEdgeAlign.Near);
// Get the last qat button
if (newView == null)
newView = ribbon.GetLastQATView();
break;
case Keys.Space:
case Keys.Enter:
case Keys.Down:
// Show the button as pressed, until told otherwise
_fixedPressed = true;
// Mouse is being pressed
UpdateTargetState();
// Generate a click event
_keyboard = true;
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 != _target1) &&
(newView != _target2 && (newView != _target3)))
{
// 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;
}
}