Ejemplo n.º 1
0
        public void LoadMenus()
        {
            this.ribbonControl.Items.Add(this.ribbonControl.ExpandCollapseItem);
            List <UserMenusVM> list = _bll.GetUserMenus(GlobalObject.User.Account);
            var parents             = list.Where(p => p.ParentID == 0).ToList();

            parents.ForEach(p =>
            {
                RibbonPage ribbonPage = new RibbonPage();
                ribbonPage.Text       = p.TabHeaderText;
                var children          = list.Where(q => q.ParentID == p.ID).ToList();
                if (children.Count == 0)
                {
                    RibbonPageGroup ribbonPageGroup = new RibbonPageGroup();

                    BarButtonItem barButtonItem = new BarButtonItem();
                    barButtonItem.Caption       = p.TabHeaderText;
                    barButtonItem.Id            = p.ID;
                    barButtonItem.RibbonStyle   = DevExpress.XtraBars.Ribbon.RibbonItemStyles.Large;
                    barButtonItem.Tag           = p.FormName;

                    ribbonControl.Items.Add(barButtonItem);
                    ribbonPageGroup.ItemLinks.Add(barButtonItem);
                    ribbonPage.Groups.Add(ribbonPageGroup);
                }
                else
                {
                    children.ForEach(c =>
                    {
                        RibbonPageGroup ribbonPageGroup = new RibbonPageGroup();

                        BarButtonItem barButtonItem = new BarButtonItem();
                        barButtonItem.Caption       = c.TabHeaderText;
                        barButtonItem.Id            = c.ID;
                        barButtonItem.RibbonStyle   = DevExpress.XtraBars.Ribbon.RibbonItemStyles.Large;
                        barButtonItem.Tag           = c.FormName;

                        ribbonControl.Items.Add(barButtonItem);
                        ribbonPageGroup.ItemLinks.Add(barButtonItem);
                        ribbonPage.Groups.Add(ribbonPageGroup);
                    });
                }
                this.ribbonControl.Pages.Add(ribbonPage);
            });
        }