Exemplo n.º 1
0
        // 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);
        }
Exemplo n.º 2
0
        // 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;
        }