public void SetScreenshots(List <IFileData> screenshots)
        {
            flpScreenshots.SuspendLayout();

            foreach (var pb in m_pictureBoxes)
            {
                pb.ImageLocation = string.Empty;
            }

            m_screenshots = screenshots.ToList();
            m_lookup.Clear();

            if (m_screenshots.Count > m_pictureBoxes.Count)
            {
                ExpandPictureBoxes(m_screenshots.Count - m_pictureBoxes.Count);
            }

            List <PictureBox> .Enumerator enumerator = m_pictureBoxes.GetEnumerator();

            foreach (IFileData screen in screenshots)
            {
                enumerator.MoveNext();
                if (enumerator.Current == null)
                {
                    break;
                }

                PictureBox pbScreen = enumerator.Current;
                flpScreenshots.Controls.Add(pbScreen);

                try
                {
                    if (screen.IsUrl)
                    {
                        pbScreen.CancelAsync();
                        pbScreen.Image = null;
                        pbScreen.LoadAsync(screen.FileName);
                    }
                    else
                    {
                        pbScreen.ImageLocation = Path.Combine(DataDirectory.GetFullPath(), screen.FileName);
                    }
                }
                catch
                {
                    pbScreen.ImageLocation = string.Empty;
                }

                m_lookup.Add(pbScreen, screen);
            }

            flpScreenshots.ResumeLayout();
        }
        public void SetScreenshots(List <IFileData> screenshots)
        {
            flpScreenshots.SuspendLayout();
            List <PictureBox> .Enumerator enumerator = m_pictureBoxes.GetEnumerator();

            m_screenshots = screenshots.ToList();
            m_lookup.Clear();

            foreach (IFileData screen in screenshots)
            {
                enumerator.MoveNext();
                if (enumerator.Current == null)
                {
                    break;
                }

                PictureBox pbScreen = enumerator.Current;
                flpScreenshots.Controls.Add(pbScreen);

                FileStream fs = null;

                try
                {
                    if (screen.IsUrl)
                    {
                        pbScreen.CancelAsync();
                        pbScreen.Image = null;
                        pbScreen.LoadAsync(screen.FileName);
                    }
                    else
                    {
                        fs             = new FileStream(Path.Combine(DataDirectory.GetFullPath(), screen.FileName), FileMode.Open, FileAccess.Read);
                        pbScreen.Image = Image.FromStream(fs);
                    }
                }
                catch
                {
                    pbScreen.Image = null;
                }
                finally
                {
                    if (fs != null)
                    {
                        fs.Close();
                    }
                }

                m_lookup.Add(pbScreen, screen);
            }

            flpScreenshots.ResumeLayout();
        }
 //加载指定视频地址的图像到特定的pictureBox
 public void LoadPicture(ref PictureBox TargetPictureBox)
 {
     try
     {
         TargetPictureBox.ImageLocation = iVideoAdd;
         TargetPictureBox.LoadAsync();
     }
     catch (System.Exception ex)
     {
         TargetPictureBox.CancelAsync();
         throw new Exception("<加载图片>:", ex);
     }
 }
Beispiel #4
0
 public void SetScreenshots(List <IFileDataSource> screenshots)
 {
     this.flpScreenshots.SuspendLayout();
     List <PictureBox> .Enumerator enumerator = this.m_pictureBoxes.GetEnumerator();
     foreach (IFileDataSource source in screenshots)
     {
         enumerator.MoveNext();
         if (enumerator.Current == null)
         {
             break;
         }
         PictureBox current = enumerator.Current;
         this.flpScreenshots.Controls.Add(current);
         FileStream stream = null;
         try
         {
             if (source.IsUrl)
             {
                 current.CancelAsync();
                 current.Image = null;
                 current.LoadAsync(source.FileName);
             }
             else
             {
                 stream        = new FileStream(Path.Combine(base.DataDirectory.GetFullPath(), source.FileName), FileMode.Open, FileAccess.Read);
                 current.Image = Image.FromStream(stream);
             }
         }
         catch
         {
         }
         finally
         {
             if (stream != null)
             {
                 stream.Close();
             }
         }
         this.m_lookup.Add(current, source);
     }
     this.flpScreenshots.ResumeLayout();
 }
Beispiel #5
0
 //<snippet4>
 private void cancelButton_Click(object sender, EventArgs e)
 {
     pictureBox1.CancelAsync();
 }
Beispiel #6
0
        public void SetScreenshots(List <IFileData> screenshots)
        {
            m_ct.Cancel();
            while (!m_imageWorkerComplete)
            {
                Thread.Sleep(10);
            }
            m_imageWorkerComplete = false;
            m_ct = new CancellationTokenSource();

            flpScreenshots.SuspendLayout();

            m_screenshots = screenshots.ToList();
            m_lookup.Clear();

            lock (m_pictureBoxes)
            {
                if (m_screenshots.Count > m_pictureBoxes.Count)
                {
                    ExpandPictureBoxes(m_screenshots.Count - m_pictureBoxes.Count);
                }

                List <PictureItem> .Enumerator enumerator = m_pictureBoxes.GetEnumerator();

                foreach (IFileData screen in screenshots)
                {
                    enumerator.MoveNext();
                    if (enumerator.Current == null)
                    {
                        break;
                    }

                    PictureBox pbScreen = enumerator.Current.PictureBox;
                    enumerator.Current.Skip = true;
                    flpScreenshots.Controls.Add(pbScreen);

                    m_lookup.Add(pbScreen, screen);

                    try
                    {
                        if (screen.IsUrl)
                        {
                            pbScreen.CancelAsync();
                            pbScreen.Image = null;
                            pbScreen.LoadAsync(screen.FileName);
                        }
                        else
                        {
                            if (screen.Equals(enumerator.Current.CurrentFile))
                            {
                                continue;
                            }

                            enumerator.Current.Skip = false;
                            Image image = pbScreen.Image;
                            pbScreen.Image = null;
                            if (image != null)
                            {
                                image.Dispose();
                            }
                        }
                    }
                    catch
                    {
                        pbScreen.ImageLocation = string.Empty;
                    }
                }
            }

            var thread = new Thread(new ThreadStart(SetImages));

            thread.Start();
            flpScreenshots.ResumeLayout();
        }