Пример #1
0
 void createRibPage(FlexModel.MenuItem el)
 {
     page1 = new DevExpress.XtraBars.Ribbon.RibbonPage(el.Caption);
     ribbon1.Pages.Add(page1);
     foreach (var item in _menus.Where(m => m.ParentID == el.ID))
     {
         if (!_security.Any(s => s.MenuItem_ID == item.ID))
         {
             createRibPageGroup(item);
         }
     }
 }
Пример #2
0
        protected override void OnLoad(EventArgs e)
        {
            foreach (IRibbonPagePlugin rbPage in rbPages.OrderBy(h => h.Order))
            {
                RibbonPage ribbonPage1 = new DevExpress.XtraBars.Ribbon.RibbonPage();
                ribbonPage1.Name = string.Format("ribbonPage{0}", rbPage.Order);
                ribbonPage1.Text = rbPage.Text;
                ribbon.Pages.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPage[] {
                    ribbonPage1
                });
                foreach (IRibbonGroupPlugin group in rbPage.rbGroups.OrderBy(h => h.Order))
                {
                    RibbonPageGroup ribbonPageGroup1 = new DevExpress.XtraBars.Ribbon.RibbonPageGroup();
                    ribbonPageGroup1.Text = group.Text;
                    ribbonPage1.Groups.AddRange(new DevExpress.XtraBars.Ribbon.RibbonPageGroup[] {
                        ribbonPageGroup1
                    });
                    foreach (IPlugin item in group.BarItems.OrderBy(h => h.Order))
                    {
                        BarButtonItem barButtonItem1 = new BarButtonItem();
                        ribbon.Items.AddRange(new DevExpress.XtraBars.BarItem[] {
                            this.ribbon.ExpandCollapseItem,
                            barButtonItem1
                        });
                        barButtonItem1.Caption = item.Text;
                        barButtonItem1.Id      = item.Order;
                        barButtonItem1.Name    = string.Format("barBtn{0}", rbPage.Order);
                        if (item.RbItemStyles == RibbonItemStyles.Large)
                        {
                            barButtonItem1.LargeGlyph = item.Icon;
                        }
                        else
                        {
                            barButtonItem1.Glyph = item.Icon;
                        }

                        barButtonItem1.Hint        = item.ToolTip;
                        barButtonItem1.RibbonStyle = item.RbItemStyles;
                        barButtonItem1.ItemClick  += (s, arg) => { item.Do(); };
                        ribbonPageGroup1.ItemLinks.Add(barButtonItem1);
                        if (!_appMenuLoaded)
                        {
                            barButtonItem1.Glyph = item.Icon;
                            this.ribbon.QuickToolbarItemLinks.Add(barButtonItem1);
                            this.appMenu.ItemLinks.Add(barButtonItem1);
                        }
                    }
                    _appMenuLoaded = true;
                }
            }

            base.OnLoad(e);
        }
