Class RenderContext
Represents an abstract rendering context for drawing on a chart.
public abstract class RenderContext : MarshalByRefObject, IStringMeasure
- Inheritance
-
objectMarshalByRefObjectRenderContext
- Implements
- Extension Methods
Remarks
This class serves as the base for specific implementations of rendering contexts, which define how the drawing methods are implemented based on the rendering platform or library being used.
Constructors
RenderContext()
Initializes a new instance of the RenderContext class.
protected RenderContext()
Properties
ClipBounds
Gets the bounds of the clip area for drawing.
public abstract Rectangle ClipBounds { get; }
Property Value
- Rectangle
FontAntiAliasingMinSize
Gets or sets the minimum font size for anti-aliasing.
public virtual float FontAntiAliasingMinSize { get; set; }
Property Value
- float
IsModified
Gets or sets a value indicating whether the rendering context has been modified.
protected virtual bool IsModified { get; }
Property Value
- bool
IsValid
Gets a value indicating whether the rendering context is valid.
public virtual bool IsValid { get; }
Property Value
- bool
Name
Gets the name of the rendering context.
protected abstract string Name { get; }
Property Value
- string
Settings
Gets settings of a context that will perform final rendering.
public virtual IRenderContextSettings Settings { get; protected set; }
Property Value
Size
Gets or sets the size of the rendering context.
public Size Size { get; protected set; }
Property Value
- Size
UseTestFramework
Gets or sets a value indicating whether the rendering control will record all draw calls timing and display it on top of the image.
public static bool UseTestFramework { get; set; }
Property Value
- bool
Methods
BeginRender()
Begins the rendering process.
public virtual void BeginRender()
Clear(Color)
Clears the drawing area with the specified color.
public abstract int Clear(Color color)
Parameters
colorColorThe color used to clear the drawing area.
Returns
- int
The result of clearing the drawing area.
CompleteLayoutRender(DrawingLayout, long)
Called by EndRender(RenderContext) when the layout content has been fully
drawn through this context. contentVersion is the layout version
captured before recording started. The default commits it immediately — correct for
backends where produced content cannot be lost before reaching the screen. Transactional
backends override this to defer the commit until after a successful present.
Added in ATAS 8.0.15.
protected virtual void CompleteLayoutRender(DrawingLayout layout, long contentVersion)
Parameters
layoutDrawingLayoutcontentVersionlong
CreateLayoutRenderContext(DrawingLayout)
Creates a new RenderContext of the specified layout size to draw to a bitmap. The layout system allows caching a batch of drawings into a bitmap and then not repainting them again (or reducing drawings).
public abstract RenderContext CreateLayoutRenderContext(DrawingLayout layout)
Parameters
layoutDrawingLayoutThe DrawingLayout specifying the size and layout of the new RenderContext.
Returns
- RenderContext
A new RenderContext instance for the specified layout.
DrawCachedHeatmap(HeatmapControl, Rectangle)
Draws prepared heatmap image. Call PrepareCachedHeatmap(HeatmapControl) once before multiple calls of this method.
If you need to draw heatmap only once then use DrawHeatmap(HeatmapControl, Rectangle) method.
public virtual int DrawCachedHeatmap(HeatmapControl heatmapControl, Rectangle dest)
Parameters
heatmapControlHeatmapControlThe HeatmapControl containing the heatmap data.
destRectangleThe destination rectangle where the heatmap will be drawn.
Returns
- int
An integer value representing the result of the drawing operation.
DrawEllipse(RenderPen, Rectangle)
Draws an ellipse using the given pen and bounding rectangle.
public abstract int DrawEllipse(RenderPen pen, Rectangle rect)
Parameters
penRenderPenThe pen used to draw the ellipse outline.
rectRectangleThe bounding rectangle of the ellipse.
Returns
- int
The result of drawing the ellipse.
DrawFillRectangle(RenderPen, Color, Rectangle)
Draws a filled rectangle with a specified pen and brush.
public virtual int DrawFillRectangle(RenderPen pen, Color brush, Rectangle rect)
Parameters
penRenderPenThe pen used to draw the rectangle outline.
brushColorThe brush used to fill the rectangle.
rectRectangleThe rectangle to draw and fill.
Returns
- int
The result of the draw operation.
DrawFillRectangle(RenderPen, Color, Rectangle, int)
Draws a filled rounded rectangle with a specified pen and brush.
public virtual int DrawFillRectangle(RenderPen pen, Color brush, Rectangle rect, int radius)
Parameters
penRenderPenbrushColorrectRectangleradiusint
Returns
- int
DrawHeatmap(HeatmapControl, Rectangle)
Draws a heatmap on the specified destination rectangle.
public virtual int DrawHeatmap(HeatmapControl heatmapControl, Rectangle dest)
Parameters
heatmapControlHeatmapControlThe HeatmapControl containing the heatmap data.
destRectangleThe destination rectangle where the heatmap will be drawn.
Returns
- int
An integer value representing the result of the drawing operation.
DrawLayout(DrawingLayout, Point)
Draws a specified DrawingLayout at the specified point on the rendering context.
public abstract int DrawLayout(DrawingLayout layout, Point point = default)
Parameters
layoutDrawingLayoutThe DrawingLayout object to draw.
pointPointThe location where the drawing layout will be drawn on the rendering context. (optional, default is Point.Empty)
Returns
- int
The result of the draw operation.
DrawLine(RenderPen, int, int, int, int)
Draws a line between two specified points using the given pen.
public abstract int DrawLine(RenderPen pen, int x1, int y1, int x2, int y2)
Parameters
penRenderPenThe pen used to draw the line.
x1intThe x-coordinate of the starting point.
y1intThe y-coordinate of the starting point.
x2intThe x-coordinate of the ending point.
y2intThe y-coordinate of the ending point.
Returns
- int
The result of drawing the line.
DrawLines(RenderPen, Point[])
Draws a series of connected lines between multiple points using the given pen.
public abstract int DrawLines(RenderPen pen, Point[] points)
Parameters
penRenderPenThe pen used to draw the lines.
pointsPoint[]An array of points defining the lines.
Returns
- int
The result of drawing the lines.
DrawPolygon(RenderPen, Point[])
Draws a polygon using the given pen and array of points.
public abstract int DrawPolygon(RenderPen pen, Point[] points)
Parameters
penRenderPenThe pen used to draw the polygon outline.
pointsPoint[]An array of points defining the vertices of the polygon.
Returns
- int
The result of drawing the polygon.
DrawQuadraticSpline(RenderPen, Point[])
Draws a chain of quadratic Bezier curves. The points go in threes: start, control point, end; each next curve starts at the end of the previous one, so a chain of n curves takes 2n + 1 points.
public abstract int DrawQuadraticSpline(RenderPen pen, Point[] points)
Parameters
penRenderPenThe pen used to draw the curves.
pointsPoint[]The start, control and end points; nothing is drawn for fewer than three.
Returns
- int
The result of drawing the curves.
DrawRectangle(RenderPen, Rectangle)
Draws a rectangle using the given pen and rectangle.
public abstract int DrawRectangle(RenderPen pen, Rectangle rect)
Parameters
penRenderPenThe pen used to draw the rectangle outline.
rectRectangleThe rectangle to draw.
Returns
- int
The result of drawing the rectangle.
DrawRectangle(RenderPen, Rectangle, int)
Draws a rounded rectangle using the given pen and rectangle.
public abstract int DrawRectangle(RenderPen pen, Rectangle rect, int radius)
Parameters
penRenderPenThe pen used to draw the rectangle outline.
rectRectangleThe rectangle to draw.
radiusintThe rectangle corners radius.
Returns
- int
The result of drawing the rectangle.
DrawSmoothedLine(RenderPen, Point[])
Draws a smooth curve through all the points (a Catmull-Rom spline drawn as Bezier segments).
public abstract int DrawSmoothedLine(RenderPen pen, Point[] points)
Parameters
penRenderPenThe pen used to draw the curve.
pointsPoint[]The points the curve passes through; nothing is drawn for fewer than two.
Returns
- int
The result of drawing the curve.
DrawStaticImage(IBitmapImage, Rectangle)
Draws a static image on the rendering context with the specified destination rectangle.
public abstract int DrawStaticImage(IBitmapImage image, Rectangle dest)
Parameters
imageIBitmapImageThe IBitmapImage to draw.
destRectangleThe destination rectangle where the image will be drawn.
Returns
- int
DrawStaticImage(Image, Rectangle)
Draws a static image on the rendering context with the specified destination rectangle.
public abstract int DrawStaticImage(Image image, Rectangle dest)
Parameters
imageImageThe image to draw.
destRectangleThe destination rectangle where the image will be drawn.
Returns
- int
The result of the draw operation.
DrawString(string, RenderFont, Color, Rectangle)
Draws a string within the specified layout rectangle using the specified font and brush.
public abstract int DrawString(string s, RenderFont font, Color brush, Rectangle layoutRectangle)
Parameters
sstringThe string to draw.
fontRenderFontThe font used for drawing the string.
brushColorThe brush used to draw the string.
layoutRectangleRectangleThe layout rectangle to constrain the drawing area.
Returns
- int
The result of drawing the string.
DrawString(string, RenderFont, Color, Rectangle, RenderStringFormat)
Draws a string within the specified layout rectangle using the specified font, brush, and string format.
public abstract int DrawString(string s, RenderFont font, Color brush, Rectangle layoutRectangle, RenderStringFormat format)
Parameters
sstringThe string to draw.
fontRenderFontThe font used for drawing the string.
brushColorThe brush used to draw the string.
layoutRectangleRectangleThe layout rectangle to constrain the drawing area.
formatRenderStringFormatThe string format to apply during drawing.
Returns
- int
The result of drawing the string.
DrawString(string, RenderFont, Color, int, int)
Draws a string at the specified position using the specified font and brush.
public abstract int DrawString(string s, RenderFont font, Color brush, int x, int y)
Parameters
sstringThe string to draw.
fontRenderFontThe font used for drawing the string.
brushColorThe brush used to draw the string.
xintThe x-coordinate of the starting position.
yintThe y-coordinate of the starting position.
Returns
- int
The result of drawing the string.
DrawString(string, RenderFont, Color, int, int, RenderStringFormat)
Draws a string at the specified position using the specified font, brush, and string format.
public abstract int DrawString(string s, RenderFont font, Color brush, int x, int y, RenderStringFormat format)
Parameters
sstringThe string to draw.
fontRenderFontThe font used for drawing the string.
brushColorThe brush used to draw the string.
xintThe x-coordinate of the starting position.
yintThe y-coordinate of the starting position.
formatRenderStringFormatThe string format to apply during drawing.
Returns
- int
The result of drawing the string.
EndRender()
Ends the rendering process.
public virtual void EndRender()
FillEllipse(Color, Rectangle)
Fills an ellipse using the specified brush and bounding rectangle.
public abstract int FillEllipse(Color brush, Rectangle rect)
Parameters
brushColorThe brush used to fill the ellipse.
rectRectangleThe bounding rectangle of the ellipse.
Returns
- int
The result of filling the ellipse.
FillHistogram(Color, Point[])
Fills a histogram with a specified color.
public virtual int FillHistogram(Color brush, Point[] points)
Parameters
brushColorThe brush used to fill the histogram.
pointsPoint[]The array of points that define the histogram shape.
Returns
- int
The result of the fill operation.
FillPie(Color, Rectangle, float, float)
Fills a pie-shaped area of an ellipse using the specified brush, bounding rectangle, start angle, and sweep angle.
public abstract int FillPie(Color brush, Rectangle rect, float startAngle, float sweepAngle)
Parameters
brushColorThe brush used to fill the pie.
rectRectangleThe bounding rectangle of the ellipse.
startAnglefloatThe start angle in degrees.
sweepAnglefloatThe sweep angle in degrees.
Returns
- int
The result of filling the pie.
FillPolygon(Color, Color, Point[], bool)
Fills a polygon with a gradient using two specified brushes and the array of points.
public abstract int FillPolygon(Color brushStart, Color brushEnd, Point[] points, bool vertical)
Parameters
brushStartColorThe first brush used for the start of the gradient.
brushEndColorThe second brush used for the end of the gradient.
pointsPoint[]An array of points defining the vertices of the polygon.
verticalboolSpecifies whether the gradient should be vertical (true) or horizontal (false).
Returns
- int
The result of filling the polygon with the gradient.
FillPolygon(Color, Point[])
Fills a polygon using the specified brush and array of points.
public abstract int FillPolygon(Color brush, Point[] points)
Parameters
brushColorThe brush used to fill the polygon.
pointsPoint[]An array of points defining the vertices of the polygon.
Returns
- int
The result of filling the polygon.
FillRectangle(Color, Color, Rectangle)
Fills a rectangle with a gradient using two specified colors.
public int FillRectangle(Color brush1, Color brush2, Rectangle rect)
Parameters
brush1ColorThe first color of the gradient.
brush2ColorThe second color of the gradient.
rectRectangleThe rectangle to fill.
Returns
- int
The result of the fill operation.
FillRectangle(Color, Color, Rectangle, bool)
Fills a rectangle with a gradient using two specified brushes and the rectangle.
public abstract int FillRectangle(Color brush1, Color brush2, Rectangle rect, bool vertical)
Parameters
brush1ColorThe first brush used for the start of the gradient.
brush2ColorThe second brush used for the end of the gradient.
rectRectangleThe rectangle to fill.
verticalboolSpecifies whether the gradient should be vertical (true) or horizontal (false).
Returns
- int
The result of filling the rectangle with the gradient.
FillRectangle(Color, Rectangle)
Fills a rectangle using the specified brush and rectangle.
public abstract int FillRectangle(Color brush, Rectangle rect)
Parameters
brushColorThe brush used to fill the rectangle.
rectRectangleThe rectangle to fill.
Returns
- int
The result of filling the rectangle.
FillRectangle(Color, Rectangle, int)
Fills a rounded rectangle by radius in pixels using the specified brush and rectangle.
public abstract int FillRectangle(Color brush, Rectangle rect, int radius)
Parameters
brushColorrectRectangleradiusint
Returns
- int
GetFontAntiAliasingByStateAndSize(RenderFont)
Gets the text rendering hint based on the specified font and minimum anti-aliasing size.
protected virtual RenderTextRenderingHint GetFontAntiAliasingByStateAndSize(RenderFont font)
Parameters
fontRenderFontThe font used for rendering.
Returns
- RenderTextRenderingHint
The text rendering hint to use.
GetStrokeWidth(RenderPen)
Gets the width a pen draws with in this context; a context that scales its strokes overrides it.
Added in ATAS 8.0.15.
protected virtual float GetStrokeWidth(RenderPen pen)
Parameters
penRenderPenThe pen.
Returns
- float
The width of the stroke; 0 for no pen.
MeasureString(string, RenderFont)
Measures the System.Drawing.Size of the specified text when drawn using the specified font.
public abstract Size MeasureString(string text, RenderFont font)
Parameters
textstringThe text to measure.
fontRenderFontThe font used for measuring the text.
Returns
- Size
The size of the text when drawn with the specified font.
MeasureStringWithOverhang(string, RenderFont)
Returns the smallest rectangle that the specified text will fit. The height of the rectangle will depend on the actual drawing characters.
public abstract Rectangle MeasureStringWithOverhang(string text, RenderFont renderFont)
Parameters
textstringThe text to measure.
renderFontRenderFontThe font used for measuring the text.
Returns
- Rectangle
The smallest rectangle that the text will fit.
Modified()
Marks the render context as modified.
protected virtual void Modified()
PrepareCachedHeatmap(HeatmapControl)
Calculates and prepares heatmap to be drawn later with DrawCachedHeatmap(HeatmapControl, Rectangle)
Cached heatmap can be drawn only for a single drawing context (single frame).
public virtual int PrepareCachedHeatmap(HeatmapControl heatmapControl)
Parameters
heatmapControlHeatmapControlThe HeatmapControl containing the heatmap data.
Returns
- int
An integer value representing the result of the preparation operation.
ResetClip()
Resets the clipping region of the rendering context to its original state.
public abstract int ResetClip()
Returns
- int
The result of the reset clip operation.
SetClip(Rectangle)
Sets the clipping region of the rendering context to the specified rectangle.
public abstract int SetClip(Rectangle rect)
Parameters
rectRectangleThe rectangle to set as the clipping region.
Returns
- int
The result of the set clip operation.
SetInterpolationMode(RenderInterpolationModes)
Sets the interpolation mode for drawing operations.
public abstract int SetInterpolationMode(RenderInterpolationModes interpolationMode)
Parameters
interpolationModeRenderInterpolationModesThe interpolation mode to set.
Returns
- int
The result of setting the interpolation mode.
SetSmoothingMode(RenderSmoothingModes)
Sets the smoothing mode for drawing operations.
public abstract int SetSmoothingMode(RenderSmoothingModes smoothingMode)
Parameters
smoothingModeRenderSmoothingModesThe smoothing mode to set.
Returns
- int
The result of setting the smoothing mode.
SetTextRenderingHint(RenderTextRenderingHint)
Sets the text rendering hint for the rendering context.
public virtual int SetTextRenderingHint(RenderTextRenderingHint textRenderingHint)
Parameters
textRenderingHintRenderTextRenderingHintThe text rendering hint to set.
Returns
- int
The result of setting the text rendering hint.
ThrowIfInvalid()
Checks if the render context is in an invalid state and throws a RenderException if so.
protected void ThrowIfInvalid()
TranslateTransform(int, int)
Translates the origin of the rendering context by the specified distance in the x and y directions.
public abstract int TranslateTransform(int dx, int dy)
Parameters
dxintThe distance to translate in the x direction.
dyintThe distance to translate in the y direction.
Returns
- int
The result of the translation transform operation.