Exemple #1
0
        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);
                }
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
                }
            }
        }
		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);
				}
			}
		}