Table of Contents

Class RGraphics

Namespace
TheArtOfDev.HtmlRenderer.Adapters
Assembly
StockSharp.Xaml.dll

Adapter for platform specific graphics rendering object - used to render graphics and text in platform specific context.
The core HTML Renderer components use this class for rendering logic, extending this class in different platform: WinForms, WPF, Metro, PDF, etc.

public abstract class RGraphics : IDisposable
Inheritance
RGraphics
Implements
Inherited Members
Extension Methods

Constructors

RGraphics(RAdapter, RRect)

Init.

protected RGraphics(RAdapter adapter, RRect initialClip)

Parameters

adapter RAdapter
initialClip RRect

Fields

Adapter

the global adapter

protected readonly RAdapter Adapter

Field Value

RAdapter

ClipStack

The clipping bound stack as clips are pushed/poped to/from the graphics

protected readonly Stack<RRect> ClipStack

Field Value

Stack<RRect>

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public abstract void Dispose()

DrawImage(RImage, RRect)

Draws the specified Image at the specified location and with the specified size.

public abstract void DrawImage(RImage image, RRect destRect)

Parameters

image RImage

Image to draw.

destRect RRect

Rectangle structure that specifies the location and size of the drawn image.

DrawImage(RImage, RRect, RRect)

Draws the specified portion of the specified RImage at the specified location and with the specified size.

public abstract void DrawImage(RImage image, RRect destRect, RRect srcRect)

Parameters

image RImage

Image to draw.

destRect RRect

Rectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.

srcRect RRect

Rectangle structure that specifies the portion of the image object to draw.

DrawLine(RPen, double, double, double, double)

Draws a line connecting the two points specified by the coordinate pairs.

public abstract void DrawLine(RPen pen, double x1, double y1, double x2, double y2)

Parameters

pen RPen

Pen that determines the color, width, and style of the line.

x1 double

The x-coordinate of the first point.

y1 double

The y-coordinate of the first point.

x2 double

The x-coordinate of the second point.

y2 double

The y-coordinate of the second point.

DrawPath(RBrush, RGraphicsPath)

Fills the interior of a GraphicsPath.

public abstract void DrawPath(RBrush brush, RGraphicsPath path)

Parameters

brush RBrush

Brush that determines the characteristics of the fill.

path RGraphicsPath

GraphicsPath that represents the path to fill.

DrawPath(RPen, RGraphicsPath)

Draws a GraphicsPath.

public abstract void DrawPath(RPen pen, RGraphicsPath path)

Parameters

pen RPen

Pen that determines the color, width, and style of the path.

path RGraphicsPath

GraphicsPath to draw.

DrawPolygon(RBrush, RPoint[])

Fills the interior of a polygon defined by an array of points specified by Point structures.

public abstract void DrawPolygon(RBrush brush, RPoint[] points)

Parameters

brush RBrush

Brush that determines the characteristics of the fill.

points RPoint[]

Array of Point structures that represent the vertices of the polygon to fill.

DrawRectangle(RBrush, double, double, double, double)

Fills the interior of a rectangle specified by a pair of coordinates, a width, and a height.

public abstract void DrawRectangle(RBrush brush, double x, double y, double width, double height)

Parameters

brush RBrush

Brush that determines the characteristics of the fill.

x double

The x-coordinate of the upper-left corner of the rectangle to fill.

y double

The y-coordinate of the upper-left corner of the rectangle to fill.

width double

Width of the rectangle to fill.

height double

Height of the rectangle to fill.

DrawRectangle(RPen, double, double, double, double)

Draws a rectangle specified by a coordinate pair, a width, and a height.

public abstract void DrawRectangle(RPen pen, double x, double y, double width, double height)

Parameters

pen RPen

A Pen that determines the color, width, and style of the rectangle.

x double

The x-coordinate of the upper-left corner of the rectangle to draw.

y double

The y-coordinate of the upper-left corner of the rectangle to draw.

width double

The width of the rectangle to draw.

height double

The height of the rectangle to draw.

DrawString(string, RFont, RColor, RPoint, RSize, bool)

