Click here to Skip to main content
Click here to Skip to main content

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

, 4 Feb 2008 CPOL
Rate this:
Please Sign up or sign in to vote.
This is a simple yet powerful wizard framework for .Net 2.0. Just drag and drop and your component is ready for use.
WizardDemo1.png

Introduction

This control allows the creation of a wizard framework in seconds. All you need to do is drag and drop and your wizard is ready for use. This wizard control has full designer support and is highly customizable according to the needs of the user.

Background

I was trying to find a control similar to the wizard in ASP.NET. I learned that it is not available in the .NET Framework, so I decided to make a framework that would allow me to make a wizard in a few simple steps. The wizard control is easy to use - a beginner user should be able to use this control without any problems. The wizard control provides full designer support to users by allowing them to view current program actions.

Using the Library

Step 1: Add a reference to Wizarddemo.dll. This step will add the control automatically to the toolbox of Visual Studio.

Step 2: Drag and drop WizardControl to the form where you want to implement the wizard.

WizardDemo3.png

Once dragged, a wizard is created for the form.

Step 3: Use the designer to customize the designer.

WizardDemo4.png
WizardDemo6.png
WizardDemo7.png
WizardDemo8.png
WizardDemo9.png
WizardDemo10.png
WizardDemo2.png
WizardDemo5.png

Points of Interest

WizardControl

Properties

  • BackButtonEnabled - Defines whether or not the Back button is enabled or disabled.
  • BackButtonText - This can be used to get or set the text of the Back button.
  • BackButtonVisible - Indicates whether the Back button is visible or not.
  • NextButtonEnabled - Defines if the Next button is enabled or disabled.
  • NextButtonText - This can be used to get or set text of the Next button.
  • NextButtonVisible - Indicates whether the Next button is visible or not.
  • CancelButtonEnabled - Defines whether the Cancel button is enabled or disabled.
  • CancelButtonText - This can be used to get or set the text of the Cancel button.
  • CancelButtonVisible - Indicates whether the Cancel button is visible or not.
  • HelpButtonEnabled - Defines whether the the Help button is enabled or disabled.
  • HelpButtonText - This can be used to get or set the text of the Help button.
  • HelpButtonVisible - Indicates whether the Help button is visible or not.
  • FinishButtonText - Text of Finish button.
  • EulaButtonEnabled - Defines if the Eula label is enabled or disabled.
  • EulaButtonText - This can be used to get or set the text of Eula label.
  • EulaButtonVisible - Indicates whether the Eula label is visible or not.

Events

  • BackButtonClick - The Back button is clicked.
  • CancelButtonClick - The Cancel button is clicked.
  • FinishButtonClick - The Finish button is clicked.
  • HelpButtonClick - The Help button is clicked.
  • NextButtonClick - The Next button is clicked.
  • EulaButtonClick - The Eula button is clicked.
  • CurrentStepIndexChanged - Occurs after a current step index is changed.

StartStep

Properties

  • Title - Title text of the step.
  • TitleAppearence - Title appearance of the step.
  • SubTitle - The subtitle text of the step.
  • SubtitleAppearence - The subtitle appearance of step.
  • LeftPair - The back color appearance of the left panel.
  • BindingImage - Image for the step.
  • Icon - Icon displayed in the start step.
  • LeftPanelBackColor - If image is null, left panel back color.

Events

  • BindingImageChanged - Fires when BindingImageChanged of the step is changed.

LicenseStep

Properties

  • Title - Title text of the step.
  • TitleAppearence - Title appearance of the step.
  • SubTitle - Subtitle text of the step.
  • SubtitleAppearence - Subtitle appearance of step.
  • Warning - Warning text.
  • WarningFont - The warning text appearance of the step.
  • BindingImage - Image for the step.
  • HeaderPair - Appearance of header.
  • Accepted - Status of license agreement.
  • AcceptText - Accept text.
  • DeclineText - Accept text.
  • LicenseFile - License file to display.

Events

  • BindingImageChanged - Fires when BindingImageChanged of the step is changed.
  • AgreementChanged - Fires when license agreement of the step is changed.

IntermediateStep

Properties

  • Title - Title text of the step.
  • TitleAppearence - The title text appearance of the step.
  • SubTitle - Subtitle text of the step.
  • SubtitleAppearence - The subtitle appearance of the step.
  • HeaderPair - Appearance of the header.
  • BindingImage - Image for the step.

