IRenderContext2D

StockSharp.Xaml.Charting.Rendering.Common

Defines the interface to a 2D RenderContext, allowing drawing, blitting and creation of pens and brushes on the RenderSurfaceBase

Implements: IDisposable

Properties

Layers
public RenderOperationLayers Layers { get; }
value = iRenderContext2D.Layers

Gets a collection of RenderOperationLayers, which allow rendering operations to be posted to a layered queue for later execution in order (and correct Z-ordering).

ViewportSize
public Size ViewportSize { get; }
value = iRenderContext2D.ViewportSize

Gets the current size of the viewport.

Methods

BeginLine
public IPathDrawingContext BeginLine(IPen2D pen, double startX, double startY)
result = iRenderContext2D.BeginLine(pen, startX, startY)

Begins a Polyline segment, returning the IPathDrawingContext. This is the fastest way to draw lines and simply a proxy to Point}) method.

pen
The pen for the line segment
startX
The start X coordinate (pixel coord)
startY
The start Y coordinate (pixel coord)

Returns: The IPathDrawingContext to continue the line

BeginPolygon
public IPathDrawingContext BeginPolygon(IBrush2D brush, double startX, double startY, double gradientRotationAngle)
result = iRenderContext2D.BeginPolygon(brush, startX, startY, gradientRotationAngle)

Begins a filled Polygon segment, returning the IPathDrawingContext. This is the fastest way to draw polygon and simply a proxy to Double) method.

brush
The brush for the polygon fill
startX
The start X coordinate (pixel coord)
startY
The start Y coordinate (pixel coord)
gradientRotationAngle
The angle which the brush is rotated by

Returns: The IPathDrawingContext to continue the polygon

Clear
public void Clear()
iRenderContext2D.Clear()

Clears the IRenderSurface2D

CreateBrush
public IBrush2D CreateBrush(Color color, double opacity, bool? alphaBlend)
result = iRenderContext2D.CreateBrush(color, opacity, alphaBlend)

Creates a IBrush2D valid for the current render pass. Use this to draw rectangles, polygons and shaded areas

color
The color of the brush, supports transparency
opacity
The opacity of the brush
alphaBlend
If true, use alphablending when shading. If null, auto-detect

Returns: The IBrush2D instance

CreateBrush
public IBrush2D CreateBrush(Brush brush, double opacity, TextureMappingMode textureMappingMode)
result = iRenderContext2D.CreateBrush(brush, opacity, textureMappingMode)

Creates a IBrush2D from WPF Brush valid for the current render pass. Use this to draw rectangles, polygons and shaded areas

brush
The WPF Brush to use as a source, e.g. this can be a , or it can be a . Note that solid colors support transparency and are faster than gradient brushes
opacity
The opacity of the brush
textureMappingMode
Defines a TextureMappingMode, e.g. brushes share a texture per viewport or a new texture per primitive drawn

Returns: The IBrush2D instance

CreatePen
public IPen2D CreatePen(Color color, bool antiAliasing, float strokeThickness, double opacity, double[] strokeDashArray, PenLineCap strokeEndLineCap)
result = iRenderContext2D.CreatePen(color, antiAliasing, strokeThickness, opacity, strokeDashArray, strokeEndLineCap)

Creates a IPen2D valid for the current render pass. Use this to draw outlines, quads and lines

color
The color of the pen, supports transparency
antiAliasing
If true, use antialiasing
strokeThickness
The strokethickness, default=1.0
opacity
The opecity of the pen
strokeDashArray
strokeEndLineCap

Returns: The IPen2D instance

CreateSprite
public ISprite2D CreateSprite(FrameworkElement fe)
result = iRenderContext2D.CreateSprite(fe)

Creates a Sprite from FrameworkElement by rendering to bitmap. This may be used in the Point) method to draw to the screen repeatedly

fe
DigitMaxSize
public Size DigitMaxSize(float fontSize, string fontFamily, FontWeight fontWeight)
result = iRenderContext2D.DigitMaxSize(fontSize, fontFamily, fontWeight)

max digit size in pixels

DisposeResourceAfterDraw
public void DisposeResourceAfterDraw(IDisposable disposable)
iRenderContext2D.DisposeResourceAfterDraw(disposable)

Call this method, passing in IDisposable instance to dispose after the render pass completes. Called internally by Ultrachart to lazy-dispose of Direct2D and Direct3D brushes and textures

disposable
DrawEllipse
public void DrawEllipse(IPen2D strokePen, IBrush2D fillBrush, Point center, double width, double height)
iRenderContext2D.DrawEllipse(strokePen, fillBrush, center, width, height)

Draws an Ellipse on the IRenderSurface2D using the specified outline IPen2DPen and fill IBrush2DBrush

strokePen
The stroke pen
fillBrush
The fill brush
center
The center of the ellipse in pixels
width
The width of the ellipse in pixels
height
The height of the ellipse in pixels
DrawEllipses
public void DrawEllipses(IPen2D strokePen, IBrush2D fillBrush, IEnumerable<Point> centres, double width, double height)
iRenderContext2D.DrawEllipses(strokePen, fillBrush, centres, width, height)

Draws 0..N Ellipses at the points passed in with the same width, height, pen and brush

strokePen
fillBrush
centres
The points to draw ellipses at
width
The common width for all ellipses
height
The common height for all ellipses
DrawLine
public void DrawLine(IPen2D pen, Point pt1, Point pt2)
iRenderContext2D.DrawLine(pen, pt1, pt2)

