コード例 #1
0
        private void LoadYoutubeThumnail(string url)
        {
            string videoID          = GetYoutubeVideoID(url);
            string thumnailUrl      = "http://img.youtube.com/vi/" + videoID + "/0.jpg";
            var    thumnailDownload = new ImageDownload(thumnailUrl);
            var    cacheImage       = thumnailDownload.FindInCacheOrLocal();

            if (cacheImage != null)
            {
                Dispatcher.BeginInvoke((Action)(delegate
                {
                    var youtubeImage = new ScreenshotImage();
                    youtubeImage.ViewModel.ScreenshotSource = cacheImage;
                    youtubeImage.ViewModel.IsYoutubeThumbnail = true;
                    ViewModel.ScreenshotsList[0] = youtubeImage;
                }));
                return;
            }
            thumnailDownload.DownloadCompleted += (image) =>
                                                  Dispatcher.BeginInvoke((Action)(delegate
            {
                var youtubeImage = new ScreenshotImage();
                youtubeImage.ViewModel.ScreenshotSource = image;
                youtubeImage.ViewModel.IsYoutubeThumbnail = true;
                ViewModel.ScreenshotsList[0] = youtubeImage;
            }));
            thumnailDownload.DownloadFailed += (s, msg) => Debug.Fail(msg);
            GlobalVariables.ImageDownloadWorker.AddDownload(thumnailDownload);
        }
コード例 #2
0
 private void UpdateScreenshots(List <string> urls)
 {
     //var youtubeImage = new MotionDetailScreenModel.ScreenshotImage { ImageSource = (BitmapImage)FindResource("YoutubeImage") };
     Dispatcher.BeginInvoke((Action)(delegate
     {
         var defaultYoutubeImage = new ScreenshotImage();
         defaultYoutubeImage.ViewModel.ScreenshotSource = (BitmapImage)FindResource("YoutubeImage");
         defaultYoutubeImage.ViewModel.IsYoutubeThumbnail = true;
         ViewModel.ScreenshotsList.Add(defaultYoutubeImage);
         for (int i = 0; i < urls.Count; i++)
         {
             var image = new ScreenshotImage();
             image.ViewModel.ScreenshotSource = null;
             image.ViewModel.IsYoutubeThumbnail = false;
             ViewModel.ScreenshotsList.Add(image);
         }
     }));
     LoadYoutubeThumnail(Info.video_url);
     int[] currentScreenshot = { 1 };
     for (int i = 0; i < urls.Count; i++)
     {
         var downloadImageRequest = new ImageDownload(urls[i]);
         var cacheImage           = downloadImageRequest.FindInCacheOrLocal();
         if (cacheImage != null)
         {
             Dispatcher.BeginInvoke((Action) delegate
             {
                 var image = new ScreenshotImage();
                 image.ViewModel.ScreenshotSource   = cacheImage;
                 image.ViewModel.IsYoutubeThumbnail = false;
                 ViewModel.ScreenshotsList[currentScreenshot[0]] = image;
                 currentScreenshot[0]++;
             });
             return;
         }
         downloadImageRequest.DownloadCompleted += (imageSource) =>
                                                   Dispatcher.BeginInvoke((Action) delegate
         {
             var image = new ScreenshotImage();
             image.ViewModel.ScreenshotSource   = imageSource;
             image.ViewModel.IsYoutubeThumbnail = false;
             ViewModel.ScreenshotsList[currentScreenshot[0]] = image;
             currentScreenshot[0]++;
         });
         downloadImageRequest.DownloadFailed += (s, msg) => Debug.Fail(msg);
         GlobalVariables.ImageDownloadWorker.AddDownload(downloadImageRequest);
     }
 }
コード例 #3
0
 private void UpdateScreenshots(List<string> urls)
 {
     //var youtubeImage = new MotionDetailScreenModel.ScreenshotImage { ImageSource = (BitmapImage)FindResource("YoutubeImage") };
     Dispatcher.BeginInvoke((Action)(delegate
     {
         var defaultYoutubeImage = new ScreenshotImage();
         defaultYoutubeImage.ViewModel.ScreenshotSource = (BitmapImage)FindResource("YoutubeImage");
         defaultYoutubeImage.ViewModel.IsYoutubeThumbnail = true;
         ViewModel.ScreenshotsList.Add(defaultYoutubeImage);
         for (int i = 0; i < urls.Count; i++)
         {
             var image = new ScreenshotImage();
             image.ViewModel.ScreenshotSource = null;
             image.ViewModel.IsYoutubeThumbnail = false;
             ViewModel.ScreenshotsList.Add(image);
         }
     }));
     LoadYoutubeThumnail(Info.video_url);
     int[] currentScreenshot = { 1 };
     for (int i = 0; i < urls.Count; i++)
     {
         var downloadImageRequest = new ImageDownload(urls[i]);
         var cacheImage = downloadImageRequest.FindInCacheOrLocal();
         if (cacheImage != null)
         {
             Dispatcher.BeginInvoke((Action)delegate
             {
                 var image = new ScreenshotImage();
                 image.ViewModel.ScreenshotSource = cacheImage;
                 image.ViewModel.IsYoutubeThumbnail = false;
                 ViewModel.ScreenshotsList[currentScreenshot[0]] = image;
                 currentScreenshot[0]++;
             });
             return;
         }
         downloadImageRequest.DownloadCompleted += (imageSource) =>
                 Dispatcher.BeginInvoke((Action)delegate
                 {
                     var image = new ScreenshotImage();
                     image.ViewModel.ScreenshotSource = imageSource;
                     image.ViewModel.IsYoutubeThumbnail = false;
                     ViewModel.ScreenshotsList[currentScreenshot[0]] = image;
                     currentScreenshot[0]++;
                 });
         downloadImageRequest.DownloadFailed += (s, msg) => Debug.Fail(msg);
         GlobalVariables.ImageDownloadWorker.AddDownload(downloadImageRequest);
     }
 }
コード例 #4
0
 private void LoadYoutubeThumnail(string url)
 {
     string videoID = GetYoutubeVideoID(url);
     string thumnailUrl = "http://img.youtube.com/vi/" + videoID + "/0.jpg";
     var thumnailDownload = new ImageDownload(thumnailUrl);
     var cacheImage = thumnailDownload.FindInCacheOrLocal();
     if (cacheImage != null)
     {
         Dispatcher.BeginInvoke((Action)(delegate
         {
             var youtubeImage = new ScreenshotImage();
             youtubeImage.ViewModel.ScreenshotSource = cacheImage;
             youtubeImage.ViewModel.IsYoutubeThumbnail = true;
             ViewModel.ScreenshotsList[0] = youtubeImage;
         }));
         return;
     }
     thumnailDownload.DownloadCompleted += (image) =>
         Dispatcher.BeginInvoke((Action)(delegate
         {
             var youtubeImage = new ScreenshotImage();
             youtubeImage.ViewModel.ScreenshotSource = image;
             youtubeImage.ViewModel.IsYoutubeThumbnail = true;
             ViewModel.ScreenshotsList[0] = youtubeImage;
         }));
     thumnailDownload.DownloadFailed += (s, msg) => Debug.Fail(msg);
     GlobalVariables.ImageDownloadWorker.AddDownload(thumnailDownload);
 }