public EditPlaylistViewModel(Playlist playlist, User user) { Playlist = playlist; User = user; _songRepo = new SongRepository(); _artRepo = new ArtRepository(); _playlistRepo = new PlaylistRepository(); _playlistRepo.Dispose(); Art = new ObservableCollection<string>(_artRepo.GetPlaylistArt()); AllSongs = new ObservableCollection<Song>(_songRepo.GetAllSongs()); PlaceholderSongs = CurrentSongs; Title = Playlist.Title; Image = Playlist.Image; PlaylistUserID = Playlist.UserID; SelectedImage = Playlist.Image; // COMMANDS AddSongToPlaylistCommand = new RelayCommand(new Action<object>(AddSongToPlaylist)); RemoveSongFromPlaylistCommand = new RelayCommand(new Action<object>(RemoveSongFromPlaylist)); CloseEditPlaylistViewCommand = new RelayCommand(new Action<object>(CloseEditPlaylistView)); SavePlaylistChangesCommand = new RelayCommand(new Action<object>(SavePlaylistChanges), Predicate => { if (TitleRule.TitleRegex.IsMatch(Title)) { return true; } else { return false; } }); }
public EditSongViewModel(Song song) { Song = song; Title = Song.Title; Artist = Song.Artist; Duration = Song.Duration; Art = Song.Image; SelectedArt = Song.Image; _artRepo = new ArtRepository(); ArtSelection = new ObservableCollection<string>(_artRepo.GetAlbumArt()); _songRepo = new SongRepository(); CloseEditSongViewCommand = new RelayCommand(new Action<object>(CloseEditSongView)); SaveChangesToSongCommand = new RelayCommand(new Action<object>(SaveChanges), Predicate => { if (TitleRule.TitleRegex.IsMatch(Title) && TitleRule.TitleRegex.IsMatch(Artist) && DurationRule.DurationRegex.IsMatch(Duration)) { return true; } else { return false; } }); }
public CreatePlaylistViewModel(User user = null) { User = user; _songRepo = new SongRepository(); _artRepo = new ArtRepository(); _songSelection = new ObservableCollection<Song>(_songRepo.GetAllSongs()); _artSelection = new ObservableCollection<string>(_artRepo.GetPlaylistArt()); _songRepo.Dispose(); CreateNewPlaylistCommand = new RelayCommand(new Action<object>(CreatePlaylist), Predicate => { if (TitleRule.TitleRegex.IsMatch(Name)) { return true; } else { return false; } }); CloseCreatePlaylistViewCommand = new RelayCommand(new Action<object>(CloseCreatePlaylistView)); }
public AddSongViewModel() { _artRepo = new ArtRepository(); _artCollection = new ObservableCollection<string>(_artRepo.GetAllArt()); _songRepo = new SongRepository(); AddNewSongCommand = new RelayCommand(new Action<object>(AddNewSong), Predicate => { if(TitleRule.TitleRegex.IsMatch(Title) && TitleRule.TitleRegex.IsMatch(Artist) && DurationRule.DurationRegex.IsMatch(Duration) && RequiredRule.RequiredRegex.IsMatch(SongPath)) { return true; } else { return false; } }); CloseAddNewSongViewCommand = new RelayCommand(new Action<object>(CloseNewSongView)); BrowseSongCommand = new RelayCommand(new Action<object>(BrowseSong)); }