当前位置: 首页>>代码示例>>C#>>正文


C# ToolStripItemCollection.Add方法代码示例

本文整理汇总了C#中System.Windows.Forms.ToolStripItemCollection.Add方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItemCollection.Add方法的具体用法?C# ToolStripItemCollection.Add怎么用?C# ToolStripItemCollection.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ToolStripItemCollection的用法示例。


在下文中一共展示了ToolStripItemCollection.Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildMenu

 public static void BuildMenu(ToolStripItemCollection items, IEnumerable<IEditorScript> scripts, Action<IEditorScript> callback)
 {
   foreach (var script in scripts)
   {
     if (script.Name.StartsWith("----"))
     {
       items.Add(new ToolStripSeparator());
     }
     else if (script.Children.Any())
     {
       var item = new ToolStripMenuItem(script.Name);
       BuildMenu(item.DropDownItems, script.Children, callback);
       items.Add(item);
     }
     else
     {
       items.Add(new ToolStripMenuItem(script.Name, null, (s, ev) =>
       {
         var query = script.Script; // Trigger execution
         if (!string.IsNullOrEmpty(query))
         {
           callback(script);
         }
       }));
     }
   }
 }
开发者ID:cornelius90,项目名称:InnovatorAdmin,代码行数:27,代码来源:EditorScript.cs

示例2: BuildMenu

 public static void BuildMenu(ToolStripItemCollection items, IEnumerable<IEditorScript> scripts, Func<IEditorScript, Task> callback)
 {
   foreach (var script in scripts)
   {
     if (script.Name.StartsWith("----"))
     {
       items.Add(new ToolStripSeparator());
     }
     else if (script.Children.Any())
     {
       var item = new ToolStripMenuItem(script.Name);
       BuildMenu(item.DropDownItems, script.Children, callback);
       items.Add(item);
     }
     else
     {
       items.Add(new ToolStripMenuItem(script.Name, null, async (s, ev) =>
       {
         var text = await script.GetScript(); // Trigger execution
         if (!string.IsNullOrEmpty(text))
         {
           await callback(script);
         }
       }));
     }
   }
 }
开发者ID:rneuber1,项目名称:InnovatorAdmin,代码行数:27,代码来源:EditorScript.cs

示例3: FillMenuItems

 private static void FillMenuItems(List<MySQL.Base.MenuItem> itemsBE, ToolStripItemCollection itemsFE)
 {
     foreach (MySQL.Base.MenuItem itemBE in itemsBE)
       {
     switch (itemBE.get_type())
     {
       case MySQL.Base.MenuItemType.MenuSeparator:
     {
       itemsFE.Add(new ToolStripSeparator());
     }
     break;
       default:
     {
       ToolStripMenuItem itemFE = new ToolStripMenuItem();
       itemFE.Tag = itemBE.get_name();
       itemFE.Text = itemBE.get_caption();
       itemFE.Enabled = itemBE.get_enabled();
       if (MySQL.Base.MenuItemType.MenuCascade == itemBE.get_type())
       {
         FillMenuItems(itemBE.get_subitems(), itemFE.DropDownItems);
       }
       else
       {
         itemFE.Click += new EventHandler(OnMenuItemClick);
       }
       itemsFE.Add(itemFE);
     }
     break;
     }
       }
 }
开发者ID:abibell,项目名称:mysql-workbench,代码行数:31,代码来源:WorkbenchToolbarManager.cs

示例4: PopulateItems

        private static void PopulateItems(ToolStripItemCollection items, IEnumerable<CommandMenuGroup> groups, CommandRegistry registry)
        {
            List<CommandMenuGroup> groupList = groups as List<CommandMenuGroup>;
            if (groupList == null)
                groupList = new List<CommandMenuGroup>(groups);

            foreach (CommandMenuGroup group in groupList) {
                if (group != groupList[0])
                    items.Add(new ToolStripSeparator());

                foreach (CommandMenuEntry entry in group) {
                    if (entry.SubMenu != null)
                        items.Add(BuildToolStripMenu(entry.SubMenu, registry));
                    else {
                        CommandRecord record = registry.Lookup(entry.Key);
                        if (record != null) {
                            ToolStripMenuItem menuItem = new ToolStripMenuItem() {
                                Tag = entry.Key,
                                Text = record.DisplayName,
                                Image = record.Image,
                                ShortcutKeys = record.Shortcut,
                                ShortcutKeyDisplayString = record.ShortcutDisplay,
                                ToolTipText = record.Description,
                            };

                            items.Add(menuItem);
                        }
                    }
                }
            }
        }
开发者ID:JuliaABurch,项目名称:Treefrog,代码行数:31,代码来源:CommandRegistry.cs

示例5: FillToolItems

 /// <summary>
 /// Fills items to the specified tool strip item collection
 /// </summary>
 public static void FillToolItems(ToolStripItemCollection items, XmlNode node)
 {
     switch (node.Name)
     {
         case "separator":
             items.Add(GetSeparator(node));
             break;
         case "button":
             items.Add(GetButtonItem(node));
             break;
     }
 }
开发者ID:thecocce,项目名称:flashdevelop,代码行数:15,代码来源:StripBarManager.cs

示例6: Apply

        /// <summary>
        /// Add the contents of this MergableMenu to a CommandBarMenu
        /// </summary>
        /// <param name="menu"></param>
        public void Apply(ToolStripItemCollection items)
        {
            int lastGroup = -1;

            foreach (MergableItem item in List)
            {
                if (item.Group != lastGroup && lastGroup > -1)
                    items.Add(new ToolStripSeparator());

                items.Add(item.Apply());
                lastGroup = item.Group;
            }
        }
开发者ID:ImaginationSydney,项目名称:flashdevelop,代码行数:17,代码来源:MergableMenu.cs

