Click here to Skip to main content
15,893,588 members
Articles / Programming Languages / C#

A Simple Wizard Control for .Net 2.0 with Full Designer Support

Rate me:
Please Sign up or sign in to vote.
4.65/5 (131 votes)
4 Feb 2008CPOL4 min read 546.5K   13.9K   382  
This is a simple yet powerful wizard framework for .Net 2.0. Just drag and drop and your component is ready for use.
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using WizardBase.Properties;

namespace WizardBase
{
    [ToolboxItem(false), Designer(typeof (WizardStepDesigner)), DefaultEvent("Click")]
    public class FinishStep : WizardStep
    {
        private ColorPair pair = new ColorPair();

        public FinishStep()
        {
#pragma warning disable DoNotCallOverridableMethodsInConstructor
            Reset();
#pragma warning restore DoNotCallOverridableMethodsInConstructor
        }

        internal override void Reset()
        {
            BackColor = SystemColors.ControlLightLight;
            BindingImage = Resources.back;
            BackgroundImageLayout = ImageLayout.Tile;
        }

        ///<summary>
        ///Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
        ///</summary>
        ///
        ///<param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data. </param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            using (Brush brush = new LinearGradientBrush(ClientRectangle, pair.BackColor1, pair.BackColor2, pair.Gradient))
            {
                e.Graphics.FillRectangle(brush, ClientRectangle);
            }
        }

        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Image BackgroundImage
        {
            get
            {
                return base.BackgroundImage;
            }
            set
            {
                base.BackgroundImage = value;
            }
        }

        [Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Color BackColor
        {
            get
            {
                return base.BackColor;
            }
            set
            {
                base.BackColor = value;
            }
        }

        [Description("Backgroung of the finish step."), Category("Appearance")]
        public Image BindingImage
        {
            get { return base.BackgroundImage; }
            set
            {
                if (value != base.BackgroundImage)
                {
                    base.BackgroundImage = value;
                    Invalidate();
                    OnBindingImageChanged();
                }
            }
        }
        [Description("Appearence of body."), Category("Appearance")]
        public ColorPair Pair
        {
            get { return pair; }
            set
            {
                if (pair != value)
                {
                    pair = value;
                    Invalidate();
                }
            }
        }

        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Browsable(false)]
        public override Color ForeColor
        {
            get { return base.ForeColor; }
            set { base.ForeColor = value; }
        }

        public bool ShouldSerializeBindingImage()
        {
            return BindingImage != Resources.back;
        }

        public void ResetBindingImage()
        {
            BindingImage = Resources.back; ;
        }

        public bool ShouldSerializePair()
        {
            return pair != new ColorPair();
        }

        public void ResetPair()
        {
            pair = new ColorPair();
        }
    }
}

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 Code Project Open License (CPOL)


Written By
Software Developer (Senior)
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions