private void AddChildrenToTreeNode(NodeEntryTreeNode treeNode) { if (treeNode.Node.Children.Count > 0) { treeNode.Nodes.AddRange(NodeEntryTreeNode.FromList(treeNode.Node.Children).ToArray()); foreach (var child in treeNode.Nodes) { AddChildrenToTreeNode((NodeEntryTreeNode)child); } } }
private void AddChildrenToTreeNodeWithFilter(NodeEntryTreeNode treeNode, string filter) { if (treeNode.Node.Children.Count > 0) { var nodes = new List <NodeEntryTreeNode>(); nodes.AddRange(NodeEntryTreeNode.FromList(treeNode.Node.Children).ToArray()); foreach (var child in nodes) { AddChildrenToTreeNodeWithFilter(child, filter); if (child.Text.ToLowerInvariant().Contains(filter) || child.Nodes.Count > 0) { treeNode.Nodes.Add(child); } } } }
private void BuildVisualSubTree(NodeEntryTreeNode treeNode, string filter) { if (treeNode.Node.Value is Inventory inv) { // For inventory, we insert virtual nodes for the sub inventories. var subinventories = inv.SubInventories.Select(_ => (NodeEntry) new VirtualNodeEntry() { Value = _ }).ToList(); foreach (var subinventory in subinventories) { var real = subinventory as VirtualNodeEntry ?? throw new Exception("subinventory is not a VirtualNodeEntry, wtf?!"); var data = real.Value as Inventory.SubInventory; var simpleItems = new VirtualNodeEntry { Value = "Simple items" }; var modableItems = new VirtualNodeEntry { Value = "Modable Items" }; foreach (var itemNode in treeNode.Node.Children) { if (data.Items.Contains(itemNode.Value) && (filter == null || itemNode.ToString().ToLowerInvariant().Contains(filter))) { var item = ((ItemData)itemNode.Value).Data; if (item is ItemData.SimpleItemData sid) { simpleItems.Children.Add(itemNode); } else { modableItems.Children.Add(itemNode); } } } if (simpleItems.Children.Count > 0) { subinventory.Children.Add(simpleItems); } if (modableItems.Children.Count > 0) { subinventory.Children.Add(modableItems); } } treeNode.Nodes.AddRange(NodeEntryTreeNode.FromList(subinventories.Where(_ => filter == null || _.Children.Count > 0).ToList()).ToArray()); foreach (var child in treeNode.Nodes) { BuildVisualSubTree((NodeEntryTreeNode)child, filter); } return; } if (treeNode.Node.Value is CharacterCustomizationAppearances cca) { // For CCA we also insert virtual nodes for the three sections var sections = new List <CharacterCustomizationAppearances.Section> { cca.FirstSection, cca.SecondSection, cca.ThirdSection }; foreach (var section in sections) { var treeSection = new NodeEntryTreeNode(new VirtualNodeEntry { Value = section }); foreach (var appearanceSection in section.AppearanceSections) { if (filter == null || appearanceSection.ToString().ToLowerInvariant().Contains(filter)) { treeSection.Nodes.Add(new NodeEntryTreeNode(new VirtualNodeEntry { Value = appearanceSection })); } } if (treeSection.Nodes.Count > 0) { treeNode.Nodes.Add(treeSection); } } return; } if (treeNode.Node.Value is FactsTable ft) { foreach (var fe in ft.FactEntries) { if (filter == null || fe.ToString().ToLowerInvariant().Contains(filter)) { treeNode.Nodes.Add(new NodeEntryTreeNode(new VirtualNodeEntry { Value = fe })); } } return; } if (treeNode.Node.Children.Count > 0) { var nodes = new List <NodeEntryTreeNode>(); nodes.AddRange(NodeEntryTreeNode.FromList(treeNode.Node.Children).ToArray()); foreach (var child in nodes) { BuildVisualSubTree((NodeEntryTreeNode)child, filter); if (filter == null || child.Text.ToLowerInvariant().Contains(filter) || child.Nodes.Count > 0) { treeNode.Nodes.Add(child); } } } }