HtmlControl

TheArtOfDev.HtmlRenderer.WPF

Provides HTML rendering using the text property. WPF control that will render html content in it's client rectangle. The control will handle mouse and keyboard events on it to support html text selection, copy-paste and mouse clicks. The major differential to use HtmlPanel or HtmlLabel is size and scrollbars. If the size of the control depends on the html content the HtmlLabel should be used. If the size is set by some kind of layout then HtmlPanel is more suitable, also shows scrollbars if the html contents is larger than the control client rectangle.LinkClicked event: Raised when the user clicks on a link in the html. Allows canceling the execution of the link. StylesheetLoad event: Raised when a 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. RenderError event: Raised when an error occurred during html rendering.

Наследует: Control

Конструкторы

HtmlControl()

Creates a new HtmlPanel and sets a basic css for it's styling.

Свойства

AvoidImagesLateLoading : bool

Gets or sets a value indicating if image loading only when visible should be avoided (default - false). True - images are loaded as soon as the html is parsed. False - images that are not visible because of scroll location are not loaded until they are scrolled to.

BaseStylesheet : string

Set base stylesheet to be used by html rendered in the panel.

IsContextMenuEnabled : bool

Is the build-in context menu enabled and will be shown on mouse right click (default - true)

IsSelectionEnabled : bool

Is content selection is enabled for the rendered html (default - true). If set to 'false' the rendered html will be static only with ability to click on links.

SelectedHtml : string

Copy the currently selected html segment with style.

SelectedText : string

Get the currently selected text segment in the html.

Text : string

Gets or sets the text of this panel

Методы

ClearSelection()

Clear the current selection.

GetElementRectangle(string) : Rect?

Get the rectangle of html element as calculated by html layout. Element if found by id (id attribute on the html element). Note: to get the screen rectangle you need to adjust by the hosting control.

elementId
the id of the element to get its rectangle

Возвращает: the rectangle of the element or null if not found

GetHtml() : string

Get html from the current DOM tree with inline style.

Возвращает: generated html

HtmlHeight(Size) : double

Get the width the HTML has to render in (not including vertical scroll iff it is visible)

HtmlWidth(Size) : double

Get the width the HTML has to render in (not including vertical scroll iff it is visible)

InvokeMouseMove()

call mouse move to handle paint after scroll or html change affecting mouse cursor.

OnDependencyProperty_valueChanged(DependencyObject, DependencyPropertyChangedEventArgs)

Handle when dependency property value changes to update the underline HtmlContainer with the new value.

OnImageLoad(HtmlImageLoadEventArgs)

Propagate the image load event from root container.

OnKeyDown(KeyEventArgs)

Handle key down event for selection, copy and scrollbars handling.

OnLinkClicked(HtmlLinkClickedEventArgs)

Propagate the LinkClicked event from root container.

OnLoadComplete(EventArgs)

Propagate the LoadComplete event from root container.

OnMouseDoubleClick(MouseButtonEventArgs)

Handle mouse double click to select word under the mouse.

OnMouseDown(MouseButtonEventArgs)

Handle mouse down to handle selection.

OnMouseLeave(MouseEventArgs)

Handle mouse leave to handle cursor change.

OnMouseMove(MouseEventArgs)

Handle mouse move to handle hover cursor and text selection.

OnMouseUp(MouseButtonEventArgs)

Handle mouse up to handle selection and link click.

OnRefresh(HtmlRefreshEventArgs)

Handle html renderer invalidate and re-layout as requested.

OnRender(DrawingContext)

Perform paint of the html in the control.

OnRenderError(HtmlRenderErrorEventArgs)

Propagate the Render Error event from root container.

OnStylesheetLoad(HtmlStylesheetLoadEventArgs)

Propagate the stylesheet load event from root container.

События

ImageLoad : RoutedEventHandler<HtmlImageLoadEventArgs>

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.

LinkClicked : RoutedEventHandler<HtmlLinkClickedEventArgs>

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

LoadComplete : RoutedEventHandler

Raised when the set html document has been fully loaded. Allows manipulation of the html dom, scroll position, etc.

RenderError : RoutedEventHandler<HtmlRenderErrorEventArgs>

Raised when an error occurred during html rendering.

StylesheetLoad : RoutedEventHandler<HtmlStylesheetLoadEventArgs>

Raised when a 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.

Поля

HtmlContainer : HtmlContainer

Underline html container instance.

ImageLoadEvent : RoutedEvent

Raised when an image is about to be loaded by file path or URI.

LinkClickedEvent : RoutedEvent

Raised when the user clicks on a link in the html.

LoadCompleteEvent : RoutedEvent

Raised when the html document has been fully loaded.

RefreshEvent : RoutedEvent

Raised when the html document has been fully loaded.

RenderErrorEvent : RoutedEvent

Raised when an error occurred during html rendering.

StylesheetLoadEvent : RoutedEvent

Raised when a stylesheet is about to be loaded by file path or URI by link element.

_baseCssData : CssData

the base stylesheet data used in the control

_lastScrollOffset : Point

The last position of the scrollbars to know if it has changed to update mouse