本文整理汇总了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 });
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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 );
}
}
}
示例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;
}
示例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;
}
示例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();
}