Class GridViewExtensions
Extensions for IGridView<T> implementations that provide basic utility functions for them.
Namespace: SadRogue.Primitives.GridViews
Assembly: TheSadRogue.Primitives.dll
Syntax
public static class GridViewExtensions : Object
Methods
ApplyOverlay<T>(ISettableGridView<T>, IGridView<T>)
Sets all the values of the current grid view to be equal to the corresponding values from the grid view you pass in.
Declaration
public static void ApplyOverlay<T>(this ISettableGridView<T> self, IGridView<T> overlay)
Parameters
Type | Name | Description |
---|---|---|
ISettableGridView<T> | self | |
IGridView<T> | overlay | The data apply to the view. Must have identical dimensions to the current view. |
Type Parameters
Name | Description |
---|---|
T |
ApplyOverlay<T>(ISettableGridView<T>, Func<Point, T>)
Sets the values for each location of the current grid view to be equal to the value returned from the given function when given that position.
Declaration
public static void ApplyOverlay<T>(this ISettableGridView<T> self, Func<Point, T> valueFunc)
Parameters
Type | Name | Description |
---|---|---|
ISettableGridView<T> | self | |
Func<Point, T> | valueFunc | Function returning data for each location in the grid view. |
Type Parameters
Name | Description |
---|---|
T |
Bounds<T>(IGridView<T>)
Gets a rectangle representing the bounds of the current grid view.
Declaration
public static Rectangle Bounds<T>(this IGridView<T> gridView)
Parameters
Type | Name | Description |
---|---|---|
IGridView<T> | gridView |
Returns
Type | Description |
---|---|
Rectangle | A rectangle representing the grid view's bounds. |
Type Parameters
Name | Description |
---|---|
T |
Contains<T>(IGridView<T>, Point)
Returns whether or not the given position is contained within the current grid view or not.
Declaration
public static bool Contains<T>(this IGridView<T> gridView, Point position)
Parameters
Type | Name | Description |
---|---|---|
IGridView<T> | gridView | |
Point | position | The position to check. |
Returns
Type | Description |
---|---|
Boolean | True if the given position is contained within this grid view, false otherwise. |
Type Parameters
Name | Description |
---|---|
T |
Contains<T>(IGridView<T>, Int32, Int32)
Returns whether or not the given position is contained within the current grid view or not.
Declaration
public static bool Contains<T>(this IGridView<T> gridView, int x, int y)
Parameters
Type | Name | Description |
---|---|---|
IGridView<T> | gridView | |
Int32 | x | X-value of the position to check. |
Int32 | y | Y-value of the position to check. |
Returns
Type | Description |
---|---|
Boolean | True if the given position is contained within this grid view, false otherwise. |
Type Parameters
Name | Description |
---|---|
T |
ExtendToString<T>(IGridView<T>, Int32, String, String, Func<T, String>, String, String, String, String)
Allows stringifying the contents of a grid view. Takes characters to surround the grid view representation, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row. Takes the size of the field to give each element, characters to surround the GridView printout, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row.
Declaration
public static string ExtendToString<T>(this IGridView<T> gridView, int fieldSize, string begin = "", string beginRow = "", Func<T, string> elementStringifier = null, string rowSeparator = "\n", string elementSeparator = " ", string endRow = "", string end = "")
Parameters
Type | Name | Description |
---|---|---|
IGridView<T> | gridView | |
Int32 | fieldSize | The amount of space each element should take up in characters. A positive number aligns the text to the right of the space, while a negative number aligns the text to the left. |
String | begin | Character(s) that should precede the IGridView printout. |
String | beginRow | Character(s) that should precede each row. |
Func<T, String> | elementStringifier | Function to use to get the string representation of each value. Null uses the ToString function of type T. |
String | rowSeparator | Character(s) to separate each row from the next. |
String | elementSeparator | Character(s) to separate each element from the next. |
String | endRow | Character(s) that should follow each row. |
String | end | Character(s) that should follow the IGridView printout. |
Returns
Type | Description |
---|---|
String | A string representation of the grid view. |
Type Parameters
Name | Description |
---|---|
T |
ExtendToString<T>(IGridView<T>, String, String, Func<T, String>, String, String, String, String)
Allows stringifying the contents of a grid view. Takes characters to surround the grid view printout, and each row, the method used to get the string representation of each element (defaulting to the ToString function of type T), and separation characters for each element and row.
Declaration
public static string ExtendToString<T>(this IGridView<T> gridView, string begin = "", string beginRow = "", Func<T, string> elementStringifier = null, string rowSeparator = "\n", string elementSeparator = " ", string endRow = "", string end = "")
Parameters
Type | Name | Description |
---|---|---|
IGridView<T> | gridView | |
String | begin | Character(s) that should precede the IGridView printout. |
String | beginRow | Character(s) that should precede each row. |
Func<T, String> | elementStringifier | Function to use to get the string representation of each value. null uses the ToString function of type T. |
String | rowSeparator | Character(s) to separate each row from the next. |
String | elementSeparator | Character(s) to separate each element from the next. |
String | endRow | Character(s) that should follow each row. |
String | end | Character(s) that should follow the IGridView printout. |
Returns
Type | Description |
---|---|
String | A string representation of the values in the grid view. |
Type Parameters
Name | Description |
---|---|
T |
Positions<T>(IGridView<T>)
Iterates through each position in the grid view.
Declaration
public static RectanglePositionsEnumerator Positions<T>(this IGridView<T> gridView)
Parameters
Type | Name | Description |
---|---|---|
IGridView<T> | gridView |
Returns
Type | Description |
---|---|
RectanglePositionsEnumerator | All positions in the IGridView. |
Type Parameters
Name | Description |
---|---|
T |