C# Class IfacesEnumsStructsClasses.HTMLEditHelper

Helper class to perform HTML editing functions For example of usage, please refer to frmHTMLEditor.cs
Exibir arquivo Open project: mcorrientes/Web-Security-Toolset

Public Properties

Property Type Description
HtmlAmp string
HtmlSpace string
HtmlTagClose string
HtmlTagOpen string

Public Methods

Method Description
AddToSelection ( string s_BeginHtml, string s_EndHtml ) : bool

1) If nothing is selected returns false 2) If the user has selected text or multiple elements inserts s_BeginHtml before and s_EndHtml behind the current selection 3)If the user has selected a control returns false

AppendAnchor ( string href, string target ) : bool
AppendChild ( IHTMLElement parent, string TagName ) : IHTMLDOMNode

Creates and appends an HTMLElement to a parent element

AppendChild ( string TagName ) : IHTMLDOMNode

Creates and appends an HTMLElement to the end of the document DOM

AppendHr ( string align, string hrcolor, string width, bool noshade ) : bool
AppendImage ( string src, string width, string height, string border, string alignment, string alt, string hspace, string vspace, string lowsrc ) : bool
AppendTable ( int colnum, int rownum, int bordersize, string alignment, int cellpadding, int cellspacing, string widthpercentage, int widthpixel, string backcolor, string bordercolor, string lightbordercolor, string darkbordercolor ) : bool
DeleteCol ( IHTMLTable table, int colindex ) : void
DeleteRow ( IHTMLTable table, int rowindex ) : void

Deletes a given rowindex in a given table zero based If the table has no rows after deletion anymore we delete it compeletely

EmbedBr ( ) : bool

Embeds a BR tag at the selection

FindParent ( IHTMLElement elem, string ParentTagName ) : IHTMLElement

Searches for a parent (or grandparent) element with the given tag ParentTagName must be in the form "TD" "TR" "TABLE" (uppercase)

GetCaretPosition ( ) : tagPOINT

Attempts to retreive Caret position

GetCharIndexFromPos ( int clientX, int clientY ) : int

Attempts to retreive char index from given X and Y coordinates relative to the body content. The point must be in client coordinates

GetColCount ( IHTMLTable table, int rowindex ) : int

Gets the column count of row(rowindex) Accounts for colSpan property

GetColIndex ( IHTMLTableCell cell ) : int

Get the column of the current cell zero based

GetDocumentColor ( DocumentColors whichcolor ) : System.Drawing.Color
GetParentRow ( IHTMLElement cellelem ) : IHTMLTableRow

Returns parent row of passed cell element

GetParentTable ( IHTMLElement cellelem ) : IHTMLTable

Returns parent table of passed cell element

GetPosFromCharIndex ( int charindex ) : tagPOINT

Attempts to retreive a character position relative to the body content based on the character index.

GetRow ( IHTMLTable table, int rowindex ) : IHTMLTableRow

Zero based

GetRowCount ( IHTMLTable table ) : int
GetRowIndex ( IHTMLElement cellelem ) : int
GetWordUnderMouse ( int clientX, int clientY ) : string

Attempts to retrive a word located under mouse pointer relative to body content

HTMLEditHelper ( ) : System
InsertCol ( IHTMLTable table, int index ) : void
InsertHTML ( IHTMLElement elem, string s_Html, bool b_AtBegin, bool b_Inside ) : void

Inserts the given HTML code inside or outside of this Html element There are 4 possible insert positions: Outside-BeforeInside-Before InnerHTML Inside-AfterOuside-After

InsertRow ( IHTMLTable table, int index, int numberofcells ) : void
IsElementEmpty ( IHTMLElement elem ) : bool

Return TRUE if the element is empty inside (e.g. )

NextSibiling ( IHTMLDOMNode node ) : IHTMLElement

Returns the right neighbour which is a IHTMLElement in the HTML hierarchy

PasteIntoSelection ( string s_Html ) : bool

The currently selected text/controls will be replaced by the given HTML code. If nothing is selected, the HTML code is inserted at the cursor position

PreviousSibling ( IHTMLDOMNode node ) : IHTMLElement

Returns the left neighbour which is a IHTMLElement in the HTML hierarchy

RemoveNode ( IHTMLElement elem, bool RemoveAllChildren ) : IHTMLDOMNode

Removes node element If RemoveAllChildren == true, Removes this element and all it's children from the document else it just strips this element but does not remove its children E.g. "Hello World" ---> strip BIG tag --> "Hello World"

RemoveUnderline ( IHTMLElement elem, IHighlightSegment ihs ) : void
Row_DeleteCol ( IHTMLTableRow row, int index ) : void
Row_GetCell ( IHTMLTableRow row, int index ) : IHTMLTableCell
Row_GetCellCount ( IHTMLTableRow row ) : int
Row_InsertCell ( IHTMLTableRow row, int index ) : IHTMLElement
Row_InsertCell ( IHTMLTableRow row, int index, string cellwidth ) : IHTMLElement
Row_InsertCol ( IHTMLTableRow row, int index ) : IHTMLElement
SetCursorAtElementStart ( IHTMLElement elem ) : bool

