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


C# Menu.Add方法代码示例

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


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

示例1: LoadMenus

 private void LoadMenus(Menu.MenuItemCollection items, IEnumerable<IPluginMenuItem> pluginMenu)
 {
     foreach (var pluginItem in pluginMenu)
     {
         var invokable = pluginItem as IPluginMenuInvokableItem;
         if (invokable != null)
         {
             var invokableHash = Guid.NewGuid().ToString();
             _form.Sc.Register(typeof(IInvokable), invokable.Invokable, invokableHash);
             items.Add(new MenuItem(invokable.Name, (sender, ev) => _form.Sc.GetInstance<IInvokable>(invokableHash).DoWork()));
             continue;
         }
         var submenu = pluginItem as IPluginSubMenuItem;
         if (submenu != null)
         {
             var item = new MenuItem(submenu.Name);
             items.Add(item);
             LoadMenus(item.MenuItems, submenu.Submenu);
             continue;
         }
         items.Add(new MenuItem(pluginItem.Name) { Enabled = false });
     }
 }
开发者ID:adziembor,项目名称:programowaniekomponentowe,代码行数:23,代码来源:FormPluginManager.cs

示例2: AddAttributesMenu

 private void AddAttributesMenu(Menu.MenuItemCollection mnuColl, EventHandler e)
 {
     IDictionaryEnumerator enumerator = this._attributes.GetEnumerator();
     while (enumerator.MoveNext())
     {
         string str = "";
         MenuItem item = new MenuItem(enumerator.Key.ToString() + str, e);
         mnuColl.Add(item);
     }
 }
开发者ID:ViniciusConsultor,项目名称:geansoft,代码行数:10,代码来源:MainForm.cs

示例3: AddMenu

		private MenuItem AddMenu(Menu.MenuItemCollection Parent,string Caption,EventHandler eh)
		{
			MenuItem NewItem=null;
			int i=-1;
			if (!allowRepeat)
			{
				i=Parent.Count;
				while (i-->0)
				{
					if (Parent[i].Text==Caption)
					{
						NewItem=Parent[i];
						break;
					}
				}
			}

			if (i==-1)//is allowRepeat or !allowRepeat but is new item 
			{
				NewItem=new MenuItem(Caption,eh);
				//	NewItem.Click+=eh;
				Parent.Add(NewItem);
			}
			MergeMenu(Parent.IndexOf(NewItem));
			return NewItem;
		}
开发者ID:Hza100,项目名称:subindex-mod,代码行数:26,代码来源:DropDownButton.cs

示例4: AddMenuItem

        /// <summary>
        /// Recursive add method to handle nesting of menu items.
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="mi"></param>
        private static void AddMenuItem(Menu.MenuItemCollection parent, SymbologyMenuItem mi)
        {
            MenuItem m;
            if (mi.Icon != null)
            {
                m = new IconMenuItem(mi.Name, mi.Icon, mi.ClickHandler);
            }
            else if (mi.Image != null)
            {
                m = new IconMenuItem(mi.Name, mi.Image, mi.ClickHandler);
            }
            else
            {
                m = new IconMenuItem(mi.Name, mi.ClickHandler);
            }

            parent.Add(m);
            foreach (SymbologyMenuItem child in mi.MenuItems)
            {
                AddMenuItem(m.MenuItems, child);
            }
        }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:27,代码来源:Legend.cs

示例5: cloneMenuItemRecursive

 /// <summary>
 /// メニューアイテムの階層を再帰的にコピーします
 /// </summary>
 /// <param name="dest"></param>
 /// <param name="src"></param>
 private void cloneMenuItemRecursive( Menu.MenuItemCollection dest, Menu.MenuItemCollection src ) {
     if ( src.Count > 0 ) {
         foreach ( MenuItem item in src ) {
             MenuItem clone = item.CloneMenu();
             cloneMenuItemRecursive( clone.MenuItems, item.MenuItems );
             dest.Add( clone );
         }
     }
 }
开发者ID:kixtarte,项目名称:cadencii,代码行数:14,代码来源:RebarBand.cs

示例6: AddMenuItemInSubmenu

        // Add dynamic menu item in a submenu. Parameter menuItems
        // contains existing menu items in the submenu.
        private void AddMenuItemInSubmenu(MenuItem menuItem,
           Menu.MenuItemCollection menuItems)
        {
            switch (_itemInsertMode)
            {
                case ItemInsertMode.Append:
                    if (_itemCount == _maxItems)
                    {
                        menuItems.RemoveAt(0);
                        _itemCount--;
                    }
                    menuItems.Add(menuItem);
                    break;

                case ItemInsertMode.Prepend:
                    if (_itemCount == _maxItems)
                    {
                        menuItems.RemoveAt(_maxItems - 1);
                        _itemCount--;
                    }
                    menuItems.Add(0, menuItem);
                    break;
                default:
                    break;
            }
            _itemCount++;
            _anchor.Enabled = true;
        }
开发者ID:erdincay,项目名称:checksum-tool,代码行数:30,代码来源:DynamicMenuMgr.cs

示例7: AddMenuItemInline

        // Add inline dynamic menu item. Parameter menuItems contains
        // existing inline dynamic menu items.
        private void AddMenuItemInline(MenuItem menuItem,
           Menu.MenuItemCollection menuItems)
        {
            int anchorIndex = _anchor.Index;
            switch (_itemInsertMode)
            {
                case ItemInsertMode.Append:
                    if (_itemCount == _maxItems)
                    {
                        menuItems.RemoveAt(anchorIndex + 1);
                        _itemCount--;
                    }
                    menuItems.Add(anchorIndex + _itemCount + 1, menuItem);
                    break;

                case ItemInsertMode.Prepend:
                    if (_itemCount == _maxItems)
                    {
                        menuItems.RemoveAt(anchorIndex + _maxItems);
                        _itemCount--;
                    }
                    menuItems.Add(anchorIndex + 1, menuItem);
                    break;
                default:
                    break;
            }
            _itemCount++;
            _separator.Visible = true;
        }
开发者ID:erdincay,项目名称:checksum-tool,代码行数:31,代码来源:DynamicMenuMgr.cs

示例8: Recurse

        public void Recurse(String aRoot, Menu.MenuItemCollection aParentItems)
        {
            IEnumerator items;
              mDataStore.GetElements(aRoot, out items);
              items.Reset();

              MenuItem item;

              while (items.MoveNext())
              {
            // |id| is the item's unique identifier within the DataStore.
            // The handling code can use this to probe for more information
            // about the selected item.
            CommandTarget current = items.Current as CommandTarget;
            if (current != null)
            {
              String id = current.Data as String;

              int idKey = id.GetHashCode();

              if (!mMenus.ContainsKey(idKey))
              {
            item = new ManticoreMenuItem(current.Label,
                                         new EventHandler(OnCommandInternal),
                                         "bookmarks-item", id);
            if (aRoot != Root)
              aParentItems.Add(item);
            else
              aParentItems.Add(mInsertionPoint++, item);
            mMenus.Add(id.GetHashCode(), item);

            if (current.IsContainer)
              Recurse(current.Data as String, item.MenuItems);
              }
            }
              }

              ResetInsertionPoint();
        }
开发者ID:nfan,项目名称:Jaxer,代码行数:39,代码来源:MenuBuilder.cs


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