/// <summary> /// Imports playlist items as SongGridViewItems. /// </summary> /// <param name="playlist">Playlist</param> public void ImportPlaylist(Playlist playlist) { _mode = SongGridViewMode.Playlist; _items = new List<SongGridViewItem>(); foreach (var playlistItem in playlist.Items) { var item = new SongGridViewItem(); item.AudioFile = playlistItem.AudioFile; item.PlaylistItemId = playlistItem.Id; _items.Add(item); } // Reset scrollbar position VerticalScrollBar.Value = 0; _songCache = null; OnInvalidateVisual(); }
/// <summary> /// Imports audio files as SongGridViewItems. /// </summary> /// <param name="audioFiles">List of AudioFiles</param> public void ImportAudioFiles(List<AudioFile> audioFiles) { _mode = SongGridViewMode.AudioFile; _items = new List<SongGridViewItem>(); var albums = audioFiles.GroupBy(x => new { x.ArtistName, x.AlbumTitle }); foreach (var album in albums) { var songs = audioFiles.Where(x => x.ArtistName == album.Key.ArtistName && x.AlbumTitle == album.Key.AlbumTitle).ToArray(); foreach (var song in songs) { var item = new SongGridViewItem(); item.AudioFile = song; item.PlaylistItemId = Guid.NewGuid(); item.AlbumArtKey = album.Key.ArtistName + "_" + album.Key.AlbumTitle; _items.Add(item); } if (songs.Length < MinimumRowsPerAlbum) { for (int a = 0; a < MinimumRowsPerAlbum - songs.Length; a++) { var item = new SongGridViewItem(); item.IsEmptyRow = true; item.AlbumArtKey = album.Key.ArtistName + "_" + album.Key.AlbumTitle; _items.Add(item); } } } VerticalScrollBar.Value = 0; _songCache = null; OnInvalidateVisual(); }