Attempts to set the cursor at the start of the given html element The element must be a textual element such as P

SetSelectionTextFromClipboard ( ) : bool

Attempts to set the selection text from clipboard

UnderLineWord ( int wordindex, int wordlen ) : void

Attempts to find and highlight a word based on it's index and wordlen within body element

UnderLineWord2 ( IHTMLTxtRange range ) : IHighlightSegment
Underline ( IHTMLElement elem ) : void

Attempts to underline a given element To change the highlighting style, please refer to HTMLRenderStyle_xxxxxxx properties

Underline2 ( IHTMLElement elem ) : IHighlightSegment

Underline variation which returns IHighlightSegmentinstance

Private Methods

Method Description
CalculateCellWidths ( int numberofcols ) : void

Method Details

AddToSelection() public method

1) If nothing is selected returns false 2) If the user has selected text or multiple elements inserts s_BeginHtml before and s_EndHtml behind the current selection 3)If the user has selected a control returns false
public AddToSelection ( string s_BeginHtml, string s_EndHtml ) : bool
s_BeginHtml string
s_EndHtml string
return bool

AppendAnchor() public method

public AppendAnchor ( string href, string target ) : bool
href string
target string
return bool

AppendChild() public method

Creates and appends an HTMLElement to a parent element
public AppendChild ( IHTMLElement parent, string TagName ) : IHTMLDOMNode
parent IHTMLElement
TagName string a, img, table,...
return IHTMLDOMNode

AppendChild() public method

Creates and appends an HTMLElement to the end of the document DOM
public AppendChild ( string TagName ) : IHTMLDOMNode
TagName string a, img, table,...
return IHTMLDOMNode

AppendHr() public method

public AppendHr ( string align, string hrcolor, string width, bool noshade ) : bool
align string
hrcolor string
width string
noshade bool
return bool

AppendImage() public method

public AppendImage ( string src, string width, string height, string border, string alignment, string alt, string hspace, string vspace, string lowsrc ) : bool
src string
width string
height string
border string
alignment string
alt string
hspace string
vspace string
lowsrc string
return bool

AppendTable() public method

public AppendTable ( int colnum, int rownum, int bordersize, string alignment, int cellpadding, int cellspacing, string widthpercentage, int widthpixel, string backcolor, string bordercolor, string lightbordercolor, string darkbordercolor ) : bool
colnum int
rownum int
bordersize int
alignment string
cellpadding int
cellspacing int
widthpercentage string
widthpixel int
backcolor string
bordercolor string
lightbordercolor string
darkbordercolor string
return bool

DeleteCol() public method

public DeleteCol ( IHTMLTable table, int colindex ) : void
table IHTMLTable
colindex int
return void

DeleteRow() public method

Deletes a given rowindex in a given table zero based If the table has no rows after deletion anymore we delete it compeletely
public DeleteRow ( IHTMLTable table, int rowindex ) : void
table IHTMLTable
rowindex int
return void

EmbedBr() public method

Embeds a BR tag at the selection
public EmbedBr ( ) : bool
return bool

FindParent() public method

Searches for a parent (or grandparent) element with the given tag ParentTagName must be in the form "TD" "TR" "TABLE" (uppercase)
public FindParent ( IHTMLElement elem, string ParentTagName ) : IHTMLElement
elem IHTMLElement
ParentTagName string
return IHTMLElement

GetCaretPosition() public method

Attempts to retreive Caret position
public GetCaretPosition ( ) : tagPOINT
return tagPOINT

GetCharIndexFromPos() public method

Attempts to retreive char index from given X and Y coordinates relative to the body content. The point must be in client coordinates
public GetCharIndexFromPos ( int clientX, int clientY ) : int
clientX int
clientY int
return int

GetColCount() public method

Gets the column count of row(rowindex) Accounts for colSpan property
public GetColCount ( IHTMLTable table, int rowindex ) : int
table IHTMLTable
rowindex int
return int

GetColIndex() public method

Get the column of the current cell zero based
public GetColIndex ( IHTMLTableCell cell ) : int
cell IHTMLTableCell
return int

GetDocumentColor() public method

public GetDocumentColor ( DocumentColors whichcolor ) : System.Drawing.Color
whichcolor DocumentColors
return System.Drawing.Color

GetParentRow() public method

Returns parent row of passed cell element
public GetParentRow ( IHTMLElement cellelem ) : IHTMLTableRow
cellelem IHTMLElement
return IHTMLTableRow

GetParentTable() public method

Returns parent table of passed cell element
public GetParentTable ( IHTMLElement cellelem ) : IHTMLTable
cellelem IHTMLElement
return IHTMLTable

GetPosFromCharIndex() public method

Attempts to retreive a character position relative to the body content based on the character index.
public GetPosFromCharIndex ( int charindex ) : tagPOINT
charindex int
return tagPOINT

GetRow() public method

Zero based
public GetRow ( IHTMLTable table, int rowindex ) : IHTMLTableRow
table IHTMLTable
rowindex int
return IHTMLTableRow

GetRowCount() public method

public GetRowCount ( IHTMLTable table ) : int
table IHTMLTable
return int

