private void BtnExit_Click(object sender, RoutedEventArgs e) { UpNextListModel.IsEditingLyric = false; MyMusicControl.UserSongListHasUpdated(); MusicInPlaylistControl.UserSongListHasUpdated(); ChangePage("MyMusic"); }
private void BtnExit_Click(object sender, RoutedEventArgs e) { if ((this.DataContext as LyricEditorVersion2ViewModel).SaveStatus == "SAVE*") { MessageBoxResult messageBoxResult = MessageBox.Show($@"Nội dung chưa được lưu, bạn có chắc chắn muốn thoát ?", "Thông báo", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (messageBoxResult == MessageBoxResult.No) { return; } } UpNextListModel.IsEditingLyric = false; MyMusicControl.UserSongListHasUpdated(); MusicInPlaylistControl.UserSongListHasUpdated(); ChangePage("MyMusic"); }
public ListMusicDialogViewModel(string PLKey) { playlistKey = PLKey; allUserSongList = SongDataAccess.GetAllSongListWithPlaylistInfo(playlistKey); foreach (SongModel song in allUserSongList) { if (song.PlaylistKey != null) { song.IsInPlaylist = true; ListSongExistedInPlaylist.Add(song.SongKey); } } ListMusic = allUserSongList; SearchKeyword = ""; CheckToChooseSongCommand = new RelayCommand <object>( (p) => { return(true); }, (p) => { SongModel songToAddToPlaylist = p as SongModel; string songToAddToPlaylistKey = (p as SongModel).SongKey; //tìm xem trong check mới hay bỏ check int index = ListSongToAddPlaylist.FindIndex(e => (e == songToAddToPlaylistKey)); //trường hợp mới check if (index == -1) { ListSongToAddPlaylist.Add(songToAddToPlaylistKey); } //trường hợp bỏ check else { ListSongToAddPlaylist.RemoveAt(index); } }); SaveCommand = new RelayCommand <object>( (p) => { return(true); }, (p) => { foreach (string songKey in ListSongToAddPlaylist) { //nếu đã có trong data base thì bỏ ra khỏi database if (ListSongExistedInPlaylist.Exists(e => e == songKey)) { if (playlistKey == "FAVORITE_PLAYLIST") { SongDataAccess.RemoveSongFromFavorite(songKey); } else { SongDataAccess.DeleteSongFromPlaylist(songKey, playlistKey); } } else { if (playlistKey == "FAVORITE_PLAYLIST") { SongDataAccess.InsertSongToFavorite(songKey); } else { SongDataAccess.InsertSongToPlaylist(songKey, playlistKey); } } } MusicInPlaylistControl.UserSongListHasUpdated(); }); }
public ListMusicInPlaylistViewModel() { PlayAllCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { PlayAllSongRequest(); }); AddToPlaylistCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { }); MusicInPlaylistControl.CurrentSongListChange += MyMusicControl_CurrentSongListChange; FavoriteCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SongModel songSelected = p as SongModel; int index = CurrentSongList.FindIndex(e => (e.SongKey == songSelected.SongKey)); if (songSelected.IsFavorite == 1) { //bỏ thích SongDataAccess.RemoveSongFromFavorite(songSelected.SongKey); if (PlaylistInfoViewModel.currentPlaylistKey == "FAVORITE_PLAYLIST") { MusicInPlaylistControl.UserSongListHasUpdated(); } else { ButtonFavoriteSongClick(index, 0); } } else { //thích SongDataAccess.InsertSongToFavorite(songSelected.SongKey); if (PlaylistInfoViewModel.currentPlaylistKey == "FAVORITE_PLAYLIST") { MusicInPlaylistControl.UserSongListHasUpdated(); } else { ButtonFavoriteSongClick(index, 1); } } }); PlayNowCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SongModel songSelected = p as SongModel; int index = CurrentSongList.FindIndex(e => (e.SongKey == songSelected.SongKey)); PlayNowRequest(index); }); MoreControlCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SongModel songSelected = p as SongModel; MiniTool.SongDetail = songSelected; }); AddToPlayingQueueCommand = new RelayCommand <object>((p) => { return(true); }, (p) => { SongModel songSelected = p as SongModel; int index = CurrentSongList.FindIndex(e => (e.SongKey == songSelected.SongKey)); AddToPlayingQueueRequest(index); }); }