Draws a single line on the IRenderSurface2D using the specified IPen2D. Note for a faster implementation in some rasterizers, use DrawLines passing in an IEnumerable

pen
The pen
pt1
The start of the line in pixels
pt2
The end of the line in pixels
DrawLines
public void DrawLines(IPen2D pen, IEnumerable<Point> points)
iRenderContext2D.DrawLines(pen, points)

Draws a multi-point line on the IRenderSurface2D using the specified IPen2D

pen
The pen
points
The points

Returns: The last point in the polyline drawn

DrawPixelsVertically
public void DrawPixelsVertically(int x, int yStartBottom, int yEndTop, IList<int> pixelColorsArgb, double opacity, bool yAxisIsFlipped)
iRenderContext2D.DrawPixelsVertically(x, yStartBottom, yEndTop, pixelColorsArgb, opacity, yAxisIsFlipped)

Draws vertical scan line for heatmap from bottom to top, from yStart to yEnd

x
Screen X coordinate where to draw pixels
yStartBottom
Screen Y coordinate of vertical scan line's bottom. Can be located outdide of visible area, in this case not all pixels in list are rendered
yEndTop
Screen Y coordinate of vertical scan line's top. Can be located outdide of visible area, in this case not all pixels in list are rendered
pixelColorsArgb
The list of pixel colors to draw
opacity
The Opacity of the line from 0.0 to 1.0
yAxisIsFlipped
if set to true then y axis is flipped.
DrawQuad
public void DrawQuad(IPen2D pen, Point pt1, Point pt2)
iRenderContext2D.DrawQuad(pen, pt1, pt2)

Draws a Quad on the IRenderSurface2D using the specified IPen2D

pen
The Pen
pt1
Left-top point in the quad
pt2
Bottom-right point in the quad
DrawSprite
public void DrawSprite(ISprite2D srcSprite, Rect srcRect, Point destPoint)
iRenderContext2D.DrawSprite(srcSprite, srcRect, destPoint)

Blits the source image onto the IRenderSurface2D

srcSprite
The source sprite to render
srcRect
The source rectangle
destPoint
The destination point, which will be the top-left coordinate of the sprite after blitting
DrawSprites
public void DrawSprites(ISprite2D sprite2D, IEnumerable<Rect> dstRects)
iRenderContext2D.DrawSprites(sprite2D, dstRects)

Batch draw of the source sprite onto the IRenderSurface2D

sprite2D
The sprite to render
dstRects
The destination rectangles to draw sprites at
DrawSprites
public void DrawSprites(ISprite2D sprite2D, Rect srcRect, IEnumerable<Point> points)
iRenderContext2D.DrawSprites(sprite2D, srcRect, points)

Batch draw of the source sprite onto the IRenderSurface2D

sprite2D
The sprite to render
srcRect
The source rectangle
points
The points to draw sprites at
DrawText
public void DrawText(string text, Rect dstBoundingRect, AlignmentX alignX, AlignmentY alignY, Color foreColor, float fontSize, string fontFamily, FontWeight fontWeight)
iRenderContext2D.DrawText(text, dstBoundingRect, alignX, alignY, foreColor, fontSize, fontFamily, fontWeight)

Draws text if it does not go outside

DrawText
public void DrawText(string text, Point basePoint, AlignmentX alignX, AlignmentY alignY, Color foreColor, float fontSize, string fontFamily, FontWeight fontWeight)
iRenderContext2D.DrawText(text, basePoint, alignX, alignY, foreColor, fontSize, fontFamily, fontWeight)

Draws text relative to base point

FillArea
public void FillArea(IBrush2D brush, IEnumerable<Tuple<Point, Point>> lines, bool isVerticalChart, double gradientRotationAngle)
iRenderContext2D.FillArea(brush, lines, isVerticalChart, gradientRotationAngle)

Fills an area defined the the Points and Heights, e.g. as in a mountain chart, using the specifie IBrush2D

brush
The brush
lines
isVerticalChart
Value, indicates whether chart is vertical
gradientRotationAngle
The angle which the brush is rotated by
FillPolygon
public void FillPolygon(IBrush2D brush, IEnumerable<Point> points)
iRenderContext2D.FillPolygon(brush, points)

Fills a polygon on the IRenderSurface2D using the specifie IBrush2D

brush
The brush
points
The list of points defining the closed polygon, where X,Y coordinates in clockwise direction
FillRectangle
public void FillRectangle(IBrush2D brush, Point pt1, Point pt2, double gradientRotationAngle)
iRenderContext2D.FillRectangle(brush, pt1, pt2, gradientRotationAngle)

Fills a rectangle on the IRenderSurface2D using the specified IBrush2D

brush
The brush
pt2
The top-left point of the rectangle
pt1
The bottom-right point of the rectangle
gradientRotationAngle
The angle which the brush is rotated by, default is zero
SetPrimitvesCachingEnabled
public void SetPrimitvesCachingEnabled(bool bEnabled)
iRenderContext2D.SetPrimitvesCachingEnabled(bEnabled)

enables/disables primitves chaching optimization ( Direct3D renderer only )

TextDrawDimensions
public void TextDrawDimensions(string text, float fontSize, Color foreColor, float width, float height, string fontFamily, FontWeight fontWeight)
iRenderContext2D.TextDrawDimensions(text, fontSize, foreColor, width, height, fontFamily, fontWeight)

Calculate space needed to draw text