Esempio n. 1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Builds a menu collection for the specified sidebar tab. The collection contains a
        /// menu item for each button plus a configure item at the end.
        /// </summary>
        /// <param name="tab">given sidebar tab</param>
        /// <returns>array of menu items from sidebar tab</returns>
        /// ------------------------------------------------------------------------------------
        public MenuItem[] BuildMenusForSideBarTab(SideBarTab tab)
        {
            List <MenuItem> mnuList = new List <MenuItem>();

            // Create a menu item for each button on the sidebar tab.
            foreach (SideBarButton button in tab.Buttons)
            {
                MenuItem menuItem = new MenuItem(button.Text);
                MenuExtender.AddMenuItem(menuItem);
                MenuExtender.SetTag(menuItem, button);
                MenuExtender.SetCommandId(menuItem, "SideBarButtonMenu");
                mnuList.Add(menuItem);
            }

            // Create the separator
            MenuItem mnuSepr = new MenuItem("-");

            MenuExtender.AddMenuItem(mnuSepr);
            MenuExtender.SetCommandId(mnuSepr, tab.ConfigureMenuCommandId);
            MenuExtender.SetTag(mnuSepr, tab);
            mnuList.Add(mnuSepr);

            // Create the configure menu item.
            MenuItem cfgMenuItem = new MenuItem(tab.ConfigureMenuText);

            MenuExtender.AddMenuItem(cfgMenuItem);
            MenuExtender.SetCommandId(cfgMenuItem, tab.ConfigureMenuCommandId);
            MenuExtender.SetImageList(cfgMenuItem, tab.ConfigureMenuImageList);
            MenuExtender.SetImageIndex(cfgMenuItem, tab.ConfigureMenuImageIndex);
            MenuExtender.SetTag(cfgMenuItem, tab);
            mnuList.Add(cfgMenuItem);

            return(mnuList.ToArray());
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates a menu for each tab and adds them to the spcecified view menu.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void BuildViewMenu()
        {
            if (ViewMenu == null || sideBarFw == null || sideBarFw.Tabs.Count == 0 ||
                MenuExtender == null)
            {
                return;
            }

            // If necessary, remove existing sidebar menu items from the view menu.
            if (m_mnuViewCollection != null)
            {
                RemoveOurViewMenuItems();
            }

            List <MenuItem> mnuList = new List <MenuItem>();

            // Go through each tab and add a menu with sub menus off the specified view menu.
            int position = 0;

            foreach (SideBarTab tab in sideBarFw.Tabs)
            {
                MenuItem menuItem = new MenuItem(tab.Title);
                mnuList.Add(menuItem);

                menuItem.MenuItems.AddRange(BuildMenusForSideBarTab(tab));
                ViewMenu.MenuItems.Add(position, menuItem);
                MenuExtender.AddMenuItem(menuItem);
                position++;
            }

            // Save the collection of meun items we added to the view menu so we can remove
            // them later if the number of buttons or tabs in the sidebar changes.
            if (mnuList.Count > 0)
            {
                m_mnuViewCollection = mnuList.ToArray();
            }
        }