Пример #3
0
        /// <summary>
        /// Naplní prvky do Ribbonu, zaháčkuje eventhandlery
        /// </summary>
        private void RibbonFillItems()
        {
            this.Ribbon.ShowApplicationButton = DevExpress.Utils.DefaultBoolean.False;

            DXB.Ribbon.RibbonPage page0 = new DXB.Ribbon.RibbonPage("GRAF");
            this.Ribbon.Pages.Add(page0);

            DXB.Ribbon.RibbonPageGroup group00 = new DXB.Ribbon.RibbonPageGroup("SPRÁVA GRAFŮ");
            page0.Groups.Add(group00);

            DXB.Ribbon.RibbonPageGroup group01 = new DXB.Ribbon.RibbonPageGroup("SPRÁVA DAT");
            page0.Groups.Add(group01);

            RibbonAddButton(group00, "Přidej", "Přidá nový graf", Properties.Resources.document_new_6_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickNewGraph);
            RibbonAddButton(group00, "Uprav", "Umožní změnit datové zdroje grafu: výběr obcí, výběr dat", Properties.Resources.document_properties_2_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickEditDataGraph);
            RibbonAddButton(group00, "Vzhled grafu", "Otevře editor vzhledu grafu", Properties.Resources.document_page_setup_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickEditLayoutGraph);
            RibbonAddButton(group00, "Smaž", "Smaže aktuální graf", Properties.Resources.document_close_4_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickDeleteGraph);
            RibbonAddButton(group01, "Aktualizuj data", "Zajistí aktualizaci dat z internetu", Properties.Resources.download_3_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickWebUpdate);
            RibbonAddButton(group01, "Značky", "Značky jsou společné, jsou vkládány do všech grafů, označují význačné časové úseky", Properties.Resources.system_switch_user_2_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickEditStrip);
            RibbonAddButton(group01, "Ulož", "Uloží všechna aktuální data do datových souborů (Structure, Data, i kompaktního DataPack, ten lze např odeslat mailem).", Properties.Resources.document_save_as_6_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickSaveData);
            RibbonAddButton(group01, "Config", "Nastavení projektu", Properties.Resources.run_build_configure_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickRunConfig);


            DXB.Ribbon.RibbonPage page1 = new DXB.Ribbon.RibbonPage("VZHLED APLIKACE");
            this.Ribbon.Pages.Add(page1);

            DXB.Ribbon.RibbonPageGroup group10 = new DXB.Ribbon.RibbonPageGroup("VZHLED");
            page1.Groups.Add(group10);

            group10.ItemLinks.Add(new DXB.SkinDropDownButtonItem());
            group10.ItemLinks.Add(new DXB.SkinPaletteRibbonGalleryBarItem());


            if (App.IsRunningInVisualStudio)
            {
                DXB.Ribbon.RibbonPage page2 = new DXB.Ribbon.RibbonPage("JINÉ TESTY");
                this.Ribbon.Pages.Add(page2);

                DXB.Ribbon.RibbonPageGroup group20 = new DXB.Ribbon.RibbonPageGroup("KOMPONENTY");
                page2.Groups.Add(group20);

                RibbonAddButton(group20, "TreeView", "Otevře okno pro testování TreeView", Properties.Resources.code_class_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickTestTreeView);
                RibbonAddButton(group20, "Analýza dat", "V databázi vyhledá mezní hodnoty pomocí analýzy", Properties.Resources.straw_32, DXB.Ribbon.RibbonItemStyles.Large, RibbonClickAnalytics);
            }
        }
        public void AddPages()
        {
            //约定菜单共有3级,第一级为大的类别,第二级为小模块分组,第三级为具体的菜单
            List <MenuNodeInfo> menuList = BLLFactory <SysMenu> .Instance.GetTree(Portal.gc.SystemType);

            if (menuList.Count == 0)
            {
                return;
            }

            int i = 0;

            foreach (MenuNodeInfo firstInfo in menuList)
            {
                //如果没有菜单的权限,则跳过
                if (!Portal.gc.HasFunction(firstInfo.FunctionId))
                {
                    continue;
                }

                //添加页面(一级菜单)
                RibbonPage page = new DevExpress.XtraBars.Ribbon.RibbonPage();
                page.Text = firstInfo.Name;
                page.Name = firstInfo.ID;
                this.control.Pages.Insert(i++, page);

                if (firstInfo.Children.Count == 0)
                {
                    continue;
                }
                foreach (MenuNodeInfo secondInfo in firstInfo.Children)
                {
                    //如果没有菜单的权限,则跳过
                    if (!Portal.gc.HasFunction(secondInfo.FunctionId))
                    {
                        continue;
                    }

                    //添加RibbonPageGroup(二级菜单)
                    RibbonPageGroup group = new RibbonPageGroup();
                    group.Text = secondInfo.Name;
                    group.Name = secondInfo.ID;
                    page.Groups.Add(group);

                    if (secondInfo.Children.Count == 0)
                    {
                        continue;
                    }
                    foreach (MenuNodeInfo thirdInfo in secondInfo.Children)
                    {
                        //如果没有菜单的权限,则跳过
                        if (!Portal.gc.HasFunction(thirdInfo.FunctionId))
                        {
                            continue;
                        }

                        //添加功能按钮(三级菜单)
                        BarButtonItem button = new BarButtonItem();
                        button.PaintStyle = BarItemPaintStyle.CaptionGlyph;
                        button.LargeGlyph = LoadIcon(thirdInfo.Icon);
                        button.Glyph      = LoadIcon(thirdInfo.Icon);

                        button.Name       = thirdInfo.ID;
                        button.Caption    = thirdInfo.Name;
                        button.Tag        = thirdInfo.WinformType;
                        button.ItemClick += (sender, e) =>
                        {
                            if (button.Tag != null && !string.IsNullOrEmpty(button.Tag.ToString()))
                            {
                                LoadPlugInForm(button.Tag.ToString());
                            }
                            else
                            {
                                MessageDxUtil.ShowTips(button.Caption);
                            }
                        };
                        group.ItemLinks.Add(button);
                    }
                }
            }
        }
