OnPaintWatermark Event |
[Top] [Chapter] [Previous] [Next] |
Declaration C# OnPaintWatermark( Object Sender, int Editor, int Mode, Graphics Canvas, float X, float Y, float X1, float Y1, float Xres, float Yres);
The .NET assembly uses different parameters than the OCX for this event type.
It passes the coordinates and the resolution as floating point variables and instead of a device handle (HDC) it passes a reference to a .NET Graphics object as drawing surface "Canvas".
Declaration OCX OnPaintWatermark(ByVal Editor As Long, ByVal Mode As Long, ByVal DC As Long, ByVal X As Long, ByVal Y As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal Xres As Long, ByVal Yres As Long)
This event can be used to paint into the background of any page. ( If you need to select a watermark which was loaded using Command(143) please use OnNotify. Example. ) Parameters: The page rectangle and specified by X,Y,X1,Y1. This values are based on the resolution specified by XRes ansd YRes. The lower 3 bytes of parameter "Mode" is the current page number.
In the higher word this bits are used:
0x1000000 : we are currently printing 0x2000000 : we are painting inside the editor 0x4000000 : we are currently exporting to PDF
Example:
private void OnPaintWatermark(object Sender, int Editor, int Mode, System.Drawing.Graphics Canvas, float X, float Y, float X1, float Y1, float Xres, float Yres) { int XMargin = (int)(Xres/2.54); int YMargin = (int)(Yres/2.54); Canvas.DrawRectangle(System.Drawing.Pens.Black, X+XMargin, Y+YMargin, X1-XMargin*2, Y1-YMargin*2);
// Draw the page number as vertical text String drawString = "Page " + ((Mode & 0xFFFFF) + 1).ToString();
Font drawFont = new Font("Arial", 11); SolidBrush drawBrush = new SolidBrush(Color.Red);
StringFormat drawFormat = new StringFormat(); drawFormat.FormatFlags = StringFormatFlags.DirectionVertical; // Draw in upper left corner Canvas.DrawString( drawString, drawFont, drawBrush, X, Y, drawFormat); }
|