private static void SaveShortcuts(MainMenu.MenuItemCollection menuItems) { foreach (MenuItem menuItem in menuItems) { NuGenBaseMenuInformation menuInformation = menuItem.Tag as NuGenBaseMenuInformation; if (menuInformation != null) { MenuFunction menuFunction = menuInformation.MenuFunction; NuGenMenuFunctionShortcut menuFunctionShortcut = new NuGenMenuFunctionShortcut(); menuFunctionShortcut.MenuFunction = menuFunction; menuFunctionShortcut.Shortcut = menuItem.Shortcut; NuGenMenuFunctionShortcut existingShortcut = Instance.FindMenuFunctionShortcut(menuFunction); if (existingShortcut != null) { Instance.Shortcuts.Remove(existingShortcut); } Instance.Shortcuts.Add(menuFunctionShortcut); } if (menuItem.MenuItems != null && menuItem.MenuItems.Count > 0) { SaveShortcuts(menuItem.MenuItems); } } }
private void UpdateShortcuts(MainMenu.MenuItemCollection menuItems) { foreach (MenuItem menuItem in menuItems) { NuGenBaseMenuInformation menuInformation = menuItem.Tag as NuGenBaseMenuInformation; if (menuInformation != null) { MenuFunction menuFunction = menuInformation.MenuFunction; NuGenMenuFunctionShortcut menuFunctionShortcut = FindMenuFunctionShortcut(menuFunction); if (menuFunctionShortcut != null) { menuItem.Shortcut = menuFunctionShortcut.Shortcut; } } if (menuItem.MenuItems != null && menuItem.MenuItems.Count > 0) { UpdateShortcuts(menuItem.MenuItems); } } }