protected bool GenerateShortcut(Shortcut sc, MenuCommandCollection mcc)
{
foreach(MenuCommand mc in mcc)
{
// Does the command match?
if (mc.Enabled && (mc.Shortcut == sc))
{
// Generate event for command
mc.OnClick(EventArgs.Empty);
return true;
}
else
{
// Any child items to test?
if (mc.MenuCommands.Count > 0)
{
// Recursive descent of all collections
if (GenerateShortcut(sc, mc.MenuCommands))
return true;
}
}
}
return false;
}