Skip to main content
All docs
V23.2

IBasePrintable.CreateArea(String, BrickGraphics) Method

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

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v23.2.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

void CreateArea(
    string areaName,
    BrickGraphics brickGraphics
)

Parameters

Name Type Description
areaName String

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

brickGraphics BrickGraphics

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.

void IBasePrintable.CreateArea(string areaName, IBrickGraphics graph) {
    this.graph = graph;
    if( areaName.Equals("PageFooter") )
        CreatePageFooter();
    else if( areaName.Equals("DetailHeader") )
        CreateDetailHeader();
    else if( areaName.Equals("Detail") )
        CreateDetail();
}

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 IBrick DrawBrick(string typeName, object[,] properties, RectangleF rect) {
    IBrick brick = ps.CreateBrick(typeName);
    brick.SetProperties(properties);
    return graph.DrawBrick(brick, rect);
}

private void CreatePageFooter() {
    string format = "Page {0} of {1}";
    DXFont font = new DXFont("Arial", 9);
    graph.DefaultBrickStyle = new BrickStyle(BorderSide.None, 1,
        Color.Black, Color.Transparent, Color.Black, font,
        new BrickStringFormat(StringAlignment.Center, StringAlignment.Center));

    float height = font.Height + 2;

    RectangleF r = 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);
}
See Also