Esempio n. 1
0
        /* ***********************************************************
        *	BuildMenuTree (IList myMenu, MainMenu parentMenu)
        *  BuildMenuTree (IList myMenu, ContextMenu parentMenu, NiceMenuClickEvent yourClickFunction)
        * -----------------------------------------------------------
        *  build the new main menus and delete the old ones
        * ***********************************************************/
        private void BuildMenuTree(IList myMenu, MainMenu parentMenu, NiceMenuClickEvent yourClickFunction)
        {
            int numOldMenu = myMenu.Count;

            foreach (MenuItem myMenuItem in myMenu)
            {
                NiceMenu newMainMenu = new NiceMenu(myMenuItem.Text);
                parentMenu.MenuItems.Add(newMainMenu);

                if (myModifyNiceMenu[contModify] == null)
                {
                    myModifyNiceMenu[contModify] = newMainMenu;
                    contModify++;
                }

                if (myMenuItem.IsParent == true)
                {
                    IList mySubMenu = new Menu.MenuItemCollection(myMenuItem);
                    BuildMenuTree(mySubMenu, newMainMenu, yourClickFunction);
                }
            }
            // Now I have to delete the old menus
            for (int i = 0; i < numOldMenu; i++)
            {
                parentMenu.MenuItems.RemoveAt(0);
            }
        }
Esempio n. 2
0
        /* ****************************************************
        *	With the context menu I need the yourClickFunction
        *	because also the main menu shall be clickable !
        * ****************************************************/
        private void BuildMenuTree(IList myMenu, ContextMenu parentMenu, NiceMenuClickEvent yourClickFunction)
        {
            int numOldMenu = myMenu.Count;

            foreach (MenuItem myMenuItem in myMenu)
            {
                // Declaration
                NiceMenu newMainMenu;

                string IndexImage   = "";
                bool   AddMenuImage = false;

                /* If in the first two characters of the menu item text
                 * there is a number I set AddMenuImage = true and the
                 * IndexImage to get the icon in the image list control. */
                if (myMenuItem.Text.Length > 2)
                {
                    IndexImage = myMenuItem.Text.Substring(0, 2);
                    if (Char.IsNumber(IndexImage, 1) == true)
                    {
                        AddMenuImage = true;
                        // I have to delete first two characters
                        myMenuItem.Text = myMenuItem.Text.Substring(2);
                    }
                }
                if (AddMenuImage == true)
                {
                    newMainMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut, MenuImages.Images[Convert.ToInt32(IndexImage)]);
                }
                else
                {
                    newMainMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut);
                }

                parentMenu.MenuItems.Add(newMainMenu);

                if (myModifyContextNiceMenu[contModifyContext] == null)
                {
                    myModifyContextNiceMenu[contModifyContext] = newMainMenu;
                    contModifyContext++;
                }

                if (myMenuItem.IsParent == true)
                {
                    IList mySubMenu = new Menu.MenuItemCollection(myMenuItem);
                    BuildMenuTree(mySubMenu, newMainMenu, yourClickFunction);
                }
            }
            // Now I have to delete the old menus
            for (int i = 0; i < numOldMenu; i++)
            {
                parentMenu.MenuItems.RemoveAt(0);
            }
        }
Esempio n. 3
0
        /* ***********************************************************
        *		BuildMenuTree (IList myMenu, MenuItem parentMenu)
        * -----------------------------------------------------------
        *		build the new submenu item
        * ***********************************************************/
        private void BuildMenuTree(IList myMenu, MenuItem parentMenu, NiceMenuClickEvent yourClickFunction)
        {
            foreach (MenuItem myMenuItem in myMenu)
            {
                // Declaration
                NiceMenu newSubMenu;

                string IndexImage   = "";
                bool   AddMenuImage = false;

                /* If in the first two characters of the menu item text
                 * there is a number I set AddMenuImage = true and the
                 * IndexImage to get the icon in the image list control. */
                if (myMenuItem.Text.Length > 2)
                {
                    IndexImage = myMenuItem.Text.Substring(0, 2);
                    if (Char.IsNumber(IndexImage, 1) == true)
                    {
                        AddMenuImage = true;
                        // I have to delete first two characters
                        myMenuItem.Text = myMenuItem.Text.Substring(2);
                    }
                }
                if (AddMenuImage == true)
                {
                    newSubMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut, MenuImages.Images[Convert.ToInt32(IndexImage)]);
                }
                else
                {
                    newSubMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut);
                }
                // I add the new menu item to its parent
                parentMenu.MenuItems.Add(newSubMenu);
                // Checked
                if (myMenuItem.Checked == true)
                {
                    newSubMenu.Checked = true;
                }
                // RadioCheck
                if (myMenuItem.RadioCheck == true)
                {
                    if (myMenuItem.Checked == true)
                    {
                        newSubMenu.RadioCheck = true;
                    }
                }
                // DefaultItem
                if (myMenuItem.DefaultItem == true)
                {
                    newSubMenu.DefaultItem = true;
                }
                // Enabled
                if (myMenuItem.Enabled == false)
                {
                    newSubMenu.Enabled = false;
                }
                // If this menu item contains child menu items
                if (myMenuItem.IsParent == true)
                {
                    IList mySubMenu = new Menu.MenuItemCollection(myMenuItem);
                    BuildMenuTree(mySubMenu, newSubMenu, yourClickFunction);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// this function will update your Context Menu.
        /// </summary>
        public void UpdateMenu(ContextMenu yourOldMenu, NiceMenuClickEvent yourClickFunction)
        {
            IList myMenuList = new Menu.MenuItemCollection(yourOldMenu);

            BuildMenuTree(myMenuList, yourOldMenu, yourClickFunction);
        }
Esempio n. 5
0
        /* ****************************************************
         *	With the context menu I need the yourClickFunction
         *	because also the main menu shall be clickable !
         * ****************************************************/
        private void BuildMenuTree(IList myMenu, ContextMenu parentMenu, NiceMenuClickEvent yourClickFunction)
        {
            int numOldMenu = myMenu.Count;

            foreach (MenuItem myMenuItem in myMenu)
            {
                // Declaration
                NiceMenu newMainMenu;

                string IndexImage = "";
                bool AddMenuImage = false;

                /* If in the first two characters of the menu item text
                 * there is a number I set AddMenuImage = true and the
                 * IndexImage to get the icon in the image list control. */
                if (myMenuItem.Text.Length > 2)
                {
                    IndexImage = myMenuItem.Text.Substring(0,2);
                    if (Char.IsNumber(IndexImage,1) == true)
                    {
                        AddMenuImage = true;
                        // I have to delete first two characters
                        myMenuItem.Text = myMenuItem.Text.Substring(2);
                    }
                }
                if (AddMenuImage == true)
                    newMainMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut, MenuImages.Images[Convert.ToInt32(IndexImage)]);
                else
                    newMainMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut);

                parentMenu.MenuItems.Add(newMainMenu);

                if (myModifyContextNiceMenu[contModifyContext] == null)
                {
                    myModifyContextNiceMenu[contModifyContext] = newMainMenu;
                    contModifyContext ++;
                }

                if (myMenuItem.IsParent == true)
                {
                    IList mySubMenu = new Menu.MenuItemCollection(myMenuItem);
                    BuildMenuTree(mySubMenu, newMainMenu, yourClickFunction);
                }
            }
            // Now I have to delete the old menus
            for (int i=0;i<numOldMenu;i++)
            {   parentMenu.MenuItems.RemoveAt(0);   }
        }
