Professional Documents
Culture Documents
https://sites.google.com/a/quest.edu.pk/dr-irfana-memon/lecture-slides
Course Content (1)
Part 1: Console Based Applications
Introduction to Microsoft Visual C# and Visual Studio
Working with variables, Data types, Operators, and Expressions
Visual C# Programming Language Constructs, Creating Methods
Invoking Methods, Handling Exceptions, Creating overloaded Methods
Using Decision Statements
4
Drawing spaces
It consists of several spaces:
6
Creating a graphic object
A graphics object can be created in a variety of ways. To create a
graphics object:
Receive a reference to a graphics object as part of
the PaintEventArgs in the Paint event of a form or control. This is
usually how you obtain a reference to a graphics object when
creating painting code for a control. Similarly, you can also obtain
a graphics object as a property of the PrintPageEventArgs when
Graphics g;
// Sets g to a graphics object representing the drawing surface of the
// control or form g is a member of.
g = this.CreateGraphics(); 9
Creating a graphic object
Create from an Image Object
Additionally, you can create a graphics object from any object
that derives from the Image class.
To create a Graphics object from an Image
Call the Graphics.FromImage method, supplying the name of
11
Drawing
• Let see How to draw Line, Rectangle, Ellipse, Polygon, etc
• We can do drawing in the PaintHandlerEvent.
1. Open New Project
2. Goto Even property of Form, double click on Paint, it will
transfer you to code page.
12
Drawing
3. How to: Draw a Line on a Windows Form
14
Drawing
5. How to: Draw a Rectangle on a Windows Form
16
Drawing
7. How to: Draw a Ellipse on a Windows Form
18
Drawing
How to Draw figure in the Center of Form ?