IBasePrintable.CreateArea(String, IBrickGraphics) Method

When implemented by a class, creates report elements (bricks) for a specific area.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Data.v20.1.dll

Declaration

void CreateArea(
    string areaName,
    IBrickGraphics graph
)
Sub CreateArea(
    areaName As String,
    graph As IBrickGraphics
)

Parameters

Name Type Description
areaName String

The name of the report area (section) for which elements should be created.

graph IBrickGraphics

An object implementing the IBrickGraphics interface, which is a graphical surface on which report elements will be drawn.

Remarks

A description of report generation is provided below. It involves using the IPrintable interface, which is a IBasePrintable descendant:

  1. A user generates a report with the ILink.CreateDocument method.
  2. A link knows about the IBasePrintable control to which it refers, and calls the IBasePrintable.Initialize method.
  3. Next, the CreateArea method is called for each section of the report. Refer to the Document Sections topic, to learn about report section types.

When implemented, the CreateArea method must construct different bricks, based on the section type, and information provided by the control.

The following code implements the CreateArea method for the control. The initialized graph object is of the IBrickGraphics interface type, and will be used in other methods listed below.


Sub CreateArea(ByVal areaName As String, ByVal graph As IBrickGraphics) _
Implements IBasePrintable.CreateArea
    Me.graph = graph
    If areaName.Equals("PageFooter") Then
        CreatePageFooter()
    ElseIf areaName.Equals("DetailHeader") Then
        CreateDetailHeader()
    ElseIf areaName.Equals("Detail") Then
        CreateDetail()
    End If
End Sub

Different methods are called to create the contents for the PageFooter, DetailHeader, and Detail sections. In the following code, we used only the CreatePageFooter method. The DrawBrick method creates a brick object by its name and sets its properties. The ps object of the IPrintingSystem interface was specified by the IBasePrintable.Initialize method.


Private Function DrawBrick(ByVal typeName As String, ByVal properties As Object(,), ByVal rect _
As RectangleF) As IBrick
    Dim brick As IBrick = ps.CreateBrick(typeName)
    brick.SetProperties(properties)
    Return graph.DrawBrick(brick, rect)
End Function

Private Sub CreatePageFooter()
    Dim format As String = "Page {0} of {1}"
    Dim font As Font = New Font("Arial", 9)

    graph.DefaultBrickStyle = New BrickStyle(BorderSide.None, 1, _
        Color.Black, Color.Transparent, Color.Black, font, _
        New BrickStringFormat(StringAlignment.Center, StringAlignment.Center))

    Dim height As Single = font.Height + 2

    Dim r As RectangleF = New RectangleF(0, 0, 0, height)
    DrawBrick("PageInfoBrick", New Object(,) {{"PageInfo", PageInfo.DateTime}, _
        {"AutoWidth", True}, {"Alignment", BrickAlignment.Near}}, r)
    DrawBrick("PageInfoBrick", New Object(,) {{"PageInfo", PageInfo.NumberOfTotal}, _
        {"Format", format}, {"Alignment", BrickAlignment.Far}, {"AutoWidth", True}}, r)

End Sub

The image below demonstrates the PageFooter section of the resulting report.

PageFooterPart

See Also