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
Fields
Adapter
the global adapter
protected readonly RAdapter Adapter
Field Value
ClipStack
The clipping bound stack as clips are pushed/poped to/from the graphics
protected readonly Stack<RRect> ClipStack
Field Value
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
RImageImage to draw.
destRect
RRectRectangle 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
RImageImage to draw.
destRect
RRectRectangle structure that specifies the location and size of the drawn image. The image is scaled to fit the rectangle.
srcRect
RRectRectangle 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
RPenPen that determines the color, width, and style of the line.
x1
doubleThe x-coordinate of the first point.
y1
doubleThe y-coordinate of the first point.
x2
doubleThe x-coordinate of the second point.
y2
doubleThe 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
RBrushBrush that determines the characteristics of the fill.
path
RGraphicsPathGraphicsPath that represents the path to fill.
DrawPath(RPen, RGraphicsPath)
Draws a GraphicsPath.
public abstract void DrawPath(RPen pen, RGraphicsPath path)
Parameters
pen
RPenPen that determines the color, width, and style of the path.
path
RGraphicsPathGraphicsPath 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
RBrushBrush 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
RBrushBrush that determines the characteristics of the fill.
x
doubleThe x-coordinate of the upper-left corner of the rectangle to fill.
y
doubleThe y-coordinate of the upper-left corner of the rectangle to fill.
width
doubleWidth of the rectangle to fill.
height
doubleHeight 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
RPenA Pen that determines the color, width, and style of the rectangle.
x
doubleThe x-coordinate of the upper-left corner of the rectangle to draw.
y
doubleThe y-coordinate of the upper-left corner of the rectangle to draw.
width
doubleThe width of the rectangle to draw.
height
doubleThe 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
stringthe string to draw
font
RFontthe font to use to draw the string
color
RColorthe text color to set
point
RPointthe location to start string draw (top-left)
size
RSizeused to know the size of the rendered text for transparent text support
rtl
boolis 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
RRectthe rectangle to get the brush for
color1
RColorthe start color of the gradient
color2
RColorthe end color of the gradient
angle
doublethe 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
RColorthe color to get the pen for
Returns
- RPen
pen instance
GetSolidBrush(RColor)
Get solid color brush.
public RBrush GetSolidBrush(RColor color)
Parameters
color
RColorthe 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
RImageThe Image object with which this TextureBrush object fills interiors.
dstRect
RRectA Rectangle structure that represents the bounding rectangle for this TextureBrush object.
translateTransformLocation
RPointThe dimension by which to translate the transformation
Returns
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
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
stringthe string to measure
font
RFontthe font to measure string with
maxWidth
doublethe max width to calculate fit characters
charFit
intthe number of characters that will fit under
restriction charFitWidth
doublethe 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
RRectRectangle 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
RRectRectangle 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
objectthe 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()