private static void ProcessConfigItem(WorkItem workItem, MenuItemElement menuItem)
        {
            BarItem uiMenuItem = menuItem.ToMenuItem();

            foreach (string site in menuItem.Site.Split(new char[] { ';' }))
            {
                // this has not been modified to handle different uiElement types
                // if a siteType contains a different uiElement type the conditional
                // will fail and the uiElement item won't be added to the system.
                if (workItem.UIExtensionSites.Contains(site))
                {
                    workItem.UIExtensionSites[site].Add(uiMenuItem);
                }
            }

            if (menuItem.Register)
            {
                workItem.UIExtensionSites.RegisterSite(menuItem.RegistrationSite, uiMenuItem);
            }

            if (!String.IsNullOrEmpty(menuItem.CommandName))
            {
                workItem.Commands[menuItem.CommandName].AddInvoker(uiMenuItem, "ItemClick");
            }
        }
 private static void ProcessConfigItem(WorkItem workItem, MenuItemElement menuItem)
 {
     if (menuItem.Register)
     {
         RibbonPageGroup ribbonGroup = new RibbonPageGroup(menuItem.Label);
         workItem.UIExtensionSites[ExtensionSiteNames.MainMenu].Add <RibbonPageGroup>(ribbonGroup);
         workItem.UIExtensionSites.RegisterSite(menuItem.RegistrationSite, ribbonGroup);
     }
     else
     {
         foreach (string siteAndType in menuItem.Site.Split(new char[] { ';' }))
         {
             BarItem      uiMenuItem = null;
             SimpleButton uiButton   = null;
             string       site       = siteAndType;
             if (siteAndType.Contains("="))
             {
                 site = InstantiateNonBarItemUiElement(workItem, menuItem, siteAndType, ref uiButton);
             }
             else if (workItem.UIExtensionSites.Contains(site))
             {
                 InstantiateBarItemUiElement(workItem, menuItem, ref uiMenuItem, site);
             }
         }
     }
 }
        private static string InstantiateNonBarItemUiElement(WorkItem workItem,
                                                             MenuItemElement menuItem, string siteAndType, ref SimpleButton uiButton)
        {
            string site;

            site = siteAndType.Substring(0, siteAndType.IndexOf('='));
            if (workItem.UIExtensionSites.Contains(site))
            {
                string type = siteAndType.Substring(siteAndType.IndexOf('=') + 1);
                if (type != "SimpleButton")
                {
                    throw new Exception("Unknown UI element type in configuration file.");
                }
                if (uiButton == null)
                {
                    uiButton = new SimpleButton();
                    // OK. I'm abusing the system here to change a command into
                    // an event. I would not do this in anything other than a demo.
                    uiButton.Tag   = menuItem.CommandName + "Event";
                    uiButton.Text  = menuItem.Label;
                    uiButton.Image = MenuItemElement.GetGlyph(menuItem.Glyph);
                }
                workItem.UIExtensionSites[site].Add(uiButton);
            }
            return(site);
        }
 private static void InstantiateBarItemUiElement(WorkItem workItem,
                                                 MenuItemElement menuItem, ref BarItem uiMenuItem, string site)
 {
     if (uiMenuItem == null)
     {
         uiMenuItem = menuItem.ToMenuItem();
         if (!String.IsNullOrEmpty(menuItem.CommandName))
         {
             workItem.Commands[menuItem.CommandName].AddInvoker(uiMenuItem, "ItemClick");
         }
     }
     workItem.UIExtensionSites[site].Add(uiMenuItem);
 }
        protected override object GetElementKey(ConfigurationElement element)
        {
            MenuItemElement e = (MenuItemElement)element;

            return(e.ID);
        }