Пример #5
0
        /// <summary> 动态加载菜单
        ///
        /// </summary>
        private void GetMenuBind()
        {
            //根据登录用户角色菜单动态创建
            //循环创建卡菜单
            DataSet dtMenus = new DataSet();// menus.GetMenusRibbon();

            dtMenus.AcceptChanges();

            DataTable baseModuleDT = dtMenus.Tables[1];

            for (int i = 0; i < baseModuleDT.Rows.Count; i++)
            {
                //创建卡
                RibbonPage ribbonPage = new DevExpress.XtraBars.Ribbon.RibbonPage();//菜单卡对象定义
                ribbonPage.Text = baseModuleDT.Rows[i]["Menu_Type_Txt"].ToString();
                this.ribbon.Pages.Add(ribbonPage);

                DataTable baseModuleDTG = dtMenus.Tables[2].Select("Menu_Type_Txt ='" + baseModuleDT.Rows[i]["Menu_Type_Txt"].ToString() + "'").CopyToDataTable();

                if (baseModuleDTG.Rows.Count <= 0)
                {
                    //没有组
                    RibbonPageGroup ribbonPageGroup = new DevExpress.XtraBars.Ribbon.RibbonPageGroup(); //菜单卡分组定义
                    ribbonPageGroup.Text = baseModuleDT.Rows[i]["Menu_Type_Txt"].ToString();            //卡片组名
                    ribbonPage.Groups.Add(ribbonPageGroup);

                    DataTable baseModuleDTB = dtMenus.Tables[0].Select("Menu_Type_Txt ='" + baseModuleDT.Rows[i]["Menu_Type_Txt"].ToString() + "'").CopyToDataTable();
                    for (int b = 0; b < baseModuleDTB.Rows.Count; b++)
                    {
                        Image image = Image.FromFile(FileHelper.GetFilePath("menuicon", "error.png"));
                        //功能按钮
                        BarButtonItem barButtonItem = new DevExpress.XtraBars.BarButtonItem();
                        barButtonItem.Caption    = baseModuleDTB.Rows[b]["Name"].ToString();
                        barButtonItem.LargeGlyph = image;// global::MemberManager.Properties.Resources.group_key;
                        barButtonItem.Name       = baseModuleDTB.Rows[b]["FormName"].ToString();
                        barButtonItem.Tag        = baseModuleDTB.Rows[b]["NavigateUrl"].ToString();;
                        ribbonPageGroup.ItemLinks.Add(barButtonItem);
                        barButtonItem.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.barButtonItem_ItemClick);//注册事件
                    }
                }
                else
                {
                    for (int g = 0; g < baseModuleDTG.Rows.Count; g++)
                    {
                        //创建组
                        RibbonPageGroup ribbonPageGroup = new DevExpress.XtraBars.Ribbon.RibbonPageGroup(); //菜单卡分组定义
                        ribbonPageGroup.Text = baseModuleDTG.Rows[g]["GroupTxt"].ToString();                //卡片组名
                        ribbonPage.Groups.Add(ribbonPageGroup);

                        DataTable baseModuleDTB = dtMenus.Tables[0].Select("GroupTxt ='" + baseModuleDTG.Rows[g]["GroupTxt"].ToString() + "' AND Menu_Type_Txt='" + baseModuleDTG.Rows[g]["Menu_Type_Txt"].ToString() + "'").CopyToDataTable();
                        for (int b = 0; b < baseModuleDTB.Rows.Count; b++)
                        {
                            Image         image         = Image.FromFile(FileHelper.GetFilePath("menuicon", "error.png"));
                            BarButtonItem barButtonItem = new DevExpress.XtraBars.BarButtonItem();
                            barButtonItem.Caption    = baseModuleDTB.Rows[b]["Name"].ToString();
                            barButtonItem.LargeGlyph = image;// global::MemberManager.Properties.Resources.group_key;
                            barButtonItem.Name       = baseModuleDTB.Rows[b]["FormName"].ToString();
                            barButtonItem.Tag        = baseModuleDTB.Rows[b]["NavigateUrl"].ToString();;
                            ribbonPageGroup.ItemLinks.Add(barButtonItem);
                            barButtonItem.ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.barButtonItem_ItemClick);//注册事件
                        }
                    }
                }
            }

            dtShortcut = dtMenus.Tables[3];
            if (ConfigHelper.GetConfigKeyValue("NeedShortcut") == "true")//是否需要显示快捷方式
            {
                gridControl1.DataSource = GetBindShortcut(dtShortcut);
            }
            else
            {
                gridControl1.Visible = false;
            }
        }
