예제 #1
0
        private void ProcessPhotos(Photo[] photos, ref long index, WebClient client, string path)
        {
            foreach (var photo in photos)
            {
                if (_cancelDownload)
                {
                    UpdateStatus(Properties.Resources.DownloadsCanceled);
                    UpdateProgress(0);
                    UpdateProgressState(TaskbarProgressBarState.NoProgress);
                    return;
                }

                if (_pauseDownload)
                {
                    UpdateStatus(Properties.Resources.DownloadsPaused);
                    UpdateProgressState(TaskbarProgressBarState.Paused);
                    _mtx.WaitOne();
                    UpdateStatus(Properties.Resources.DownloadsResume);
                    UpdateProgressState(TaskbarProgressBarState.Normal);
                }

                index++;
                int percentage = (int)(100 * index / _totalPhotos);

                FlickrNet.Sizes sizes = FlickrFactory.GetInstance().PhotosGetSizes(photo.PhotoId);
                FlickrNet.Size  size  = sizes.SizeCollection[sizes.SizeCollection.Length - 1];

                string fileName = size.Source.Substring(size.Source.LastIndexOf("/") + 1);

                if (photo.Media == "photo")
                {
                    string localPath = Path.Combine(path, fileName);

                    if (File.Exists(localPath))
                    {
                    }

                    client.DownloadFile(size.Source, localPath);


                    // We want to avoid any calculations problems and report 100% progress before we are truly finished.
                    if (percentage < 100)
                    {
                        backgroundWorker.ReportProgress(percentage, index);
                    }
                }
            }
        }
예제 #2
0
 public PhotoService()
 {
     Service = FlickrFactory.GetInstance();
     Reset();
 }