Wednesday, January 23, 2008

C# Wizard for Beginners

For Code Mail Us :- Codes.jinesh@gmail.com


Join Our community :- Mad Engineerss...!


What's new?

Bugs in the installer software have been corrected.


Introduction


This is a wizard for use in the C# environment.

Background

A lot of time is spent in developing simple but time-consuming user interfaces in Visual studio .NET in the C# environment in the initial stages since, Microsoft Corporation has provided only a plain and simple form in the Wizard which is bundled with Visual Studio, you got to add the controls like Toolbar, StatusBar , Menu which are commonly used in most applications. In order to reduce the burden of creating and adding the usual controls I thought of creating a Wizard which would accomplish all these tasks, I managed to complete the Wizard and have been using it for quite sometime now, so I just decided to give it away others who may want to use it. This is especially useful for beginners who may find it difficult to create those Windows Explorer like interfaces. And since the Add Form option in Visual Studio .NET has a similar plain interface I decided to add a Form Designing wizard using this technique.


Features
With this Wizard you can create the following type of user interfaces
1. Plain Form
2. Windows Explorer like interface (vertical)
3. Windows Explorer like interface (horizontal)
4. Windows Explorer like interface (3-Pane)
5. Outlook Express like interface
6. Single Document interface
7. Multi Document interface


The above interfaces can optionally have

!~ ToolBar
!~ StatusBar
!~ MainMenu
!~ About Box

In the above interfaces you can select the Control for each pane from a pull-down list and can also set the System Menu, Minimize and Maximize options, you can also set the Maximized or Minimized state of the Window; Initial size of the Window can also be set.

Menu can be the plain menu as provided by C# or can have a Owner-Drawn menu option, read the "Owner-Drawn Menus" section below.


Owner-Drawn Menus
If you select the Owner-Drawn menu option the menu will be drawn using internal code and look a bit different from the usual C# menus. if you created the application by selecting "Owner-Drawn menus" option and at a latter stage want to add new menu items to the menu, to give the newly added menus Owner-Drawn status, do the following.


For each of the newly added menu items set the OwnerDrawn property to true, make Checked and RadioCheck options false (menu items will not be visible if these are set true either at design-time or through code). if you are adding a Separator , do not make its OwnerDrawn property true (I have not found a way out for this). And in the Form1_OnLoad(..) function add the following lines of code.

this.menuItemFile.DrawItem += new System.Windows.Forms.DrawItemEventHandler(
this.menuItem_DrawItem);
this.menuItemFile.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(
this.menuItem_MeasureItem);

Remember to change the name "menuItemFile" above to the name of you MenuItem

If you feel the the owner-drawn option is okay and want to add this to any Context Menus that you plan to add to the application you can use the Owner-Drawn state by following the guidelines for normal menu items above.


Common-Control Manifest
If you check the Common-Control Manifest option on the User-Interface Features page a file named .exe.manifest will be copied in your projects bin\debug folder, when you build and run the project it will have Windows XP Style look. However, for all controls that you will add to the project at a later stage, you must set the FlatStyle property, read the section "About FlatStyle Property".

You have to bundle the manifest file (.exe.manifest) along with your applications executable, it must be in the same folder as the applications executable when installing the application at your Client's site


About FlatStyle property
For Controls you add to have a Windows XP like look you have to set the FlatStyle property to System. There is a down-side to this setting, you may not be able to display icons or images on these controls or align Text. Given below is a list of controls, Column "FlatStyle" indicates if this Controls has "FlatStyle" property, Column "Effective" indicates if changing this property has any effect on the control.

How to Install
Download the Wizard installer at the top and click on the Install button, if all goes well you can start Visual Studio and you find the icons in the New Project Wizard and Add Form options. This was developed Tested and used on Visual Studio Enterprise edition.