Events

  • BindingImageChanged - Fires when BindingImageChanged of the step is changed.

FinishStep

Properties

  • BindingImage - Background of the finish step.
  • Pair - Appearance of the body.

Events

  • BindingImageChanged - Fires when BindingImageChanged of the step is changed.

Known Issues

  • During the removal of the wizard control, the step code is not removed from the designer.

History

This is the first release of the wizard. Suggestions are welcome for improving this framework.

First revision: 02/2008

  • Generic designer integrated.
  • Advanced generic collections used.
  • Advanced generic type converters.
  • Very small in size.
  • Serialization support.
  • Reset support.
  • Shadow text support.
  • During the removal of the wizard control, the step code is not removed from the designer: fixed.
  • Problem with binding image fixed; it was not setting to null.
  • New events added.
  • License agreement step added.
  • Finish page updated.
  • Other small issues fixed.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Manish Ranjan Kumar
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

 
Questionbug with the wizard control right to left support Pinmembermahdi87_gh25-Oct-14 23:27 
QuestionAdding extra button in next-prev strip PinmemberAmarjeet Banwait24-Jun-13 4:55 
AnswerRe: Adding extra button in next-prev strip Pinmemberxuanguang27-Jul-13 19:11 
GeneralRe: Adding extra button in next-prev strip PinmemberAmarjeet Banwait14-Mar-14 2:15 
QuestionFinish Button Behavior Pinmemberlyricette31-Dec-12 6:55 
AnswerRe: Finish Button Behavior PinmemberMember 98042814-Feb-13 7:07 
GeneralGood example PinmemberWenqingShieh25-Apr-12 18:37 
Questioninteresting PinmemberCIDev7-Nov-11 8:03 
QuestionNice Job PinmemberMike Hankey21-Aug-11 4:32 
QuestionWizardControl not appearing in toolbox PinmemberMember 81389305-Aug-11 5:32 
AnswerRe: WizardControl not appearing in toolbox PinmemberMember 43130936-Dec-11 14:17 
GeneralGetting Started PinmemberJimboStink11-Feb-11 12:49 
GeneralThis is interesting, but odd and unneccesary. PinmemberDiamonddrake18-Jul-10 6:23 
GeneralRe: This is interesting, but odd and unneccesary. PinmemberMember 871442129-Nov-13 9:15 
GeneralControlling the buttons Pinmembersecurigy23-Jun-10 2:19 
GeneralMy vote of 2 Pinmembersecurigy23-Jun-10 1:59 
GeneralBug-free version Pinmemberspencepk3-Mar-10 5:46 
QuestionNew version of WizardControl [modified] PinmemberFBCode19-Oct-09 23:44 
QuestionHow to control the navigation with Next & Back buttons by a criteria PinmemberEng.Zargar2-Aug-09 22:23 
AnswerRe: How to control the navigation with Next & Back buttons by a criteria Pinmemberxuanguang27-Jul-13 19:02 
GeneralOutsatnding Pinmembergujavierdra14-Jul-09 12:54 
GeneralLicenseFile Pinmembersqldevpro1-Mar-09 10:07 
QuestionWilling to change license to a less restrictive license? PinmemberMarkEWaite10-Dec-08 12:55 
AnswerRe: Willing to change license to a less restrictive license? PinmvpJohn Simmons / outlaw programmer12-Dec-08 5:43 
GeneralRe: Willing to change license to a less restrictive license? PinmemberMarkEWaite12-Dec-08 14:11 
GeneralBindingImage Change PinmvpJohn Simmons / outlaw programmer9-Dec-08 4:31 
I'm using VS2008/.Net 3.5:
 
I didn't like the way the binding image was stretched to fill the graphic panel, so I made the following modifications:
 
In StartStep.cs, replace the original OnPaint() method with the code below:
 
