CSharp forms with GDI


Using CSharp forms with GDI

Using CSharp forms with GDI is fun and creativity . That sort creativity should be learned by the developer of graphic area. But programming has no limit. You have to excel in every aspect of programming. But don’t worry, pracice makes a man perfect

The required class for GDI is System.Drawing.Graphics class and it has the large number of methods to do the drawing.It is infact a large pool of drawing.

The Pen object

This helps us like a normal pen.It can draw many shapes that a normal pn can draw.
You can change many attributes such as color,thickness etc with the pen object

Brush

A brush is derived from System.Drawing.Brush. This is mainly used for filling the objects such as circles. After using this, you become virtual painter 🙂

Bitmaps and Images

System.Drawing.Image is the abstract class and many GDI+ methods use this. However it is abstract and has two descendants- Bitmap (System.Drawing.Bitmap) and MetaFile

Alpha Blending

GDI+ class has the methods that can make a drawing opaque as well per requirement.

Text

GDI+ let us use text as well . You can draw text using any pen, color or brush, and in any font installed on your PC.

A simple example will demonstrate this

protected override void Painting(PaintEventArgs paint)
{
Graphics myGraphics = paint.Graphics ;
Rectangle r = new Rectangle(50, 30, 100, 100);
LinearGradientBrush lBrush = new LinearGradientBrush(r, Color.Red, Color.Yellow, LinearGradientMode.BackwardDiagonal);
g.FillRectangle(lBrush, r);
}

Run it an see it

Syed Adeel Ahmed
Syed Adeel Ahmed
Analyst, Programmer, Educationist and Blogger at Technofranchise
Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.

Published by

Syed Adeel Ahmed

Computer Systems Engineer from Sir Syed University Of Engineering & Technology.I am passionate about all types of programming.

Leave a Reply