public void RefreshTreeview(TagCompound compound, TreeNode node) { node.Nodes.Clear(); foreach (TagCompound tag in compound.EnumerateCompounds()) { TreeNode n = new TreeNode(tag.Name, Functions.TagIcons[TagType.TagCompound], Functions.TagIcons[TagType.TagCompound]); node.Nodes.Add(n); this.RefreshTreeview(tag, n); } foreach (Tag tag in compound.EnumerateTags()) { int imageIndex = Functions.TagIcons.Keys.Contains(tag.Type) ? Functions.TagIcons[tag.Type] : 0; TreeNode n = new TreeNode(tag.Name + ": " + (tag.Value == null ? "" : tag.Value.ToString()), imageIndex, imageIndex); if (tag.GetType().IsGenericType&& tag.GetType().GetGenericTypeDefinition().IsAssignableFrom(typeof(TagList <>))) { n = new TreeNode(tag.Name, imageIndex, imageIndex); dynamic list = compound.GetTag(tag.Name); int itemImageIndex = Functions.TagIcons.Keys.Contains((TagType)list.ListType) ? Functions.TagIcons[list.ListType] : 0; for (int i = 0; i < list.Tags.Length; i++) { Tag item = list.Tags[i]; TreeNode itemNode = new TreeNode((list.ListType == TagType.TagCompound ? i.ToString() : (i.ToString() + ": " + (item.Value == null ? "Null" : item.Value.ToString()))), itemImageIndex, itemImageIndex); if (list.ListType == TagType.TagCompound) { this.RefreshTreeview((TagCompound)item, itemNode); } n.Nodes.Add(itemNode); } } node.Nodes.Add(n); } }