private void Button_Lyrics_OK_Click(object sender, RoutedEventArgs e) { int SelectedIndex = DataListBox.SelectedIndex; if (SelectedIndex < 0 || SelectedIndex > SongList.Count - 1) { return; } ID3v2 id3v2 = new ID3v2(SongList[SelectedIndex].SongPath, true); if (id3v2.TextWithLanguageFrames.Count > 0) { id3v2.TextWithLanguageFrames.Clear(); } id3v2.TextWithLanguageFrames.Add(new ID3.ID3v2Frames.TextFrames.TextWithLanguageFrame("USLT", 0, Textbox_EditLyrics.Text, "", TextEncodings.UTF_16, "eng")); SongList[SelectedIndex].SongLyrics = Textbox_EditLyrics.Text; id3v2.Save(); DataListBox.SelectedIndex = -1; DataListBox.SelectedIndex = SelectedIndex; Sb5.Begin(); DataListBox.IsEnabled = true; }
public void SaveTest() { string filePath = string.Empty; // TODO: Initialize to an appropriate value bool LoadData = false; // TODO: Initialize to an appropriate value ID3v2 target = new ID3v2(filePath, LoadData); // TODO: Initialize to an appropriate value target.Save(); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
private void Button_SaveSong_Click(object sender, RoutedEventArgs e) { //保存信息 //悲催的代码让我的歌曲化为灰烬…… try { int NowSelect = DataListBox.SelectedIndex; if (NowSelect < 0) { return; } string FileName = SongList[NowSelect].SongPath; bool NeedToSave = false; ID3v2 id3v2 = new ID3v2(FileName, true); id3v2.TextFrames.Add(new ID3.ID3v2Frames.TextFrames.TextFrame("TIT2", 0, TextBox_Title.Text, TextEncodings.UTF_16, 3)); id3v2.TextFrames.Add(new ID3.ID3v2Frames.TextFrames.TextFrame("TPE1", 0, TextBox_Artist.Text, TextEncodings.UTF_16, 3)); id3v2.TextFrames.Add(new ID3.ID3v2Frames.TextFrames.TextFrame("TALB", 0, TextBox_Album.Text, TextEncodings.UTF_16, 3)); if (Checkbox_lyrics.IsChecked == true && (string)Checkbox_lyrics.Content == "保存歌曲歌词" && !string.IsNullOrEmpty(SongList[NowSelect].SongLyricsUnsaved)) { NeedToSave = true; SongList[NowSelect].SongLyrics = SongList[NowSelect].SongLyricsUnsaved; id3v2.TextWithLanguageFrames.Add(new ID3.ID3v2Frames.TextFrames.TextWithLanguageFrame("USLT", 0, SongList[NowSelect].SongLyrics, "", TextEncodings.UTF_16, "eng")); } if (Checkbox_albumpicture.IsChecked == true && (string)Checkbox_albumpicture.Content == "保存专辑封面") { NeedToSave = true; BitmapImage Bitmap = (BitmapImage)Image_album.Source; while (Bitmap.IsDownloading) { Thread.Sleep(50); System.Windows.Forms.Application.DoEvents(); } SongList[NowSelect].SongAlbum = Bitmap; JpegBitmapEncoder encoder = new JpegBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(Bitmap)); MemoryStream stream = new MemoryStream(); encoder.Save(stream); id3v2.AttachedPictureFrames.Add(new ID3.ID3v2Frames.BinaryFrames.AttachedPictureFrame(0, "", TextEncodings.UTF_16, "image/jpeg", ID3.ID3v2Frames.BinaryFrames.AttachedPictureFrame.PictureTypes.Cover_Front, stream)); } if (NeedToSave) { id3v2.Save(); } } catch (Exception ex) { MessageBox.Show("保存出错,请将下列信息反馈到官方博客,以帮助我们改进软件。谢谢!\n(官方博客:http://www.4321.la,下列信息Ctrl+C可复制)" + ex.Message); } }
private void OnSaveFile() { List <IAttachedPicture> deleteList = new List <IAttachedPicture>(ID3v2.PictureList); foreach (var picture in PictureCollection) { if (picture.AttachedPicture != null) { picture.AttachedPicture.Description = picture.Description; picture.AttachedPicture.PictureType = picture.PictureType; deleteList.Remove(picture.AttachedPicture); } else { IAttachedPicture apic = ID3v2.PictureList.AddNew(); apic.Description = picture.Description; apic.PictureType = picture.PictureType; apic.PictureData = picture.PictureBytes; } } foreach (var deletePicture in deleteList) { ID3v2.PictureList.Remove(deletePicture); } // TODO: Multiple comments /*IComments comments = _id3v2.CommentsList.FirstOrDefault(); * * if (!string.IsNullOrWhiteSpace(Comment)) * { * if (comments == null) * { * comments = _id3v2.CommentsList.AddNew(); * } * comments.Value = Comment; * } * else * { * if (comments != null) * _id3v2.CommentsList.Remove(comments); * }*/ ID3v2.Save(FullFileName); }
private void Menu_DeleteAlbum_Click(object sender, RoutedEventArgs e) { int SelectedIndex = DataListBox.SelectedIndex; if (SelectedIndex < 0 || SelectedIndex > SongList.Count - 1) { return; } if (ShowMessageBoxOkCancel("\n确定要删除当前歌曲封面吗?") == 1) { ID3v2 id3v2 = new ID3v2(SongList[SelectedIndex].SongPath, true); if (id3v2.AttachedPictureFrames.Count > 0) { id3v2.AttachedPictureFrames.Clear(); } id3v2.Save(); SongList[SelectedIndex].SongAlbum = null; DataListBox.SelectedIndex = -1; DataListBox.SelectedIndex = SelectedIndex; } }
private void Menu_DeleteLyrics_Click(object sender, RoutedEventArgs e) { int SelectedIndex = DataListBox.SelectedIndex; if (SelectedIndex < 0 || SelectedIndex > SongList.Count - 1) { return; } if (ShowMessageBoxOkCancel("\n确定要删除当前歌曲歌词吗?") == 1) { ID3v2 id3v2 = new ID3v2(SongList[SelectedIndex].SongPath, true); if (id3v2.TextWithLanguageFrames.Count > 0) { id3v2.TextWithLanguageFrames.Clear(); } id3v2.Save(); SongList[SelectedIndex].SongLyrics = null; SongList[SelectedIndex].SongLyricsUnsaved = null; DataListBox.SelectedIndex = -1; DataListBox.SelectedIndex = SelectedIndex; } }
/// <summary> /// Save both ID3v2 and ID3v1 /// </summary> public void Save() { _ID3v2.Save(); _ID3v1.Save(); }