Пример #1
0
        private void PopulateMenuNode(TreeNodeCollection nodes, MenuType menuType, string menuName)
        {
            //
            //  Get the Image URLs
            //
            string systemImageUrl = Page.ClientScript.GetWebResourceUrl(
                this.GetType(),
                "MVPSI.JAMSWeb.Controls.Resources.System.png");
            string menuImageUrl = Page.ClientScript.GetWebResourceUrl(
                this.GetType(),
                "MVPSI.JAMSWeb.Controls.Resources.System.png");
            string jobImageUrl = Page.ClientScript.GetWebResourceUrl(
                this.GetType(),
                "MVPSI.JAMSWeb.Controls.Resources.Job.png");
            string setupImageUrl = Page.ClientScript.GetWebResourceUrl(
                this.GetType(),
                "MVPSI.JAMSWeb.Controls.Resources.Setup.png");

            //
            //  Build the menu
            //
            var menu = BuildMenu.Find(menuType, menuName, GetServer());

            //
            //  Add each entry in the menu as a TreeNode
            //
            foreach (MenuEntry entry in menu)
            {
                TreeNode node = new TreeNode(
                    entry.MenuText,
                    string.Format("{0},{1},{2}", (int)entry.MenuType, entry.ID, entry.MenuName));

                //
                //  Pick the correct image
                //
                switch (entry.MenuType)
                {
                case MenuType.Job:
                    node.ImageUrl = jobImageUrl;
                    break;

                case MenuType.Setup:
                    node.ImageUrl = setupImageUrl;
                    break;

                case MenuType.Folder:
                    node.ImageUrl = systemImageUrl;
                    break;

                default:
                    node.ImageUrl = menuImageUrl;
                    break;
                }

                //
                //  Should this be expandable?
                //
                if ((entry.MenuType == MenuType.Menu) ||
                    (entry.MenuType == MenuType.Folder))
                {
                    node.PopulateOnDemand = true;
                    node.SelectAction     = TreeNodeSelectAction.Expand;
                }

                //
                //  Add the node to the collection
                //
                nodes.Add(node);
            }
        }