Home | Gaming | Programming | Play Online | Contact | Keyword Query
Games++ Games & Game Programming

GDI in C# Import Method List

By Anand Narayanaswamy

Purpose Syntax Example
Rectangle DrawRectangle(
System.Drawing.Pen,
float x,
float y,
float width,
float height
)
g.DrawRectangle(
new Pen(Color.Pink, 3),
15, 15, 200, 150
);
Filled Rectangle FillRectangle(
System.Drawing.Brush,
float x,
float y,
float width,
float height
)
g.FillRectangle(
new SolidBrush(Color.Pink, 3),
15, 15, 200, 150
);
Line DrawLine(
System.Drawing.Pen,
float x,
float y,
float width,
float height
)
g.DrawLine(
new Pen(Color.Pink, 3),
15, 15, 200, 150
);
Ellipse DrawEllipse(
System.Drawing.Pen,
float x,
float y,
float width,
float height
)
g.DrawEllipse(
new Pen(Color.Pink, 3),
15, 15, 200, 150
);
Filled Ellipse FillEllipse(
System.Drawing.Brush,
float x,
float y,
float width,
float height
)
g.FillEllipse(
new SolidBrush(Color.Pink, 3),
15, 15, 200, 150
);
Pie DrawPie(
System.Drawing.Pen,
float x,
float y,
float width,
float height,
float angleX,
float angleY
)
g.DrawPie(
new Pen(Color.Pink, 3),
15, 15, 200, 150
);
FilledPie FillPie(
System.Drawing.Brush,
float x,
float y,
float width,
float height,
float angleX,
float angleY
)
g.FillPie(
new SolidBrush(Color.Pink, 3),
15, 15, 200, 150
);
Polygon DrawPolygon(
System.Drawing.Pen,
new Point[]
{
new Point(x,y),
new Point(x,y),
new Point(x,y),
new Point(x,y),
new Point(x,y),
new Point(x,y)
});
g.DrawPolygon(
new Pen(Color.Red, 2),
new Point[]
{
new Point( 30,140),
new Point(270,250),
new Point(110,240),
new Point(200,170),
new Point( 70,350),
new Point( 50,200)
});
Filled Polygon FillPolygon(
System.Drawing.Brsuh,
new Point[]
{
new Point(x,y),
new Point(x,y),
new Point(x,y),
new Point(x,y),
new Point(x,y),
new Point(x,y)
});
g.FillPolygon(
new Brush(Color.Red, 2),
new Point[]
{
new Point( 30,140),
new Point(270,250),
new Point(110,240),
new Point(200,170),
new Point( 70,350),
new Point( 50,200)
});

Note: Using Pen class you can specify color of the border and also the thickness. From the examples given above, it can be seen that Pen class is applied for drawing shapes while Brush class is applied for filling shapes.


About the Author: Anand Narayanaswamy is a graduate of the University of Kerala. He is currently working as an instructor in a institution affiliated to Manipal Academy of Higher Education at Thiruvananthapuram, Kerala State, India. He is having over 2+ years of experience in the following skills: Java, JavaScript, Visual Basic, ASP, XML, Microsoft FrontPage, HTML, Microsoft Visual Interdev, NT Server Administration, SQL Server.

Currently he is exploring the possibilities and the features of C# and related .Net Technologies. He also runs http://www.learnxpress.com/.