public TagEditorViewModel(LocalTrack track, Window baseWindow) { TagFile = File.Create(track.Path); Track = track; baseWindow.Closed += (s, e) => TagFile.Dispose(); _baseWindow = baseWindow; AllGenres = Genres.Audio.ToList(); AllGenres.AddRange(Enum.GetValues(typeof(Genre)).Cast <Genre>().Select(PlayableBase.GenreToString).Where(x => !AllGenres.Contains(x))); AllGenres.Sort(); SelectedGenres = track.Genres.Select(PlayableBase.GenreToString).ToList(); }
public void ID3RegexReplace(string SelectPattern, string newValue, Music_Tag ToUpdate) { if (Music_Tag.Empty == ToUpdate) { ID3RegexReplace(SelectPattern, newValue); } else { RFile currentFile; TagLib.File TagFile; TagLib.File NewTagFile; for (int i = 0; i < files.Length; i++) { currentFile = files[i]; TagFile = currentFile.Tag.File; NewTagFile = null; if (TagFile.Tag != null) { switch (ToUpdate) { case Music_Tag.Album: TagFile.Tag.Album = Regex.Replace(TagFile.Tag.Album, SelectPattern, newValue); break; case Music_Tag.Artist: TagFile.Tag.Performers[0] = Regex.Replace(TagFile.Tag.Performers[0], SelectPattern, newValue); break; case Music_Tag.Title: TagFile.Tag.Title = Regex.Replace(TagFile.Tag.Title, SelectPattern, newValue); break; } NewTagFile = TagFile; } RenamerTag NewTag = new RenamerTag(NewTagFile); currentFile.SaveTag(NewTag); TagFile.Dispose(); NewTagFile.Dispose(); } } }