예제 #1
0
        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);
                }
            }
        }
예제 #2
0
 public void AddEntry(string Category, IMenuEntry Entry)
 {
     if (!Menu.ContainsKey(Category))
     {
         AddCategory(Category);
     }
     Menu[Category].Add(Entry);
 }
예제 #3
0
 /// <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;
         }
     }
 }
예제 #4
0
        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);
        }
예제 #5
0
 protected void AddMenuEntry(IMenuEntry menuEntry)
 {
     menuEntry.LoadContent(this);
     MenuEntries.AddItem(menuEntry);
 }
예제 #6
0
파일: BaseMenu.cs 프로젝트: pleb/Tank
 public bool AddEntry(IMenuEntry entry)
 {
     return MenuEntries.Add(entry);
 }