Class RAdapter
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.
Inheritance
Inherited Members
Namespace: TheArtOfDev.HtmlRenderer.Adapters
Assembly: Telerik.WinControls.RadMap.dll
Syntax
public abstract class RAdapter
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.
Declaration
protected RAdapter()
Properties
DefaultCssData
Get the default CSS stylesheet data.
Declaration
public CssData DefaultCssData { get; }
Property Value
|
CssData
|
Methods
AddFontFamily(RFontFamily)
Adds a font family to be used.
Declaration
public void AddFontFamily(RFontFamily fontFamily)
Parameters
|
RFontFamily
fontFamily
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.
Declaration
public void AddFontFamilyMapping(string fromFamily, string toFamily)
Parameters
|
System.String
fromFamily
the font family to replace |
|
System.String
toFamily
the font family to replace with |
ConvertImage(Object)
Convert image object returned from HtmlImageLoadEventArgs to RImage.
Declaration
public RImage ConvertImage(object image)
Parameters
|
System.Object
image
the image returned from load event |
Returns
|
RImage
converted image or null |
ConvertImageInt(Object)
Convert image object returned from HtmlImageLoadEventArgs to RImage.
Declaration
protected abstract RImage ConvertImageInt(object image)
Parameters
|
System.Object
image
the image returned from load event |
Returns
|
RImage
converted image or null |
CreateContextMenuInt()
Create a context menu that can be used on the control
Declaration
protected virtual RContextMenu CreateContextMenuInt()
Returns
|
RContextMenu
new context menu |
CreateFontInt(String, Double, RFontStyle)
Get font instance by given font family name, size and style.
Declaration
protected abstract RFont CreateFontInt(string family, double size, RFontStyle style)
Parameters
|
System.String
family
the font family name |
|
System.Double
size
font size |
|
RFontStyle
style
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.
Declaration
protected abstract RFont CreateFontInt(RFontFamily family, double size, RFontStyle style)
Parameters
|
RFontFamily
family
the font family instance |
|
System.Double
size
font size |
|
RFontStyle
style
font style |
Returns
|
RFont
font instance |
CreateLinearGradientBrush(RRect, RColor, RColor, Double)
Get linear gradient color brush from color1 to color2.
Declaration
protected abstract RBrush CreateLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
Parameters
|
RRect
rect
the rectangle to get the brush for |
|
RColor
color1
the start color of the gradient |
|
RColor
color2
the end color of the gradient |
|
System.Double
angle
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.
Declaration
protected abstract RPen CreatePen(RColor color)
Parameters
|
RColor
color
the color to get pen for |
Returns
|
RPen
pen instance |
CreateSolidBrush(RColor)
Get cached solid brush instance for the given color.
Declaration
protected abstract RBrush CreateSolidBrush(RColor color)
Parameters
|
RColor
color
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.
Declaration
public object GetClipboardDataObject(string html, string plainText)
Parameters
|
System.String
html
the html data |
|
System.String
plainText
the plain text data |
Returns
|
System.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.
Declaration
protected virtual object GetClipboardDataObjectInt(string html, string plainText)
Parameters
|
System.String
html
the html data |
|
System.String
plainText
the plain text data |
Returns
|
System.Object
drag-drop data object |
GetColor(String)
Resolve color value from given color name.
Declaration
public RColor GetColor(string colorName)
Parameters
|
System.String
colorName
the color name |
Returns
|
RColor
color value |
GetColorInt(String)
Resolve color value from given color name.
Declaration
protected abstract RColor GetColorInt(string colorName)
Parameters
|
System.String
colorName
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.
Declaration
public RContextMenu GetContextMenu()
Returns
|
RContextMenu
new context menu |
GetFont(String, Double, RFontStyle)
Get font instance by given font family name, size and style.
Declaration
public RFont GetFont(string family, double size, RFontStyle style)
Parameters
|
System.String
family
the font family name |
|
System.Double
size
font size |
|
RFontStyle
style
font style |
Returns
|
RFont
font instance |
GetLinearGradientBrush(RRect, RColor, RColor, Double)
Get linear gradient color brush from color1 to color2.
Declaration
public RBrush GetLinearGradientBrush(RRect rect, RColor color1, RColor color2, double angle)
Parameters
|
RRect
rect
the rectangle to get the brush for |
|
RColor
color1
the start color of the gradient |
|
RColor
color2
the end color of the gradient |
|
System.Double
angle
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.
Declaration
public RImage GetLoadingFailedImage()
Returns
|
RImage
|
GetLoadingImage()
Get image to be used while HTML image is loading.
Declaration
public RImage GetLoadingImage()
Returns
|
RImage
|
GetPen(RColor)
Get cached pen instance for the given color.
Declaration
public RPen GetPen(RColor color)
Parameters
|
RColor
color
the color to get pen for |
Returns
|
RPen
pen instance |
GetSolidBrush(RColor)
Get cached solid brush instance for the given color.
Declaration
public RBrush GetSolidBrush(RColor color)
Parameters
|
RColor
color
the color to get brush for |
Returns
|
RBrush
brush instance |
ImageFromStream(Stream)
Create an RImage object from the given stream.
Declaration
public RImage ImageFromStream(Stream memoryStream)
Parameters
|
System.IO.Stream
memoryStream
the stream to create image from |
Returns
|
RImage
new image instance |
ImageFromStreamInt(Stream)
Create an RImage object from the given stream.
Declaration
protected abstract RImage ImageFromStreamInt(Stream memoryStream)
Parameters
|
System.IO.Stream
memoryStream
the stream to create image from |
Returns
|
RImage
new image instance |
IsFontExists(String)
Check if the given font exists in the system by font family name.
Declaration
public bool IsFontExists(string font)
Parameters
|
System.String
font
the font name to check |
Returns
|
System.Boolean
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.
Declaration
public void SaveToFile(RImage image, string name, string extension, RControl control = null)
Parameters
|
RImage
image
the image to save |
|
System.String
name
the name of the image for save dialog |
|
System.String
extension
the extension of the image for save dialog |
|
RControl
control
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.
Declaration
protected virtual void SaveToFileInt(RImage image, string name, string extension, RControl control = null)
Parameters
|
RImage
image
the image to save |
|
System.String
name
the name of the image for save dialog |
|
System.String
extension
the extension of the image for save dialog |
|
RControl
control
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.
Declaration
public void SetToClipboard(string text)
Parameters
|
System.String
text
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.
Declaration
public void SetToClipboard(string html, string plainText)
Parameters
|
System.String
html
the html data |
|
System.String
plainText
the plain text data |
SetToClipboard(RImage)
Set the given image to clipboard.
Not relevant for platforms that don't render HTML on UI element.
Declaration
public void SetToClipboard(RImage image)
Parameters
|
RImage
image
the image object to set to clipboard |
SetToClipboardInt(String)
Set the given text to the clipboard
Declaration
protected virtual void SetToClipboardInt(string text)
Parameters
|
System.String
text
the text to set |
SetToClipboardInt(String, String)
Set the given html and plain text data to clipboard.
Declaration
protected virtual void SetToClipboardInt(string html, string plainText)
Parameters
|
System.String
html
the html data |
|
System.String
plainText
the plain text data |
SetToClipboardInt(RImage)
Set the given image to clipboard.
Declaration
protected virtual void SetToClipboardInt(RImage image)
Parameters
|
RImage
image
|