Ejemplo n.º 1
0
        public void BuildMenu(SortedList menu, IList m)
        {
            bool separator = false;

            foreach (SortedList group in menu.Values)
            {
                if (group.Count == 0)
                {
                    continue;
                }
                if (separator)
                {
                    m.Add(new CommandMenuItem("-"));
                }
                separator = true;
                foreach (CommandMenuItem cmi in group.Values)
                {
                    CommandMenuItem cmiNew = (cmi.MenuCommand != null)
                                                ? new CommandMenuItem(cmi.Text, cmi.MenuCommand.CommandID.Guid, cmi.MenuCommand.CommandID.ID)
                                                : cmi;
                    cmiNew.IsDynamic = cmi.IsDynamic;
                    cmiNew.Popup    += new EventHandler(subMenu_Popup);
                    cmiNew.Click    += new CommandMenuEventHandler(item_Click);
                    m.Add(cmiNew);
                }
            }
        }
Ejemplo n.º 2
0
 public CommandMenuEventArgs(CommandMenuItem item)
 {
     this.item = item;
 }
Ejemplo n.º 3
0
        public int SetStatus(IMenuAdapter menu, ICommandTarget ct)
        {
            int visibleItemsInGroup = 0;
            int iLastSeparator      = -1;
            int totalVisible        = 0;

            for (int i = 0; i < menu.Count; ++i)
            {
                if (menu.IsSeparator(i))
                {
                    cmdStatus.Status    = visibleItemsInGroup > 0 ? MenuStatus.Visible | MenuStatus.Enabled : 0;
                    visibleItemsInGroup = 0;
                    iLastSeparator      = i;
                    menu.SetStatus(i, cmdStatus.Status);
                }
                else if (menu.IsTemporary(i))
                {
                    menu.RemoveAt(i);
                    --i;
                }
                else
                {
                    var cmdId = menu.GetCommandID(i);
                    cmdStatus.Status = 0;
                    if (cmdId == null)
                    {
                        cmdStatus.Status = MenuStatus.Enabled | MenuStatus.Visible;
                        ++visibleItemsInGroup;
                        ++totalVisible;
                    }
                    else if (ct.QueryStatus(cmdId, cmdStatus, cmdText))
                    {
                        if (menu.IsDynamic(i))
                        {
                            menu.SetText(i, cmdText.Text);
                            cmdId = new CommandID(cmdId.Guid, cmdId.ID + 1);
                            while (ct.QueryStatus(cmdId, cmdStatus, cmdText))
                            {
                                CommandMenuItem itemNew = new CommandMenuItem(cmdText.Text, cmdId.Guid, cmdId.ID);
                                itemNew.IsTemporary = true;
                                itemNew.Popup      += popupHandler;
                                itemNew.Click      += clickHandler;
                                menu.InsertAt(++i, itemNew);
                                if ((cmdStatus.Status & MenuStatus.Visible) != 0)
                                {
                                    ++visibleItemsInGroup;
                                    ++totalVisible;
                                }
                                cmdId = new CommandID(cmdId.Guid, cmdId.ID + 1);
                            }
                        }
                        else
                        {
                            if ((cmdStatus.Status & MenuStatus.Visible) != 0)
                            {
                                ++visibleItemsInGroup;
                                ++totalVisible;
                            }
                        }
                    }
                    menu.SetStatus(i, cmdStatus.Status);
                }
            }
            if (iLastSeparator >= 0 && visibleItemsInGroup == 0)
            {
                menu.SetStatus(iLastSeparator, 0);
            }
            return(totalVisible);
        }
Ejemplo n.º 4
0
 public void SetItemVisibility(CommandMenuItem item, CommandStatus cmdStatus)
 {
     item.Visible = (cmdStatus.Status & MenuStatus.Visible) != 0;
     item.Enabled = (cmdStatus.Status & MenuStatus.Enabled) != 0;
     item.Checked = (cmdStatus.Status & MenuStatus.Checked) != 0;
 }