Exemple #1
0
        public static void AddChildren(List <ListElement> listElements, TreeElement parent)
        {
            int Index = FindIndex(listElements, parent.Name);

            // Die Childindizes sammeln um alle anzuhängen
            List <int> ChildIndices = new List <int>();

            foreach (var listElement in listElements[Index].Children)
            {
                ChildIndices.Add(FindIndex(listElements, listElement));
            }

            foreach (var childIndex in ChildIndices)
            {
                parent.Add(listElements[childIndex].Name, listElements[childIndex].Weight);
            }

            foreach (var child in parent.Children)
            {
                AddChildren(listElements, child);
            }
        }
Exemple #2
0
        private static TreeElement BuildTree(List <ListElement> listElements, int index)
        {
            TreeElement TestElement = new TreeElement(listElements[index].Name, listElements[index].Weight);

            // Die Childindizes sammeln um alle anzuhängen
            List <int> ChildIndices = new List <int>();

            foreach (var child in listElements[index].Children)
            {
                ChildIndices.Add(FindIndex(listElements, child));
            }

            foreach (var childIndex in ChildIndices)
            {
                TestElement.Add(listElements[childIndex].Name, listElements[childIndex].Weight);
            }

            foreach (var child in TestElement.Children)
            {
                AddChildren(listElements, child);
            }

            return(TestElement);
        }