Esempio n. 6
0
        /* ***********************************************************
         *	BuildMenuTree (IList myMenu, MainMenu parentMenu)
         *  BuildMenuTree (IList myMenu, ContextMenu parentMenu, NiceMenuClickEvent yourClickFunction)
         * -----------------------------------------------------------
         *  build the new main menus and delete the old ones
         * ***********************************************************/
        private void BuildMenuTree(IList myMenu, MainMenu parentMenu, NiceMenuClickEvent yourClickFunction)
        {
            int numOldMenu = myMenu.Count;

            foreach (MenuItem myMenuItem in myMenu)
            {
                NiceMenu newMainMenu = new NiceMenu(myMenuItem.Text);
                parentMenu.MenuItems.Add(newMainMenu);

                if (myModifyNiceMenu[contModify] == null)
                {
                    myModifyNiceMenu[contModify] = newMainMenu;
                    contModify ++;
                }

                if (myMenuItem.IsParent == true)
                {
                    IList mySubMenu = new Menu.MenuItemCollection(myMenuItem);
                    BuildMenuTree(mySubMenu, newMainMenu, yourClickFunction);
                }
            }
            // Now I have to delete the old menus
            for (int i=0;i<numOldMenu;i++)
            {   parentMenu.MenuItems.RemoveAt(0);   }
        }
Esempio n. 7
0
        /* ***********************************************************
         *		BuildMenuTree (IList myMenu, MenuItem parentMenu)
         * -----------------------------------------------------------
         *		build the new submenu item
         * ***********************************************************/
        private void BuildMenuTree(IList myMenu, MenuItem parentMenu, NiceMenuClickEvent yourClickFunction)
        {
            foreach (MenuItem myMenuItem in myMenu)
            {
                // Declaration
                NiceMenu newSubMenu;

                string IndexImage = "";
                bool AddMenuImage = false;

                /* If in the first two characters of the menu item text
                 * there is a number I set AddMenuImage = true and the
                 * IndexImage to get the icon in the image list control. */
                if (myMenuItem.Text.Length > 2)
                {
                    IndexImage = myMenuItem.Text.Substring(0,2);
                    if (Char.IsNumber(IndexImage,1) == true)
                    {
                        AddMenuImage = true;
                        // I have to delete first two characters
                        myMenuItem.Text = myMenuItem.Text.Substring(2);
                    }
                }
                if (AddMenuImage == true)
                    newSubMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut, MenuImages.Images[Convert.ToInt32(IndexImage)]);
                else
                    newSubMenu = new NiceMenu(myMenuItem.Text, new EventHandler(yourClickFunction), myMenuItem.Shortcut);
                // I add the new menu item to its parent
                parentMenu.MenuItems.Add(newSubMenu);
                // Checked
                if (myMenuItem.Checked == true) newSubMenu.Checked = true;
                // RadioCheck
                if (myMenuItem.RadioCheck == true)
                    if (myMenuItem.Checked == true) newSubMenu.RadioCheck = true;
                // DefaultItem
                if (myMenuItem.DefaultItem == true) newSubMenu.DefaultItem = true;
                // Enabled
                if (myMenuItem.Enabled == false) newSubMenu.Enabled = false;
                // If this menu item contains child menu items
                if (myMenuItem.IsParent == true)
                {
                    IList mySubMenu = new Menu.MenuItemCollection(myMenuItem);
                    BuildMenuTree(mySubMenu, newSubMenu, yourClickFunction);
                }
            }
        }
Esempio n. 8
0
 /// <summary>
 /// this function will update your Context Menu.
 /// </summary>
 public void UpdateMenu(ContextMenu yourOldMenu, NiceMenuClickEvent yourClickFunction)
 {
     IList myMenuList = new Menu.MenuItemCollection(yourOldMenu);
     BuildMenuTree(myMenuList, yourOldMenu, yourClickFunction);
 }