当前位置: 首页>>代码示例>>C#>>正文


C# TreeNodeCollection.AddRange方法代码示例

本文整理汇总了C#中TreeNodeCollection.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNodeCollection.AddRange方法的具体用法?C# TreeNodeCollection.AddRange怎么用?C# TreeNodeCollection.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeNodeCollection的用法示例。


在下文中一共展示了TreeNodeCollection.AddRange方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetTreeNodes

        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            if (id == Constants.System.Root.ToInvariantString())
            {
                //list out all the letters
                for (var i = 97; i < 123; i++)
                {
                    var charString = ((char) i).ToString(CultureInfo.InvariantCulture);
                    var folder = CreateTreeNode(charString, id, queryStrings, charString, "icon-folder-close", true);
                    folder.NodeType = "member-folder";
                    nodes.Add(folder);
                }
                //list out 'Others' if the membership provider is umbraco
                if (Membership.Provider.Name == Constants.Conventions.Member.UmbracoMemberProviderName)
                {
                    var folder = CreateTreeNode("others", id, queryStrings, "Others", "icon-folder-close", true);
                    folder.NodeType = "member-folder";
                    nodes.Add(folder);
                }
            }
            else
            {
                //if it is a letter
                if (id.Length == 1 && char.IsLower(id, 0))
                {
                    if (Membership.Provider.Name == Constants.Conventions.Member.UmbracoMemberProviderName)
                    {
                        //get the members from our member data layer
                        nodes.AddRange(
                            Member.getMemberFromFirstLetter(id.ToCharArray()[0])
                                        .Select(m => CreateTreeNode(m.UniqueId.ToString("N"), id, queryStrings, m.Text, "icon-user")));
                    }
                    else
                    {
                        //get the members from the provider
                        int total;
                        nodes.AddRange(
                            FindUsersByName(char.Parse(id)).Cast<MembershipUser>()
                                      .Select(m => CreateTreeNode(GetNodeIdForCustomProvider(m.ProviderUserKey), id, queryStrings, m.UserName, "icon-user")));
                    }
                }
                else if (id == "others")
                {
                    //others will only show up when in umbraco membership mode
                    nodes.AddRange(
                        Member.getAllOtherMembers()
                                    .Select(m => CreateTreeNode(m.Id.ToInvariantString(), id, queryStrings, m.Text, "icon-user")));
                }
            }
            return nodes;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:53,代码来源:MemberTreeController.cs

示例2: PerformGetTreeNodes

 /// <summary>
 /// Gets the tree nodes for the given id
 /// </summary>
 /// <param name="id"></param>
 /// <param name="queryStrings"></param>
 /// <returns></returns>
 /// <remarks>
 /// If the content item is a container node then we will not return anything
 /// </remarks>
 protected override TreeNodeCollection PerformGetTreeNodes(string id, FormDataCollection queryStrings)
 {
     var nodes = new TreeNodeCollection();
     var entities = GetChildEntities(id);
     nodes.AddRange(entities.Select(entity => GetSingleTreeNode(entity, id, queryStrings)).Where(node => node != null));            
     return nodes;
 }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:16,代码来源:ContentTreeController.cs

示例3: OnActionExecuted

        /// <summary>
        /// Called by the ASP.NET MVC framework after the action method executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            if (filterContext.Result is RebelTreeResult)
            {
                var treeResult = (RebelTreeResult)filterContext.Result;

                var nodeCollection = new TreeNodeCollection();
                nodeCollection.AddRange(treeResult.NodeCollection);

                foreach (var node in nodeCollection)
                {
                    var menuActions = node.MenuActions.ToList();
                    foreach (var menuAction in menuActions)
                    {
                        var attributes = menuAction.Metadata.ComponentType.GetCustomAttributes(typeof(RebelAuthorizeAttribute), true);
                        if (attributes.Length > 0)
                        {
                            var authorized = attributes.Aggregate(false, (current, attribute) => current || ((RebelAuthorizeAttribute)attribute).IsAuthorized(filterContext.HttpContext, node.HiveId));
                            if (!authorized)
                                node.MenuActions.Remove(menuAction);
                        }
                    }
                }

                filterContext.Result = new RebelTreeResult(nodeCollection, filterContext.Controller.ControllerContext);
            }
        }
开发者ID:RebelCMS,项目名称:rebelcmsxu5,代码行数:33,代码来源:MenuItemsPermissionFilterAttribute.cs

示例4: GetTreeNodes

        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();

            nodes.AddRange(_getNodes(id, queryStrings));

            return nodes;
        }
开发者ID:ruanzx,项目名称:UmbracoBookshelf,代码行数:8,代码来源:UmbracoBookshelfTreeController.cs

示例5: AddFolders

        private TreeNodeCollection AddFolders(string parent, FormDataCollection queryStrings)
        {
            var pickerApiController = new FilePickerApiController();

            var filter = queryStrings.Get("filter").Split(',').Select(a => a.Trim().EnsureStartsWith(".")).ToArray();

            var treeNodeCollection = new TreeNodeCollection();
            treeNodeCollection.AddRange(pickerApiController.GetFolders(parent,filter)
                .Select(dir => CreateTreeNode(dir.FullName.Replace(IOHelper.MapPath("~"), "").Replace("\\", "/"),
                    "~/" + parent, queryStrings, dir.Name,
                    "icon-folder", filter[0]=="." ? dir.EnumerateDirectories().Any() || pickerApiController.GetFiles(dir.FullName.Replace(IOHelper.MapPath("~"), "").Replace("\\", "/"), filter).Any() : pickerApiController.GetFiles(dir.FullName.Replace(IOHelper.MapPath("~"), "").Replace("\\", "/"), filter).Any())));

            return treeNodeCollection;
        }
