Esempio n. 1
0
        // Expand/multiselect node if the path is found under it.
        private bool SearchAndSelectPath(TreeViewNode node, string path)
        {
            if (node is DirectoryTreeViewNode)
            {
                DirectoryTreeViewNode directory = node as DirectoryTreeViewNode;

                if (path.StartsWith(directory.FullPath + "/"))
                {
                    foreach (TreeViewNode child in directory.Children)
                    {
                        bool found = SearchAndSelectPath(child, path);

                        if (found)
                        {
                            directory.IsExpanded = true;
                            return(true);
                        }
                    }
                }
            }
            else if (node is SongMetadataTreeViewNode)
            {
                SongMetadataTreeViewNode song = node as SongMetadataTreeViewNode;

                if (song.Song.Path == path)
                {
                    song.IsMultiSelected = true;
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
        private void PopulateGenreTree()
        {
            GenreTreeController.ClearMultiSelection();
            GenreTree.Clear();

            foreach (string genre in m_DataModel.Database.Genres)
            {
                GenreTreeViewNode genreNode = new GenreTreeViewNode(genre, null, GenreTreeController);

                foreach (AlbumMetadata album in m_DataModel.Database.AlbumsByGenre(genre))
                {
                    AlbumMetadataTreeViewNode albumNode = new AlbumMetadataTreeViewNode(album, genreNode, GenreTreeController);
                    genreNode.AddChild(albumNode);

                    foreach (SongMetadata song in m_DataModel.Database.SongsByAlbum(album))
                    {
                        if (song.Genre == genre)
                        {
                            SongMetadataTreeViewNode songNode = new SongMetadataTreeViewNode("", song, albumNode, GenreTreeController);
                            albumNode.AddChild(songNode);
                        }
                    }
                }

                GenreTree.Add(genreNode);
            }

            int id = 0;

            foreach (TreeViewNode baseNode in GenreTree)
            {
                id = AssignTreeViewNodeIDs(baseNode, id);
            }
        }
Esempio n. 3
0
        private void PopulateDirectoryTree()
        {
            DirectoryTreeController.ClearMultiSelection();
            DirectoryTree.Clear();

            DirectoryTreeViewNode rootNode = new DirectoryTreeViewNode("/", null, DirectoryTreeController);
            IDictionary <string, TreeViewNode> directoryLookup = new SortedDictionary <string, TreeViewNode>();

            directoryLookup[rootNode.DisplayString] = rootNode;

            foreach (SongMetadata song in m_DataModel.Database.Songs)
            {
                TreeViewNode             parent = FindDirectoryNode(song.Directory, directoryLookup, rootNode);
                SongMetadataTreeViewNode leaf   = new SongMetadataTreeViewNode(song.Filename, song, parent, DirectoryTreeController);
                parent.AddChild(leaf);
            }

            AssignTreeViewNodeIDs(rootNode, 0);

            if (rootNode.Children.Count > 0)
            {
                DirectoryTree.Add(rootNode);
                rootNode.IsExpanded = true;
            }
        }
Esempio n. 4
0
        private void PopulateArtistTree()
        {
            ArtistTree.Clear();
            ArtistTreeController.MultiSelection.Clear();

            foreach (string artist in m_DataModel.Database.Artists)
            {
                ArtistTreeViewNode artistNode = new ArtistTreeViewNode(artist, null, ArtistTreeController);

                foreach (AlbumMetadata album in m_DataModel.Database.AlbumsByArtist(artist))
                {
                    AlbumMetadataTreeViewNode albumNode = new AlbumMetadataTreeViewNode(album, artistNode, ArtistTreeController);
                    artistNode.AddChild(albumNode);

                    foreach (SongMetadata song in m_DataModel.Database.SongsByAlbum(album))
                    {
                        SongMetadataTreeViewNode songNode = new SongMetadataTreeViewNode("", song, albumNode, ArtistTreeController);
                        albumNode.AddChild(songNode);
                    }
                }

                ArtistTree.Add(artistNode); // Insert now that branch is fully populated.
            }

            int id = 0;

            foreach (TreeViewNode baseNode in ArtistTree)
            {
                id = AssignTreeViewNodeIDs(baseNode, id);
            }
        }
Esempio n. 5
0
        public void ShowSongsInGenreTree(IEnumerable <SongMetadata> selectedSongs)
        {
            ISet <string>        selectedGenres    = new SortedSet <string>();
            ISet <AlbumMetadata> selectedAlbums    = new SortedSet <AlbumMetadata>();
            ISet <string>        selectedSongPaths = new SortedSet <string>(StringComparer.Ordinal);

            foreach (SongMetadata song in selectedSongs)
            {
                if (song.IsLocal)
                {
                    selectedGenres.Add(song.Genre);
                    selectedAlbums.Add(new AlbumMetadata(song.Artist, song.Album, null));
                    selectedSongPaths.Add(song.Path);
                }
            }

            GenreTreeController.ClearMultiSelection();

            foreach (TreeViewNode rootNode in GenreTreeController.RootLevelNodes)
            {
                GenreTreeViewNode genreNode = rootNode as GenreTreeViewNode;
                genreNode.IsExpanded = false;

                if (selectedGenres.Contains(genreNode.Genre))
                {
                    genreNode.IsExpanded = true;

                    foreach (TreeViewNode midNode in genreNode.Children)
                    {
                        AlbumMetadataTreeViewNode albumNode = midNode as AlbumMetadataTreeViewNode;
                        albumNode.IsExpanded = false;

                        if (selectedAlbums.Contains(albumNode.Album))
                        {
                            albumNode.IsExpanded = true;

                            foreach (TreeViewNode leafNode in albumNode.Children)
                            {
                                SongMetadataTreeViewNode songNode = leafNode as SongMetadataTreeViewNode;

                                if (selectedSongPaths.Contains(songNode.Song.Path))
                                {
                                    songNode.IsMultiSelected = true;
                                }
                            }
                        }
                    }
                }
            }
        }