Пример #6
0
        /// <summary>
        /// 增加TabPage
        /// </summary>
        /// <remarks> 处理所有的SystemType</remarks>
        public async Task InitRibbonMenus()
        {
            //约定菜单共有3级,第一级为大的类别,第二级为小模块分组,第三级为具体的菜单
            List <MenuNodeInfo> menuList = new List <MenuNodeInfo>();

            #region 菜单系统信息获取
            try
            {
                menuList = await CallerFactory <IMenuService> .Instance.GetTreeAsyn(Portal.gc.SystemType).TimeOut <List <MenuNodeInfo> >(Portal.gc.AsynTimeOut);
            }
            catch (Exception ex)
            {
                MessageDxUtil.ShowError(ex.Message);
            }
            if (menuList.Count == 0)
            {
                return;
            }
            #endregion

            control.BeginInit();
            #region 处理RibbonControl的菜单系统
            int i = 0;
            //添加1级Ribbon
            foreach (MenuNodeInfo firstInfo in menuList)
            {
                //如果没有菜单的权限,则跳过
                if (!Portal.gc.HasFunction(firstInfo.FunctionId))
                {
                    continue;
                }

                if (firstInfo.Children.Count == 0)
                {
                    continue;
                }

                //添加页面(一级菜单),edit by xuyi,2016.2.16
                RibbonPage page = null;
                #region 防止系统管理和帮助重复,将一级菜单Page加进RibbonControl
                if (!(firstInfo.Name.Trim().Equals("系统管理") || firstInfo.Name.Trim().Equals("帮助")))
                {
                    page      = new DevExpress.XtraBars.Ribbon.RibbonPage();
                    page.Text = firstInfo.Name;
                    page.Name = firstInfo.ID;
                    this.control.Pages.Insert(i++, page);
                }
                else
                {
                    page = control.Pages.GetPageByText(firstInfo.Name.Trim());
                }
                #endregion

                //添加对应的Group
                foreach (MenuNodeInfo secondInfo in firstInfo.Children)
                {
                    //如果没有菜单的权限,则跳过
                    if (!Portal.gc.HasFunction(secondInfo.FunctionId))
                    {
                        continue;
                    }

                    if (secondInfo.Children.Count == 0)
                    {
                        continue;
                    }

                    //添加RibbonPageGroup(二级菜单)edit by xuyi 2016.2.16
                    RibbonPageGroup group = page.Groups.GetGroupByText(secondInfo.Name);

                    #region 将Group加进Ribbon
                    if (group == null)
                    {
                        group      = new RibbonPageGroup();
                        group.Text = secondInfo.Name;
                        group.Name = secondInfo.ID;
                        if (firstInfo.Name.Trim().Equals("系统管理") || firstInfo.Name.Trim().Equals("帮助"))
                        {
                            page.Groups.Insert(0, group);
                        }
                        else
                        {
                            page.Groups.Add(group);
                        }
                    }
                    else
                    {
                        group.ItemLinks.Clear();
                    }
                    group.Tag = new StringBuilder().
                                Append(secondInfo.WinformType)
                                .Append("|")
                                .Append(secondInfo.SystemType_ID)
                                .Append("|")
                                .Append(secondInfo.Data1)
                                .Append(",")
                                .Append(secondInfo.Data2)
                                .Append(",")
                                .Append(secondInfo.Data3).ToString();
                    group.CaptionButtonClick += Group_CaptionButtonClick;
                    #endregion

                    //添加具体的Button
                    foreach (MenuNodeInfo thirdInfo in secondInfo.Children)
                    {
                        //如果没有菜单的权限,则跳过
                        if (!Portal.gc.HasFunction(thirdInfo.FunctionId))
                        {
                            continue;
                        }

                        //添加功能按钮(三级菜单)
                        group.ItemLinks.Add(initBarButtonItem(thirdInfo));
                    } //endof 三级

                    //如果是空组则删除
                    if (group.ItemLinks.Count == 0)
                    {
                        page.Groups.Remove(group);
                    }
                } //endof 二级
                //如果空page删除
                if (page.Groups.Count == 0)
                {
                    this.control.Pages.Remove(page);
                    i--;
                }
            }
            #endregion
            control.EndInit();
        }