Пример #1
0
        public AlbumMetadata AlbumOfSong(SongMetadata song)
        {
            AlbumMetadata album = null;

            if (m_AlbumBySong.TryGetValue(song, out album))
            {
                return(album);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        private void PopulateSongPathsByAlbum()
        {
            foreach (SongMetadata song in m_LocalSongCollection.Values)
            {
                AlbumMetadata album = m_AlbumsByArtistAndName[song.Artist][song.Album];

                if (!m_SongPathsByAlbum.ContainsKey(album))
                {
                    m_SongPathsByAlbum[album] = new SortedSet <string>();
                }

                m_SongPathsByAlbum[album].Add(song.Path);
            }
        }
Пример #3
0
        public AlbumMetadataTreeViewNode(AlbumMetadata album, TreeViewNode parent, TreeViewController controller) :
            base(parent, controller)
        {
            Album = album;

            if (parent is ArtistTreeViewNode)
            {
                m_DisplayString = Album.Title;
            }
            else
            {
                m_DisplayString = Album.Artist + ": " + Album.Title;
            }
        }
Пример #4
0
        public void ShowSongsInGenreList(IEnumerable <SongMetadata> selectedSongs)
        {
            foreach (MusicCollectionItem genreItem in Genres)
            {
                genreItem.IsSelected = false;

                foreach (SongMetadata selectedSong in selectedSongs)
                {
                    if (genreItem.Content as string == selectedSong.Genre)
                    {
                        genreItem.IsSelected = true;
                    }
                }
            }

            OnSelectedGenresChanged();

            foreach (MusicCollectionItem albumItem in AlbumsOfSelectedGenres)
            {
                albumItem.IsSelected = false;
                AlbumMetadata album = albumItem.Content as AlbumMetadata;

                foreach (SongMetadata selectedSong in selectedSongs)
                {
                    if (album.Artist == selectedSong.Artist && album.Title == selectedSong.Album)
                    {
                        albumItem.IsSelected = true;
                    }
                }
            }

            OnSelectedAlbumsOfSelectedGenresChanged();

            foreach (MusicCollectionItem songItem in SongsOnSelectedAlbumsOfSelectedGenres)
            {
                songItem.IsSelected = false;
                SongMetadata songInView = songItem.Content as SongMetadata;

                foreach (SongMetadata selectedSong in selectedSongs)
                {
                    if (songInView.Path == selectedSong.Path)
                    {
                        songItem.IsSelected = true;
                    }
                }
            }
        }
Пример #5
0
        public ISet <SongMetadata> SongsByAlbum(AlbumMetadata byAlbum)
        {
            SortedSet <SongMetadata> result = new SortedSet <SongMetadata>();

            if (m_SongPathsByAlbum.ContainsKey(byAlbum))
            {
                foreach (string path in m_SongPathsByAlbum[byAlbum])
                {
                    if (m_LocalSongCollection.ContainsKey(path))
                    {
                        result.Add(m_LocalSongCollection[path]);
                    }
                }
            }

            return(result);
        }
Пример #6
0
        private void PopulateAlbumsByArtist()
        {
            // Create a lookup table of unique artist/album pairs. Find
            // the last timestamp for each.
            IDictionary <string, IDictionary <string, string> > artistTitleAndDate = new SortedDictionary <string, IDictionary <string, string> >();

            foreach (SongMetadata song in m_LocalSongCollection.Values)
            {
                if (artistTitleAndDate.ContainsKey(song.Artist))
                {
                    IDictionary <string, string> titleAndDate = artistTitleAndDate[song.Artist];
                    string existingDate = null;
                    titleAndDate.TryGetValue(song.Album, out existingDate);

                    if (existingDate == null || song.Date != null && existingDate.CompareTo(song.Date) < 0)
                    {
                        titleAndDate[song.Album] = song.Date;
                    }
                }
                else
                {
                    IDictionary <string, string> titleAndDate = new SortedDictionary <string, string>();
                    titleAndDate[song.Album]        = song.Date;
                    artistTitleAndDate[song.Artist] = titleAndDate;
                }
            }

            // Now create the proper AlbumMetadata objects and add them to
            // the various lookups.
            foreach (string artist in artistTitleAndDate.Keys)
            {
                IDictionary <string, string> titleAndDate = artistTitleAndDate[artist];
                m_AlbumsByArtist[artist] = new SortedSet <AlbumMetadata>(AlbumSortRule);
                ISet <AlbumMetadata> albumsByArtist = m_AlbumsByArtist[artist];
                m_AlbumsByArtistAndName[artist] = new SortedDictionary <string, AlbumMetadata>();
                IDictionary <string, AlbumMetadata> albumsByArtistAndName = m_AlbumsByArtistAndName[artist];

                foreach (string album in artistTitleAndDate[artist].Keys)
                {
                    AlbumMetadata node = new AlbumMetadata(artist, album, titleAndDate[album]);
                    albumsByArtist.Add(node);
                    albumsByArtistAndName[album] = node;
                }
            }
        }
Пример #7
0
        public int CompareTo(object o)
        {
            if (o is AlbumMetadata)
            {
                AlbumMetadata rhs = o as AlbumMetadata;

                if (Artist != rhs.Artist)
                {
                    return(StringComparer.Ordinal.Compare(Artist, rhs.Artist));
                }
                else
                {
                    return(StringComparer.Ordinal.Compare(Title, rhs.Title));
                }
            }
            else
            {
                throw new Exception("SongMetadata: attempt to compare to an incompatible object");
            }
        }