Table of Contents

Class RAdapter

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

Platform adapter to bridge platform specific objects to HTML Renderer core library.
Core uses abstract renderer objects (RAdapter/RControl/REtc...) to access platform specific functionality, the concrete platforms implements those objects to provide concrete platform implementation. Those allowing the core library to be platform agnostic.

Platforms: WinForms, WPF, Metro, PDF renders, etc.
Objects: UI elements(Controls), Graphics(Render context), Colors, Brushes, Pens, Fonts, Images, Clipboard, etc.

public abstract class RAdapter
Inheritance
RAdapter
Derived
Inherited Members
Extension Methods

Remarks

It is best to have a singleton instance of this class for concrete implementation!
This is because it holds caches of default CssData, Images, Fonts and Brushes.

Constructors

RAdapter()

Init.

protected RAdapter()

Properties

DefaultCssData

Get the default CSS stylesheet data.

public CssData DefaultCssData { get; }

Property Value

CssData

Methods

AddFontFamily(RFontFamily)

Adds a font family to be used.

public void AddFontFamily(RFontFamily fontFamily)

Parameters

fontFamily RFontFamily

The font family to add.

AddFontFamilyMapping(string, string)

Adds a font mapping from fromFamily to toFamily iff the fromFamily is not found.
When the fromFamily font is used in rendered html and is not found in existing fonts (installed or added) it will be replaced by toFamily.

public void AddFontFamilyMapping(string fromFamily, string toFamily)

Parameters

fromFamily string

the font family to replace

toFamily string

the font family to replace with

ConvertImage(ImageSource)

Convert image object returned from HtmlImageLoadEventArgs to RImage.

public RImage ConvertImage(ImageSource image)

Parameters

image ImageSource

the image returned from load event

Returns

RImage

converted image or null

ConvertImageInt(ImageSource)

Convert image object returned from HtmlImageLoadEventArgs to RImage.

protected abstract RImage ConvertImageInt(ImageSource image)

Parameters

image ImageSource

the image returned from load event

Returns

RImage

converted image or null

CreateContextMenuInt()

Create a context menu that can be used on the control

protected virtual RContextMenu CreateContextMenuInt()

Returns

RContextMenu

new context menu

CreateFontInt(string, double, RFontStyle)

Get font instance by given font family name, size and style.

protected abstract RFont CreateFontInt(string family, double size, RFontStyle style)

Parameters

family string

the font family name

size double

font size

style RFontStyle

font style

Returns

RFont

font instance

CreateFontInt(RFontFamily, double, RFontStyle)

Get font instance by given font family instance, size and style.
Used to support custom fonts that require explicit font family instance to be created.

protected abstract RFont CreateFontInt(RFontFamily family, double size, RFontStyle style)

Parameters

family RFontFamily

the font family instance

size double

font size

style RFontStyle

font style

Returns

RFont

font instance

CreateLinearGradientBrush(RRect, RColor, RColor, double)

Get linear gradient color brush from color1 to color2.

