# HtmlContainer Class

`HtmlRenderer.HtmlContainer`

> Low level handling of Html Renderer logic, this class is used by HtmlPanel, HtmlLabel, HtmlToolTip and HtmlRender.
> The class allows html layout and rendering without association to actual winforms control, thouse allowing to handle html rendering on any graphics object.
> Using this class will require the client to handle all propogation of mouse\keyboard events, layout/paint calls, scrolling offset and location/size/rectangle handling and UI refresh requests.

> ## Properties

> - CssData - the parsed stylesheet data used for handling the html.
> - AvoidGeometryAntialias - Gets or sets a value indicating if antialiasing should be avoided for geometry like backgrounds and borders (default - false).
> - IsSelectionEnabled - Is content selection is enabled for the rendered html (default - true).
> - IsContextMenuEnabled - Is the build-in context menu enabled and will be shown on mouse right click (default - true).
> - ScrollOffset - The scroll offset of the html.
> - Location - the top-left most location of the rendered html.
> - MaxSize - the max width and height of the rendered html, effects layout, actual size cannot exceed this values. Set zero for unlimited.
> - ActualSize - The actual size of the rendered html (after layout).

> ## Methods

> - GetHtml(HtmlGenerationStyle styleGen = HtmlGenerationStyle.Inline) - Get html from the current DOM tree with style if requested.
> - PerformLayout(Graphics) - Measures the bounds of box and children, recursively.
> - PerformPaint(Graphics) - Render the html using the given device.
> - HandleMouseDown(Control, MouseEventArgs) - Handle mouse down to handle selection.
> - HandleMouseUp(Control, MouseEventArgs) - Handle mouse up to handle selection and link click.
> - HandleMouseDoubleClick(Control, MouseEventArgs) - Handle mouse double click to select word under the mouse.
> - HandleMouseMove(Control, MouseEventArgs) - Handle mouse move to handle hover cursor and text selection.
> - HandleMouseLeave(Control, MouseEventArgs) - Handle mouse move to handle hover cursor.
> - HandleKeyDown(parent, KeyEventArgs) - Handle key down event for selection and copy.

> ## Events

> - LinkClicked - Raised when the user clicks on a link in the html, Allows canceling the execution of the link.
> - Refresh - Raised when html renderer requires refresh of the control hosting (invalidation and re-layout).
> - RenderError - Raised when an error occured during html rendering.
> - StylesheetLoad - Raised when aa stylesheet is about to be loaded by file path or URI by link element. This event allows to provide the stylesheet manually or provide new source (file or uri) to load from.
> - ImageLoad - Raised when an image is about to be loaded by file path or URI. This event allows to provide the image manually, if not handled the image will be loaded from file or download from URI.

> # Remarks

> ### MaxSize and ActualSize

> The max width and height of the rendered html.
> The max width will effect the html layout wrapping lines, resize images and tables where possible.
> The max height does NOT effect layout, but will not render outside it (clip).
> ActualSize can be exceed the max size by layout restrictions (unwrappable line, set image size, etc.).
> Set zero for unlimited (width\height separately).

> ### ScrollOffset

> This will adjust the rendered html by the given offset so the content will be "scrolled".
> Element that is rendered at location (50,100) with offset of (0,200) will not be rendered as it will be at -100 therefore outside the client rectangle of the control.

> ### LinkClicked event

> Raised when the user clicks on a link in the html.
> Allows canceling the execution of the link.

> ### StylesheetLoad event

> Raised when aa stylesheet is about to be loaded by file path or URI by link element.
> This event allows to provide the stylesheet manually or provide new source (file or uri) to load from.
> If no alternative data is provided the original source will be used.

> ### ImageLoad event

> Raised when an image is about to be loaded by file path or URI.
> This event allows to provide the image manually, if not handled the image will be loaded from file or download from URI.

> ### Refresh event

> Raised when html renderer requires refresh of the control hosting (invalidation and re-layout).
> There is no garantie that the event will be raised on the main thread, it can be raised on threadpool thread.

> ### RenderError event

> Raised when an error occured during html rendering.