Click here to Skip to main content
15,891,943 members
Articles / Desktop Programming / Windows Forms

Storm - the world's best IDE framework for .NET

Rate me:
Please Sign up or sign in to vote.
4.96/5 (82 votes)
4 Feb 2010LGPL311 min read 276.6K   6.5K   340  
Create fast, flexible, and extensible IDE applications easily with Storm - it takes nearly no code at all!
namespace Storm.Docking.Visual.Drawing
{
	using System;
    using System.Collections;
	using System.Collections.Generic;
	using System.ComponentModel;
	using System.Data;
	using System.Drawing;
	using System.Drawing.Drawing2D;
	using System.Drawing.Imaging;
	using System.Text;
	using System.Windows.Forms;

	/// <summary>
	/// Represents an image with a transparent background.
	/// </summary>
	[ToolboxItem(false)]
	public class TransImage
        : Panel
    {
        #region Properties

        /// <summary>
        /// Gets or sets the image of the TransImage.
        /// </summary>
        public Image Image
		{
			get { return this.BackgroundImage; }
			set
			{
                if (value != null)
                {
                    Bitmap bitmap = new Bitmap(value);
                    bitmap.MakeTransparent();

                    this.BackgroundImage = bitmap;
                    Size = bitmap.Size;
                }
			}
        }

        #endregion

		/// <summary>
		/// Initializes a new instance of the <see cref="TransImage"/> class.
		/// </summary>
		/// <param name="image">The image.</param>
		public TransImage(Image image)
		{
            // Set styles to enable transparent background
			this.SetStyle(ControlStyles.Selectable, false);
			this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);

			this.BackColor = Color.Transparent;
			this.Image = image;
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU Lesser General Public License (LGPLv3)



Comments and Discussions