public static async Task <int> getNewestComicNumber()
        {
            HttpClient client   = new HttpClient();
            string     response = await client.GetStringAsync(new Uri("http://www.xkcd.com/info.0.json"));

            XkcdJsonObject jsonObject = JsonConvert.DeserializeObject <XkcdJsonObject>(response);

            return(jsonObject.num);
        }
 public void OnComicLoaded(XkcdJsonObject comicJson)
 {
     for (int i = 0; i < pivotBuffer; i++)
     {
         if (comicPanels[i].comic == comicJson)
         {
             pivotItems[i].Header = comicJson.title;
         }
     }
 }
 private void loadFailed(int num)
 {
     scrollViewer.Visibility    = Visibility.Collapsed;
     loadFailedPanel.Visibility = Visibility.Visible;
     loadFailedText.Text        = "Could not load comic " + num;
     comic = new XkcdJsonObject
     {
         num   = num,
         title = num + " not found",
         alt   = "",
         img   = ""
     };
 }
 private void loadFailed(int num)
 {
     scrollViewer.Visibility = Visibility.Collapsed;
     loadFailedPanel.Visibility = Visibility.Visible;
     loadFailedText.Text = "Could not load comic " + num;
     comic = new XkcdJsonObject
     {
         num = num,
         title = num+" not found",
         alt = "",
         img = ""
     };
 }
        private async Task <XkcdJsonObject> getComicJson(int number)
        {
            try {
                HttpClient client   = new HttpClient();
                string     response = await client.GetStringAsync(new Uri("http://www.xkcd.com/" + number + "/info.0.json"));

                XkcdJsonObject jsonObject = JsonConvert.DeserializeObject <XkcdJsonObject>(response);
                return(jsonObject);
            }
            catch (Exception)
            {
                return(null);
            }
        }
 private async void loadComic(int number)
 {
     comic = await getComicJson(number);
     if (comic != null)
     {
         image.Source = new BitmapImage(new Uri(comic.img));
         scrollViewer.Visibility = Visibility.Visible;
         loadFailedPanel.Visibility = Visibility.Collapsed;
     }
     else
     {
         loadFailed(number);
     }
     foreach (OnComicLoadListener l in onComicLoadListeners)
     {
         l.OnComicLoaded(comic);
     }
 }
        private async void loadComic(int number)
        {
            comic = await getComicJson(number);

            if (comic != null)
            {
                image.Source               = new BitmapImage(new Uri(comic.img));
                scrollViewer.Visibility    = Visibility.Visible;
                loadFailedPanel.Visibility = Visibility.Collapsed;
            }
            else
            {
                loadFailed(number);
            }
            foreach (OnComicLoadListener l in onComicLoadListeners)
            {
                l.OnComicLoaded(comic);
            }
        }
 public void OnComicLoaded(XkcdJsonObject comicJson)
 {
     for (int i = 0; i < pivotBuffer; i++)
     {
         if (comicPanels[i].comic == comicJson)
         {
             pivotItems[i].Header = comicJson.title;
         }
     }
 }