Example #1
0
        /* Shamelessly borrowed from Jim Durkin at Durkin Computing */
        /* Add a menu item under TOOLS */
        private void addMenuItem(string urn, string menuText, Act.UI.CommandHandler handler, Act.UI.ActApplication actApplication, int position, bool hasSeperator, System.Drawing.Icon ico)
        {
            // Check if the connected menu exists
            if (actApplication.Explorer.CommandBarCollection["Connected Menus"] == null)
            {
                return;
            }
            // Add a menu item that delegates back to us
            if (menuItemExists(urn, actApplication) == true)
            {
                removeMenuItem(urn, actApplication);
            }
            try
            {
                CommandBarControl parentMenu = actApplication.Explorer.CommandBarCollection["Connected Menus"].ControlCollection[getParentControlURN(urn)];
                CommandBarButton  newMenu    = new CommandBarButton(menuText, menuText, null, urn, null, null);
                actApplication.RegisterCommand(urn, handler, RegisterType.Shell);

                // Are we displaying an icon?
                if (ico != null)
                {
                    newMenu.Icon         = ico;
                    newMenu.DisplayStyle = CommandBarControl.ItemDisplayStyle.ImageAndText;
                }
                else
                {
                    newMenu.DisplayStyle = CommandBarControl.ItemDisplayStyle.TextOnly;
                }

                // If this is the first add-on under this plugin, add the seperator
                if (parentMenu == null)
                {
                    newMenu.HasSeparator = true;
                }
                else
                {
                    newMenu.HasSeparator = hasSeperator;
                }

                if (position == 0)
                {
                    parentMenu.AddSubItem(newMenu);
                }
                else
                {
                    parentMenu.AddSubItem(newMenu, position);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Example #2
0
 private void AddMenuItem(string urn, string text, Act.UI.CommandHandler Handler)
 {
     try
     {
         if (MenuItemExists(urn) == true)
         {
             RemoveMenuItem(urn);
         }
         Act.UI.Core.CommandBarControl parentMenu = this.application.Explorer.CommandBarCollection[CONNECTED_MENUBAR].ControlCollection[GetParentControlURN(urn)];
         Act.UI.Core.CommandBarButton  newMenu    = new Act.UI.Core.CommandBarButton(text, text, null, urn, null, null);
         newMenu.DisplayStyle = Act.UI.Core.CommandBarControl.ItemDisplayStyle.TextOnly;
         this.application.RegisterCommand(urn, new Act.UI.CommandHandler(Handler), Act.UI.RegisterType.Shell);
         parentMenu.AddSubItem(newMenu);
     }
     catch { }
 }