Class LambdaSettableTranslationGridView<T1, T2>
A simple SettableTranslationGridView<T1, T2> implementation that allows you to provide functions/lambdas for the translation functions. For a version offering only "get" functionality, see LambdaTranslationGridView<T1, T2>.
Inherited Members
Namespace: SadRogue.Primitives.GridViews
Assembly: TheSadRogue.Primitives.dll
Syntax
public sealed class LambdaSettableTranslationGridView<T1, T2> : SettableTranslationGridView<T1, T2>, ISettableGridView<T2>, IGridView<T2>
Type Parameters
Name | Description |
---|---|
T1 | The type of your underlying data. |
T2 | The type of the data being exposed by the grid view. |
Constructors
LambdaSettableTranslationGridView(ISettableGridView<T1>, ISettableGridView<T2>, Func<T1, T2>, Func<T2, T1>)
Constructor. Takes an existing grid view to create a view from and applies view data to it.
Declaration
public LambdaSettableTranslationGridView(ISettableGridView<T1> baseGrid, ISettableGridView<T2> overlay, Func<T1, T2> getter, Func<T2, T1> setter)
Parameters
Type | Name | Description |
---|---|---|
ISettableGridView<T1> | baseGrid | Your underlying grid data. |
ISettableGridView<T2> | overlay | The view data to apply to the underlying representation. Must have identical dimensions to
|
Func<T1, T2> | getter | The TranslateGet implementation. |
Func<T2, T1> | setter | The TranslateSet implementation. |
LambdaSettableTranslationGridView(ISettableGridView<T1>, ISettableGridView<T2>, Func<Point, T1, T2>, Func<Point, T2, T1>)
Constructor. Takes an existing grid view to create a view from and applies view data to it.
Declaration
public LambdaSettableTranslationGridView(ISettableGridView<T1> baseGrid, ISettableGridView<T2> overlay, Func<Point, T1, T2> getter, Func<Point, T2, T1> setter)
Parameters
Type | Name | Description |
---|---|---|
ISettableGridView<T1> | baseGrid | Your underlying grid data. |
ISettableGridView<T2> | overlay | The view data to apply to the underlying representation. Must have identical dimensions to
|
Func<Point, T1, T2> | getter | The TranslateGet implementation. |
Func<Point, T2, T1> | setter | The TranslateSet implementation. |
LambdaSettableTranslationGridView(ISettableGridView<T1>, Func<T1, T2>, Func<T2, T1>)
Constructor. Takes an existing grid view to create a view from, and getter/setter functions taking only a value from the underlying representation.
Declaration
public LambdaSettableTranslationGridView(ISettableGridView<T1> baseGrid, Func<T1, T2> getter, Func<T2, T1> setter)
Parameters
Type | Name | Description |
---|---|---|
ISettableGridView<T1> | baseGrid | Your underlying grid data. |
Func<T1, T2> | getter | The TranslateGet implementation. |
Func<T2, T1> | setter | The TranslateSet implementation. |
Remarks
If a position is also needed to perform the translation, an overload is provided taking corresponding functions.
LambdaSettableTranslationGridView(ISettableGridView<T1>, Func<Point, T1, T2>, Func<Point, T2, T1>)
Constructor. Takes an existing grid view to create a view from, and getter/setter functions taking a map value and its corresponding position.
Declaration
public LambdaSettableTranslationGridView(ISettableGridView<T1> baseGrid, Func<Point, T1, T2> getter, Func<Point, T2, T1> setter)
Parameters
Type | Name | Description |
---|---|---|
ISettableGridView<T1> | baseGrid | Your underlying grid data. |
Func<Point, T1, T2> | getter | The TranslateGet implementation. |
Func<Point, T2, T1> | setter | The TranslateSet implementation. |
Methods
TranslateGet(Point, T1)
Translates your grid data into the view type by calling the getter function specified in the class constructor.
Declaration
protected override T2 TranslateGet(Point position, T1 value)
Parameters
Type | Name | Description |
---|---|---|
Point | position | Position corresponding to given data value of your underlying representation. |
T1 | value | The data value from your grid. |
Returns
Type | Description |
---|---|
T2 | A value of the mapped data type (via the getter specified in the class constructor). |
Overrides
TranslateSet(Point, T2)
Translates the view type into the appropriate form for your grid data, by calling the setter function specified in the class constructor.
Declaration
protected override T1 TranslateSet(Point position, T2 value)
Parameters
Type | Name | Description |
---|---|---|
Point | position | Position corresponding to the given mapped data type. |
T2 | value | A value of the mapped data type. |
Returns
Type | Description |
---|---|
T1 | The value to apply to the underlying representation via the setter specified in the class constructor. |