Quang Dinh Luong

Quang Dinh Luong

  • NA
  • 76
  • 18.6k

PictureBox doesn't load image?

Mar 27 2016 10:24 AM
I wrote this:
  1. int abc = 0;
  2. foreach (SubPod subPod in pod.SubPods)  
  3. {  
  4.     //rtbLoG.Text += subPod.Title + Environment.NewLine;  
  5.     //rtbLoG.Text += subPod.Plaintext + Environment.NewLine;  
  6.     //rtbLoG.ScrollToCaret();  
  7.     //pictureBox1.ImageLocation = subPod.Image.Src;  
  8.   
  9.     WebClient webClient = new WebClient();  
  10.     webClient.DownloadFile(new Uri(subPod.Image.Src.Trim()), @"Pictures\\" + abc + ".png");  
  11.   
  12.     Form newForm = new Form();  
  13.     newForm.Size = new Size((subPod.Image.Width) + 10, (subPod.Image.Height) + 37); //10,37  
  14.     newForm.MaximizeBox = false;  
  15.     newForm.MinimizeBox = false;  
  16.     newForm.Text = subPod.Title;  
  17.     newForm.StartPosition = FormStartPosition.Manual;  
  18.     newForm.ShowIcon = false;  
  19.     newForm.ShowInTaskbar = false;  
  20.     newForm.TopMost = true;  
  21.     newForm.MinimumSize = newForm.Size;  
  22.   
  23.     PictureBox newImage = new PictureBox();  
  24.     newImage.ImageLocation = @"Pictures\\" + abc + ".png";  
  25.     newImage.Dock = DockStyle.Fill;  
  26.     newImage.SizeMode = PictureBoxSizeMode.Zoom;  
  27.     newImage.MouseDown += new MouseEventHandler(newImage_MouseDown);  
  28.     newImage.CancelAsync();  
  29.     newForm.Controls.Add(newImage);  
  30.     newForm.Show();  
  31.     abc++;  
  32. }
  33. abc = 0;
 The debug process OK, but it runs poorly. Images are not loaded, the windows contain them freeze, I tried both load directly using Image.Load(src) and indirectly (as above - download then load) but it still not load.
Any suggestion? The code is a mess, sorry :P
 
I also attached the entire code, so you can see the error clearly.
P/s: Click record (wait for a second) and ask sth like: WHo is Bill Gates? It will load the code above and you will understand the error 

Attachment: consciousness.rar