Beispiel #1
0
        /// <summary>
        ///   Displays an image on the screen.
        /// </summary>
        /// 
        /// <param name="title">The text to display in the title bar of the image box.</param>
        /// <param name="image">The image to show.</param>
        /// <param name="sizeMode">How to display the image inside the image box.</param>
        /// <param name="width">The width of the image box.</param>
        /// <param name="height">The height of the image box.</param>
        /// <param name="backColor">The background color to use in the window. 
        ///   Default is <see cref="Color.Black"/>.</param>
        /// 
        public static DialogResult Show(string title, UnmanagedImage image, PictureBoxSizeMode sizeMode, int width, int height, Color backColor)
        {
            if (image == null)
                throw new ArgumentNullException("image");

            DialogResult result;

            using (ImageBox box = new ImageBox())
            {
                box.Text = title;
                box.pictureBox.Width = width;
                box.pictureBox.Height = height;
                box.pictureBox.SizeMode = sizeMode;
                box.pictureBox.Image = image.ToManagedImage();
                box.BackColor = backColor;
                result = box.ShowDialog();
            }

            return result;
        }