private void CreateSubMenu(ToolStripItemCollection parentItems, IMenuEntry parentMenuItem) { bool separatorPending = false; foreach (IMenuEntry mi in parentMenuItem) { if (mi is MenuSeparator) { separatorPending = true; } else { if (separatorPending) { parentItems.Add(new ToolStripSeparator()); separatorPending = false; } var tsmi = new ToolStripMenuItem(mi.Name); tsmi.Tag = mi; tsmi.Click += MenuItemClickedCB; tsmi.ShortcutKeys = mi.ShortcutKeys; tsmi.Enabled = mi.Enabled; parentItems.Add(tsmi); //recursively add downtree menus CreateSubMenu(tsmi.DropDownItems, mi); } } }
public void AddEntry(string Category, IMenuEntry Entry) { if (!Menu.ContainsKey(Category)) { AddCategory(Category); } Menu[Category].Add(Entry); }
/// <summary> /// Remove a menu entry from the menu /// </summary> /// <param name="entry"></param> protected void RemoveMenuEntry(IMenuEntry entry) { //try to remove the entry from the list if (MenuEntries.RemoveItem(entry)) { //set the selected item if needed if (SelectedIndex >= MenuEntries.Items.Count) { SelectedIndex = MenuEntries.Items.Count - 1; } } }
private IMenuEntry FindMenuEntryByKeyData(IMenuEntry parent, Keys keyData) { if (parent.ShortcutKeys == keyData) { return(parent); } foreach (var entry in parent) { var result = FindMenuEntryByKeyData(entry, keyData); if (result != null) { return(result); } } return(null); }
protected void AddMenuEntry(IMenuEntry menuEntry) { menuEntry.LoadContent(this); MenuEntries.AddItem(menuEntry); }
public bool AddEntry(IMenuEntry entry) { return MenuEntries.Add(entry); }