示例#1
0
        public FlickrImage(FlickrImageSet imageSet, string smallImageUri, string largeImageUri, string title, DateTime date)
        {
            this.ImageUri = smallImageUri;
            this.LargeImageUri = largeImageUri;

            this.ImageSet = imageSet;
            this.Image = new BitmapImage(new Uri(smallImageUri));
            this.Title = title;
            this.Date = date;
        }
        public void Load()
        {
            var flickrUser = _GetUserProfileAsync(this.Username).Result;
            var photoSetCollection = _GetPhotosetCollectionAsync(flickrUser.UserId).Result;

            foreach (var photoSet in photoSetCollection)
            {
                FlickrImageSet imageSet = new FlickrImageSet(photoSet.PhotosetSmallUrl, photoSet.Title, photoSet.DateUpdated, photoSet.Description);
                this.ImageSets.Add(imageSet);
                base.OnPropertyChanged("ImageSets");

                var photosetPhotosCollection = _GetCollectionForSetAsync(photoSet.PhotosetId).Result;

                foreach (var photo in photosetPhotosCollection)
                {
                    var image = new FlickrImage(imageSet, photo.SmallUrl, photo.DoesLargeExist ? photo.LargeUrl : photo.Medium640Url, photo.Title, photo.DateTaken, photoSet.Description);
                    imageSet.Collection.Add(image);
                }
            }
        }
        public Task<IList<FlickrImageSet>> LoadAsync(Windows.UI.Core.CoreDispatcher dispatcher)
        {
            var task = Task.Run(() =>
            {
                var flickrUser = _GetUserProfileAsync(this.Username).Result;
                var photoSetCollection = _GetPhotosetCollectionAsync(flickrUser.UserId).Result;

                foreach (var photoSet in photoSetCollection)
                {
                    FlickrImageSet imageSet = null;

                    dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        imageSet = new FlickrImageSet(photoSet.PhotosetSmallUrl, photoSet.Title, photoSet.DateUpdated, photoSet.Description);
                        this.ImageSets.Add(imageSet);
                        base.OnPropertyChanged("ImageSets");
                    }
                    );

                    var photosetPhotosCollection = _GetCollectionForSetAsync(photoSet.PhotosetId).Result;

                    foreach (var photo in photosetPhotosCollection)
                    {
                        dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                        {
                            var image = new FlickrImage(imageSet, photo.SmallUrl, photo.DoesLargeExist ? photo.LargeUrl : photo.Medium640Url, photo.Title, photo.DateTaken, photoSet.Description);
                            imageSet.Collection.Add(image);

                        });
                    }
                }

                return this.ImageSets;
            });

            return task;
        }