C# Класс LayoutFarm.Demo.HtmlPanel

Provides HTML rendering using the text property.
WinForms control that will render html content in it's client rectangle.
If AutoScroll is true and the layout of the html resulted in its content beyond the client bounds of the panel it will show scrollbars (horizontal/vertical) allowing to scroll the content.
If AutoScroll is false html content outside the client bounds will be clipped.
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.

AutoScroll:

Allows showing scrollbars if html content is placed outside the visible boundaries of the panel.

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.

Наследование: System.Windows.Forms.ScrollableControl
Показать файл Открыть проект Примеры использования класса

Private Properties

Свойство Тип Описание
BuildCssBoxTree void
CreateMouseEventArg LayoutFarm.UI.UIMouseEventArgs
GetDC IntPtr
GetSharedPainter PaintVisitor
GetUIMouseButton LayoutFarm.UI.UIMouseButtons
OnRefresh void
OnScrollChange void
PaintMe void
PaintMe void
PerformHtmlLayout void
ReleaseDC IntPtr
ReleaseSharedPainter void
SetHtml void
UpdateScroll void
myHtmlContainer_NeedUpdateDom void

Открытые методы

Метод Описание
ForceRefreshHtmlDomChange ( LayoutFarm doc ) : void
GetHtml ( ) : string

Get html from the current DOM tree with inline style.

GetHtmlContainer ( ) : HtmlContainer
HtmlPanel ( PixelFarm p, int w, int h ) : System

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

LoadHtmlDom ( LayoutFarm doc, string defaultCss ) : void
SetHtmlHost ( HtmlHost htmlhost ) : void

Защищенные методы

Метод Описание
Dispose ( bool disposing ) : void

Release the html container resources.

IsInputKey ( Keys keyData ) : bool

Used to add arrow keys to the handled keys in OnKeyDown.

OnClick ( EventArgs e ) : void

Set focus on the control for keyboard scrrollbars handling.

OnKeyDown ( KeyEventArgs e ) : void

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

OnLayout ( LayoutEventArgs levent ) : void

Perform the layout of the html in the control.

OnMouseDown ( MouseEventArgs e ) : void

Handle mouse down to handle selection.

OnMouseLeave ( EventArgs e ) : void

Handle mouse leave to handle cursor change.

OnMouseMove ( MouseEventArgs e ) : void

Handle mouse move to handle hover cursor and text selection.

OnMouseUp ( MouseEventArgs e ) : void

Handle mouse up to handle selection and link click.

OnPaint ( PaintEventArgs e ) : void

Perform paint of the html in the control.

Приватные методы

Метод Описание
BuildCssBoxTree ( MyHtmlContainer htmlCont, CssActiveSheet cssData ) : void
CreateMouseEventArg ( MouseEventArgs e ) : LayoutFarm.UI.UIMouseEventArgs
GetDC ( IntPtr hWnd ) : IntPtr
GetSharedPainter ( LayoutFarm htmlCont, PixelFarm canvas ) : PaintVisitor
GetUIMouseButton ( MouseButtons mouseButton ) : LayoutFarm.UI.UIMouseButtons
OnRefresh ( object sender, EventArgs e ) : void

Handle html renderer invalidate and re-layout as requested.

OnScrollChange ( object sender, HtmlScrollEventArgs e ) : void

On html renderer scroll request adjust the scrolling of the panel to the requested location.

PaintMe ( ) : void
PaintMe ( PaintEventArgs e ) : void
PerformHtmlLayout ( ) : void

Perform html container layout by the current panel client size.

ReleaseDC ( IntPtr hWnd, IntPtr hdc ) : IntPtr
ReleaseSharedPainter ( PaintVisitor p ) : void
SetHtml ( LayoutFarm htmlContainer, string html, CssActiveSheet cssData ) : void
UpdateScroll ( Point location ) : void

Adjust the scrolling of the panel to the requested location.

myHtmlContainer_NeedUpdateDom ( object sender, EventArgs e ) : void

Описание методов

Dispose() защищенный Метод

Release the html container resources.
protected Dispose ( bool disposing ) : void
disposing bool
Результат void

ForceRefreshHtmlDomChange() публичный Метод

public ForceRefreshHtmlDomChange ( LayoutFarm doc ) : void
doc LayoutFarm
Результат void

GetHtml() публичный Метод

Get html from the current DOM tree with inline style.
public GetHtml ( ) : string
Результат string

GetHtmlContainer() публичный Метод

public GetHtmlContainer ( ) : HtmlContainer
Результат HtmlContainer

HtmlPanel() публичный Метод

Creates a new HtmlPanel and sets a basic css for it's styling.
public HtmlPanel ( PixelFarm p, int w, int h ) : System
p PixelFarm
w int
h int
Результат System

IsInputKey() защищенный Метод

Used to add arrow keys to the handled keys in OnKeyDown.
protected IsInputKey ( Keys keyData ) : bool
keyData Keys
Результат bool

LoadHtmlDom() публичный Метод

public LoadHtmlDom ( LayoutFarm doc, string defaultCss ) : void
doc LayoutFarm
defaultCss string
Результат void

OnClick() защищенный Метод

Set focus on the control for keyboard scrrollbars handling.
protected OnClick ( EventArgs e ) : void
e EventArgs
Результат void

OnKeyDown() защищенный Метод

Handle key down event for selection, copy and scrollbars handling.
protected OnKeyDown ( KeyEventArgs e ) : void
e KeyEventArgs
Результат void

OnLayout() защищенный Метод

Perform the layout of the html in the control.
protected OnLayout ( LayoutEventArgs levent ) : void
levent LayoutEventArgs
Результат void

OnMouseDown() защищенный Метод

Handle mouse down to handle selection.
protected OnMouseDown ( MouseEventArgs e ) : void
e MouseEventArgs
Результат void

OnMouseLeave() защищенный Метод

Handle mouse leave to handle cursor change.
protected OnMouseLeave ( EventArgs e ) : void
e EventArgs
Результат void

OnMouseMove() защищенный Метод

Handle mouse move to handle hover cursor and text selection.
protected OnMouseMove ( MouseEventArgs e ) : void
e MouseEventArgs
Результат void

OnMouseUp() защищенный Метод

Handle mouse up to handle selection and link click.
protected OnMouseUp ( MouseEventArgs e ) : void
e MouseEventArgs
Результат void

OnPaint() защищенный Метод

Perform paint of the html in the control.
protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs
Результат void

SetHtmlHost() публичный Метод

public SetHtmlHost ( HtmlHost htmlhost ) : void
htmlhost HtmlHost
Результат void