GetRowIndex() public method

public GetRowIndex ( IHTMLElement cellelem ) : int
cellelem IHTMLElement
return int

GetWordUnderMouse() public method

Attempts to retrive a word located under mouse pointer relative to body content
public GetWordUnderMouse ( int clientX, int clientY ) : string
clientX int Left cocordinates based relative to client
clientY int Top cocordinates based relative to client
return string

HTMLEditHelper() public method

public HTMLEditHelper ( ) : System
return System

InsertCol() public method

public InsertCol ( IHTMLTable table, int index ) : void
table IHTMLTable
index int
return void

InsertHTML() public method

Inserts the given HTML code inside or outside of this Html element There are 4 possible insert positions: Outside-BeforeInside-Before InnerHTML Inside-AfterOuside-After
public InsertHTML ( IHTMLElement elem, string s_Html, bool b_AtBegin, bool b_Inside ) : void
elem IHTMLElement
s_Html string
b_AtBegin bool
b_Inside bool
return void

InsertRow() public method

public InsertRow ( IHTMLTable table, int index, int numberofcells ) : void
table IHTMLTable
index int
numberofcells int
return void

IsElementEmpty() public method

Return TRUE if the element is empty inside (e.g. )
public IsElementEmpty ( IHTMLElement elem ) : bool
elem IHTMLElement
return bool

NextSibiling() public method

Returns the right neighbour which is a IHTMLElement in the HTML hierarchy
public NextSibiling ( IHTMLDOMNode node ) : IHTMLElement
node IHTMLDOMNode
return IHTMLElement

PasteIntoSelection() public method

The currently selected text/controls will be replaced by the given HTML code. If nothing is selected, the HTML code is inserted at the cursor position
public PasteIntoSelection ( string s_Html ) : bool
s_Html string
return bool

PreviousSibling() public method

Returns the left neighbour which is a IHTMLElement in the HTML hierarchy
public PreviousSibling ( IHTMLDOMNode node ) : IHTMLElement
node IHTMLDOMNode
return IHTMLElement

RemoveNode() public method

Removes node element If RemoveAllChildren == true, Removes this element and all it's children from the document else it just strips this element but does not remove its children E.g. "Hello World" ---> strip BIG tag --> "Hello World"
public RemoveNode ( IHTMLElement elem, bool RemoveAllChildren ) : IHTMLDOMNode
elem IHTMLElement
RemoveAllChildren bool
return IHTMLDOMNode

RemoveUnderline() public method

public RemoveUnderline ( IHTMLElement elem, IHighlightSegment ihs ) : void
elem IHTMLElement
ihs IHighlightSegment
return void

Row_DeleteCol() public method

public Row_DeleteCol ( IHTMLTableRow row, int index ) : void
row IHTMLTableRow
index int
return void

Row_GetCell() public method

public Row_GetCell ( IHTMLTableRow row, int index ) : IHTMLTableCell
row IHTMLTableRow
index int
return IHTMLTableCell

Row_GetCellCount() public method

public Row_GetCellCount ( IHTMLTableRow row ) : int
row IHTMLTableRow
return int

Row_InsertCell() public method

public Row_InsertCell ( IHTMLTableRow row, int index ) : IHTMLElement
row IHTMLTableRow
index int
return IHTMLElement

Row_InsertCell() public method

public Row_InsertCell ( IHTMLTableRow row, int index, string cellwidth ) : IHTMLElement
row IHTMLTableRow
index int
cellwidth string
return IHTMLElement

Row_InsertCol() public method

public Row_InsertCol ( IHTMLTableRow row, int index ) : IHTMLElement
row IHTMLTableRow
index int
return IHTMLElement

SetCursorAtElementStart() public method

Attempts to set the cursor at the start of the given html element The element must be a textual element such as P
public SetCursorAtElementStart ( IHTMLElement elem ) : bool
elem IHTMLElement
return bool

SetSelectionTextFromClipboard() public method

Attempts to set the selection text from clipboard
public SetSelectionTextFromClipboard ( ) : bool
return bool

UnderLineWord() public method

Attempts to find and highlight a word based on it's index and wordlen within body element
public UnderLineWord ( int wordindex, int wordlen ) : void
wordindex int
wordlen int
return void

UnderLineWord2() public method

public UnderLineWord2 ( IHTMLTxtRange range ) : IHighlightSegment
range IHTMLTxtRange
return IHighlightSegment

Underline() public method

Attempts to underline a given element To change the highlighting style, please refer to HTMLRenderStyle_xxxxxxx properties
public Underline ( IHTMLElement elem ) : void
elem IHTMLElement
return void

Underline2() public method

Underline variation which returns IHighlightSegmentinstance
public Underline2 ( IHTMLElement elem ) : IHighlightSegment
elem IHTMLElement
return IHighlightSegment

Property Details

HtmlAmp public_oe property

public string HtmlAmp
return string

HtmlSpace public_oe property

public string HtmlSpace
return string

HtmlTagClose public_oe property

public string HtmlTagClose
return string

HtmlTagOpen public_oe property

public string HtmlTagOpen
return string