public void BuildTree() { var root = new SDEFListing(); tv_SDEFListing.Items.Clear(); root.Name = $"Root - {Database.ParameterRoot.CustomTypeName}"; BuildChildTree(root, Database.ParameterRoot); tv_SDEFListing.Items.Add(root); }
public void BuildChildTree(SDEFListing item, SDEFBase current) { foreach (var entry in current.ChildParameters) { var listing = new SDEFListing(); listing.Entry = entry; listing.Name = listing.ToString(); if (entry.NodeType == NodeType.CustomType) { BuildChildTree(listing, entry); } else if (entry.NodeType == NodeType.CustomTypeArray) { SDEFParamArray array = entry as SDEFParamArray; for (int i = 0; i < array.Values.Count; i++) { SDEFBase element = array.Values[i]; var arrValueListing = new SDEFListing() { Name = $"[{i}] - {array.CustomTypeName}" }; BuildChildTree(arrValueListing, element); listing.Items.Add(arrValueListing); } } else if (entry.NodeType == NodeType.RawValueArray) { SDEFParamArray array = entry as SDEFParamArray; for (int i = 0; i < array.RawValuesArray.Length; i++) { SDEFVariant elem = array.RawValuesArray[i]; var arrValueListing = new SDEFListing() { Name = $"[{i}] - {elem.ToString()}" }; arrValueListing.ArrayElement = elem; arrValueListing.ArrayElementIndex = i; listing.Items.Add(arrValueListing); } } item.Items.Add(listing); } }