private void Mp3Files_OnKeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.A) { if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { Mp3Files.SelectedItems.Clear(); Mp3Files.SelectAll(); } } if (e.Key == Key.Escape) { Mp3Files.SelectedItems.Clear(); } }
private void LoadFiles(string folderpath) { List <TagTypes> tags = new List <TagTypes>() { TagTypes.Ape, TagTypes.Apple, TagTypes.Asf, TagTypes.AudibleMetadata, TagTypes.DivX, TagTypes.FlacMetadata, TagTypes.GifComment, TagTypes.IPTCIIM, TagTypes.Id3v1, TagTypes.Id3v2, TagTypes.JpegComment, TagTypes.MovieId, TagTypes.Png, TagTypes.RiffInfo, TagTypes.TiffIFD, TagTypes.XMP, TagTypes.Xiph }; List <string> additionalTags = new List <string>() { "album", "artists", "comment", "lyrics", "composers", "disc", "disccount", "genres", "performers", "title", "trackcount", "year" }; Mp3Files.SelectionMode = SelectionMode.Multiple; Mp3Files.Items.Clear(); var files = GetFilesInFolder(folderpath); foreach (var file in files) { using (TagLib.File f = TagLib.File.Create(file)) { string name = Path.GetFileName(file); Trace.WriteLine("Some info: " + name); foreach (var tag in tags) { try { var info = f.GetTag(tag); if (info != null) { Trace.WriteLine(" " + tag + ": " + info); } } catch { // ignore } } foreach (var tagname in additionalTags) { try { ShowTag(f, tagname); } catch { // ignore } } //string tagPerfomer = string.Join(",", f.Tag.PerformersSort); string tagAlbum = f.Tag.Album; string tagTitle = f.Tag.Title; bool hasId3Tag = !string.IsNullOrEmpty(tagAlbum) || !string.IsNullOrEmpty(tagTitle); string additionalInformation = string.Format("{0} - {1}", string.IsNullOrEmpty(tagAlbum) ? "x" : tagAlbum, string.IsNullOrEmpty(tagTitle) ? "x" : tagTitle ); var item = new FileItem() { Name = string.Format("{0} ({1})", name, additionalInformation), Filename = file, HasId3Tag = hasId3Tag }; Mp3Files.Items.Add(item); } } Mp3Files.SelectAll(); }