C# Class TextTools.TextTable

A class for rendering text based tables. This class needs just a printing function (like Console.WriteLine) and the maximum width of the table that has to be rendered. Therefore it is suitable for use in linux consoles with Mono
ファイルを表示 Open project: txdv/sharpmod Class Usage Examples

Public Methods

Method Description
Render ( IList data ) : void

The Render function which uses Console.Write for printing and Console.WindowWith to determine the with of the console.

Render ( IList data, OutputFunction outputFunction, int maximumWidth ) : void

The classic Render functions, which lets you supply the maximum width and the function which has to be used for printing.

TextTable ( IList
header ) : System

A constructor which requires an array of Header or a class with the IList

interaface implemeneted.

TextTable ( IList header ) : System

A constructor which requires an array of strings or a class with the IList interaface implemeneted. Internally the array will be converted in an array of Header with the default values used in TextTable.

Protected Methods

Method Description
GetHeaderArrayOfStringArray ( IList header ) : TextTools.Header[]

A function for converting the string array into a header array, needed to fit in the constructor.

GetLongestDataEntryLength ( IList data, int row ) : int

Gets the longest data entry length in a data set of a specific row.

GetLongestDataEntryLengthArray ( IList data ) : int[]

Gets the longest data entry lengths of all rows.

Trim ( Align alignment, string text, int length ) : string

Trims the text according to length and alignment.

Method Details

GetHeaderArrayOfStringArray() protected static method

A function for converting the string array into a header array, needed to fit in the constructor.
protected static GetHeaderArrayOfStringArray ( IList header ) : TextTools.Header[]
header IList /// An array of strings ///
return TextTools.Header[]

GetLongestDataEntryLength() protected method

Gets the longest data entry length in a data set of a specific row.
protected GetLongestDataEntryLength ( IList data, int row ) : int
data IList /// A data object ///
row int /// The row to examine ///
return int

GetLongestDataEntryLengthArray() protected method

Gets the longest data entry lengths of all rows.
protected GetLongestDataEntryLengthArray ( IList data ) : int[]
data IList /// A data object ///
return int[]

Render() public method

The Render function which uses Console.Write for printing and Console.WindowWith to determine the with of the console.
public Render ( IList data ) : void
data IList /// A data object, the second dimension must fit the header length. ///
return void

Render() public method

The classic Render functions, which lets you supply the maximum width and the function which has to be used for printing.
public Render ( IList data, OutputFunction outputFunction, int maximumWidth ) : void
data IList /// A data object ///
outputFunction OutputFunction /// A delegate to the output function ///
maximumWidth int /// the maximum width of the table ///
return void

TextTable() public method

A constructor which requires an array of Header or a class with the IList
interaface implemeneted.
public TextTable ( IList
header ) : System
header IList
/// A header array ///
return System

TextTable() public method

A constructor which requires an array of strings or a class with the IList interaface implemeneted. Internally the array will be converted in an array of Header with the default values used in TextTable.
public TextTable ( IList header ) : System
header IList /// A string array ///
return System

Trim() protected method

Trims the text according to length and alignment.
protected Trim ( Align alignment, string text, int length ) : string
alignment Align /// Alignment value ///
text string /// Text to trim ///
length int /// The maximum length ///
return string