示例#1
0
        static IList CreateToolBarItems(IEnumerable descriptors)
        {
            ArrayList result = new ArrayList();

            foreach (ToolbarItemDescriptor descriptor in descriptors)
            {
                object item = CreateToolBarItemFromDescriptor(descriptor);
                if (item is IMenuItemBuilder)
                {
                    IMenuItemBuilder submenuBuilder = (IMenuItemBuilder)item;
                    result.AddRange(submenuBuilder.BuildItems(descriptor.Codon, descriptor.Caller));
                }
                else
                {
                    result.Add(item);
                }
            }
            return(result);
        }
示例#2
0
        static IList CreateToolBarItems(UIElement inputBindingOwner, IEnumerable descriptors)
        {
            ArrayList result = new ArrayList();

            foreach (ToolbarItemDescriptor descriptor in descriptors)
            {
                object           item           = CreateToolBarItemFromDescriptor(inputBindingOwner, descriptor);
                IMenuItemBuilder submenuBuilder = item as IMenuItemBuilder;
                if (submenuBuilder != null)
                {
                    result.AddRange(submenuBuilder.BuildItems(descriptor.Codon, descriptor.Caller));
                }
                else
                {
                    result.Add(item);
                }
            }
            return(result);
        }
示例#3
0
 static void AddItemsToMenu(ToolStripItemCollection collection, IEnumerable <MenuItemDescriptor> descriptors)
 {
     foreach (MenuItemDescriptor descriptor in descriptors)
     {
         object item = CreateMenuItemFromDescriptor(descriptor);
         if (item is ToolStripItem)
         {
             collection.Add((ToolStripItem)item);
             if (item is IStatusUpdate)
             {
                 ((IStatusUpdate)item).UpdateStatus();
             }
         }
         else
         {
             IMenuItemBuilder submenuBuilder = (IMenuItemBuilder)item;
             collection.AddRange(submenuBuilder.BuildItems(descriptor.Codon, descriptor.Parameter).Cast <ToolStripItem>().ToArray());
         }
     }
 }
示例#4
0
 void CreateDropDownItems()
 {
     DropDownItems.Clear();
     foreach (object item in subItems)
     {
         if (item is ToolStripItem)
         {
             DropDownItems.Add((ToolStripItem)item);
             if (item is IStatusUpdate)
             {
                 ((IStatusUpdate)item).UpdateStatus();
                 ((IStatusUpdate)item).UpdateText();
             }
         }
         else
         {
             IMenuItemBuilder submenuBuilder = (IMenuItemBuilder)item;
             DropDownItems.AddRange(submenuBuilder.BuildItems(codon, caller).Cast <ToolStripItem>().ToArray());
         }
     }
 }
        void CreateDropDownItems()
        {
            // let's assume that if a menuBuilder exists,
            // as in the Search Results panel or the Class
            // Browser toolbar, it will handle this step.
            if (menuBuilder != null)
            {
                return;
            }

            // also, let's prevent a null exception
            // in the event that there are no subitems
            if (subItems == null || subItems.Count == 0)
            {
                return;
            }

            DropDownItems.Clear();
            foreach (object item in subItems)
            {
                if (item is ToolStripItem)
                {
                    DropDownItems.Add((ToolStripItem)item);
                    if (item is IStatusUpdate)
                    {
                        ((IStatusUpdate)item).UpdateStatus();
                        ((IStatusUpdate)item).UpdateText();
                    }
                }
                else
                {
                    IMenuItemBuilder submenuBuilder = (IMenuItemBuilder)item;
                    DropDownItems.AddRange(submenuBuilder.BuildItems(codon, caller).Cast <ToolStripItem>().ToArray());
                }
            }
        }
        public static ToolStripItem[] CreateToolStripItems(object owner, AddInTreeNode treeNode)
        {
            if (treeNode == null)
            {
                return(new ToolStripItem[0]);
            }
            List <ToolStripItem> collection = new List <ToolStripItem>();

            foreach (ToolbarItemDescriptor descriptor in treeNode.BuildChildItems <ToolbarItemDescriptor>(owner))
            {
                object item = CreateToolbarItemFromDescriptor(descriptor);
                if (item is ToolStripItem)
                {
                    collection.Add((ToolStripItem)item);
                }
                else if (item is IMenuItemBuilder)
                {
                    IMenuItemBuilder submenuBuilder = (IMenuItemBuilder)item;
                    collection.AddRange(submenuBuilder.BuildItems(descriptor.Codon, owner).Cast <ToolStripItem>().ToArray());
                }
            }

            return(collection.ToArray());
        }
 public IEnumerable <object> BuildItems()
 {
     return(builder.BuildItems(codon, caller));
 }
示例#8
0
 public ICollection BuildItems()
 {
     return(builder.BuildItems(codon, caller));
 }
        private static List <SearchItem> HandleMenuCodon(SearchPathDescriptor descriptor, Codon codon, string path, List <string> pathChain)
        {
            List <SearchItem> result = new List <SearchItem>();

            if (codon.Name != "MenuItem")
            {
                return(result);
            }

            List <string> nextPathChain = new List <string>(pathChain);
            string        nextPath      = string.Format("{0}/{1}", path, codon.Id);

            if (codon.Properties.Contains("type") && codon.Properties["type"] == "Menu")
            {
                nextPathChain.Add(AddNextPathChainString(codon));
                if (AddInTree.ExistsTreeNode(nextPath))
                {
                    AddInTreeNode node = AddInTree.GetTreeNode(nextPath);
                    foreach (Codon innerCodon in node.Codons)
                    {
                        result.AddRange(HandleMenuCodon(descriptor, innerCodon, nextPath, nextPathChain));
                    }
                }
            }

            if (!codon.Properties.Contains("type") || (codon.Properties.Contains("type") && (codon.Properties["type"] == "Item" || codon.Properties["type"] == "Command")))
            {
                HandleItemMenuType(descriptor, codon, nextPath, nextPathChain, result);
            }

            if (codon.Properties.Contains("type") && codon.Properties["type"] == "Builder")
            {
                try
                {
                    IMenuItemBuilder builder = codon.AddIn.CreateObject(codon.Properties["class"]) as IMenuItemBuilder;
                    if (builder == null)
                    {
                        return(result);
                    }
                    ICollection collection = builder.BuildItems(codon, null);
                    foreach (MenuItem menuItem in collection)
                    {
                        SearchItem item = GenerateSearchItem(descriptor, codon, nextPath, nextPathChain);
                        item.Label            = menuItem.Header.ToString();
                        item.Command          = menuItem.Command;
                        item.CommandParameter = menuItem.CommandParameter;
                        item.Shortcut         = menuItem.InputGestureText;

                        if (String.IsNullOrWhiteSpace(item.CommandTypeString) && item.Command == null)
                        {
                            continue;
                        }

                        item.Id = path + "/" + item.Label;
                        result.Add(item);
                    }
                }
                catch (Exception ex)
                {
                    LoggingService.Warn(String.Format("Could not load search item from builder at {0} - {1}", codon.Id, codon.AddIn.FileName), ex);
                }
            }
            return(result);
        }