Пример #1
0
        /// <summary>
        /// 初始化菜单
        /// </summary>
        void InitMenu(DevComponents.DotNetBar.ButtonItem item, INavigateGroup m_Group)
        {
            IList <INavigateGroup> m_GroupList = navigationProxy.GetGroupList(m_Group == null ? string.Empty : m_Group.ID);
            int mask = (int)GroupType.Windows;

            //1.处理下级组。
            foreach (INavigateGroup var in m_GroupList)
            {
                if ((var.Attributes & mask) == mask)
                {
                    DevComponents.DotNetBar.ButtonItem miMan = new DevComponents.DotNetBar.ButtonItem();
                    miMan.Text          = var.Name;
                    miMan.Image         = imageList1.Images[0];
                    miMan.ImagePosition = eImagePosition.Left;
                    miMan.ButtonStyle   = eButtonStyle.ImageAndText;
                    miMan.Tag           = var.Attributes;

                    if (item == null)
                    {
                        this.barMenu.Items.Add(miMan);
                    }
                    else
                    {
                        item.SubItems.Add(miMan);
                    }

                    this.InitMenu(miMan, var);
                }
            }

            //2.增加功能插件
            if (m_Group != null)  //功能节点
            {
                IList <INavigateModule> m_moduleList = navigationProxy.GetModuleList(m_Group.ID);
                foreach (INavigateModule module in m_moduleList)
                {
                    DevComponents.DotNetBar.ButtonItem miSub = new DevComponents.DotNetBar.ButtonItem();
                    miSub.Image  = imageList1.Images[1];
                    miSub.Text   = module.Name;
                    miSub.Tag    = module;
                    miSub.Click += new EventHandler(miSub_Click);
                    item.SubItems.Add(miSub);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 普通用户导航初始化。
        /// </summary>
        private void InitializeNavigationPublic(TreeNode node, INavigateGroup Group)
        {
            int mask  = (int)GroupType.Windows;
            int mask2 = (int)GroupType.Expend;

            IList <INavigateGroup> groupList = navigationProxy.GetGroupList(Group == null ? Guid.Empty.ToString() : Group.ID);

            foreach (INavigateGroup var in groupList) //下级组
            {
                if ((var.Attributes & mask) == mask)
                {
                    TreeNode subNode = new TreeNode(var.Name, 0, 1);
                    this.InitializeNavigationPublic(subNode, var);
                    node.Nodes.Add(subNode);

                    if ((var.Attributes & mask2) == mask2)
                    {
                        node.Expand();
                    }
                }
            }

            if (Group != null)  //功能节点
            {
                TreeNode itemNode = null;

                IList <INavigateModule> moduleList = navigationProxy.GetModuleList(Group.ID);

                foreach (INavigateModule mv in moduleList)
                {
                    itemNode     = new TreeNode(mv.Name, 2, 2);
                    itemNode.Tag = mv;
                    node.Nodes.Add(itemNode);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 初始导航。
        /// </summary>
        void InitializeNavigationPublic()
        {
            //清空。
            for (int i = this.ribbonControl.Items.Count - 1; i >= 0; i--)
            {
                var tabItem = this.ribbonControl.Items[i] as RibbonTabItem;
                if (tabItem != null)
                {
                    this.ribbonControl.Items.RemoveAt(i);
                    this.ribbonControl.Controls.Remove(tabItem.Panel);
                }
            }

            //初始化导航
            int mask = (int)GroupType.Windows;
            IList <INavigateGroup> rootGroups = navigationProxy.GetGroupList(Guid.Empty.ToString().ToUpper());
            int index = 0;

            foreach (var vGroup in rootGroups)  //根分组。
            {
                if ((vGroup.Attributes & mask) == mask)
                {
                    #region 一级组/RibbonTabItem

                    DevComponents.DotNetBar.RibbonPanel ribbonPanel = new DevComponents.DotNetBar.RibbonPanel();
                    ribbonPanel.ColorSchemeStyle          = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
                    ribbonPanel.Size                      = new System.Drawing.Size(908, 100);
                    ribbonPanel.Dock                      = System.Windows.Forms.DockStyle.Fill;
                    ribbonPanel.Padding                   = new System.Windows.Forms.Padding(3, 0, 3, 3);
                    ribbonPanel.Style.CornerType          = DevComponents.DotNetBar.eCornerType.Square;
                    ribbonPanel.StyleMouseDown.CornerType = DevComponents.DotNetBar.eCornerType.Square;
                    ribbonPanel.StyleMouseOver.CornerType = DevComponents.DotNetBar.eCornerType.Square;

                    DevComponents.DotNetBar.RibbonTabItem ribbonTabItem = new DevComponents.DotNetBar.RibbonTabItem();
                    //ribbonTabItem.Checked = true;
                    ribbonTabItem.Text  = vGroup.Name;
                    ribbonTabItem.Tag   = vGroup;
                    ribbonTabItem.Panel = ribbonPanel;

                    //二级组
                    IList <INavigateGroup> groups = navigationProxy.GetGroupList(vGroup.ID);
                    if (groups.Count == 0)
                    {
                        groups.Add(vGroup);
                    }

                    //工作组。
                    foreach (var xGroup in groups)
                    {
                        #region 工作组/RibbonBar

                        DevComponents.DotNetBar.RibbonBar ribbonBar = new DevComponents.DotNetBar.RibbonBar();
                        ribbonBar.Text  = xGroup.Name;
                        ribbonBar.Tag   = xGroup;
                        ribbonBar.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;

                        var modules = navigationProxy.GetAllModuleList(xGroup.ID);
                        foreach (var module in modules)
                        {
                            DevComponents.DotNetBar.ButtonItem buttonItem = new DevComponents.DotNetBar.ButtonItem();
                            buttonItem.Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled;
                            buttonItem.Text  = module.Name;
                            buttonItem.Tag   = module;

                            buttonItem.ImagePosition = DevComponents.DotNetBar.eImagePosition.Top;

                            Image image = this.GetModuleImage(module.Icon);
                            if (image == null)
                            {
                                image = DrugShop.Res.Properties.Resources.buttonImage;
                            }
                            buttonItem.Image = image;

                            buttonItem.Click += new EventHandler(buttonItem_Click);
                            ribbonBar.Items.Add(buttonItem);
                        }

                        ribbonPanel.Controls.Add(ribbonBar);

                        #endregion
                    }

                    this.ribbonControl.Controls.Add(ribbonPanel);
                    this.ribbonControl.Items.Add(ribbonTabItem, 1 + index);

                    #endregion
                }
            }

            if (rootGroups.Count > 0)
            {
                this.ribbonControl.SelectedRibbonTabItem = this.ribbonControl.Items[1] as RibbonTabItem;
            }
        }