PageCanvas.DrawLine(RichEditPenBase, Point, Point, DocumentLayoutUnit) Method
Draws a custom line.
Namespace: DevExpress.XtraRichEdit.API.Layout
Assembly: DevExpress.RichEdit.v24.1.Core.dll
NuGet Packages: DevExpress.RichEdit.Core, DevExpress.Win.Navigation
Declaration
public void DrawLine(
RichEditPenBase pen,
Point point1,
Point point2,
DocumentLayoutUnit unit
)
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.
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