Brick Graphics
- 3 minutes to read
This topic explains how you can use the BrickGraphics class to draw some content on a document page, and the IBrickGraphics interface to print DevExpress components and custom controls.
This topic consists of the following sections.
The BrickGraphics Class
The BrickGraphics class is designed to simplify the process of document creation. It provides appropriate methods for drawing various types of bricks in a document.
The following table lists all these methods with the corresponding brick types.
Method | Description | Brick Type |
---|---|---|
BrickGraphics.DrawBrick | Adds a custom brick to a document. | Custom Brick |
BrickGraphics.DrawCheckBox | Adds a brick with a check box inside it. | CheckBoxBrick |
BrickGraphics.DrawEmptyBrick | Adds a non-visual brick to combine other bricks into groups. | EmptyBrick |
BrickGraphics.DrawImage | Adds a brick with an image inside it | ImageBrick |
BrickGraphics.DrawLine | Adds a brick containing a line. | LineBrick |
BrickGraphics.DrawRect | Adds a visual brick (an empty rectangle without borders). | VisualBrick |
BrickGraphics.DrawPageImage | Adds a brick with an image inside the page header or footer. | PageImageBrick |
BrickGraphics.DrawPageInfo | Adds a brick with page information to the page header or footer. | PageInfoBrick |
BrickGraphics.DrawString | Adds a brick with formatted text. | TextBrick |
Before adding a brick, it is necessary to specify the appropriate document section via the BrickGraphics.Modifier property.
When specifying document section modifiers, you can omit any sections that are not needed but retain the following order.
graph.PrintingSystem.Begin();
graph.Modifier = BrickModifier.MarginalHeader;
/* MarginalHeader creation */
graph.Modifier = BrickModifier.MarginalFooter;
/* MarginalFooter creation */
graph.Modifier = BrickModifier.InnerPageHeader;
/* InnerPageHeader creation */
graph.Modifier = BrickModifier.InnerPageFooter;
/* InnerPageFooter creation */
graph.Modifier = BrickModifier.ReportHeader;
/* ReportHeader creation */
graph.Modifier = BrickModifier.DetailHeader;
/* DetailHeader creation */
graph.Modifier = BrickModifier.Detail;
/* Detail creation */
graph.Modifier = BrickModifier.DetailFooter;
/* DetailFooter creation */
graph.Modifier = BrickModifier.ReportFooter;
/* ReportFooter creation */
graph.PrintingSystem.End();
For a code example, see How to: Use Modifiers of BrickGraphics.
The BrickGraphics class provides a set of options that completely define the appearance of added bricks. All these options (such as font, foreground color, background color, etc.) are in effect only for the bricks added after modifying these properties. For example, the BrickGraphics.BorderWidth property affects all bricks that are added after setting this property.
To define measurement units that are used to define the size and coordinates of a brick’s rectangle, use the BrickGraphics.PageUnit property.
For a code example, see How to: Use Bricks of Different Types.
The IBrickGraphics Interface
All DevExpress components that can be printed using the XtraPrinting Library implement the IPrintable interface. Among them are the following controls.
- ChartControl (XtraCharts Suite)
- GridControl (Grid Control Suite)
- LayoutControl (DevExpress Layout Manager Library)
- PivotGridControl (XtraPivotGrid Suite)
- SchedulerControl (XtraScheduler Suite)
- TreeList (Tree List Suite)
- VGridControl and PropertyGridControl (XtraVerticalGrid Suite)
- ASPxPivotGridExporter (ASPxPivotGrid Suite)
To print these components (as well as your custom ones), you need to use the IBrickGraphics interface instead of the BrickGraphics class.
This interface provides the IBrickGraphics.DrawBrick method, which adds an object implementing the IBrick interface to a document. In fact, the BrickGraphics class also implements this interface, so all brick drawing methods of this class internally use the IBrickGraphics.DrawBrick method’s implementation.