private void SaveButton_OnClick(object sender, RoutedEventArgs e) { MatroskaTags tags; try { tags = MatroskaLoader.ReadTagFromXML(textEditorNew.Text); if (tags == null) { MessageBox.Show("invalid tag file."); return; } } catch (Exception) { MessageBox.Show("invalid tag file."); return; } MessageBoxResult result = MessageBox.Show("Do you really want to overwrite the old tags with the new ones?", "Overwrite tags", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No); if (result == MessageBoxResult.Yes) { MatroskaLoader.WriteTags(tags, txtFilename.Text); SetFile(txtFilename.Text); } }
private void UpdatePreview(object sender, TextChangedEventArgs e) { textEditorNew.Text = string.Empty; MatroskaTags tag; if (!ReferenceEquals(originalTag, null)) { string xmlString = MatroskaLoader.GetXML(originalTag); tag = MatroskaLoader.ReadTagFromXML(xmlString); } else { tag = new MatroskaTags(); } #region Album if (!string.IsNullOrEmpty(albumArtist.Value)) { tag.MusicVideo.AlbumArtist = albumArtist.Value; } if (!string.IsNullOrEmpty(albumTitle.Value)) { tag.MusicVideo.AlbumTitle = albumTitle.Value; } if (!string.IsNullOrEmpty(albumReleaseDate.Value)) { tag.MusicVideo.AlbumReleaseDate = albumReleaseDate.Value; } //if (albumReleaseDate.Value.HasValue) //{ // tag.MusicVideo.AlbumReleaseDate = albumReleaseDate.Value.Value; //} #endregion Album #region Track if (!string.IsNullOrEmpty(trackArtist.Value)) { tag.MusicVideo.TrackArtist = trackArtist.Value; } if (!string.IsNullOrEmpty(trackTitle.Value)) { tag.MusicVideo.TrackTitle = trackTitle.Value; } if (!string.IsNullOrEmpty(trackNumber.Value)) { int index; if (int.TryParse(trackNumber.Value, out index)) { tag.MusicVideo.TrackNumber = index; } } if (!string.IsNullOrEmpty(trackReleaseDate.Value)) { tag.MusicVideo.TrackReleaseDate = trackReleaseDate.Value; } if (trackGenre.Value.Count > 0) { tag.MusicVideo.GenreList = trackGenre.Value; } #endregion Track textEditorNew.Text = MatroskaLoader.GetXML(tag); saveButton.IsEnabled = true; }