Отображать изображения из списка<T> в flowLayoutPanel

Я борюсь с отображением изображений из списка изображений в flowLayoutPanel. На самом деле, я создаю приложение для сканирования, которое сканирует документы из устройства подачи или планшета. Когда он сканирует документ из устройства подачи, он отображает первый отсканированный документ в передний блок PictureBox, а остальные - в список. Я могу отображать только первое изображение на панели, а другие изображения ведут себя так, будто их даже нет. Вот пример кода:

// Perform scanning
                List<Image> images = this.ScannerDevice.PerformScan().ToList();

                // Show picture in window
                this.Invoke((MethodInvoker)delegate
                {
                    this.FrontImage = images[0];
                    this.BackImage = (images.Count > 1) ? images[1] : null;

                    this.SetDuplexDisplayOrientation();

                    this.splitContainer.Panel2Collapsed = (this.BackImage == null);
                    this.panelProgress.Visible = false;                       

                    foreach (Image image in images)
                    {
                        PictureBox pf = new PictureBox();
                        pf.SizeMode = PictureBoxSizeMode.StretchImage;
                        pf.Height = 150;
                        pf.Width = 170;
                        pf.Image = pictureBoxFront.Image;
                        pf.Click += new EventHandler(picture_click_scanned);
                        flowLayoutPanel2.Controls.Add(pf);
                    }

                    ScanFinishedEventArgs eventArgs = new ScanFinishedEventArgs { AcceptScan = true };
                    if (this.ScanFinished != null)
                        this.ScanFinished(this, eventArgs);
                    this.buttonOK.Enabled = eventArgs.AcceptScan;
                });
            }
            catch (COMException ex)
            {
                string message = WiaException.GetMessageFromComException(ex);
                MessageBox.Show(message, "Greška u skeniranju", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), "Greška", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            // UI to the Ready-to-Save or Retry mode
            this.Invoke((MethodInvoker)delegate
            {
                this.UseWaitCursor = false;
                this.buttonRetry.Enabled = true;
                this.button3.Enabled = true;
                this.trackBarThreshold.Enabled = true;
                this.panelProgress.Visible = false;
            });

        }) { IsBackground = true }.Start();
    }

Также:

public Image FrontImage
    {
        get { return this.pictureBoxFront.Image; }
        private set { this.pictureBoxFront.Image = value; }
    }

    /// <summary>
    /// Returns the scanned, but possibly post-processed image of the back (if duplex scan)
    /// </summary>
    public Image BackImage
    {
        get { return this.pictureBoxBack.Image; }
        private set { this.pictureBoxBack.Image = value; }
    }

0 ответов

Другие вопросы по тегам