internal void AlertSongChanged(SongViewModel songViewModel, string propertyName) { foreach (MixViewModel mix in MixCollection) { mix.OnSongPropertyChanged(songViewModel, propertyName); } }
public void ReevaulateSong(SongViewModel song) { bool belongsInList = !IsCircular && RootEvaluator.Eval(song); bool updated = false; if (belongsInList && !CurrentSongs.ActuallyContains(song)) { CurrentSongs.Add(song); updated = true; } else if (!belongsInList && CurrentSongs.ActuallyContains(song)) { CurrentSongs.Remove(song); updated = true; } if (updated && !IsCircular) { foreach (MixViewModel mixViewModel in DependentMixes) { mixViewModel.ReevaulateSong(song); } } }
private SongViewModel LookupSong(SongModel song) { if (song == null) { return(null); } if (SongLookupMap.ContainsKey(song.SongId)) { return(SongLookupMap[song.SongId]); } else { ArtistViewModel artist = LookupArtistById(song.ArtistId); AlbumViewModel album = LookupAlbumById(song.AlbumId); SongViewModel newSongViewModel = new SongViewModel(song, artist, album); SongLookupMap.Add(newSongViewModel.SongId, newSongViewModel); SongCollection.Add(newSongViewModel, newSongViewModel.SortName); FlatSongCollection.Add(newSongViewModel); if (LibraryLoaded) { NotifyPropertyChanged(Properties.IsEmpty); } return(newSongViewModel); } }
public int CompareTo(object obj) { if (obj == null) { return(1); } SongViewModel otherSong = obj as SongViewModel; if (otherSong != null) { if (otherSong.SortName == this.SortName) { return(this.Album.CompareTo(otherSong.Album)); } else { return(this.SortName.CompareTo(otherSong.SortName)); } } else { throw new ArgumentException("Object is not a SongViewModel"); } }
internal void RemoveAllInstancesOfSong(SongViewModel song) { rootModel.RemoveSong(song.SongId); foreach (MixViewModel mixViewModel in DependentMixes) { mixViewModel.ReevaulateSong(song); } }
public void AddSong(SongViewModel songToAdd) { rootModel.AddSong(songToAdd.SongId); foreach (MixViewModel mixViewModel in DependentMixes) { mixViewModel.ReevaulateSong(songToAdd); } }
public void ReevaulateSong(SongViewModel song) { bool belongsInList = !IsCircular && RootEvaluator.Eval(song); if (belongsInList && !CurrentSongs.ActuallyContains(song)) { CurrentSongs.Add(song); } else if (!belongsInList && CurrentSongs.ActuallyContains(song)) { CurrentSongs.Remove(song); } }
internal bool AddSong(StorageProviderSong song, bool resetSongData) { SongModel songFromSource = LibraryModel.Current.GetSongFromSource(StorageProviderSourceToSongOriginSource(song.Origin), song.Source); if (songFromSource != null) { if (resetSongData) { SongViewModel songViewModel = LookupSong(songFromSource); songViewModel.Name = song.Name; songViewModel.ArtistName = song.Artist; string newAlbumName = song.Album; string newAlbumAristName = song.AlbumArtist; if (newAlbumName != songViewModel.Album.Name || newAlbumAristName != songViewModel.Album.ArtistName) { ArtistViewModel albumArtistViewModel = LibraryViewModel.Current.LookupArtistByName(newAlbumAristName); AlbumViewModel newAlbumViewModel = LibraryViewModel.Current.LookupAlbumByName(newAlbumName, albumArtistViewModel.ArtistId); songViewModel.UpdateAlbum(newAlbumViewModel); } songViewModel.TrackNumber = song.TrackNumber; } return(false); } SongModel newSongModel = LibraryModel.Current.AddNewSong( song.Artist, song.Album, song.AlbumArtist, song.Name, song.Source, StorageProviderSourceToSongOriginSource(song.Origin), song.Duration.Ticks, song.Rating, song.TrackNumber ); if (LookupSong(newSongModel) == null) { DebugHelper.Alert(new CallerInfo(), "Failed to add song"); return(false); } return(true); }
private void HandleAllSongsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Reset) { foreach (SongViewModel oldSongViewModel in FlatSongCollection) { oldSongViewModel.Album.Songs.Remove(oldSongViewModel); oldSongViewModel.Artist.Songs.Remove(oldSongViewModel); SongCollection.Remove(oldSongViewModel, oldSongViewModel.SortName); FlatSongCollection.Remove(oldSongViewModel); SongLookupMap.Remove(oldSongViewModel.SongId); } } else { if (e.OldItems != null) { foreach (SongModel oldSong in e.OldItems) { SongViewModel oldSongViewModel = LookupSong(oldSong); SongCollection.Remove(oldSongViewModel, oldSongViewModel.SortName); FlatSongCollection.Remove(oldSongViewModel); SongLookupMap.Remove(oldSongViewModel.SongId); oldSongViewModel.Album.Songs.Remove(oldSongViewModel); oldSongViewModel.Artist.Songs.Remove(oldSongViewModel); } } if (e.NewItems != null) { foreach (SongModel newSong in e.NewItems) { LookupSong(newSong); } } } if (LibraryLoaded) { NotifyPropertyChanged(Properties.IsEmpty); ShuffleAllSongs.RaiseExecuteChanged(); } }
internal void DeleteSong(SongViewModel song) { foreach (PlaylistViewModel playlist in PlaylistCollection) { playlist.RemoveAllInstancesOfSong(song); } PlayQueue.RemoveAllInstancesOfSong(song); AlbumViewModel album = song.Album; ArtistViewModel artist = song.Artist; LibraryModel.Current.DeleteSong(song.SongId); RemoveAlbumIfNeeded(album); RemoveArtistIfNeeded(artist); }
public void OnSongPropertyChanged(SongViewModel song, string propertyName) { if (RootEvaluator.IsPropertyAffected(propertyName)) { ReevaulateSong(song); } if (propertyName == MixSortOrderToSongProperty(SortType)) { // Remove and reinsert to update sort order if (CurrentSongs.ActuallyContains(song)) { CurrentSongs.Remove(song); CurrentSongs.Add(song); } } }
private async void SearchSongs(string query) { Songs.Clear(); List <int> foundSongs = await SearchManagerModel.SearchSongs(query); foreach (int songId in foundSongs) { SongViewModel foundSong = LibraryViewModel.Current.LookupSongById(songId); if (foundSong != null) { Songs.Add(foundSong); } } songSearchInProgress = false; NotifyPropertyChanged(Properties.SearchInProgress); NotifyPropertyChanged(Properties.ContentInfoSongs); }
internal void RemoveAllInstancesOfSong(SongViewModel song) { rootModel.RemoveSong(song.SongId); }
public void QueueSong(SongViewModel s) { rootModel.QueueSong(s.SongId); }
public void PlaySong(SongViewModel s) { rootModel.PlaySong(s.SongId); }
internal bool ContainsSong(SongViewModel song) { return(CurrentSongs.Contains(song)); }
internal bool ContainsSong(SongViewModel song) { return(rootModel.ContainsSong(song.SongId)); }
internal void AlertSongNameChanged(SongViewModel songViewModel, string oldName) { SongCollection.Remove(songViewModel, oldName); SongCollection.Add(songViewModel, songViewModel.SortName); }