UDOGraphics

<< Click to Display Table of Contents >>

Navigation:  UDO - User Defined Objects >

UDOGraphics

Previous pageReturn to chapter overviewNext page

[.NET only]

This property is only accessible while you are processing the event DoUDOPaint() (VCL: OnUDOPaint(), .NET: UDOPaint()). Reading this property while not processing the event will return a null value.

It returns the current GDI+ drawing surface, which VPE is painting on (this maybe the screen or a printer). Using this GDI+ drawing surface, you can call any GDI+ method or property and paint yourself onto the drawing surface.

property Graphics VPE.UDOGraphics

read; runtime only

Returns:

the Graphics object of the UDO that has to be painted

Remarks:

Before VPE fires the UDOPaint() event, it draws the Box object the UDO object is inherited from.

Example:

Doc.CreateUDO(1, 1, -18, -18, 1);

Creates a UDO with the current properties of the Box-Object and the ID (=lParam) "1"

 

Processing of the UDOPaint() event in C#: creating UDO’s

private void Form1_Load(object sender, System.EventArgs e)

{

 Doc.OpenDoc();

 Doc.PenSize = 0;        // no frame

 Doc.CreateUDO(1, 1, -11.5, -1, 1);

 Doc.CreateUDO(1, 3, -11.5, -1, 2);

 Doc.Preview();

}

 

The event handler for painting the content of the UDO:

private void Doc_UDOPaint(object sender, System.EventArgs e)
{

 int left = Doc.nUDOLeft;

 int top = Doc.nUDOTop;

 int width = Doc.nUDORight - vpe.nUDOLeft;

 int height = Doc.nUDOBottom - vpe.nUDOTop;

 

 Doc.UDOGraphics.DrawRectangle(

         new Pen(Color.Green, 3), left, top, width, height);

 

 if (Doc.UDOlParam == 1)

 {

         Doc.UDOGraphics.DrawString(

                 "Hello, I am a UDO (User Defined Object).",

                 new Font("Arial", 10, FontStyle.Bold),

                 new SolidBrush(Color.Black),

                 left, top);

 }

 else if (Doc.UDOlParam == 2)

 {

         Doc.UDOGraphics.DrawString(

                 "Hello, I am UDO #2.",

                 new Font("Arial", 12, FontStyle.Italic),

                 new SolidBrush(Color.Green),

                 left, top);

 }

}

 

The example draws the contents of two different UDO’s. You will notice that the same UDOPaint() event handler is called for each UDO that appears in the document. The UDO that needs to be drawn is identified by the property UDOlParam. When we had called CreateUDO() we had specified for the first UDO for UDOlParam the value 1, and for the second the value 2.