/// <summary> /// reset method. /// change the current playlist that is showed to the user /// to the original playlist that he entered with to the /// editor. /// </summary> public void reset() { CurrentPlayList.Songs.Clear(); CurrentGeners.Clear(); TempoList.Clear(); foreach (Song item in OriginalPlayList.Songs) { CurrentPlayList.Songs.Add(item); } resolveGenres(CurrentPlayList); resolveTempo(CurrentPlayList); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VM_GetPlayList")); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Vm_CurrentGenres")); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Vm_TempoList")); }
/// <summary> /// Filter method. /// filter playlist according to user choice. /// first check for generes that user want, than clear /// the collection that the playlist is based on and add /// the appropriate songs to the playlist, and notify the viewmodel /// </summary> public void Filter() { List <string> genres = choosenGenres(); List <string> tempoes = chosenTempo(); if (genres.Count == 0 && tempoes.Count == 0) { return; } ObservableCollection <Song> temp = new ObservableCollection <Song>(CurrentPlayList.Songs); CurrentPlayList.Songs.Clear(); foreach (Song song in temp) { if (genres.Count == 0 && tempoes.Count != 0) { string tempo = tempoType(song); if (tempoes.Contains(tempo)) { CurrentPlayList.Songs.Add(song); continue; } } if (genres.Contains(song.Artist.Genre)) { if (tempoes.Count == 0) { CurrentPlayList.Songs.Add(song); } else { string tempo = tempoType(song); if (tempoes.Contains(tempo)) { CurrentPlayList.Songs.Add(song); } } } } this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VM_GetPlayList")); CurrentGeners.Clear(); resolveGenres(CurrentPlayList); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Vm_CurrentGenres")); TempoList.Clear(); resolveTempo(CurrentPlayList); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Vm_TempoList")); }
/// <summary> /// remove the choosen song from the playlist. /// </summary> public void RemoveSong() { if (SongRemove != null) { foreach (Song item in CurrentPlayList.Songs) { if (item.ID == SongRemove.ID) { CurrentPlayList.Songs.Remove(item); break; } } CurrentGeners.Clear(); TempoList.Clear(); resolveGenres(CurrentPlayList); resolveTempo(CurrentPlayList); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("VM_GetPlayList")); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Vm_CurrentGenres")); this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Vm_TempoList")); } }