Пример #1
0
        private GroupEntry RecursiveGroupLoad(XElement element)
        {
            GroupEntry entry = new GroupEntry()
            {
                Name = element.AttributeOrDefault("Name")
            };

            foreach (XElement s in element.Elements("Song"))
            {
                entry.Songs.Add(new SongEntry()
                {
                    UniqueId = s.AttributeOrDefault("UniqueId")
                });
            }
            foreach (XElement g in element.Elements("Group"))
            {
                entry.Groups.Add(RecursiveGroupLoad(g));
            }

            return(entry);
        }
Пример #2
0
        private void PopulateGroup(TreeNode parent, GroupEntry group, List <SongEntry> remainingSongs)
        {
            TreeNodeCollection nodes = parent == null ? GroupList.Nodes : parent.Nodes;

            TreeNode groupNode = nodes.Add(group.Name);

            groupNode.ForeColor = Color.RoyalBlue;

            foreach (var g in group.Groups)
            {
                PopulateGroup(groupNode, g, remainingSongs);
            }
            foreach (var s in group.Songs)
            {
                TreeNode node = groupNode.Nodes.Add(s.UniqueId, (from r in remainingSongs where r.UniqueId == s.UniqueId select r.ToString()).FirstOrDefault() ?? "Unknown Song", 1, 1);

                SongEntry matching = remainingSongs.Find(song => song.UniqueId == s.UniqueId) ?? s;
                node.Tag = matching;

                remainingSongs.RemoveAll(song => song.UniqueId == s.UniqueId);
            }
        }
        void PopulateGroup(TreeNode parent, GroupEntry group, List <SongEntry> remainingSongs)
        {
            TreeNode n = new TreeNode()
            {
                Name = group.Name, IsGroup = true, Parent = parent
            };

            (parent == null ? Groups.Data : parent.Children).Add(n);

            foreach (var g in group.Groups)
            {
                PopulateGroup(n, g, remainingSongs);
            }
            foreach (var s in group.Songs)
            {
                TreeNode node = new TreeNode()
                {
                    SongId = s.UniqueId, Name = (from r in remainingSongs where r.UniqueId == s.UniqueId select r.ToString()).FirstOrDefault() ?? s.ToString(), IsGroup = false, Parent = n
                };
                n.Children.Add(node);

                remainingSongs.RemoveAll(song => song.UniqueId == s.UniqueId);
            }
        }