示例#1
0
        private void Removebtn_click(object sender, RoutedEventArgs e)
        {
            var  playlist = playlistListBox.SelectedItem?.ToString();
            Song s        = dataGrid.SelectedItem as Song;

            if (playlist == "All Music" || playlist == null)
            {
                string           msgtext = "Are you sure you want to remove this song?";
                string           txt     = "Confirmation";
                MessageBoxImage  icon    = MessageBoxImage.Question;
                MessageBoxButton button  = MessageBoxButton.YesNo;

                if (MessageBox.Show(msgtext, txt, button, icon) == MessageBoxResult.Yes)
                {
                    musicLib.DeleteSong(s.Id);
                }
            }
            else
            {
                //remove from playlist
                musicLib.RemoveSongFromPlaylist(s.Position, s.Id, playlist);
            }

            RefreshSongs();
        }
示例#2
0
        private void Delete_Song(object sender, RoutedEventArgs e)
        {
            if (playListBox.SelectedItem.ToString() == "All Music")
            {
                DataRowView currentItem = songGrid.SelectedItem as DataRowView;
                int         songID      = (int)currentItem["id"];

                //https://social.msdn.microsoft.com/Forums/vstudio/en-US/d3f223ac-7fca-486e-8939-adb46e9bf6c9/how-can-i-get-yesno-from-a-messagebox-in-wpf?forum=wpf
                if (MessageBox.Show("Are you sure you wish to delete this song?", "Question", MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.No)
                {
                }
                else
                if (currentItem != null)
                {
                    musicLibrary.DeleteSong(songID);
                }
            }
            else
            {
                DataRowView currentItem = songGrid.SelectedItem as DataRowView;
                var         current     = currentItem.Row.ItemArray;

                //Same method of retrieving the songID above wouldn't work for playlist songs...
                int songID   = Convert.ToInt32(current[0]);
                int position = Convert.ToInt32(currentItem["position"]);

                musicLibrary.RemoveSongFromPlaylist(position, songID, playListBox.SelectedItem.ToString());

                var selectedPlaylist = playListBox.SelectedItem.ToString();
                var songs            = musicLibrary.SongsForPlaylist(selectedPlaylist);

                songGrid.ItemsSource = songs.DefaultView;
            }
        }
示例#3
0
        private void RemoveFromPlaylist_Click(object sender, RoutedEventArgs e)
        {
            DataRowView row      = (DataRowView)dataGrid.SelectedItem;
            int         id       = Int16.Parse(row["id"].ToString());
            int         pos      = Int16.Parse(row["position"].ToString());
            string      playlist = row["playlist_name"].ToString();

            musicLib.RemoveSongFromPlaylist(pos, id, playlist);
            dataGrid.ItemsSource = musicLib.GetPlaylist(playlist).DefaultView;
            musicLib.Save();
        }