Exemplo n.º 1
0
        private void Downloader_DownloadPreview(ImageDownloadEventArgs e)
        {
            if (e.StatusOk)
            {
                Refresh = false;
                string fullPath;
                lock (_lock)
                {
                    fullPath = _memoryManager.SaveToTemp(e.FileBytes, e.PictureId);
                }
                sw.Stop();
                Debug.WriteLine($"{sw.ElapsedMilliseconds} ms", "Downloaded image");
                sw.Reset();
                sw.Start();
                list = Items;

                list.Add(new TestImage
                {
                    FileName  = e?.PictureId,
                    ImagePath = fullPath,
                    Source    = ImageSource.FromFile(fullPath),
                    PinId     = e.PinId
                });

                Items = list;
                NotifyPropertyChanged("Items");
            }
            else
            {
            }
        }
Exemplo n.º 2
0
 private void Downloader_DownloadFull(ImageDownloadEventArgs e)
 {
     if (e.StatusOk)
     {
         _memoryManager.SaveToPicture(e.FileBytes, e.PictureId);
         DownloadProgress = $"Downloading {Progress++}/{Count}";
         if (Progress == Count)
         {
             Progress         = 0;
             DownloadProgress = "Done!";
             // Indsat her
             Items = list;
         }
     }
 }
Exemplo n.º 3
0
        private ImageDownloadResult Download(IImageHeader destination)
        {
            ImageDownloadEventArgs e = new ImageDownloadEventArgs(destination);
            OnDownloading(e);
            if (e.Cancel)
            {
                return new ImageDownloadResult(ImageDownloadResultStatus.None);
            }

            ImageDownloadResult result = destination.Download();
            e.Result = result;

            OnDownloaded(e);
            return result;
        }
Exemplo n.º 4
0
 protected virtual void OnDownloading(ImageDownloadEventArgs e)
 {
     if (!e.Image.Downloadable || e.Image.DownloadCompleted)
     {
         e.Cancel = true;
     }
     if (Downloading != null)
     {
         Downloading(null, e);
     }
 }
Exemplo n.º 5
0
 protected virtual void OnDownloaded(ImageDownloadEventArgs e)
 {
     if (Downloaded != null)
     {
         Downloaded(null, e);
     }
     if (e.Result.Data != null)
     {
         InternetClient.PerformResponseRecieved(new InternetClientEventArgs(e.Result.Data.LongLength, 0));
     }
     switch (e.Result.Status)
     {
         case ImageDownloadResultStatus.BlockedImagePass:
             OnImagePassRequired(new ImagePassEventArgs(this, (ImageHeader)e.Image));
             break;
     }
     System.Threading.Thread.Sleep(DownloadInterval);
 }