Exemplo n.º 1
0
        public async void GetImages()
        {
            _client = new HttpClient();
            HttpResponseMessage response = await _client.GetAsync(host);

            string textRespose = await response.Content.ReadAsStringAsync();

            var items = textRespose.FromJson <List <Image> >().OrderByDescending(x => x.ParsedDate);

            foreach (Image image in items)
            {
                var oimage = new NatGeoImage(
                    image.Id.ToString(),
                    image.Title,
                    image.Url,
                    image.Description);
                oimage.DownloadUrl      = image.DownloadUrl;
                oimage.ImageUrl         = image.Url;
                oimage.PhotographerName = image.Photographer;
                oimage.PhotographerUrl  = image.PhotographerUrl;
                oimage.Date             = image.ParsedDate.ToString("MMMM dd, yyyy");
                NatGeoImageCollection.AllItems.Add(oimage);
                _natGeoImageCollection.Add(oimage);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null && pageState.ContainsKey("SelectedItem"))
            {
                navigationParameter = pageState["SelectedItem"];
            }

            NatGeoImage item = NatGeoDataSource.GetItem((String)navigationParameter);

            DefaultViewModel["Items"] = NatGeoDataSource.Items;
            DefaultViewModel["Item"]  = flipView.SelectedItem = item;
        }
Exemplo n.º 3
0
        private NatGeoImage GetImage(Image i)
        {
            var ii = new NatGeoImage();

            ii.Date            = i.Date.ToString("MM/dd/yyyy");
            ii.Description     = i.Description;
            ii.DownloadUrl     = i.DownloadUrl;
            ii.Id              = i.Id;
            ii.Photographer    = i.Photographer;
            ii.PhotographerUrl = i.PhotographerUrl;
            ii.ThumbnailUrl    = i.ThumbnailUrl;
            ii.Title           = i.Title;
            ii.Url             = i.Url;
            return(ii);
        }