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 buttonModifyLyric_Click(object sender, EventArgs e) { //得到要修改的txt文件,显示在textBox中 if (listViewUserMusicList.Items.Count <= 0 || listViewUserMusicList.SelectedIndices.Count == 0 || listViewUserMusicList.SelectedIndices[0] < 0) { return; } //得到选中的音乐的名字,并显示在文本框中供修改 FormLyric formLyric = new FormLyric(); formLyric.Text = "修改歌词后,按[保存]键确认"; string strTxtFilePath = listViewUserMusicList.SelectedItems[0].Tag.ToString().Substring(0, listViewUserMusicList.SelectedItems[0].Tag.ToString().Length - 3) + "txt"; formLyric.Lyric = MusicHelper.GetLyricsByLyricFilePath(strTxtFilePath); if (formLyric.ShowDialog() == DialogResult.OK) { if (formLyric.Lyric != "") { MusicHelper.SetLyricsByLyricFilePath(strTxtFilePath, formLyric.Lyric); } } formLyric.Dispose(); }