public static bool FilterTracks(PlayableTrack track, string filter) { // Trim is required here, otherwise the filter might flip on the space at the beginning (and probably at the end) string[] pieces = filter.Trim().Split(Convert.ToChar(" ")); // Just making sure that all fields are not Nothing if (track.TrackTitle == null) { track.TrackTitle = string.Empty; } if (track.ArtistName == null) { track.ArtistName = string.Empty; } if (track.AlbumTitle == null) { track.AlbumTitle = string.Empty; } if (track.FileName == null) { track.FileName = string.Empty; } if (track.Year == null) { track.Year = 0; } return(pieces.All((s) => track.TrackTitle.ToLower().Contains(s.ToLower()) | track.ArtistName.ToLower().Contains(s.ToLower()) | track.AlbumTitle.ToLower().Contains(s.ToLower()) | track.FileName.ToLower().Contains(s.ToLower()) | track.Year.ToString().Contains(s.ToLower()))); }
public static PlayableTrack CreateDefault(string path) { var track = new PlayableTrack(); track.Path = path; track.SafePath = path.ToSafePath(); track.FileName = System.IO.Path.GetFileNameWithoutExtension(path); track.ArtistName = Defaults.UnknownArtistString; track.GenreName = Defaults.UnknownGenreString; track.AlbumTitle = Defaults.UnknownAlbumString; track.AlbumArtist = Defaults.UnknownAlbumArtistString; return(track); }