示例7: CreateButton

 private static void CreateButton(ToolStripItemCollection items, string title, EventHandler handler,
     Workitem item)
 {
     var button = new ToolStripMenuItem(title, null, handler);
     items.Add(button);
     button.Tag = item;
 }
开发者ID:versionone,项目名称:V1TaskManager,代码行数:7,代码来源:MainForm.cs

示例8: Sort

        public static void Sort(ToolStripItemCollection collection, IComparer comparer)
        {
            ArrayList items = new ArrayList(collection);
            items.Sort(comparer);

            collection.Clear();
            foreach (object itm in items)
                collection.Add(itm as ToolStripItem);
        }
开发者ID:isakkarlsson,项目名称:iphonebackupbrowser-enhanced,代码行数:9,代码来源:Util.cs

示例9: GetNamedChild

		ToolStripMenuItem GetNamedChild(ToolStripItemCollection container, string name)
		{
			foreach (ToolStripMenuItem item in container)
				if (name == item.Text)
					return item as ToolStripMenuItem;

			ToolStripMenuItem newItem = new ToolStripMenuItem(name);
			container.Add(newItem);

			return newItem;
		}
开发者ID:chrisforbes,项目名称:Ijw.Framework,代码行数:11,代码来源:MenuBuilder.cs

示例10: InsertTemplate

        /// <summary>
        /// Add template to a specific list
        /// </summary>
        /// <param name="collection">List, where to add template</param>
        /// <param name="template">Template to add</param>
        /// <param name="onClick">Click handlers</param>
        public static void InsertTemplate(ToolStripItemCollection collection, MoneyDataSet.TransactionTemplatesRow template, EventHandler onClick)
        {
            Image image = null;
            if (template.ID.Equals(MoneyDataSet.IDs.TransactionTemplates.Transfer))
            {
                image = Properties.Resources.table_relationship;
            }
            ToolStripMenuItem tsmiFromTemplate = new ToolStripMenuItem(template.Title, image, onClick);
            tsmiFromTemplate.Tag = template;
            tsmiFromTemplate.ToolTipText = template.Message;

            collection.Add(tsmiFromTemplate);
        }
开发者ID:e-Deniska,项目名称:easyMoney,代码行数:19,代码来源:FormHelper.cs

示例11: AddItemsToMenu

		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());
				}
			}
		}
开发者ID:Paccc,项目名称:SharpDevelop,代码行数:14,代码来源:MenuService.cs

示例12: FillMenuItems

 /// <summary>
 /// Fills items to the specified tool strip item collection
 /// </summary>
 public static void FillMenuItems(ToolStripItemCollection items, XmlNode node)
 {
     switch (node.Name)
     {
         case "menu" :
             String name = XmlHelper.GetAttribute(node, "name");
             if (name == "SyntaxMenu") node.InnerXml = GetSyntaxMenuXml();
             items.Add(GetMenu(node));
             break;
         case "separator" :
             items.Add(GetSeparator(node));
             break;
         case "button" :
             ToolStripMenuItem menu = GetMenuItem(node);
             items.Add(menu); // Add menu first to get the id correct
             String id = GetMenuItemId(menu);
             if (id.IndexOf('.') > -1)
             {
                 Globals.MainForm.RegisterShortcutItem(GetMenuItemId(menu), menu);
             }
             break;
     }
 }
开发者ID:thecocce,项目名称:flashdevelop,代码行数:26,代码来源:StripBarManager.cs

示例13: AddItemsToMenu

		public static void AddItemsToMenu(ToolStripItemCollection collection, object owner, string addInTreePath)
		{
			ArrayList buildItems = AddInTree.GetTreeNode(addInTreePath).BuildChildItems(owner);
			foreach (object item in buildItems) {
				if (item is ToolStripItem) {
					collection.Add((ToolStripItem)item);
					if (item is IStatusUpdate)
						((IStatusUpdate)item).UpdateStatus();
				} else {
					ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
					collection.AddRange(submenuBuilder.BuildSubmenu(null, owner));
				}
			}
		}
开发者ID:stophun,项目名称:fdotoolbox,代码行数:14,代码来源:MenuService.cs

示例14: AddItemsToMenu

		static void AddItemsToMenu(ToolStripItemCollection collection, List<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 {
					ISubmenuBuilder submenuBuilder = (ISubmenuBuilder)item;
					collection.AddRange(submenuBuilder.BuildSubmenu(descriptor.Codon, descriptor.Caller));
				}
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:14,代码来源:MenuService.cs

示例15: addSaveSlots

 private void addSaveSlots(ToolStripItemCollection items)
 {
     //test(mnuSaveSlots.DropDownItems);
     ToolStripMenuItem mnuAll = new ToolStripMenuItem();
     // 
     // mnuAll
     // 
     mnuAll.Name = "mnuAll";
     mnuAll.Size = new System.Drawing.Size(152, 22);
     mnuAll.Text = "All";
     mnuAll.Click += new EventHandler(this.mnuAll_Click);
     items.Add(mnuAll);
     
     for (int i = 1; i <= 20; i++)
     {
         ToolStripMenuItem mnuSlot;
         mnuSlot = new ToolStripMenuItem();
         mnuSlot.Name = "mnuSlot" + i;
         mnuSlot.Size = new System.Drawing.Size(152, 22);
         mnuSlot.Text = "Slot " + i;
         mnuSlot.Click += new System.EventHandler(this.mnuSlot_Click);
         items.Add(mnuSlot);
     }
 }
开发者ID:merttas077,项目名称:muaopenheroselect,代码行数:24,代码来源:SaveSlots.cs


注:本文中的System.Windows.Forms.ToolStripItemCollection.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。