protected override void OnPaint(PaintEventArgs e)
{
	Rectangle rect;
	Rectangle iconRect;
	RectangleF titleRect;
	RectangleF subtitleRect;
	base.OnPaint(e);
	Graphics graphics = e.Graphics;
	rect = LeftRectangle;
	GetTextBounds(out titleRect, out subtitleRect);
 
	Rectangle gradientRect = new Rectangle(rect.Location, rect.Size);
	Rectangle bindingRect = new Rectangle(0, 0, 0, 0);
 
	if (bindingImage != null)
	{
		// establish the rectangle of the bindingImage graphic
		bindingRect.Size = new Size(bindingImage.Size.Width, bindingImage.Size.Height);
 
		// if the image is too large to fit within the left-side graphic area, resize it to fit
		if (bindingRect.Width != rect.Width)
		{
			float pct = (float)rect.Width / (float)bindingRect.Width;
			bindingRect.Size = new Size(rect.Width, (int)(bindingRect.Height * pct));
		}
		gradientRect.Location = new Point(gradientRect.X, gradientRect.Y + bindingRect.Height - 1);
		gradientRect.Size = new Size(gradientRect.Width, gradientRect.Height - bindingRect.Height);
	}
	// paint the background no matter what
	using (Brush brush = new LinearGradientBrush(gradientRect, leftPair.BackColor1, leftPair.BackColor2, leftPair.Gradient))
	{
		graphics.FillRectangle(brush, gradientRect);
	}
 
	// if a binding image has been specified, paint it
	if (bindingImage != null)
	{
		graphics.DrawImage(bindingImage, bindingRect);
	}
 
	if (iconImage != null)
	{
		iconRect = IconRectangle;
		iconRect.Inflate(-1, -1);
		graphics.DrawImage(iconImage, iconRect);
	}
 
	DrawText(graphics, titleRect, title, titleAppearence);
	DrawText(graphics, subtitleRect, subtitle, subtitleAppearence);
}
 
In IntermediateStep.cs, LicenseStep.cs, and FinalStep.cs, replace the original OnPaint() with this one:
 
protected override void OnPaint(PaintEventArgs e)
{
	base.OnPaint(e);
	Graphics graphics = e.Graphics;
	Rectangle rect = HeaderRectangle;
	Rectangle rectangle;
	RectangleF titleRect;
	RectangleF subtitleRect;
	Rectangle gradientRect = new Rectangle(rect.Location, rect.Size);
	Rectangle bindingRect = new Rectangle(0, 0, 0, 0);
 
	GetTextBounds(out titleRect, out subtitleRect);
	if (bindingImage != null)
	{
		// establish the rectangle of the bindingImage graphic
		bindingRect.Size = new Size(bindingImage.Size.Width, bindingImage.Size.Height);
 
		// if the image is too large to fit within the header graphic area, resize it to fit
		if (bindingRect.Height != rect.Height)
		{
			float pct = (float)rect.Height / (float)bindingRect.Height;
			bindingRect.Size = new Size((int)((float)bindingRect.Width * pct), rect.Height);
			bindingRect.Location = new Point(gradientRect.Width - bindingRect.Width, 0);
		}
		gradientRect.Location = new Point(gradientRect.X, gradientRect.Y);
		gradientRect.Size = new Size(gradientRect.Width - bindingRect.Width, gradientRect.Height);
	}
 
	headerPair = new ColorPair(Color.White, Color.DarkSlateBlue, 180);
	using (Brush brush = new LinearGradientBrush(gradientRect, headerPair.BackColor1, headerPair.BackColor2, headerPair.Gradient))
	{
		graphics.FillRectangle(brush, gradientRect);
	}
 
	if (bindingImage != null)
	{
		graphics.DrawImage(bindingImage, bindingRect);
	}
	titleAppearence.TextShadowColor = Color.Transparent;
	titleAppearence.TextColor = Color.White;
	subtitleAppearence.TextColor = Color.White;
	subtitleAppearence.TextShadowColor = Color.Transparent;
	DrawText(graphics, titleRect, title, titleAppearence);
	DrawText(graphics, subtitleRect, subtitle, subtitleAppearence);
}
 
The code above resizes the bindingImage to fit inside the graphic panel, while maintaining the original aspect ratio of the image. It further changes the gradient rectangle so that it ends where the bindingImage starts, thus providing a reasonable transition from the gradient to the image. Of course, this only really looks good if the bindingImage has a single-color background, but you can also just set the gradient colors to be the same (essentially eliminating the gradient).
 
Other things I had to do:
 
0) I had to comment out all the pragmas because I kept getting compile errors.
 
1) I had to comment out the set functionality in the LeftPair property because I kept getting the serialization n compiler error.
 
