//只能删除一个 /// <summary> /// 删除音乐 /// </summary> private void DeleteMusic() { List <MusicItemViewModel> selectedItem = MusicList.Where(i => i.IsSelected == true).ToList(); var selectedPlayList = PlayLists.Where(i => i.IsSelected == true).First(); if (selectedItem.Count > 0) { PlayListService.DeleteMusic(selectedPlayList.PlayList, selectedItem[0].Music); InitMusicList(selectedPlayList); } }
//打开一个文件夹 private void OpenFolder() { FolderBrowserDialog folder = new FolderBrowserDialog(); folder.Description = "选择要打开的文件夹"; if (folder.ShowDialog() == DialogResult.OK) { var selectedPlayList = PlayLists.Where(i => i.IsSelected == true).First(); var playList = selectedPlayList.PlayList; PlayListService.CleanMusic(playList); PlayListService.AddMusic(playList, OpenMusicService.OpenFolder(folder.SelectedPath)); InitMusicList(selectedPlayList); } }
/// <summary> /// 打开一首音乐 /// </summary> private void OpenMusic() { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "所有支持的文件|*.mp3;*.wav|mp3|*.mp3|wav|*.wav"; ofd.ValidateNames = true; ofd.CheckPathExists = true; ofd.CheckFileExists = true; ofd.Multiselect = false; if (ofd.ShowDialog() == DialogResult.OK) { var selectedPlayList = PlayLists.Where(i => i.IsSelected == true).First(); var playList = selectedPlayList.PlayList; PlayListService.CleanMusic(playList); PlayListService.AddMusic(playList, OpenMusicService.OpenMusic(ofd.FileName)); InitMusicList(selectedPlayList); } }
/// <summary> /// 切换播放列表 /// </summary> private void PlayListClick() { var selectedPlayList = PlayLists.Where(i => i.IsSelected == true).First(); InitMusicList(selectedPlayList); }