Class GraphicCache
Represents a cache of graphics objects such as pens, brushes, fonts and text formats.
Inheritance
Implements
Inherited Members
Namespace: FastReport
Assembly: FastReport.OpenSource.dll
Syntax
public class GraphicCache : IDisposable
Remarks
Cache holds all used graphics objects. There is no need to dispose objects returned by GetXXX calls.
Examples
This example demonstrates how to use graphic cache.
public void Draw(FRPaintEventArgs e)
{
Brush brush = e.Cache.GetBrush(BackColor);
Pen pen = e.Cache.GetPen(BorderColor, 1, BorderStyle);
e.Graphics.FillRectangle(brush, Bounds);
e.Graphics.DrawRectangle(pen, Bounds);
}
Constructors
GraphicCache()
Initializes a new instance of the GraphicCache class with default settings.
Declaration
public GraphicCache()
Methods
Dispose()
Disposes resources used by this object.
Declaration
public void Dispose()
GetBrush(Color)
Gets a brush with specified color.
Declaration
public SolidBrush GetBrush(Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color | Color of a brush. |
Returns
Type | Description |
---|---|
SolidBrush | The SolidBrush object. |
GetFont(String, Single, FontStyle)
Gets a font with specified settings.
Declaration
public Font GetFont(string name, float size, FontStyle style)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of a font. |
System.Single | size | Size of a font. |
FontStyle | style | Style of a font. |
Returns
Type | Description |
---|---|
Font | The Font object. |
GetPen(Color, Single, DashStyle)
Gets a pen with specified settings.
Declaration
public Pen GetPen(Color color, float width, DashStyle style)
Parameters
Type | Name | Description |
---|---|---|
Color | color | Color of a pen. |
System.Single | width | Width of a pen. |
DashStyle | style | Dash style of a pen. |
Returns
Type | Description |
---|---|
Pen | The Pen object. |
GetPen(Color, Single, DashStyle, LineJoin)
Gets a pen with specified settings.
Declaration
public Pen GetPen(Color color, float width, DashStyle style, LineJoin lineJoin)
Parameters
Type | Name | Description |
---|---|---|
Color | color | Color of a pen. |
System.Single | width | Width of a pen. |
DashStyle | style | Dash style of a pen. |
LineJoin | lineJoin | Line join of a pen. |
Returns
Type | Description |
---|---|
Pen | The Pen object. |
GetStringFormat(StringAlignment, StringAlignment, StringTrimming, StringFormatFlags, Single, Single)
Gets a string format with specified settings.
Declaration
public StringFormat GetStringFormat(StringAlignment align, StringAlignment lineAlign, StringTrimming trimming, StringFormatFlags flags, float firstTab, float tabWidth)
Parameters
Type | Name | Description |
---|---|---|
StringAlignment | align | Text alignment information on the vertical plane. |
StringAlignment | lineAlign | Line alignment on the horizontal plane. |
StringTrimming | trimming | StringTrimming enumeration. |
StringFormatFlags | flags | StringFormatFlags enumeration that contains formatting information. |
System.Single | firstTab | The number of spaces between the beginning of a line of text and the first tab stop. |
System.Single | tabWidth | Distance between tab stops. |
Returns
Type | Description |
---|---|
StringFormat | The StringFormat object. |