private void BuildTree(Collection coll, int depth, PhotosetCollectionModel parent) { var cur = new PhotosetCollectionModel(coll.CollectionId, coll.Title, coll.Description); parent.Items.Add(cur); var spaces = new string(' ', depth *2); Debug.WriteLine($"{spaces}Collection: {coll.Title}"); foreach (var subT in coll.Collections) { BuildTree(subT, depth + 1, cur); } //var f = _flickr; //var result = f.PhotosSearch(new PhotoSearchOptions("147869897@N08") {Text = "Aqua"}); //f.PhotosetsAddPhoto(setId, photoId); foreach (var set in coll.Sets) { _subPhotosets.Add(set.SetId); var s = new Photoset { PhotosetId = set.SetId, Title = set.Title, Description = set.Description }; //too slow calling this for each set - using background task instead //f.PhotosetsGetInfo(set.SetId); AddPhotoset(s, cur); Debug.WriteLine($"{spaces} Set: {set.Title} ({set.SetId})"); } }
private void ReloadTree() { var f = _mgr.Surrogate; var coll = f.CollectionsGetTree(); var tree = new PhotosetCollectionModel { Title = "Root" }; foreach (var t in coll) { BuildTree(t, 0, tree); } var sets = f.PhotosetsGetList(); foreach (var set in sets) { if (_subPhotosets.Contains(set.PhotosetId)) { continue; } AddPhotoset(set, tree); Debug.WriteLine($"Set: {set.Title} ({set.PhotosetId})"); } PhotosetsTree = tree; }
private void AddPhotoset(Photoset set, PhotosetCollectionModel tree) { var m = new PhotosetModel(set.PhotosetId, set.Title, set.Description) { PhotosCount = set.NumberOfPhotos, VideosCount = set.NumberOfVideos }; tree.Items.Add(m); }
private PhotosetModel TryGetSet(string photosetId, PhotosetCollectionModel parent) { var i = parent.Items.FirstOrDefault( e => e.GetType() == typeof(PhotosetModel) && e.Id.Equals(photosetId, StringComparison.InvariantCulture)); if (i != null) { return(i); } var colls = parent.Items.OfType <PhotosetCollectionModel>().ToArray(); foreach (var col in colls) { i = TryGetSet(photosetId, col); if (i != null) { return(i); } } return(null); }