Wednesday, July 13, 2011

Windows Based Applications Basics

Some views and ideas to make windows application presentable,

It is best practice to change the cursor to busy cursor when an event fires, Once the event is completed then change the cursor back to default.

How to Change a cursor in windows forms?

You can access the cursor of the current form using the “this” key word.

Here is the code snippet for changing cursor to Busy Cursor (In C#)
this.Cursor = Cursors.WaitCursor;

To change the cursor back to default,
this.Cursor = Cursors.Default;

It is usual that the developer will name the windows forms at design time; it is a good practice to rename the Windows Form according to the application name at run time.

To do this, you can add a single line of code in the Page Load event,
this.Text = Application.ProductName;

This will read the Product Name from the assembly information section of the project properties.

To change this Assembly related Information, Please use the following types of Assembly Attributes

Assembly Identity Attributes
Informational Attributes
Assembly Manifest Attributes
Strong Name Attributes

Example:

// Set version number for the assembly.
[assembly:AssemblyVersionAttribute("4.3.2.1")]
// Set culture as German.
[assembly:AssemblyCultureAttribute("en")]



Assembly Identity Attributes
AssemblyCultureAttribute
AssemblyFlagsAttribute
AssemblyVersionAttribute

Informational Attributes
AssemblyCompanyAttribute
AssemblyCopyrightAttribute
AssemblyFileVersionAttribute
AssemblyInformationalVersionAttribute
AssemblyProductAttribute
AssemblyTrademarkAttribute


Assembly Manifest Attributes
AssemblyConfigurationAttribute
AssemblyDefaultAliasAttribute
AssemblyDescriptionAttribute
AssemblyTitleAttribute


Strong Name Attributes
AssemblyDelaySignAttribute
AssemblyKeyFileAttribute
AssemblyKeyNameAttribute



These are the total number of attributes that are available for an Assembly to have.