示例#1
0
 public PlaylistViewModel(PlaylistViewModel playlistViewModel)
 {
     _EventAggregator  = playlistViewModel._EventAggregator;
     _SettingsManager  = playlistViewModel._SettingsManager;
     Tracks            = new ObservableCollection <TrackViewModel>(playlistViewModel.Tracks);
     Playlist          = new PlaylistModel(playlistViewModel.Playlist);
     AllTracksSelected = playlistViewModel.AllTracksSelected;
     Expanded          = playlistViewModel.Expanded;
 }
示例#2
0
        public async void Handle(DataRefreshAuthorizedEvent message)
        {
            _Logger.Info("Retrieving playlists of the logged-in Spotify user...");
            _EventAggregator.PublishOnUIThread(new DisplayProgressEvent(Localization.Playlists.RetrievingPlaylistsDialogTitle,
                                                                        Localization.Playlists.RetrievingPlaylistsDialogMessage));
            var playlistCollection = await message.Session.GetPlaylistCollection();

            var playlists = new List <Playlist>(await playlistCollection.GetPlaylists());

            _Logger.Debug(String.Format("{0} playlists were retrieved from the playlist container", playlists.Count));
            _Logger.Debug("Fetching playlists and applying them to the collection...");

            Playlists = new ObservableCollection <PlaylistViewModel>();
            foreach (var playlist in playlists)
            {
                var fetchedPlaylistViewModel = new PlaylistViewModel(await PlaylistModel.FromLibrary(playlist, message.Session),
                                                                     _EventAggregator, _SettingsManager);
                Playlists.Add(fetchedPlaylistViewModel);
                _Logger.Info(String.Format("Added playlist {0} ({1} tracks)", fetchedPlaylistViewModel.Name, fetchedPlaylistViewModel.Tracks.Count));
            }

            _Logger.Info("Retrieving playlists finished");
            _EventAggregator.PublishOnUIThread(new HideProgressEvent());
        }