PageCanvas.DrawLine(RichEditPenBase, Point, Point, DocumentLayoutUnit) Method
Draws a custom line.
Namespace: DevExpress.XtraRichEdit.API.Layout
Assembly: DevExpress.RichEdit.v19.1.Core.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
pen | RichEditPenBase | The RichEditPenBase descendant that sets the line’s color and thickness. |
point1 | Point | Sets the line’s start point coordinates. |
point2 | Point | Sets the line’s end point coordinates. |
unit | DocumentLayoutUnit | Specifies measurement units for line parameters |
Remarks
When you print or export documents, document objects may appear differently from the way they look on screen. To make them look the same in both outputs, set the DocumentLayoutUnit parameter to the same DocumentLayoutUnit value as the one specified for the document layout.
Note
Using this parameter is effective only if the drawn shape has coordinates and parameters represented by absolute values – coordinates represented by relative values already have the same measurement unit as the whole document layout.
To set the line style, use the RichEditPenBase.DashStyle method.
Example
This code snippet illustrates the implementation of the PageCanvas.DrawLine and PageCanvas.DrawString methods. They draw two color lines and two strings in place of the header.
One line was drawn without setting the DocumentLayoutUnit parameter, the other was drawn with this parameter set to the same DocumentLayoutUnit value as the one specified for the document layout.
The line with the set parameter will look the same both in Print Preview and on display, whereas the other will look different in Print Preview.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/layout-api-simple-example-t245818
Public Overrides Sub DrawHeader(ByVal header As LayoutHeader)
If Form1.customDrawHeader = True Then
Dim p1 As New Point(0, 0)
Dim p2 As New Point(100, 100)
Canvas.DrawLine(New RichEditPen(Color.Red, 5), p1, p2)
Canvas.DrawString("Default Layout Unit", New Font("Comic Sans", 12), New RichEditBrush(Color.Red), New Point(0, 0))
Dim p3 As New Point(0, 100)
Dim p4 As New Point(100, 200)
Canvas.DrawLine(New RichEditPen(Color.Blue, 5), p3, p4, DocumentLayoutUnit.Pixel)
Canvas.DrawString("Layout Unit Specified", New Font("Comic Sans", 12), New RichEditBrush(Color.Blue), New Point(0, 100), DocumentLayoutUnit.Pixel)
Else
MyBase.DrawHeader(header)
End If
End Sub
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DrawLine(RichEditPenBase, Point, Point, DocumentLayoutUnit) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.