Ejemplo n.º 1
0
        private static void PopulateItems(ToolStripItemCollection items, IEnumerable <CommandMenuGroup> groups, CommandRegistry registry)
        {
            List <CommandMenuGroup> groupList = groups as List <CommandMenuGroup>;

            if (groupList == null)
            {
                groupList = new List <CommandMenuGroup>(groups);
            }

            foreach (CommandMenuGroup group in groupList)
            {
                if (group != groupList[0])
                {
                    items.Add(new ToolStripSeparator());
                }

                foreach (CommandMenuEntry entry in group)
                {
                    if (entry.SubMenu != null)
                    {
                        items.Add(BuildToolStripMenu(entry.SubMenu, registry));
                    }
                    else
                    {
                        CommandRecord record = registry.Lookup(entry.Key);
                        if (record != null)
                        {
                            ToolStripMenuItem menuItem = new ToolStripMenuItem()
                            {
                                Tag                      = new CommandMenuTag(entry.Key, entry.Param),
                                Text                     = record.DisplayName,
                                Image                    = record.Image,
                                ShortcutKeys             = record.Shortcut,
                                ShortcutKeyDisplayString = record.ShortcutDisplay,
                                ToolTipText              = record.Description,
                            };

                            if (entry.Default)
                            {
                                menuItem.Font = new Font(menuItem.Font, menuItem.Font.Style | FontStyle.Bold);
                            }

                            items.Add(menuItem);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void Register(CommandKey key, string displayName, Image resource = null, Keys shortcut = Keys.None, string description = null, string shortcutDisplay = null)
        {
            CommandRecord record = new CommandRecord(key)
            {
                DisplayName     = displayName,
                Description     = description,
                Shortcut        = shortcut,
                ShortcutDisplay = shortcutDisplay,
            };

            if (resource != null)
            {
                record.Image = resource;
            }

            _default.Register(record);
        }
Ejemplo n.º 3
0
 public void Register(CommandRecord inst)
 {
     _registry[inst.Key] = inst;
 }
Ejemplo n.º 4
0
        private static void Register(CommandKey key, string displayName, Image resource = null, Keys shortcut = Keys.None, string description = null, string shortcutDisplay = null)
        {
            CommandRecord record = new CommandRecord(key) {
                DisplayName = displayName,
                Description = description,
                Shortcut = shortcut,
                ShortcutDisplay = shortcutDisplay,
            };

            if (resource != null)
                record.Image = resource;

            _default.Register(record);
        }
Ejemplo n.º 5
0
 public void Register(CommandRecord inst)
 {
     _registry[inst.Key] = inst;
 }
Ejemplo n.º 6
0
        private static void Register(CommandKey key, string displayName, string resource = null, Keys shortcut = Keys.None, string description = null, string shortcutDisplay = null)
        {
            CommandRecord record = new CommandRecord(key) {
                DisplayName = displayName,
                Description = description,
                Shortcut = shortcut,
                ShortcutDisplay = shortcutDisplay,
            };

            if (resource != null)
                record.Image = Image.FromStream(_assembly.GetManifestResourceStream(resource));

            _default.Register(record);
        }