Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
                }
            }
        }