Draw the given string using the given font and foreground color at given location.

public abstract void DrawString(string str, RFont font, RColor color, RPoint point, RSize size, bool rtl)

Parameters

str string

the string to draw

font RFont

the font to use to draw the string

color RColor

the text color to set

point RPoint

the location to start string draw (top-left)

size RSize

used to know the size of the rendered text for transparent text support

rtl bool

is to render the string right-to-left (true - RTL, false - LTR)

GetClip()

Gets a Rectangle structure that bounds the clipping region of this Graphics.

public RRect GetClip()

Returns

RRect

A rectangle structure that represents a bounding rectangle for the clipping region of this Graphics.

GetGraphicsPath()

Get GraphicsPath object.

public abstract RGraphicsPath GetGraphicsPath()

Returns

RGraphicsPath

graphics path instance

GetLinearGradientBrush(RRect, RColor, RColor, double)

Get linear gradient color brush from color1 to color2.

public RBrush GetLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)

Parameters

rect RRect

the rectangle to get the brush for

color1 RColor

the start color of the gradient

color2 RColor

the end color of the gradient

angle double

the angle to move the gradient from start color to end color in the rectangle

Returns

RBrush

linear gradient color brush instance

GetPen(RColor)

Get color pen.

public RPen GetPen(RColor color)

Parameters

color RColor

the color to get the pen for

Returns

RPen

pen instance

GetSolidBrush(RColor)

Get solid color brush.

public RBrush GetSolidBrush(RColor color)

Parameters

color RColor

the color to get the brush for

Returns

RBrush

solid color brush instance

GetTextureBrush(RImage, RRect, RPoint)

Get TextureBrush object that uses the specified image and bounding rectangle.

public abstract RBrush GetTextureBrush(RImage image, RRect dstRect, RPoint translateTransformLocation)

Parameters

image RImage

The Image object with which this TextureBrush object fills interiors.

dstRect RRect

A Rectangle structure that represents the bounding rectangle for this TextureBrush object.

translateTransformLocation RPoint

The dimension by which to translate the transformation

Returns

RBrush

MeasureString(string, RFont)

Measure the width and height of string str when drawn on device context HDC using the given font font.

public abstract RSize MeasureString(string str, RFont font)

Parameters

str string

the string to measure

font RFont

the font to measure string with

Returns

RSize

the size of the string

MeasureString(string, RFont, double, out int, out double)

Measure the width of string under max width restriction calculating the number of characters that can fit and the width those characters take.
Not relevant for platforms that don't render HTML on UI element.

public abstract void MeasureString(string str, RFont font, double maxWidth, out int charFit, out double charFitWidth)

Parameters

str string

the string to measure

font RFont

the font to measure string with

maxWidth double

the max width to calculate fit characters

charFit int

the number of characters that will fit under restriction

charFitWidth double

the width that only the characters that fit into max width take

PopClip()

Pop the latest clip push.

public abstract void PopClip()

PushClip(RRect)

Push the clipping region of this Graphics to interception of current clipping rectangle and the given rectangle.

public abstract void PushClip(RRect rect)

Parameters

rect RRect

Rectangle to clip to.

PushClipExclude(RRect)

Push the clipping region of this Graphics to exclude the given rectangle from the current clipping rectangle.

public abstract void PushClipExclude(RRect rect)

Parameters

rect RRect

Rectangle to exclude clipping in.

ResumeClipping()

Resumes the suspended clips.

public void ResumeClipping()

ReturnPreviousSmoothingMode(object)

Return to previous smooth mode before anti-alias was set as returned from SetAntiAliasSmoothingMode().

public abstract void ReturnPreviousSmoothingMode(object prevMode)

Parameters

prevMode object

the previous mode to set

SetAntiAliasSmoothingMode()

Set the graphics smooth mode to use anti-alias.
Use ReturnPreviousSmoothingMode(object) to return back the mode used.

public abstract object SetAntiAliasSmoothingMode()

Returns

object

the previous smooth mode before the change

SuspendClipping()

Restore the clipping region to the initial clip.

public void SuspendClipping()