C# Класс YamuiFramework.HtmlRenderer.WinForms.HtmlLabel

Provides HTML rendering using the text property.
WinForms control that will render html content in it's client rectangle.
Using AutoSize and AutoSizeHeightOnly client can control how the html content effects the size of the label. Either case scrollbars are never shown and html content outside of client bounds will be clipped. MaximumSize and MinimumSize with AutoSize can limit the max/min size of the control
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.

AutoSize:

AutoSize = AutoSizeHeightOnly = false
The label size will not change by the html content. MaximumSize and MinimumSize are ignored.

AutoSize = true
The width and height is adjustable by the html content, the width will be longest line in the html, MaximumSize.Width will restrict it but it can be lower than that.

AutoSizeHeightOnly = true
The width of the label is set and will not change by the content, the height is adjustable by the html content with restrictions to the MaximumSize.Height and MinimumSize.Height values.

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.

RenderError event:

Raised when an error occurred during html rendering.

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

Защищенные свойства (Protected)

Свойство Тип Описание
_autoSizeHight bool
_baseCssData YamuiFramework.HtmlRenderer.Core.Core.CssData
_baseRawCssData string
_borderStyle BorderStyle
_htmlContainer HtmlContainer
_text string
_textRenderingHint TextRenderingHint
_useSystemCursors bool

Private Properties

Свойство Тип Описание
OnImageLoad void
OnLinkClicked void
OnRefresh void
OnRenderError void
OnStylesheetLoad void
WndProc void
YamuiThemeManagerOnOnCssChanged void

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

Метод Описание
GetElementRectangle ( string elementId ) : RectangleF?

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.

GetHtml ( ) : string

Get html from the current DOM tree with inline style.

HtmlLabel ( ) : System

Creates a new HTML Label

SetNeededSize ( string content, int minWidth, int maxWidth, bool dontSquareIt = false ) : void

adapts width to content (the label needs to be in AutoSizeHeight only)

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

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

Release the html container resources.

OnBorderStyleChanged ( EventArgs e ) : void

Raises the BorderStyleChanged event.

OnImageLoad ( YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlImageLoadEventArgs e ) : void

Propagate the image load event from root container.

OnLayout ( System.Windows.Forms.LayoutEventArgs levent ) : void

Perform the layout of the html in the control.

OnLinkClicked ( YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlLinkClickedEventArgs e ) : void

Propagate the LinkClicked event from root container.

OnMouseDoubleClick ( MouseEventArgs e ) : void

Handle mouse double click to select word under the mouse.

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.

OnRefresh ( HtmlRefreshEventArgs e ) : void

Handle html renderer invalidate and re-layout as requested.

OnRenderError ( YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlRenderErrorEventArgs e ) : void

Propagate the Render Error event from root container.

OnStylesheetLoad ( YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlStylesheetLoadEventArgs e ) : void

Propagate the stylesheet load event from root container.

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

Метод Описание
OnImageLoad ( object sender, YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlImageLoadEventArgs e ) : void
OnLinkClicked ( object sender, YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlLinkClickedEventArgs e ) : void
OnRefresh ( object sender, HtmlRefreshEventArgs e ) : void
OnRenderError ( object sender, YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlRenderErrorEventArgs e ) : void
OnStylesheetLoad ( object sender, YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlStylesheetLoadEventArgs e ) : void
WndProc ( Message &m ) : void
YamuiThemeManagerOnOnCssChanged ( ) : void

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

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

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

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

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.
public GetElementRectangle ( string elementId ) : RectangleF?
elementId string the id of the element to get its rectangle
Результат RectangleF?

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

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

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

Creates a new HTML Label
public HtmlLabel ( ) : System
Результат System

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

Raises the BorderStyleChanged event.
protected OnBorderStyleChanged ( EventArgs e ) : void
e System.EventArgs
Результат void

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

Propagate the image load event from root container.
protected OnImageLoad ( YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlImageLoadEventArgs e ) : void
e YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlImageLoadEventArgs
Результат void

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

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

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

Propagate the LinkClicked event from root container.
protected OnLinkClicked ( YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlLinkClickedEventArgs e ) : void
e YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlLinkClickedEventArgs
Результат void

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

Handle mouse double click to select word under the mouse.
protected OnMouseDoubleClick ( MouseEventArgs e ) : void
e MouseEventArgs
Результат 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 System.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

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

Handle html renderer invalidate and re-layout as requested.
protected OnRefresh ( HtmlRefreshEventArgs e ) : void
e HtmlRefreshEventArgs
Результат void

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

Propagate the Render Error event from root container.
protected OnRenderError ( YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlRenderErrorEventArgs e ) : void
e YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlRenderErrorEventArgs
Результат void

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

Propagate the stylesheet load event from root container.
protected OnStylesheetLoad ( YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlStylesheetLoadEventArgs e ) : void
e YamuiFramework.HtmlRenderer.Core.Core.Entities.HtmlStylesheetLoadEventArgs
Результат void

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

adapts width to content (the label needs to be in AutoSizeHeight only)
public SetNeededSize ( string content, int minWidth, int maxWidth, bool dontSquareIt = false ) : void
content string
minWidth int
maxWidth int
dontSquareIt bool
Результат void

Описание свойств

_autoSizeHight защищенное свойство

is to handle auto size of the control height only
protected bool _autoSizeHight
Результат bool

_baseCssData защищенное свойство

the base stylesheet data used in the panel
protected CssData,YamuiFramework.HtmlRenderer.Core.Core _baseCssData
Результат YamuiFramework.HtmlRenderer.Core.Core.CssData

_baseRawCssData защищенное свойство

the raw base stylesheet data used in the control
protected string _baseRawCssData
Результат string

_borderStyle защищенное свойство

The current border style of the control
protected BorderStyle _borderStyle
Результат BorderStyle

_htmlContainer защищенное свойство

Underline html container instance.
protected HtmlContainer,YamuiFramework.HtmlRenderer.WinForms _htmlContainer
Результат HtmlContainer

_text защищенное свойство

the current html text set in the control
protected string _text
Результат string

_textRenderingHint защищенное свойство

The text rendering hint to be used for text rendering.
protected TextRenderingHint _textRenderingHint
Результат TextRenderingHint

_useSystemCursors защищенное свойство

If to use cursors defined by the operating system or .NET cursors
protected bool _useSystemCursors
Результат bool