public override IEnumerable <IResult> SaveChanges() { if (SongTitle.Trim() == string.Empty) { MessageBox.Show("Please provide an Song Title.", "Error", MessageBoxButton.OK); yield return(null); } foreach (RawTrack media in MediaList) { try { if (SongTitle.Trim() != "Multiple Titles") { media.TrackTitle = SongTitle.Trim(); } if (SongAlbum.Trim() != "Multiple Albums") { media.AlbumTitle = SongAlbum.Trim(); } //if (SongComposer.Trim() != "Multiple Composers") //{ // var composers = new List<string>(); // foreach (string composer in SongComposer.Trim().Split(';')) // { // if (composer != null) // { // if (composer.Trim() != string.Empty) // composers.Add(composer.Trim()); // } // } // media.Composers = composers.ToArray(); //} if (SongAlbumArtist.Trim() != "Multiple Artists") { media.ArtistName = SongAlbumArtist.Trim(); } if (SongGenre.Trim() != "Multiple Genres") { media.Genre = SongGenre.Trim(); } if (SongYear != -1) { media.Year = SongYear; } if (SongId != -1) { media.TrackNumber = SongId; } if (media is Mp3Track) { (media as Mp3Track).WriteTag(); } } catch { MessageBox.Show("Could not update " + media, "Error", MessageBoxButton.OK); } } yield return(new CloseResult()); }
public override IEnumerable <IResult> SaveChanges() { if (string.IsNullOrEmpty(SongAlbum)) { MessageBox.Show("Please provide an Album Name.", "Error", MessageBoxButton.OK); yield return(null); } if (string.IsNullOrEmpty(SongAlbumArtist)) { MessageBox.Show("Please provide an Artist Name.", "Error", MessageBoxButton.OK); yield return(null); } foreach (RawTrack media in MediaList) { try { bool hasChanged = false; if (SongAlbum.Trim() != "Multiple Album Titles") { media.AlbumTitle = SongAlbum.Trim(); hasChanged = true; } if (SongAlbumArtist.Trim() != "Multiple Album Artists") { media.ArtistName = SongAlbumArtist.Trim(); hasChanged = true; } if (SongGenre != "Multiple Genres") { if (media.Genre != SongGenre.Trim()) { media.Genre = SongGenre.Trim(); hasChanged = true; } } if (SongYear != -1) { if (media.Year != SongYear) { media.Year = SongYear; hasChanged = true; } } //TODO:media factory if (hasChanged) { if (media is Mp3Track) { (media as Mp3Track).WriteTag(); } } } catch { MessageBox.Show("Could not update " + media, "Error", MessageBoxButton.OK); } } yield return(new CloseResult()); }