Class HtmlImageLoadEventArgs
- Namespace
- TheArtOfDev.HtmlRenderer.Core.Entities
- Assembly
- StockSharp.Xaml.dll
Invoked when an image is about to be loaded by file path, URL or inline data in 'img' element or background-image CSS style.
Allows to overwrite the loaded image by providing the image object manually, or different source (file or URL) to load from.
Example: image 'src' can be non-valid string that is interpreted in the overwrite delegate by custom logic to resource image object
Example: image 'src' in the html is relative - the overwrite intercepts the load and provide full source URL to load the image from
Example: image download requires authentication - the overwrite intercepts the load, downloads the image to disk using custom code and
provide file path to load the image from. Can also use the asynchronous image overwrite not to block HTML rendering is applicable.
If no alternative data is provided the original source will be used.
public sealed class HtmlImageLoadEventArgs : EventArgs
- Inheritance
-
HtmlImageLoadEventArgs
- Inherited Members
- Extension Methods
Properties
Attributes
collection of all the attributes that are defined on the image element or CSS style
public Dictionary<string, string> Attributes { get; }
Property Value
Handled
Indicate the image load is handled asynchronously.
Cancel this image loading and overwrite the image asynchronously using callback method.
public bool Handled { get; set; }
Property Value
Src
the source of the image (file path, URL or inline data)
public string Src { get; }
Property Value
Methods
Callback()
Callback to overwrite the loaded image with error image.
Can be called directly from delegate handler or asynchronously after setting Handled to True.
public void Callback()
Callback(string)
Callback to overwrite the loaded image with image to load from given URI.
Can be called directly from delegate handler or asynchronously after setting Handled to True.
public void Callback(string path)
Parameters
path
stringthe path to the image to load (file path or URL)
Callback(string, double, double, double, double)
Callback to overwrite the loaded image with an image loaded from the given URI. This method can be invoked directly from a delegate handler or asynchronously after setting Handled to true. Only the specified rectangle defined by (x, y, width, height) will be used from the loaded image; the actual size of the image is ignored. The specified rectangle is used for sizing purposes.
public void Callback(string path, double x, double y, double width, double height)
Parameters
path
stringThe path to the image to load (file path or URL).
x
doubleThe x-coordinate of the top-left corner of the rectangle.
y
doubleThe y-coordinate of the top-left corner of the rectangle.
width
doubleThe width of the rectangle.
height
doubleThe height of the rectangle.
Callback(ImageSource)
Callback to overwrite the loaded image with given image object.
Can be called directly from delegate handler or asynchronously after setting Handled to True.
public void Callback(ImageSource image)
Parameters
image
ImageSourcethe image to load
Callback(ImageSource, double, double, double, double)
Callback to overwrite the loaded image with given image object.
Can be called directly from delegate handler or asynchronously after setting Handled to True.
Only the specified rectangle (x,y,width,height) will be used from the loaded image and not all of it, also
the rectangle will be used for size and not the actual image size.
public void Callback(ImageSource image, double x, double y, double width, double height)
Parameters
image
ImageSourcethe image to load
x
doubleThe x-coordinate of the top-left corner of the rectangle.
y
doubleThe y-coordinate of the top-left corner of the rectangle.
width
doubleThe width of the rectangle.
height
doubleThe height of the rectangle.