Table of Contents

Class RenderContext

Namespace
OFT.Rendering.Context
Assembly
OFT.Rendering.dll

Represents an abstract rendering context for drawing on a chart.

public abstract class RenderContext : MarshalByRefObject, IStringMeasure
Inheritance
object
MarshalByRefObject
RenderContext
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

IRenderContextSettings

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

color Color

The 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

layout DrawingLayout
contentVersion long

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

layout DrawingLayout

The 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

heatmapControl HeatmapControl

The HeatmapControl containing the heatmap data.

dest Rectangle

The 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

pen RenderPen

The pen used to draw the ellipse outline.

rect Rectangle

The 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

pen RenderPen

The pen used to draw the rectangle outline.

brush Color

The brush used to fill the rectangle.

rect Rectangle

The 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

pen RenderPen
brush Color
rect Rectangle
radius int

Returns

int

DrawHeatmap(HeatmapControl, Rectangle)

Draws a heatmap on the specified destination rectangle.

public virtual int DrawHeatmap(HeatmapControl heatmapControl, Rectangle dest)

Parameters

heatmapControl HeatmapControl

The HeatmapControl containing the heatmap data.

dest Rectangle

The 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

layout DrawingLayout

The DrawingLayout object to draw.

point Point

The 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

pen RenderPen

The pen used to draw the line.

x1 int

The x-coordinate of the starting point.

y1 int

The y-coordinate of the starting point.

x2 int

The x-coordinate of the ending point.

y2 int

The 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

pen RenderPen

The pen used to draw the lines.

points Point[]

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

pen RenderPen

The pen used to draw the polygon outline.

points Point[]

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

pen RenderPen

The pen used to draw the curves.

points Point[]

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

pen RenderPen

The pen used to draw the rectangle outline.

rect Rectangle

The 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

pen RenderPen

The pen used to draw the rectangle outline.

rect Rectangle

The rectangle to draw.

radius int

The 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

pen RenderPen

The pen used to draw the curve.

points Point[]

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

image IBitmapImage

The IBitmapImage to draw.

dest Rectangle

The 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

image Image

The image to draw.

dest Rectangle

The 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

s string

The string to draw.

font RenderFont

The font used for drawing the string.

brush Color

The brush used to draw the string.

layoutRectangle Rectangle

The 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

s string

The string to draw.

font RenderFont

The font used for drawing the string.

brush Color

The brush used to draw the string.

layoutRectangle Rectangle

The layout rectangle to constrain the drawing area.

format RenderStringFormat

The 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

s string

The string to draw.

font RenderFont

The font used for drawing the string.

brush Color

The brush used to draw the string.

x int

The x-coordinate of the starting position.

y int

The 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

s string

The string to draw.

font RenderFont

The font used for drawing the string.

brush Color

The brush used to draw the string.

x int

The x-coordinate of the starting position.

y int

The y-coordinate of the starting position.

format RenderStringFormat

The 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

brush Color

The brush used to fill the ellipse.

rect Rectangle

The 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

brush Color

The brush used to fill the histogram.

points Point[]

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

brush Color

The brush used to fill the pie.

rect Rectangle

The bounding rectangle of the ellipse.

startAngle float

The start angle in degrees.

sweepAngle float

The 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

brushStart Color

The first brush used for the start of the gradient.

brushEnd Color

The second brush used for the end of the gradient.

points Point[]

An array of points defining the vertices of the polygon.

vertical bool

Specifies 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

brush Color

The brush used to fill the polygon.

points Point[]

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

brush1 Color

The first color of the gradient.

brush2 Color

The second color of the gradient.

rect Rectangle

The 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

brush1 Color

The first brush used for the start of the gradient.

brush2 Color

The second brush used for the end of the gradient.

rect Rectangle

The rectangle to fill.

vertical bool

Specifies 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

brush Color

The brush used to fill the rectangle.

rect Rectangle

The 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

brush Color
rect Rectangle
radius int

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

font RenderFont

The 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

pen RenderPen

The 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

text string

The text to measure.

font RenderFont

The 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

text string

The text to measure.

renderFont RenderFont

The 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

heatmapControl HeatmapControl

The 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

rect Rectangle

The 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

interpolationMode RenderInterpolationModes

The 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

smoothingMode RenderSmoothingModes

The 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

textRenderingHint RenderTextRenderingHint

The 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

dx int

The distance to translate in the x direction.

dy int

The distance to translate in the y direction.

Returns

int

The result of the translation transform operation.