Пример #1
0
 private Task <MemoryStream> GetImage(ApodObject obj)
 {
     return(Task.Run(() =>
     {
         // var c = new WebClient();
         using (var c = new WebClient())
         {
             var bytes = c.DownloadData(obj.hdurl);
             var ms = new MemoryStream(bytes);
             return ms;
         }
     }));
 }
Пример #2
0
        private async void DownloadButtonClick(object sender, RoutedEventArgs e)
        {
            downloadProgressBar.Visibility      = Visibility.Visible;
            downloadProgressBar.IsIndeterminate = true;
            mainApod = await DownloadJson(pictureDatePicker.SelectedDate);

            var source = await GetImage(mainApod);

            if (mainApod.media_type == "image")
            {
                var bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = source;
                bitmap.EndInit();

                Apply(bitmap);
            }
        }