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); } } }
public int CompareTo(object obj) { int result = 0; if (obj == null) { result = 1; } else { NuGenMenuFunctionShortcut otherShortcut = obj as NuGenMenuFunctionShortcut; if (otherShortcut != null) { result = MenuFunction.CompareTo(otherShortcut.MenuFunction); if (result == 0) { result = Shortcut.CompareTo(otherShortcut.Shortcut); } } else { throw new ArgumentException("Incorrect argument type: " + obj.GetType().FullName, "obj"); } } return(result); }
private NuGenMenuFunctionShortcut FindMenuFunctionShortcut(MenuFunction menuFunction) { NuGenMenuFunctionShortcut result = null; int index = 0; while (result == null && index < Shortcuts.Count) { NuGenMenuFunctionShortcut menuFunctionShortcut = Shortcuts[index++]; if (menuFunctionShortcut.MenuFunction == menuFunction) { result = menuFunctionShortcut; } } return(result); }
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); } } }