C# Class 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.

Inheritance: System.Windows.Forms.ScrollableControl
Afficher le fichier Open project: prepare/HTML-Renderer Class Usage Examples

Private Properties

Свойство Type Description
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

Méthodes publiques

Méthode Description
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

Méthodes protégées

Méthode Description
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.

Private Methods

Méthode Description
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

Method Details

Dispose() protected méthode

Release the html container resources.
protected Dispose ( bool disposing ) : void
disposing bool
Résultat void

ForceRefreshHtmlDomChange() public méthode

public ForceRefreshHtmlDomChange ( LayoutFarm doc ) : void
doc LayoutFarm
Résultat void

GetHtml() public méthode

Get html from the current DOM tree with inline style.
public GetHtml ( ) : string
Résultat string

GetHtmlContainer() public méthode

public GetHtmlContainer ( ) : HtmlContainer
Résultat HtmlContainer

HtmlPanel() public méthode

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
Résultat System

IsInputKey() protected méthode

Used to add arrow keys to the handled keys in OnKeyDown.
protected IsInputKey ( Keys keyData ) : bool
keyData Keys
Résultat bool

LoadHtmlDom() public méthode

public LoadHtmlDom ( LayoutFarm doc, string defaultCss ) : void
doc LayoutFarm
defaultCss string
Résultat void

OnClick() protected méthode

Set focus on the control for keyboard scrrollbars handling.
protected OnClick ( EventArgs e ) : void
e EventArgs
Résultat void

OnKeyDown() protected méthode

Handle key down event for selection, copy and scrollbars handling.
protected OnKeyDown ( KeyEventArgs e ) : void
e KeyEventArgs
Résultat void

OnLayout() protected méthode

Perform the layout of the html in the control.
protected OnLayout ( LayoutEventArgs levent ) : void
levent LayoutEventArgs
Résultat void

OnMouseDown() protected méthode

Handle mouse down to handle selection.
protected OnMouseDown ( MouseEventArgs e ) : void
e MouseEventArgs
Résultat void

OnMouseLeave() protected méthode

Handle mouse leave to handle cursor change.
protected OnMouseLeave ( EventArgs e ) : void
e EventArgs
Résultat void

OnMouseMove() protected méthode

Handle mouse move to handle hover cursor and text selection.
protected OnMouseMove ( MouseEventArgs e ) : void
e MouseEventArgs
Résultat void

OnMouseUp() protected méthode

Handle mouse up to handle selection and link click.
protected OnMouseUp ( MouseEventArgs e ) : void
e MouseEventArgs
Résultat void

OnPaint() protected méthode

Perform paint of the html in the control.
protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs
Résultat void

SetHtmlHost() public méthode

public SetHtmlHost ( HtmlHost htmlhost ) : void
htmlhost HtmlHost
Résultat void