protected abstract RBrush CreateLinearGradientBrush(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

CreatePen(RColor)

Get cached pen instance for the given color.

protected abstract RPen CreatePen(RColor color)

Parameters

color RColor

the color to get pen for

Returns

RPen

pen instance

CreateSolidBrush(RColor)

Get cached solid brush instance for the given color.

protected abstract RBrush CreateSolidBrush(RColor color)

Parameters

color RColor

the color to get brush for

Returns

RBrush

brush instance

GetClipboardDataObject(string, string)

Get data object for the given html and plain text data.
The data object can be used for clipboard or drag-drop operation.
Not relevant for platforms that don't render HTML on UI element.

public object GetClipboardDataObject(string html, string plainText)

Parameters

html string

the html data

plainText string

the plain text data

Returns

object

drag-drop data object

GetClipboardDataObjectInt(string, string)

Get data object for the given html and plain text data.
The data object can be used for clipboard or drag-drop operation.

protected virtual object GetClipboardDataObjectInt(string html, string plainText)

Parameters

html string

the html data

plainText string

the plain text data

Returns

object

drag-drop data object

GetColor(string)

Resolve color value from given color name.

public RColor GetColor(string colorName)

Parameters

colorName string

the color name

Returns

RColor

color value

GetColorInt(string)

Resolve color value from given color name.

protected abstract RColor GetColorInt(string colorName)

Parameters

colorName string

the color name

Returns

RColor

color value

GetContextMenu()

Create a context menu that can be used on the control
Not relevant for platforms that don't render HTML on UI element.

public RContextMenu GetContextMenu()

Returns

RContextMenu

new context menu

GetFont(string, double, RFontStyle)

Get font instance by given font family name, size and style.

public RFont GetFont(string family, double size, RFontStyle style)

Parameters

family string

the font family name

size double

font size

style RFontStyle

font style

Returns

RFont

font 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

GetLoadingFailedImage()

Get image to be used if HTML image load failed.

public RImage GetLoadingFailedImage()

Returns

RImage

GetLoadingImage()

Get image to be used while HTML image is loading.

public RImage GetLoadingImage()

Returns

RImage

GetPen(RColor)

Get cached pen instance for the given color.

public RPen GetPen(RColor color)

Parameters

color RColor

the color to get pen for

Returns

RPen

pen instance

GetSolidBrush(RColor)

Get cached solid brush instance for the given color.

public RBrush GetSolidBrush(RColor color)

Parameters

color RColor

the color to get brush for

Returns

RBrush

brush instance

ImageFromStream(string, byte[])

Creates an RImage object from the given byte array with the specified image extension.

public RImage ImageFromStream(string extension, byte[] body)

Parameters

extension string

The image file extension indicating the format of the image data.

body byte[]

The byte array containing image data to create the image from.

Returns

RImage

A new RImage instance.

ImageFromStreamInt(string, byte[])

Create an RImage object from the given stream.

protected abstract RImage ImageFromStreamInt(string extension, byte[] body)

Parameters

extension string

The image file extension indicating the format of the image data.

body byte[]

The byte array containing image data to create the image from.

Returns

RImage

new image instance

IsFontExists(string)

Check if the given font exists in the system by font family name.

public bool IsFontExists(string font)

Parameters

font string

the font name to check

Returns

bool

true - font exists by given family name, false - otherwise

SaveToFile(RImage, string, string, RControl)

Save the given image to file by showing save dialog to the client.
Not relevant for platforms that don't render HTML on UI element.

public void SaveToFile(RImage image, string name, string extension, RControl control = null)

Parameters

image RImage

the image to save

name string

the name of the image for save dialog

extension string

the extension of the image for save dialog

control RControl

optional: the control to show the dialog on

SaveToFileInt(RImage, string, string, RControl)

Save the given image to file by showing save dialog to the client.

protected virtual void SaveToFileInt(RImage image, string name, string extension, RControl control = null)

Parameters

image RImage

the image to save

name string

the name of the image for save dialog

extension string

the extension of the image for save dialog

control RControl

optional: the control to show the dialog on

SetToClipboard(string)

Set the given text to the clipboard
Not relevant for platforms that don't render HTML on UI element.

public void SetToClipboard(string text)

Parameters

text string

the text to set

SetToClipboard(string, string)

Set the given html and plain text data to clipboard.
Not relevant for platforms that don't render HTML on UI element.

public void SetToClipboard(string html, string plainText)

Parameters

html string

the html data

plainText string

the plain text data

SetToClipboard(RImage)

Set the given image to clipboard.
Not relevant for platforms that don't render HTML on UI element.

public void SetToClipboard(RImage image)

Parameters

image RImage

the image object to set to clipboard

SetToClipboardInt(string)

Set the given text to the clipboard

protected virtual void SetToClipboardInt(string text)

Parameters

text string

the text to set

SetToClipboardInt(string, string)

Set the given html and plain text data to clipboard.

protected virtual void SetToClipboardInt(string html, string plainText)

Parameters

html string

the html data

plainText string

the plain text data

SetToClipboardInt(RImage)

Set the given image to clipboard.

protected virtual void SetToClipboardInt(RImage image)

Parameters

image RImage