Ejemplo n.º 1
0
        //创建主菜单。
        //如果还存在多级菜单就修改为递归的方式来实现。
        private void createMainMenu()
        {
            IOrderedEnumerable <XMenuInfo> menus = CommandGroups.UIMainGroups.OrderBy <XMenuInfo, int>(o => o.Index);

            foreach (XMenuInfo info in menus)
            {
                DevExpress.XtraBars.BarSubItem subItem = new DevExpress.XtraBars.BarSubItem();
                subItem.Caption = info.Description;
                this._BarManager.Items.Add(subItem);

                this._BarMainMenu.LinksPersistInfo.Add(new DevExpress.XtraBars.LinkPersistInfo(subItem));

                if (info.Childs == null || info.Childs.Length == 0)
                {
                    continue;
                }

                IOrderedEnumerable <XMenuInfo> childsMenu = info.Childs.OrderBy <XMenuInfo, int>(o => o.Index);
                foreach (XMenuInfo child in childsMenu)
                {
                    DevExpress.XtraBars.BarButtonItem btnItem = createDefaultButtonItem(child);
                    this._BarManager.Items.Add(btnItem);
                    subItem.LinksPersistInfo.Add(new DevExpress.XtraBars.LinkPersistInfo(btnItem, child.BeginGroup));
                    //如果是EditGroup 或者是SearchGroup 需要对应的Item 加上BarEdit 上。
                    if (info.ShowToCommandBar)
                    {
                        bool beginGroup = child.BeginGroup;
                        DevExpress.XtraBars.LinkPersistInfo cmdButton = new DevExpress.XtraBars.LinkPersistInfo(btnItem, beginGroup);
                        btnItem.PaintStyle       = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph;
                        cmdButton.UserPaintStyle = DevExpress.XtraBars.BarItemPaintStyle.CaptionGlyph;
                        this._BarEdit.LinksPersistInfo.Add(cmdButton);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        static public void setPopupmenuLinkPersistInfo(DevExpress.XtraBars.PopupMenu _ctr_popup_menu, ArrayList _link_item_array)
        {
            if (null == _ctr_popup_menu || null == _link_item_array)
            {
                return;
            }

            DevExpress.XtraBars.LinkPersistInfo[] links = new DevExpress.XtraBars.LinkPersistInfo[_link_item_array.Count];
            for (int i = 0; i < _link_item_array.Count; i++)
            {
                DevExpress.XtraBars.LinkPersistInfo link_info = (DevExpress.XtraBars.LinkPersistInfo)(_link_item_array[i]);
                links[i] = link_info;
            }

            _ctr_popup_menu.LinksPersistInfo.AddRange(links);
        }