// Get an image with specified dimension and pixel format public Bitmap GetImage(object sender, String text, Size size, PixelFormat format) { ArrayList names = new ArrayList(); ArrayList images = new ArrayList(); foreach (Content doc in dockManager.Documents) { if ((doc != sender) && (doc is ImageDoc)) { Bitmap img = ((ImageDoc)doc).Image; // check pixel format, width and height if ((img.PixelFormat == format) && ((size.Width == -1) || ((img.Width == size.Width) && (img.Height == size.Height)))) { names.Add(doc.Text); images.Add(img); } } } SelectImageForm form = new SelectImageForm(); form.Description = text; form.ImageNames = names; // allow user to select an image if ((form.ShowDialog() == DialogResult.OK) && (form.SelectedItem != -1)) { return((Bitmap)images[form.SelectedItem]); } return(null); }
// Get an image with specified dimension and pixel format public Bitmap GetImage(object sender, String text, Size size, PixelFormat format) { ArrayList names = new ArrayList(); ArrayList images = new ArrayList(); foreach (Content doc in dockManager.Documents) { if ((doc != sender) && (doc is ImageDoc)) { Bitmap img = ((ImageDoc) doc).Image; // check pixel format, width and height if ((img.PixelFormat == format) && ((size.Width == -1) || ((img.Width == size.Width) && (img.Height == size.Height)))) { names.Add(doc.Text); images.Add(img); } } } SelectImageForm form = new SelectImageForm(); form.Description = text; form.ImageNames = names; // allow user to select an image if ((form.ShowDialog() == DialogResult.OK) && (form.SelectedItem != -1)) { return (Bitmap) images[form.SelectedItem]; } return null; }