Пример #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 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 CreditTransactionViewModel(User user)
        {
            User = user;
            CurrentCredits = user.Credits;
            _userRepo = new UserRepository();
            PaymentOptions = new ObservableCollection<string>();
            PaymentOptions.Add("Credit Card");
            PaymentOptions.Add("PayPal");
            PaymentOptions.Add("Cash");

            TransactCreditsCommand = new RelayCommand(new Action<object>(TransactCredits));
            CloseCreditTransactionViewCommand = new RelayCommand(new Action<object>(CloseCreditTransactionView));
        }
Пример #4
0
        public SongListViewModel(SongRepository repo)
        {
            _songRepository = repo;
            _songs = new ObservableCollection<Song>(_songRepository.GetSongs());
            _songRepository.Dispose();
            MediaControl = new RelayCommand(new Action<object>(SendMediaControlMessage));

            // Listens for PlaylistListViewModel.cs to select a playlist
            Messenger.Default.Register<Playlist>(this, UpdateSongsList, "PlaylistSelected");

            Messenger.Default.Register<bool>(this, RefreshSongList, "SongUpdated");

            Messenger.Default.Register<bool>(this, CanPlaySongUpdate, "NoCredits");
        }
Пример #5
0
        public SongViewModel()
        {
            _song = null;
            _songRepo = new SongRepository();
            PlayMedia = new RelayCommand(new Action<object>(SendPlayMediaMessage));

            // listens to SongListViewModel.cs
            Messenger.Default.Register<Song>(this, UpdateCurrentSong, "UpdateCurrentSong");

            // SongView Code Behind Sends this
            Messenger.Default.Register<bool>(this, IncrementSong, "PlayNextSong");
            Messenger.Default.Register<TimeSpan>(this, UpdateSongTime, "TimeSpanFound");
            Messenger.Default.Register<int>(this, IncrementTimeStamp, "IncrementDuration");
        }
Пример #6
0
        public MenuViewModel()
        {
            DeletePlaylistCommand = new RelayCommand(new Action<object>(DeletePlaylist));
            DeleteSongCommand = new RelayCommand(new Action<object>(DeleteSong));

            CreatePlaylistViewCommand = new RelayCommand(new Action<object>(CreatePlaylistView));
            CreateLoginViewCommand = new RelayCommand(new Action<object>(CreateLoginView));
            CreateRegisterViewCommand = new RelayCommand(new Action<object>(CreateRegisterView));
            CreateAddNewSongViewCommand = new RelayCommand(new Action<object>(CreateAddNewSongView));
            CreateEditPlaylistViewCommand = new RelayCommand(new Action<object>(CreateEditPlaylistView));
            CreateEditSongViewCommand = new RelayCommand(new Action<object>(CreateEditSongView));
            CreateCreditTransactionViewCommand = new RelayCommand(new Action<object>(CreateCreditTransactionView));
            LogoutUserCommand = new RelayCommand(new Action<object>(CloseLoginView));

            Messenger.Default.Register<Playlist>(this,UpdatePlaylist,"PlaylistSelected");
            Messenger.Default.Register<Song>(this, UpdateSong, "SongSelected");
        }
Пример #7
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));
        }
Пример #8
0
        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));
        }
Пример #9
0
 public LoginUserViewModel()
 {
     CloseLoginView = new RelayCommand(new Action<object>(CloseLoginViewMessage));
     LoginUser = new RelayCommand(new Action<object>(LoginUserMessage), Predicate => { if (Username == null || Username == "") { return false; } else { return true; } });
 }
Пример #10
0
 public RegisterViewModel()
 {
     CloseRegisterViewCommand = new RelayCommand(new Action<object>(CloseRegisterView));
     RegisterNewUserCommand = new RelayCommand(new Action<object>(RegisterNewUser), Predicate => { if (Username == null || Username == "" || Username.Length < 6 || !UsernameRule.UsernameRegex.IsMatch(Username)) { return false; } else { return true; } });
     _userRepo = new UserRepository();
 }