private void HandleFlatSongCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Remove || e.Action == NotifyCollectionChangedAction.Replace) { foreach (SongViewModel song in e.OldItems) { ReevaulateSong(song); } } if (e.Action == NotifyCollectionChangedAction.Add || e.Action == NotifyCollectionChangedAction.Replace) { foreach (SongViewModel song in e.NewItems) { ReevaulateSong(song); } } if (e.Action == NotifyCollectionChangedAction.Reset) { CurrentSongs.Clear(); if (!IsCircular) { foreach (MixViewModel mixViewModel in DependentMixes) { mixViewModel.Reset(); } } } }
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 void Search() { CurrentSongs.Clear(); CurrentSongs = new ObservableCollection <ENTITIES.Song>(oServicio.GetCompleteSongs()); switch (SelectedEnumTypeSearch) { case MUSIC.ENTITIES.TypesSeach.Titulo: if (TextSearch != string.Empty) { CurrentSongs = new ObservableCollection <ENTITIES.Song>(CurrentSongs.Where(source => source.Source.ToUpper().Contains(TextSearch.ToUpper())).ToList <ENTITIES.Song>()); } break; case MUSIC.ENTITIES.TypesSeach.Autor: if (TextSearch != string.Empty) { CurrentSongs = new ObservableCollection <ENTITIES.Song>(CurrentSongs.Where(source => source.Autor.ToUpper().Contains(TextSearch.ToUpper())).ToList <ENTITIES.Song>()); } break; case MUSIC.ENTITIES.TypesSeach.Album: if (TextSearch != string.Empty) { CurrentSongs = new ObservableCollection <ENTITIES.Song>(CurrentSongs.Where(source => source.Album.Name.ToUpper().Contains(TextSearch.ToUpper())).ToList <ENTITIES.Song>()); } break; case MUSIC.ENTITIES.TypesSeach.Todos: TextSearch = string.Empty; CurrentSongs = new ObservableCollection <ENTITIES.Song>(oServicio.GetCompleteSongs()); break; } SetConfigurationView(); }
private void RemoveTrackItem_OnClick(object sender, RoutedEventArgs e) { var item = (Song)CurrentPlayingListView.SelectedItem; var index = CurrentSongs.FindIndex(x => x.Name.Equals(item.Name)); player.RemoveTrack(index); CurrentSongs.RemoveAt(index); //CurrentSongs.Remove(item); ReloadCurrentPlayingListViewItemsSource(); }
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); } }
private void AddTrackToPlaylistItem_OnClick(object sender, RoutedEventArgs e) { var song = sender.ToString(); AddTrackToPlaylistWindow dialog = new AddTrackToPlaylistWindow(PlaylistsToString); if (dialog.ShowDialog() == true) { var item = (Song)CurrentPlayingListView.SelectedItem; var index = CurrentSongs.FindIndex(x => x.Name.Equals(item.Name)); var playlistName = dialog.SelectedPlaylistName; player.AddTrackToPlaylist(index, playlistName); ReloadPlaylistsListViewItemsSource(); ReloadCurrentPlayingListViewItemsSource(); } }
public void Reset() { CurrentSongs.Clear(); CurrentSongs.CollectionChanged -= HandleCurrentSongsCollectionChanged; CurrentSongs.UpdateLimit((uint)Limit, HasLimit); CurrentSongs.UpdateSortFunction(new SongSortGenericOrder(MixSortOrderToSongProperty(SortType), MixSortOrderToIsAscending(SortType))); List <MixViewModel> oldDependentMixes = new List <MixViewModel>(DependentMixes); UpdateDependencyList(); if (!IsCircular) { foreach (SongViewModel song in LibraryViewModel.Current.FlatSongCollection) { if (RootEvaluator.Eval(song)) { CurrentSongs.Add(song); } } } // Reset any mixes that used to depend on this and might not anymore foreach (MixViewModel mixViewModel in oldDependentMixes) { if (!DependentMixes.Contains(mixViewModel)) { mixViewModel.Reset(); } } if (!IsCircular) { // Reset any mixes that now depend on this List <MixViewModel> copyDependentMixes = new List <MixViewModel>(DependentMixes); foreach (MixViewModel mixViewModel in copyDependentMixes) { mixViewModel.Reset(); } } CurrentSongs.CollectionChanged += HandleCurrentSongsCollectionChanged; ResetLength(); }
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); } } }
internal bool ContainsSong(SongViewModel song) { return(CurrentSongs.Contains(song)); }
private void GetSongFromList() { CurrentSongs.Clear(); CurrentSongs = new ObservableCollection <ENTITIES.Song>((oServicio.GetSongsByList(SelectListSong).ToList <ENTITIES.Song>())); SetConfigurationView(); }