コード例 #1
0
        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);
                }
            });
        }
コード例 #2
0
        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));
        }