private void RemoveDownloadHandlers(ImageDownloader downloader) { downloader.DownloadDataCompleted -= downloader_DownloadDataCompleted; downloader.DownloadProgressChanged -= downloader_DownloadProgressChanged; }
/// <summary> /// This routine load the image from a web uri. /// To achieve this it will start a thread in order to not block the application to continue working. /// </summary> /// <param name="ImageUri">The URI of the resource</param> public void LoadScreenshot(string ImageUri) { //_screenshot = null; _imageUri = ImageUri; //Here I create/start the thread to download the image downloader = new ImageDownloader(_imageUri); AddDownloadHandlers(downloader); _progress = new ProgressBar(); _progress.Height = 10; _progress.Width = this.Width - 50; _progress.Top = (this.Height / 2) - 5; _progress.Left = (this.Width / 2) - (_progress.Width / 2); _progress.Style = ProgressBarStyle.Continuous; _progress.Minimum = 0; _progress.Maximum = 100; _progress.Visible = true; this.Controls.Add(_progress); _thread = new Thread(downloader.DoWork); _thread.Start(); }