开发者ID:vnbaaij,项目名称:umbraco7-filepicker,代码行数:14,代码来源:FolderTreeController.cs

示例6: GetTreeNodes

        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var nodes = new TreeNodeCollection();
            const string activeIcon = "icon-timer color-green";
            const string disabledIcon = "icon-timer color-red";

            var schedules = _schedulerApi.GetAllSchedules();
            nodes.AddRange(
                schedules.Select(s =>
                    CreateTreeNode(
                        s.Id.ToString(),
                        Constants.System.Root.ToString(),
                        queryStrings,
                        s.Name,
                        s.Disabled ? disabledIcon : activeIcon)));

            return nodes;
        }
开发者ID:AffinityID,项目名称:uScheduler,代码行数:18,代码来源:SchedulerTreeController.cs

示例7: GetTreeNodes

        /// <summary>
        /// The get tree nodes.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="queryStrings">
        /// The query strings.
        /// </param>
        /// <returns>
        /// The <see cref="TreeNodeCollection"/>.
        /// </returns>
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var collection = new TreeNodeCollection();

            var backoffice = MerchelloConfiguration.Current.BackOffice;

            var rootTrees = backoffice.GetTrees().Where(x => x.Visible);

            var currentTree = rootTrees.FirstOrDefault(x => x.Id == id && x.Visible);

            collection.AddRange(
                currentTree != null
                    ? currentTree.SubTree.GetTrees().Where(x => x.Visible)
                            .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings, currentTree))
                    : backoffice.GetTrees().Where(x => x.Visible)
                            .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings)));

            return collection;
        }
开发者ID:robbaman,项目名称:Merchello,代码行数:31,代码来源:MerchelloTreeController.cs

示例8: AddFiles

        private TreeNodeCollection AddFiles(string folder, FormDataCollection queryStrings)
        {
            var pickerApiController = new FilePickerApiController();
            //var str = queryStrings.Get("startfolder");

            if (string.IsNullOrWhiteSpace(folder))
                return null;

            var filter = queryStrings.Get("filter").Split(',').Select(a=>a.Trim().EnsureStartsWith(".")).ToArray();

            var path = IOHelper.MapPath(folder);
            var rootPath = IOHelper.MapPath(queryStrings.Get("startfolder"));
            var treeNodeCollection = new TreeNodeCollection();
            treeNodeCollection.AddRange(pickerApiController.GetFiles(folder, filter)
                .Select(file => CreateTreeNode(file.FullName.Replace(rootPath, "").Replace("\\", "/"),
                    path, queryStrings, file.Name, "icon-document", false)));

            return treeNodeCollection;
        }
开发者ID:vnbaaij,项目名称:umbraco7-filepicker,代码行数:19,代码来源:FolderTreeController.cs

示例9: GetTreeNodes

        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            //we only support one tree level for data types
            if (id != Constants.System.Root.ToInvariantString())
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            var collection = new TreeNodeCollection();
            collection.AddRange(
                Services.DataTypeService.GetAllDataTypeDefinitions()
                        .OrderBy(x => x.Name)
                        .Select(dt =>
                                CreateTreeNode(
                                    dt.Id.ToInvariantString(),
                                    id,
                                    queryStrings,
                                    dt.Name,
                                    "icon-autofill",
                                    false)));
            return collection;
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:22,代码来源:DataTypeTreeController.cs

示例10: GetTreeNodes

        /// <summary>
        /// The get tree nodes.
        /// </summary>
        /// <param name="id">
        /// The id.
        /// </param>
        /// <param name="queryStrings">
        /// The query strings.
        /// </param>
        /// <returns>
        /// The <see cref="TreeNodeCollection"/>.
        /// </returns>
        protected override TreeNodeCollection GetTreeNodes(string id, FormDataCollection queryStrings)
        {
            var collection = new TreeNodeCollection();
            var backoffice = MerchelloConfiguration.Current.BackOffice;
            var currentTree = _rootTrees.FirstOrDefault(x => x.Id == id && x.Visible);
            var splitId = new SplitRoutePath(id);

            collection.AddRange(
                currentTree != null
                    ? currentTree.Id == "reports" ?
                        GetAttributeDefinedTrees(queryStrings) :

                        _collectiontrees.Contains(splitId.CollectionId) ?

                        this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings)

                            :
                        currentTree.SubTree.GetTrees().Where(x => x.Visible)
                            .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings, currentTree))

                    :
                    _collectiontrees.Contains(splitId.CollectionId) ?

                    this.GetTreeNodesForCollections(splitId.CollectionId, MakeCollectionRoutePathId(splitId.CollectionId, splitId.CollectionKey), queryStrings, false) :

                    backoffice.GetTrees().Where(x => x.Visible)
                            .Select(tree => GetTreeNodeFromConfigurationElement(tree, queryStrings)));

            return collection;
        }
开发者ID:drpeck,项目名称:Merchello,代码行数:42,代码来源:MerchelloTreeController.cs


注:本文中的TreeNodeCollection.AddRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。