示例#1
0
        public VSDevExpressMenuItem CreateItem(bool isPopup)
        {
            if (VSSource == null)
            {
                return(null);
            }
            var commandBarControl = (CommandBarControl)VSSource;

            if (commandBarControl.Type != MsoControlType.msoControlPopup)
            {
                CommandBar parentCommandBar = commandBarControl.Parent;
                if (parentCommandBar == null)
                {
                    return(null);
                }
                int savedIndex = commandBarControl.Index;
                VSSource = parentCommandBar.Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, savedIndex, Type.Missing) as CommandBarPopup;
                commandBarControl.Delete();
            }
            var childItem = new VSDevExpressMenuItem();

            childItem.VSSource = isPopup
                ? ((CommandBarPopup)VSSource).Controls.Add(MsoControlType.msoControlPopup, Type.Missing, Type.Missing, Type.Missing, Type.Missing)
                : ((CommandBarPopup)VSSource).Controls.Add(MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            itemsInternal.Add(childItem);
            childItem.Parent = this;
            return(childItem);
        }
示例#2
0
        public VSDevExpressMenuItem CreateOrGetItem(string header, bool isPopup = false)
        {
            VSDevExpressMenuItem childItem = GetItemByHeader(header);

            if (childItem != null)
            {
                return(childItem);
            }
            childItem        = CreateItem(isPopup);
            childItem.Header = header;
            return(childItem);
        }
示例#3
0
        protected void CreateChildrenFromSource()
        {
            var commandBarPopup = VSSource as CommandBarPopup;

            if (commandBarPopup == null)
            {
                return;
            }
            foreach (CommandBarControl control in commandBarPopup.Controls)
            {
                if (control.Type == MsoControlType.msoControlButton || control.Type == MsoControlType.msoControlPopup)
                {
                    var item = new VSDevExpressMenuItem(control);
                    item.Parent = this;
                    itemsInternal.Add(item);
                }
            }
        }