コード例 #1
0
        /// <summary>
        /// Finds the tool or menu strip items by name or text
        /// </summary>
        public static List <ToolStripItem> FindMenuItems(String name)
        {
            List <ToolStripItem> found = new List <ToolStripItem>();

            for (Int32 i = 0; i < Items.Count; i++)
            {
                ToolStripItem item = Items[i];
                if (item.Name == name)
                {
                    found.Add(item);
                }
            }
            ShortcutItem item2 = ShortcutManager.GetRegisteredItem(name);

            if (item2 != null)
            {
                found.Add(item2.Item);
            }
            ToolStripItem item3 = ShortcutManager.GetSecondaryItem(name);

            if (item3 != null)
            {
                found.Add(item3);
            }
            return(found);
        }
コード例 #2
0
        /// <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 && ShortcutManager.GetRegisteredItem(id) == null)
                {
                    ShortcutManager.RegisterItem(id, menu);
                }
                else
                {
                    ShortcutManager.RegisterSecondaryItem(menu);
                }
                break;
            }
        }
コード例 #3
0
        /// <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":
                ToolStripItem button = GetButtonItem(node);
                items.Add(button);     // Add button first to get the id correct
                ShortcutManager.RegisterSecondaryItem(button);
                break;
            }
        }
コード例 #4
0
ファイル: ShortcutManager.cs プロジェクト: benny-yau/.NET-RCP
 /// <summary>
 /// Applies all shortcuts to the items
 /// </summary>
 public static void ApplyAllShortcuts()
 {
     ShortcutManager.UpdateAllShortcuts();
     foreach (ShortcutItem item in RegisteredItems)
     {
         if (item.Item != null)
         {
             item.Item.ShortcutKeys = Keys.None;
             item.Item.ShortcutKeys = item.Custom;
         }
         else if (item.Default != item.Custom)
         {
             DataEvent de = new DataEvent(EventType.Shortcut, item.Id, item.Custom);
             EventManager.DispatchEvent(Globals.MainForm, de);
         }
     }
 }
コード例 #5
0
        /// <summary>
        /// Finds the tool or menu strip item by name or text
        /// </summary>
        public static ToolStripItem FindMenuItem(String name)
        {
            for (Int32 i = 0; i < Items.Count; i++)
            {
                ToolStripItem item = Items[i];
                if (item.Name == name)
                {
                    return(item);
                }
            }
            ShortcutItem item2 = ShortcutManager.GetRegisteredItem(name);

            if (item2 != null)
            {
                return(item2.Item);
            }
            ToolStripItem item3 = ShortcutManager.GetSecondaryItem(name);

            return(item3);
        }
コード例 #6
0
 /// <summary>
 /// Applies all shortcuts to the items
 /// </summary>
 public static void ApplyAllShortcuts()
 {
     ShortcutManager.UpdateAllShortcuts();
     foreach (ShortcutItem item in RegisteredItems)
     {
         if (item.Item != null)
         {
             item.Item.ShortcutKeys = Keys.None;
             item.Item.ShortcutKeys = item.Custom;
         }
         else if (item.Default != item.Custom)
         {
             ScintillaControl.UpdateShortcut(item.Id, item.Custom);
             DataEvent de = new DataEvent(EventType.Shortcut, item.Id, item.Custom);
             EventManager.DispatchEvent(Globals.MainForm, de);
         }
     }
     foreach (ToolStripItem button in SecondaryItems)
     {
         ApplySecondaryShortcut(button);
     }
 }