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
Methods
AddFontFamily(RFontFamily)
Adds a font family to be used.
public void AddFontFamily(RFontFamily fontFamily)
Parameters
fontFamily
RFontFamilyThe 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
ConvertImage(ImageSource)
Convert image object returned from HtmlImageLoadEventArgs to RImage.
public RImage ConvertImage(ImageSource image)
Parameters
image
ImageSourcethe 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
ImageSourcethe 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
stringthe font family name
size
doublefont size
style
RFontStylefont 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
RFontFamilythe font family instance
size
doublefont size
style
RFontStylefont 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
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
CreatePen(RColor)
Get cached pen instance for the given color.
protected abstract RPen CreatePen(RColor color)
Parameters
color
RColorthe 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
RColorthe 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
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
Returns
- object
drag-drop data object
GetColor(string)
Resolve color value from given color name.
public RColor GetColor(string colorName)
Parameters
colorName
stringthe color name
Returns
- RColor
color value
GetColorInt(string)
Resolve color value from given color name.
protected abstract RColor GetColorInt(string colorName)
Parameters
colorName
stringthe 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
stringthe font family name
size
doublefont size
style
RFontStylefont 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
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
GetLoadingFailedImage()
Get image to be used if HTML image load failed.
public RImage GetLoadingFailedImage()
Returns
GetLoadingImage()
Get image to be used while HTML image is loading.
public RImage GetLoadingImage()
Returns
GetPen(RColor)
Get cached pen instance for the given color.
public RPen GetPen(RColor color)
Parameters
color
RColorthe 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
RColorthe 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
stringThe image file extension indicating the format of the image data.
body
byte[]The byte array containing image data to create the image from.
Returns
ImageFromStreamInt(string, byte[])
Create an RImage object from the given stream.
protected abstract RImage ImageFromStreamInt(string extension, byte[] body)
Parameters
extension
stringThe 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
stringthe 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
RImagethe image to save
name
stringthe name of the image for save dialog
extension
stringthe extension of the image for save dialog
control
RControloptional: 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
RImagethe image to save
name
stringthe name of the image for save dialog
extension
stringthe extension of the image for save dialog
control
RControloptional: 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
stringthe 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
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
RImagethe image object to set to clipboard
SetToClipboardInt(string)
Set the given text to the clipboard
protected virtual void SetToClipboardInt(string text)
Parameters
text
stringthe 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
SetToClipboardInt(RImage)
Set the given image to clipboard.
protected virtual void SetToClipboardInt(RImage image)
Parameters
image
RImage