public MainViewModel() { _viewModels = new ObservableCollection<ViewModelBase>(); _playlistRepository = new PlaylistRepository(); _songRepository = new SongRepository(); _userRepo = new UserRepository(); _playlistListViewModel = new PlaylistListViewModel(_playlistRepository); _songListViewModel = new SongListViewModel(_songRepository); _songViewModel = new SongViewModel(); _menuViewModel = new MenuViewModel(); _viewModels.Add(_playlistListViewModel); _viewModels.Add(_songListViewModel); _viewModels.Add(_songViewModel); _viewModels.Add(_menuViewModel); #region Registering for ViewModel Commands // Listens for a click in menuViewModel Messenger.Default.Register<bool>(this, SetCreatePlaylistViewModel, "CreatePlaylistView"); Messenger.Default.Register<bool>(this, CloseCreatePlaylistView, "CloseCreatePlaylistView"); // Listens for click in menuViewModel Messenger.Default.Register<bool>(this, SetLoginViewModel, "CreateLoginView"); // Listens for LoginUserViewModel to send this message Messenger.Default.Register<bool>(this, CloseLoginViewModel, "CloseLoginView"); // Listens for menuViewModel logout button click Messenger.Default.Register<bool>(this, LogoutUser, "LogoutUser"); // Listens for register button click in MenuViewModel Messenger.Default.Register<bool>(this, SetRegisterViewModel, "CreateRegisterView"); Messenger.Default.Register<bool>(this, CloseRegisterViewModel, "CloseRegisterView"); // Listens for menuviewModel AddNewSong button click Messenger.Default.Register<bool>(this, SetAddNewSongViewModel, "CreateAddNewSongView"); Messenger.Default.Register<bool>(this, CloseAddNewSongViewModel, "CloseAddNewSongView"); // Listenes for menuviewModel EditPlaylist button click Messenger.Default.Register<Playlist>(this, SetEditPlaylistViewModel, "CreateEditPlaylistView"); Messenger.Default.Register<bool>(this, CloseEditPlaylistView, "CloseEditPlaylistView"); // listens for menuviewmodel Edit Song button click Messenger.Default.Register<Song>(this, SetEditSongViewModel, "CreateEditSongView"); Messenger.Default.Register<bool>(this, CloseEditSongView, "CloseEditSongView"); // Listenes for menuvireModel Credits button Messenger.Default.Register<bool>(this, SetCreditTransactionViewModel, "CreateCreditTransactionView"); Messenger.Default.Register<bool>(this, CloseCreditTransactionView, "CloseCreditTransactionView"); // Listens for LoginViewModel successful login, or a RegisterViewModel sucessful registration Messenger.Default.Register<User>(this, LoginUser, "UserLogin"); // Listens for when song is selected, changed, etc Messenger.Default.Register<bool>(this, UserPlayedSong, "UserCreditCheck"); // Listens from MenuViewModel for delete commands Messenger.Default.Register<Playlist>(this, DeletePlaylist, "DeletePlaylist"); Messenger.Default.Register<Song>(this, DeleteSong, "DeleteSong"); #endregion User = new User(); }
public MainViewModel() { _viewModels = new ObservableCollection <ViewModelBase>(); _playlistRepository = new PlaylistRepository(); _songRepository = new SongRepository(); _userRepo = new UserRepository(); _playlistListViewModel = new PlaylistListViewModel(_playlistRepository); _songListViewModel = new SongListViewModel(_songRepository); _songViewModel = new SongViewModel(); _menuViewModel = new MenuViewModel(); _viewModels.Add(_playlistListViewModel); _viewModels.Add(_songListViewModel); _viewModels.Add(_songViewModel); _viewModels.Add(_menuViewModel); #region Registering for ViewModel Commands // Listens for a click in menuViewModel Messenger.Default.Register <bool>(this, SetCreatePlaylistViewModel, "CreatePlaylistView"); Messenger.Default.Register <bool>(this, CloseCreatePlaylistView, "CloseCreatePlaylistView"); // Listens for click in menuViewModel Messenger.Default.Register <bool>(this, SetLoginViewModel, "CreateLoginView"); // Listens for LoginUserViewModel to send this message Messenger.Default.Register <bool>(this, CloseLoginViewModel, "CloseLoginView"); // Listens for menuViewModel logout button click Messenger.Default.Register <bool>(this, LogoutUser, "LogoutUser"); // Listens for register button click in MenuViewModel Messenger.Default.Register <bool>(this, SetRegisterViewModel, "CreateRegisterView"); Messenger.Default.Register <bool>(this, CloseRegisterViewModel, "CloseRegisterView"); // Listens for menuviewModel AddNewSong button click Messenger.Default.Register <bool>(this, SetAddNewSongViewModel, "CreateAddNewSongView"); Messenger.Default.Register <bool>(this, CloseAddNewSongViewModel, "CloseAddNewSongView"); // Listenes for menuviewModel EditPlaylist button click Messenger.Default.Register <Playlist>(this, SetEditPlaylistViewModel, "CreateEditPlaylistView"); Messenger.Default.Register <bool>(this, CloseEditPlaylistView, "CloseEditPlaylistView"); // listens for menuviewmodel Edit Song button click Messenger.Default.Register <Song>(this, SetEditSongViewModel, "CreateEditSongView"); Messenger.Default.Register <bool>(this, CloseEditSongView, "CloseEditSongView"); // Listenes for menuvireModel Credits button Messenger.Default.Register <bool>(this, SetCreditTransactionViewModel, "CreateCreditTransactionView"); Messenger.Default.Register <bool>(this, CloseCreditTransactionView, "CloseCreditTransactionView"); // Listens for LoginViewModel successful login, or a RegisterViewModel sucessful registration Messenger.Default.Register <User>(this, LoginUser, "UserLogin"); // Listens for when song is selected, changed, etc Messenger.Default.Register <bool>(this, UserPlayedSong, "UserCreditCheck"); // Listens from MenuViewModel for delete commands Messenger.Default.Register <Playlist>(this, DeletePlaylist, "DeletePlaylist"); Messenger.Default.Register <Song>(this, DeleteSong, "DeleteSong"); #endregion User = new User(); }