private XmlDisc GetDiscFromFolder(string dirPath) { List <XmlTrack> tracks = new List <XmlTrack>(); foreach (string ext in Program.Config.SupportedFileTypes) { Directory.GetFiles(dirPath, string.Format("*.{0}", ext), SearchOption.TopDirectoryOnly).ToList().ForEach(delegate(string fp) { tracks.Add(new XmlTrack(fp)); }); } string dirName = Path.GetFileName(dirPath); Regex r = new Regex(@"\d+"); Match discNumber = r.Match(dirName); XmlDisc tempDisc = new XmlDisc(tracks); if (discNumber.Success) { tempDisc.DiscNumber = uint.Parse(discNumber.Value); } Discs.Add(tempDisc); Tracks.AddRange(tempDisc.Tracks.ToArray()); if (tempDisc.DiscNumber > 0) { tracks.ToList().ForEach(x => x.DiscNumber = tempDisc.DiscNumber); } tracks.ToList().ForEach(x => x.AlbumArtist = tempDisc.AlbumArtist); return(tempDisc); }
internal void MergeWith(RenderItem Donor) { RenderFormat = Donor.RenderFormat; RenderTemplate = Donor.RenderTemplate; RenderParams.MergeWith(Donor.RenderParams); Tracks.AddRange(Donor.Tracks); }
public bool Refresh() { var newTracks = Filter.Apply(LibraryTracks); if (!newTracks.SequenceEqual(Tracks)) { Tracks.Clear(); Tracks.AddRange(Filter.Apply(LibraryTracks)); RaisePropertyChanged("Tracks"); return(true); } return(false); }
public FilteredTracks(LibraryFilter library, TrackDanceFilter filter, bool isDefault = false) { Library = library; IsDefault = isDefault; Filter = filter; Tracks.AddRange(Filter.Apply(LibraryTracks)); Filter.PropertyChanged += FilterPropertyChangeHandler; Filter.Dances.CollectionChanged += (s, e) => Refresh(); if (!IsDefault) { Library.DefaultFilter.PropertyChanged += FilterOrTrackChangeHandler; } }
public void LoadItems(int pageSize = 50) { if (_page < 0 || pageSize <= 0) { return; } if (Tracks.Count < (_page * pageSize) + pageSize) { var missingItems = _page * pageSize + pageSize - Tracks.Count; Tracks.AddRange(TrackSource.Skip(Tracks.Count).Take(missingItems)); _page++; } }
//TO DO: Need to generalize the parameter so it accepts a number that corresponds to the total //number of songs the user has //NOTE: *** Potenially may have to add a comparison function based off of individual data sizes so one user isn't favored over all others *** public async Task GetTracks(int x) { //Creates list of tasks that grab (50 * i) tracks var trackCall = Enumerable.Range(0, x).Select(i => _client.GetAsync("https://api.spotify.com/v1/me/tracks?limit=50&offset=" + (i * 50))).ToList(); var tracksGrab = await Task.WhenAll(trackCall); foreach (var item in tracksGrab) { var tracksContent = await item.Content.ReadAsStringAsync(); var tracks = JsonConvert.DeserializeObject <Paging <SavedTrack> >(tracksContent); var Swag = tracks.Items.Select(z => z.Track.Id).ToList(); Tracks.AddRange(Swag); } }
private void ProcessTracks() { if (SourceTracks != null) { _trackProcessor.KalmanEnabled = Filtering; _trackProcessor.StopsDetection = StopsDetection; _trackProcessor.SpikeDetection = SpikeDetection; Tracks.Clear(); Tracks.AddRange(SourceTracks); FilterResult = _trackProcessor.ProcessTracks(SourceTracks); FilterResult.Name = "Result"; Tracks.Add(FilterResult); } }
/// <summary> /// Loads the library from the cache. /// </summary> public void LoadFromDatabase() { if (!File.Exists(LibraryCacheFilename)) { return; } try { var tracks = SerializationHelper <List <Track> > .FromXmlFile(LibraryCacheFilename); lock (Tracks) { Tracks.Clear(); Tracks.AddRange(tracks.ToArray()); } } catch { // ignored } }
/// <summary> /// Bind the new playlist to the page /// </summary> /// <returns></returns> public async Task BindPlaylist() { ShowPlaylistSaved = false; Loaded = false; try { Tracks.Clear(); foreach (var artist in Artists) { try { Tracks.AddRange((await SpotifyService.GetArtistTopTracks(artist.Id, AuthenticationService.AuthenticationToken)).Take(3).ToList()); if (Tracks.Count % 33 == 0) { StateHasChanged(); } } catch (Exception ex) { PageException = ex; } } } catch (Exception ex) { PageException = ex; } Tracks = Tracks.OrderBy(o => Guid.NewGuid()).ToList(); Loaded = true; StateHasChanged(); }
public void LoadTracksFromDatabase() { Tracks.AddRange(musicDatabase.LoadTracks()); LogHelper.Log("Error selecting tracks from database."); }