/// <summary> /// Recursively creates tree nodes for the children market groups of the given group. /// The added blueprints will be the ones which require the current skill (<see cref="m_skill"/>) at the specified level. /// </summary> /// <param name="blueprintMarketGroup">The blueprint market group.</param> /// <param name="blueprints">The blueprints.</param> /// <param name="level">The level.</param> /// <returns></returns> private IEnumerable <TreeNode> CreateMarketGroupsNode(BlueprintMarketGroup blueprintMarketGroup, IEnumerable <Item> blueprints, int level) { // Add categories foreach (BlueprintMarketGroup category in blueprintMarketGroup.SubGroups) { IEnumerable <TreeNode> children = CreateMarketGroupsNode(category, blueprints, level); if (children.IsEmpty()) { continue; } TreeNode node = new TreeNode(category.Name); node.Nodes.AddRange(children.ToArray()); yield return(node); } // Add blueprints foreach (Item blueprint in blueprints.Where(x => x.MarketGroup == blueprintMarketGroup)) { List <string> listOfActivities = blueprint.Prerequisites .Where(x => x.Skill == m_skill.StaticData && x.Level == level) .Select(x => x.Activity.GetDescription()).ToList(); TreeNode node = CreateNode(blueprint, blueprint.Prerequisites .Where(x => listOfActivities.Contains(x.Activity.GetDescription())).ToCharacter(m_character)); node.Text = String.Format("{0} ({1})", node.Text, string.Join(", ", listOfActivities)); yield return(node); } }
/// <summary> /// Create the tree nodes for the given category and add them to the given nodes collection /// </summary> /// <param name="cat"></param> /// <param name="nodeCollection"></param> /// <returns></returns> private int BuildSubtree(BlueprintMarketGroup group, TreeNodeCollection nodeCollection) { // Total blueprints count in this category and its subcategories int result = 0; // Add all subcategories foreach (BlueprintMarketGroup childGroup in group.SubGroups) { TreeNode node = new TreeNode() { Text = childGroup.Name }; // Add this subcategory's blueprints count result += BuildSubtree(childGroup, node.Nodes); // Only add if this subcategory has children if (node.GetNodeCount(true) > 0) { nodeCollection.Add(node); } } // Add all blueprints foreach (Blueprint childItem in group.Blueprints.Where(x => m_usabilityPredicate(x) && m_metaGroupPredicate(x))) { TreeNode node = new TreeNode() { Text = childItem.Name, Tag = childItem }; nodeCollection.Add(node); result++; } return(result); }