2) I had to hard-code my gradient colors because the designer refused to keep the settings I made.
 
3) When I tried to set the bindingImage for the intermediate step page, I was getting an error from the IDE saying the setting already existed. All I did was click on it - I never got to the point where I could change the setting.
 
4) When I try to add a handler for normal form events, the method templates aren't being added to the application - anywhere.
 
IMHO, this could would be better if there were templates created to create the form and it's child pages. I think that would simplify the code and enable us to better isolate deficiencies.
 
I also think you would have been better served to create a StepBase class and put all the common stuff in it, such as the graphic panel, the binding image, and the gradient color pair stuff, just to name a few of the items.
 
Personal note to the author:
 
You seemed to have put a lot of work into the code, but you stopped far short of coming up with something viable. There is absolutely no reason for me to have to hard-code stuff into the control itself to make changes, especially with the effort you put into making the control compatible with the IDE designer. Further, you seem to have abandoned the code, forcing your users to try to figure out what the hell your code does. There is no documentation, and pitifully few comments, thus making the code a royal bitch to maintain. It now falls on someone else to take your c ode and recreate it in their own image, and hopefully post a new article with code that actually works.
 

"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
-----
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

GeneralSuggestion PinmemberAndrew day8-Dec-08 9:59 
GeneralRe: Suggestion PinmvpJohn Simmons / outlaw programmer9-Dec-08 4:08 
GeneralRe: Suggestion PinmemberAndrew day9-Dec-08 4:24 
GeneralRe: Suggestion PinmvpJohn Simmons / outlaw programmer9-Dec-08 4:32 
GeneralRe: Suggestion PinmemberAndrew day9-Dec-08 4:36 
GeneralRe: Suggestion PinmvpJohn Simmons / outlaw programmer9-Dec-08 5:48 
GeneralNo overload for 'wizardControl1_NextButtonClick' matches delegate 'WizardBase.GenericCancelEventHandler<wizardbase.wizardcontrol></wizardbase.wizardcontrol> PinmemberAndrew day8-Dec-08 9:53 
GeneralRe: No overload for 'wizardControl1_NextButtonClick' matches delegate 'WizardBase.GenericCancelEventHandler PinmemberMember 323068223-Dec-08 6:00 
GeneralRe: No overload for 'wizardControl1_NextButtonClick' matches delegate 'WizardBase.GenericCancelEventHandler PinmemberMetalzang9-Mar-09 16:39 
AnswerRe: No overload for 'wizardControl1_NextButtonClick' matches delegate 'WizardBase.GenericCancelEventHandler PinmemberMetalzang22-Mar-09 15:35 
GeneralRe: No overload for 'wizardControl1_NextButtonClick' matches delegate 'WizardBase.GenericCancelEventHandler Pinmemberwhuili1-Apr-09 13:49 
GeneralRe: No overload for 'wizardControl1_NextButtonClick' matches delegate 'WizardBase.GenericCancelEventHandler PinmemberMetalzang1-Apr-09 23:25 
GeneralRe: No overload for 'wizardControl1_NextButtonClick' matches delegate 'WizardBase.GenericCancelEventHandler PinmemberRavindranathW19-Aug-09 11:04 
GeneralMy vote of 2 PinmvpJohn Simmons / outlaw programmer5-Dec-08 11:49 
GeneralDesign support for steps PinmvpGiorgi Dalakishvili26-Nov-08 23:58 
General[Message Removed] PinmemberKatekortez25-Oct-08 10:07 
GeneralError i wizard PinmemberMember 237150223-Oct-08 11:16 
GeneralRe: Error i wizard PinmemberFrits van Soldt10-Nov-08 23:38 
GeneralSetting CurrentStepIndex Pinmemberdave5280312-Oct-08 18:12 
GeneralRe: Setting CurrentStepIndex Pinmembergujavierdra6-Aug-09 14:23 
Generalshortcuts and tootips PinmemberMember 226441716-Sep-08 4:28 
QuestionStepIndex always -1? PinmemberStonkie22-Jul-08 13:08 
GeneralEvent NextButton other Button Pinmembervitor.dumont18-Jul-08 4:54 
GeneralSuggested Improvement Pinmembermichieldejong16-Jul-08 5:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.1411019.1 | Last Updated 4 Feb 2008
Article Copyright 2007 by Manish Ranjan Kumar
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid