private void buttonCreateLyric_Click(object sender, EventArgs e) { //提示输入文件名 FormInput formInput = new FormInput(); formInput.Text = "请输入音乐名称"; if (formInput.ShowDialog() == DialogResult.OK) { if (formInput.StrReturnValue != "") { //修改文件编号 string strIndexTemp = (listViewUserMusicList.Items.Count + 1).ToString("d3"); string strTxtFileName = strIndexTemp + formInput.StrReturnValue + ".txt"; string strTxtFilePath = MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(), comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strTxtFileName); //提示输入歌词,保存 FormLyric formLyric = new FormLyric(); if (formLyric.ShowDialog() == DialogResult.OK) { if (formLyric.Lyric != "") { MusicHelper.SetLyricsByLyricFilePath(strTxtFilePath, formLyric.Lyric); comboBoxAlbumList_SelectedIndexChanged(null, null); } } } } }
private void comboBoxAlbumList_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxAlbumList.SelectedIndex < 0) { return; } listViewUserMusicList.Items.Clear(); //显示音乐列表 string strMusicList = ListHelper.GetMusicList(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(), comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString()); if (strMusicList != "") { string[] strsContent = strMusicList.Split('|'); for (int i = 0; i < strsContent.Length; i++) { if (strsContent[i] != "") { //string strID = strsContent[i].Substring(0, 3); //string strName = strsContent[i].Remove(strsContent[i].Length - 4, 4).Substring(3); string strName = strsContent[i].Remove(strsContent[i].Length - 4, 4); ////去掉开头的0 //while (strID[0] == '0') //{ // strID = strID.Substring(1, strID.Length - 1); //} ListViewItem item = new ListViewItem(strName); //item.SubItems.Add(strName); //将音频文件路径存入tag属性 //将目录和文件名拼接起来,自动匹配mp3,wma,mid格式 string strAudioFilePath = null; strAudioFilePath = MusicHelper.GetAudioFilePathByLyricFilePath(MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(), comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strsContent[i])); if (strAudioFilePath == "") { item.Tag = MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(), comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strsContent[i]); } else { item.Tag = strAudioFilePath; } listViewUserMusicList.Items.Add(item); } } Array.Clear(strsContent, 0, strsContent.Length); } }
//选择专辑后,显示音乐列表 private void comboBoxAlbumList_SelectedIndexChanged(object sender, EventArgs e) { if (comboBoxAlbumList.SelectedIndex < 0) { return; } StrLastMusicianList = comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(); StrLastAlbumList = comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(); _configHelper.Write("LastMusicianList", StrLastMusicianList); _configHelper.Write("LastAlbumList", StrLastAlbumList); if (StrLastAlbumList == "") { return; } listViewMusicList.Items.Clear(); //显示音乐列表 string strMusicList = ListHelper.GetMusicList(StrLastMusicianList, StrLastAlbumList); //清除WMP中的音乐列表 axWindowsMediaPlayer1.currentPlaylist.clear(); if (strMusicList != "") { string[] strsContent = strMusicList.Split('|'); for (int i = 0; i < strsContent.Length; i++) { if (strsContent[i] != "") { //ListViewItem item = new ListViewItem((i + 1).ToString()); //item.SubItems.Add(strsContent[i].Remove(strsContent[i].Length - 4, 4)); //string strID = strsContent[i].Substring(0, 3); //string strName = strsContent[i].Remove(strsContent[i].Length - 4, 4).Substring(3); string strName = strsContent[i].Remove(strsContent[i].Length - 4, 4); ////去掉开头的0 //while (strID[0] == '0') //{ // strID = strID.Substring(1, strID.Length - 1); //} ListViewItem item = new ListViewItem(strName); //item.SubItems.Add(strName); //将音频文件路径存入tag属性 //将目录和文件名拼接起来,自动匹配mp3,wma,mid格式 string strAudioFilePath = null; strAudioFilePath = MusicHelper.GetAudioFilePathByLyricFilePath(MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(), comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strsContent[i])); if (strAudioFilePath == "") { item.Tag = MusicHelper.GetLyricFilePathByLyricFileName(comboBoxMusicianList.Items[comboBoxMusicianList.SelectedIndex].ToString(), comboBoxAlbumList.Items[comboBoxAlbumList.SelectedIndex].ToString(), strsContent[i]); } else { item.Tag = strAudioFilePath; } listViewMusicList.Items.Add(item); //axWindowsMediaPlayer1.currentPlaylist.appendItem(axWindowsMediaPlayer1.newMedia(strAudioFilePath)); } } Array.Clear(strsContent, 0, strsContent.Length); } /* * * try * { * * //显示经文列表,读取文件中的内容并显示到listView中 * string strSelectedFileName = comboBoxLectionList.Items[comboBoxLectionList.SelectedIndex].ToString(); * if (strSelectedFileName == "") * { * //空白,清空 * listViewLectionList.Items.Clear(); * } * else if (strSelectedFileName == _strCreateNewList) * { * //空白,清空 * listViewLectionList.Items.Clear(); * * ////新建经文列表 * ////弹出窗口让用户输入播经文列表名 * * * ShowNewList(CreateNewList()); * * * * } * else * { * //空白,清空 * listViewLectionList.Items.Clear(); * * //显示经文列表 * string strFileContent = ListHelper.ReadFileContent(strSelectedFileName + ".txt"); * if (strFileContent != "") * { * string[] strContent = strFileContent.Split('|'); * * for (int i = 0; i < strContent.Length; i++) * { * ListViewItem item = new ListViewItem((i + 1).ToString()); * item.SubItems.Add(strContent[i]); * * listViewLectionList.Items.Add(item); * } * } * } * * StrLastLectionList = strSelectedFileName; * _configHelper.Write("LastLectionList", strSelectedFileName); * * } * catch (Exception) * { * } * */ }
private void listViewAlbumList_SelectedIndexChanged(object sender, EventArgs e) { this.listViewMusicList.Items.Clear(); if (listViewAlbumList.Items.Count <= 0 || listViewAlbumList.SelectedIndices.Count == 0 || listViewAlbumList.SelectedIndices[0] < 0) { return; } try { string strList = ListHelper.GetMusicList(listViewMusicianList.Items[listViewMusicianList.SelectedIndices[0]].Text, listViewAlbumList.Items[listViewAlbumList.SelectedIndices[0]].Text); if (strList != "") { string[] strsMusic = strList.Split('|'); for (int i = 0; i < strsMusic.Length; i++) { if (strsMusic[i] == "") { } else { //string strID = strsMusic[i].Substring(0, 3); //string strName = strsMusic[i].Remove(strsMusic[i].Length - 4, 4).Substring(3); string strName = strsMusic[i].Remove(strsMusic[i].Length - 4, 4); ////去掉开头的0 //while (strID[0] == '0') //{ // strID = strID.Substring(1, strID.Length - 1); //} //ListViewItem item = new ListViewItem(strID); //item.SubItems.Add(strName); ListViewItem item = new ListViewItem(strName); //将音频文件路径存入tag属性 //将目录和文件名拼接起来,自动匹配mp3,wma,mid格式 string strAudioFilePath = null; strAudioFilePath = MusicHelper.GetAudioFilePathByLyricFilePath(MusicHelper.GetLyricFilePathByLyricFileName(listViewMusicianList.Items[listViewMusicianList.SelectedIndices[0]].Text, listViewAlbumList.Items[listViewAlbumList.SelectedIndices[0]].Text, strsMusic[i])); if (strAudioFilePath == "") { item.Tag = MusicHelper.GetLyricFilePathByLyricFileName(listViewMusicianList.Items[listViewMusicianList.SelectedIndices[0]].Text, listViewAlbumList.Items[listViewAlbumList.SelectedIndices[0]].Text, strsMusic[i]); } else { item.Tag = strAudioFilePath; } listViewMusicList.Items.Add(item); } } Array.Clear(strsMusic, 0, strsMusic.Length); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }