GDI+ [creating trapezium in main (I created an instance)]

Jul 14 2008 3:17 AM

Hi,

 

I wanted to know how do I create the exact polygon(trapezium) in my main form.

I've now created a class "PolygonShape" and inside there is this code(this is a shape of a trapezium):

 

protected override void OnPaint(PaintEventArgs pe)

{

 

                 

 

   // Create pen.

   Pen blackPen = new Pen(Color.Black, 3);

   // Create points that define polygon.

   Point point1 = new Point(0, 0);

   Point point2 = new Point(0, 50);

   Point point3 = new Point(150, 50);

   Point point7 = new Point(70, 0);

   Point[] curvePoints =

   {

      point1,

      point2,

      point3,

      point7

   };

   // Draw polygon to screen.

   pe.Graphics.DrawPolygon(blackPen, curvePoints);

        

 

}

 

 

Then in my main, I've initialize as below and I created an instance of it

 

PolygonShape poliA = new PolygonShape();

poliA.Width = 100;  //(this width and height turn out to be a rectangle)

poliA.Height = 50;

poliA.BackColor = Color.Azure;

 

P/S  :  i know why it turn out to be rectangle... but i don't know how to make it to follow the design at top when displaying it..

 

 

PROBLEM : when i run this code, then it will come out with a rectangle shape.I've alread tried to research.. but i dont get any ways to make the shape become the shape of the trapezium. Any idea?


Answers (1)