IGLib
1.7.2
The IGLib base library for development of numerical, technical and business applications.
|
Generates and composes a HTML document. More...
Public Member Functions | |
HtmlWriter (string filePath) | |
Creates a new HTML generator and connests it with the specified file. More... | |
HtmlWriter (string filePath, string cssPath) | |
Creates a new HTML generator and connests it with the specified file. More... | |
string | GetIndent () |
Returns indentation string for the current indentation level. More... | |
int | GetIndentLevel () |
Returns current indentation level of the document. More... | |
void | AddDocumentComment (string commentText) |
Adds another commet to the document that will be written in the document head. More... | |
string[] | GetDocumentComments () |
Returns an array of comments of the document that will be written in the document head. More... | |
void | AddSingleKeyWord (string keyword) |
Adds a keyword to the document (keywords are written as meta tag). More... | |
void | AddKeywords (params string[] keywords) |
Adds the specified keywords to the document (keywords are written as meta tag). More... | |
string[] | GetKeywords () |
Returns an array of current keywords on the document. More... | |
void | CloseWriter () |
Closes the text writer used for assembling the HTML document. More... | |
void | BeginDocument () |
Begins the HTML document. More... | |
void | EndDocument () |
Ends the HTML document. After this method is called, writing is not possible any more. More... | |
void | AppendPlainText (string text) |
Adds plain text to HTML (without any markup, indentation or newlines, unless contained in the text string). More... | |
void | AddPlainTextLine (string text) |
Adds a line of plain text to HTML (without any markup, unless contained in the text string), indented and with newline fillowed. More... | |
void | BeginTag (string tagName) |
Adds the specified tag to the document. More... | |
void | BeginTag (string tagName, params string[] attributeNameValuePairs) |
Adds the specified tag to the document. More... | |
void | BeginTagWithText (string tagName, string text) |
Adds the specified tag containing the specified text to the document. More... | |
void | BeginTagWithText (string tagName, string text, params string[] attributeNameValuePairs) |
Adds the specified tag containing the specified text to the document. More... | |
void | EndTag (string tagName) |
Adds the specified tag containing the specified text to the document. More... | |
void | BeginSection (params string[] attributeNameValuePairs) |
Begins a new section. More... | |
void | EndSection () |
Ends a section. More... | |
void | AddNewLine () |
Adds a newline to HTML. More... | |
void | AppendAttributes (string[] attributeNameValuePairs) |
Writes definition of the specified attriutes of a HTML element to the HTML document. More... | |
void | AddTag (string tagName, string text, bool withLineBreak) |
Adds the specified tag containing the specified text to the document. More... | |
void | AddTag (string tagName, string text) |
Adds the specified tag containing the specified text to the document. More... | |
void | AddTag (string tagName, string text, params string[] attributeNameValuePairs) |
Adds the specified tag containing the specified text to the document. More... | |
void | AddTag (string tagName, string text, bool withLineBreak, params string[] attributeNameValuePairs) |
Adds the specified tag containing the specified text to the document. More... | |
void | AddParagraph (string paragraphText, string[] attributeNameValuePairs) |
Adds a new paragraph with the specified text to the HTML document. More... | |
void | AddParagraph (string paragraphText) |
Adds a new paragraph with the specified text to the HTML document. More... | |
void | AddHeading1 (string headingText, params string[] attributeNameValuePairs) |
Adds a new level 1 heading with the specified text to the HTML document. More... | |
void | AddHeading1 (string headingText) |
Adds a new level 1 heading with the specified text to the HTML document. More... | |
void | AddHeading2 (string headingText, params string[] attributeNameValuePairs) |
Adds a new level 2 heading with the specified text to the HTML document. More... | |
void | AddHeading2 (string headingText) |
Adds a new level 2 heading with the specified text to the HTML document. More... | |
void | AddHeading3 (string headingText, params string[] attributeNameValuePairs) |
Adds a new level 3 heading with the specified text to the HTML document. More... | |
void | AddHeading3 (string headingText) |
Adds a new level 3 heading with the specified text to the HTML document. More... | |
void | AddHeading4 (string headingText, params string[] attributeNameValuePairs) |
Adds a new level 4 heading with the specified text to the HTML document. More... | |
void | AddHeading4 (string headingText) |
Adds a new level 4 heading with the specified text to the HTML document. More... | |
void | AddImage (string imageLink, string altText, string captionText, int width, int height, int originalWidth, int originalHeight, bool constrainRatio) |
Adds a linked image to the HTML document with specified custom size different than the original size. More... | |
void | AddImage (string imageLink, string altText, string captionText, int width, int height, bool defineSize) |
Adds a linked image to the HTML document. More... | |
void | Dispose () |
Implementation of IDisposable interface. More... | |
Static Public Member Functions | |
static void | Example (string htmlDocumentPath, string styleSheetPath, string imagePath1, string imagePath2) |
Writes an example HTML document. More... | |
Public Attributes | |
int | IndentSpaces = 2 |
Number of spaces used in each level of indentation) More... | |
string | ImageCaption = "Figure" |
Protected Member Functions | |
string | GetIndent (int level) |
Returns indentation string for the specified indentation level. More... | |
virtual void | WriteDocumentTitle () |
Adds the title meta tag to the document. More... | |
virtual void | WriteDocumentStyle () |
Adds the style tag to the document. More... | |
virtual void | WriteCssPath () |
virtual void | WriteDocumentComments () |
Writes document comments. More... | |
virtual void | WriteMetaTagGeneral (params string[] attributeNameValuePairs) |
Wirtes the meta tag with specified pairs of field names and corresponding values. More... | |
virtual void | WriteMetaContent () |
Adds a contenbt meta tag. More... | |
virtual void | WriteMetaTag (string name, string content) |
Adds a meta tag with specified values of the name and content fields. More... | |
virtual void | WriteMetaAuthor () |
Writes the author meta tag to the document. More... | |
virtual void | WriteMetaDescription () |
Adds the audescription meta tag to the document. More... | |
virtual void | WriteMetaKeywords () |
Adds the keywords meta tag to the document. More... | |
bool | IsAttributesDefined (string[] attributeNameValuePairs) |
Returns true if the specified array of attribute name-value pairs defines any attributes, false otherwise. More... | |
void | AddImageCaption (string captionText) |
Adds Image caption to the current HTML document. More... | |
virtual void | Dispose (bool disposing) |
Does the job of freeing resources. More... | |
Protected Attributes | |
bool | _headWritten = false |
bool | _tailWritten = false |
string | _filePath |
int | IndentLevel = 0 |
Current level of indentation. More... | |
string | _cssPath |
string | _styleString |
string | _documentTitle = "Generated HTML Document" |
string | _documentAuthor = "IGLIb (by Igor Gresovnik)" |
string | _documentDescription = "This document was programatically generated by IGLib (Investigative Generic Library), http://www2.arnes.si/~ljc3m2/igor/iglib/" |
List< string > | _documentComments |
List< string > | _keywords |
TextWriter | _writer |
bool | _lockBeginDocument = false |
Properties | |
string | ConstAttributeClass [get] |
The class attribute. Specifies one or more classnames for an element (refers to a class in a style sheet). More... | |
string | ConstAttributeId [get] |
The id attribute. Specifies a unique id for an element. More... | |
string | ConstAttributeStyle [get] |
The style attribute. Specifies an inline CSS style for an element. More... | |
string | ConstAttributeTitle [get] |
The style attribute. Specifies extra information about an element. More... | |
string | ConstAttributeTextDirection [get] |
The text direction attribute. Specifies text direction for the content in an element. More... | |
string | ConstAttributeLanguage [get] |
The language attribute. Specifies the language of the element's content. More... | |
string | ConstAttributeLanguageXml [get] |
The xml language attribute. Specifies the language of the element's content (for XHTML documents). More... | |
string | ConstAttributeShortcutKey [get] |
The shortcut key attribute. Specifies a shortcut key to activate/focus an element. More... | |
string | ConstAttributeTabIndex [get] |
The tab index attribute. Specifies the tabbing order of an element. More... | |
string | FilePath [get, protected set] |
Path to file containing the generator. More... | |
string | CssPath [get, set] |
Path to the associated CSS file (Cascaded Style Sheets). More... | |
string | DocumentStyle [get, set] |
CSS string with internal style definitions. More... | |
virtual string | DocumentTitle [get, set] |
virtual string | DocumentAuthor [get, set] |
virtual string | DocumentDescription [get, set] |
TextWriter | Writer [get] |
Text writer used for writing on the document. More... | |
Private Member Functions | |
HtmlWriter () | |
Prevent argument-less constructor. More... | |
~HtmlWriter () | |
Private Attributes | |
int | _sectionLevel = 0 |
int | _imageNum = 0 |
bool | disposed = false |
Generates and composes a HTML document.
Each object of this class can be used for generation of only one HTML document.
$A Igor xx Feb12;
|
inlineprivate |
Prevent argument-less constructor.
|
inline |
Creates a new HTML generator and connests it with the specified file.
filePath | Path to the HTML file that is created. |
|
inline |
Creates a new HTML generator and connests it with the specified file.
filePath | Path to the HTML file that is created. |
cssPath | Path (usually relative) to the CSS (Cascading Style Sheets) file. |
|
inlineprivate |
|
inlineprotected |
Returns indentation string for the specified indentation level.
level | Level of indentation for which indentation string is returned. |
|
inline |
Returns indentation string for the current indentation level.
Level is increased or decreased automatically with respect to what is done with the document.
|
inline |
Returns current indentation level of the document.
|
inline |
Adds another commet to the document that will be written in the document head.
Must be called before the document head is written, otherwise the comment will not be written.
commentText | Text of the comment to be added. |
|
inline |
Returns an array of comments of the document that will be written in the document head.
|
inline |
Adds a keyword to the document (keywords are written as meta tag).
Must be called before the document head is written, otherwise the keyword will not be written.
keyword | Keyword to be added to the document. |
|
inline |
Adds the specified keywords to the document (keywords are written as meta tag).
Must be called before the document head is written, otherwise the keyword will not be written.
keywords | Keywords to be added. |
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Returns an array of current keywords on the document.
|
inline |
Closes the text writer used for assembling the HTML document.
Referenced by IG.Lib.HtmlWriter.Example().
|
inlineprotectedvirtual |
Adds the title meta tag to the document.
Must be called within the method for writing document head.
|
inlineprotectedvirtual |
Adds the style tag to the document.
Must be called within the method for writing document head.
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
Writes document comments.
Must be called within the method for writing document head.
|
inlineprotectedvirtual |
Wirtes the meta tag with specified pairs of field names and corresponding values.
Must be called within the method for writing document head.
attributeNameValuePairs | Pairs of attribute names and values that will comprise the meta tag. |
|
inlineprotectedvirtual |
Adds a contenbt meta tag.
Must be called within the method for writing document head.
|
inlineprotectedvirtual |
Adds a meta tag with specified values of the name and content fields.
Must be called within the method for writing document head.
name | Name of the meta tag. |
content | Content of the meta tag. |
|
inlineprotectedvirtual |
Writes the author meta tag to the document.
Must be called within the method for writing document head.
|
inlineprotectedvirtual |
Adds the audescription meta tag to the document.
Must be called within the method for writing document head.
|
inlineprotectedvirtual |
Adds the keywords meta tag to the document.
Must be called within the method for writing document head.
|
inline |
Begins the HTML document.
Adds HTML head if necessary.
|
inline |
Ends the HTML document. After this method is called, writing is not possible any more.
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Adds plain text to HTML (without any markup, indentation or newlines, unless contained in the text string).
text | Text to be added. |
|
inline |
Adds a line of plain text to HTML (without any markup, unless contained in the text string), indented and with newline fillowed.
text | Text to be added. |
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Adds the specified tag to the document.
tagName | Tag name. |
|
inline |
Adds the specified tag to the document.
tagName | Tag name. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
|
inline |
Adds the specified tag containing the specified text to the document.
tagName | Tag name. |
text | Tag text. |
|
inline |
Adds the specified tag containing the specified text to the document.
tagName | Tag name. |
text | Tag text. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
|
inline |
Adds the specified tag containing the specified text to the document.
tagName | Tag name. |
|
inline |
Begins a new section.
attributeNameValuePairs | Eventual attributes (in form of attribute name - value pairs). |
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Ends a section.
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Adds a newline to HTML.
Referenced by IG.Lib.HtmlWriter.Example().
|
inlineprotected |
Returns true if the specified array of attribute name-value pairs defines any attributes, false otherwise.
attributeNameValuePairs | Pairs of attribute names and values to be added to some tag. |
|
inline |
Writes definition of the specified attriutes of a HTML element to the HTML document.
attributeNameValuePairs | Pairs of attribute names and values that will be added to the html element. |
|
inline |
Adds the specified tag containing the specified text to the document.
tagName | Tag name. |
text | Tag text. |
withLineBreak | Whether line break is added or not. |
|
inline |
Adds the specified tag containing the specified text to the document.
Tag has no attributes. Line break is not added.
tagName | Tag name. |
text | Tag text. |
|
inline |
Adds the specified tag containing the specified text to the document.
Line breakis not added.
tagName | Tag name. |
text | Tag text. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
|
inline |
Adds the specified tag containing the specified text to the document.
tagName | Tag name. |
text | Tag text. |
withLineBreak | Whether line break is added or not. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
|
inline |
Adds a new paragraph with the specified text to the HTML document.
paragraphText | Text of the paragraph. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Adds a new paragraph with the specified text to the HTML document.
The added HTML element has no attributes.
paragraphText | Text of the paragraph. |
|
inline |
Adds a new level 1 heading with the specified text to the HTML document.
headingText | Text of the heading. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Adds a new level 1 heading with the specified text to the HTML document.
The added HTML element has no attributes.
headingText | Text of the heading. |
|
inline |
Adds a new level 2 heading with the specified text to the HTML document.
headingText | Text of the heading. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Adds a new level 2 heading with the specified text to the HTML document.
The added HTML element has no attributes.
headingText | Text of the heading. |
|
inline |
Adds a new level 3 heading with the specified text to the HTML document.
headingText | Text of the heading. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
|
inline |
Adds a new level 3 heading with the specified text to the HTML document.
The added HTML element has no attributes.
headingText | Text of the heading. |
|
inline |
Adds a new level 4 heading with the specified text to the HTML document.
headingText | Text of the heading. |
attributeNameValuePairs | Pairs of attribute names and values that will be added to the tag. |
|
inline |
Adds a new level 4 heading with the specified text to the HTML document.
The added HTML element has no attributes.
headingText | Text of the heading. |
|
inline |
Adds a linked image to the HTML document with specified custom size different than the original size.
It is possible to constraint height/width ratio to the original one, in this case the original width and height must be specified.
imageLink | Link to the image. Must not be null or empty string. |
altText | Alternative text to be displayed when image is not shown. |
captionText | Text below the image. |
width | Width of the image in pixels. Takes effect when size is defined. |
height | Height of the image in pixels. Takes effect when size is defined. |
originalWidth | Original image width. Must be specified only if the ratio is constrained (i.e. if constrainRatio = true) |
originalHeight | Original image height. Must be specified only if the ratio is constrained (i.e. if constrainRatio = true) |
constrainRatio | If true then ratio between width and height is kept the same as in the original. In this case, original width and height must be specified, too. |
When ratio between image width and height is not constrained to the original ratio of the image (constrainRatio = false) both width and height must be greater than 0 and they represent image dimensions in rendered HTML.
When ratio between image width and height is constrained to the original ratio of the image (constrainRatio = true), either the specified width or height may be less or equal to 0. In this case the remaining dimension is calculatd from the specified one in such a way that original ratio between width and height is preserved.
When ratio between image width and height is constrained to the original ratio of the image (constrainRatio = true) and both image width and height are specified,
Referenced by IG.Lib.HtmlWriter.Example().
|
inline |
Adds a linked image to the HTML document.
imageLink | Link to the image. Must not be null or empty string. |
altText | Alternative text to be displayed when image is not shown. |
captionText | Text below the image. |
width | Width of the image in pixels. Takes effect when defineSize =true. |
height | Width of the image in pixels. Takes effect when defineSize =true. |
defineSize | Whether size (in pixels) of the displayed image is defined or not. |
|
inlineprotected |
Adds Image caption to the current HTML document.
captionText | Caption text. |
|
inline |
Implementation of IDisposable interface.
|
inlineprotectedvirtual |
Does the job of freeing resources.
This method can be eventually overridden in derived classes (if they use other resources that must be freed - in addition to such resources of the current class). In the case of overriding this method, you should usually call the base. See disposing . in the overriding method.
disposing | Tells whether the method has been called form Dispose() method. |
|
inlinestatic |
Writes an example HTML document.
htmlDocumentPath | Path to the created HTML document. |
styleSheetPath | Path to StyleSheet (CSS file). |
imagePath1 | Path to the first image included (can be null). |
imagePath2 | Path to the second image included (can be null). |
References IG.Lib.HtmlWriter.AddHeading1(), IG.Lib.HtmlWriter.AddHeading2(), IG.Lib.HtmlWriter.AddImage(), IG.Lib.HtmlWriter.AddKeywords(), IG.Lib.HtmlWriter.AddNewLine(), IG.Lib.HtmlWriter.AddParagraph(), IG.Lib.HtmlWriter.AddPlainTextLine(), IG.Lib.HtmlWriter.BeginSection(), IG.Lib.HtmlWriter.CloseWriter(), IG.Lib.HtmlWriter.ConstAttributeClass, IG.Lib.HtmlWriter.ConstAttributeId, IG.Lib.HtmlWriter.DocumentStyle, IG.Lib.HtmlWriter.DocumentTitle, IG.Lib.HtmlWriter.EndDocument(), IG.Lib.HtmlWriter.EndSection(), and IG.Lib.UtilSystem.OpenFileInDefaultBrowser().
|
protected |
|
protected |
|
protected |
int IG.Lib.HtmlWriter.IndentSpaces = 2 |
Number of spaces used in each level of indentation)
|
protected |
Current level of indentation.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
private |
|
private |
string IG.Lib.HtmlWriter.ImageCaption = "Figure" |
|
private |
|
get |
The class attribute. Specifies one or more classnames for an element (refers to a class in a style sheet).
Referenced by IG.Lib.HtmlWriter.Example().
|
get |
The id attribute. Specifies a unique id for an element.
Referenced by IG.Lib.HtmlWriter.Example().
|
get |
The style attribute. Specifies an inline CSS style for an element.
|
get |
The style attribute. Specifies extra information about an element.
|
get |
The text direction attribute. Specifies text direction for the content in an element.
|
get |
The language attribute. Specifies the language of the element's content.
|
get |
The xml language attribute. Specifies the language of the element's content (for XHTML documents).
|
get |
The shortcut key attribute. Specifies a shortcut key to activate/focus an element.
|
get |
The tab index attribute. Specifies the tabbing order of an element.
|
getprotected set |
Path to file containing the generator.
|
getset |
Path to the associated CSS file (Cascaded Style Sheets).
Must be set before the document head is written, otherwise it will have no effect.
|
getset |
CSS string with internal style definitions.
Referenced by IG.Lib.HtmlWriter.Example().
|
getset |
Referenced by IG.Lib.HtmlWriter.Example().
|
getset |
|
getset |
|
get |
Text writer used for writing on the document.
Lazy evaluation, automatically opened when first needed.