private void LoadFile(Wisej.Core.HttpFileCollection files) { if (files == null) { return; } if (files.Count == 0) { this.pictureBox.Image = null; } else { this.pictureBox.Image = GetImageFromStream(files[0].InputStream); } }
// Process multiple files and create a new child PictureBox inside // the flow layout panel. Each PictureBox handles the click event to trigger the download of the // uploaded file. private void LoadFiles(Wisej.Core.HttpFileCollection files) { if (files == null) { return; } int count = files.Count; if (count > 0) { for (int i = 0; i < count; i++) { PictureBox box = new PictureBox() { Name = files[i].FileName, Width = 64, Height = 64, SizeMode = PictureBoxSizeMode.Zoom, BorderStyle = BorderStyle.Solid, Margin = new Padding(5), Cursor = Cursors.Hand }; box.Image = GetImageFromStream(files[i].InputStream); box.MouseClick += (se, ev) => { DialogResult result = MessageBox.Show( "You clicked " + box.Name + "<br/><br/>Would you like to download this file?", "Download", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Application.Download(box.Image, box.Name); } }; this.flowLayoutPanel.Controls.Add(box); } } }