Show / Hide Table of Contents

Class SettableTranslationGridView<T1, T2>

Class implementing ISettableGridView<T> by providing a functions that translate values from one grid view with complex data types, to a grid view with simple data types, and vice versa. For a version that provides only "get" functionality, see TranslationGridView<T1, T2>.

Inheritance
Object
SettableGridViewBase<T2>
SettableTranslationGridView<T1, T2>
LambdaSettableTranslationGridView<T1, T2>
Implements
ISettableGridView<T2>
IGridView<T2>
Inherited Members
SettableGridViewBase<T2>.Fill(T2)
SettableGridViewBase<T2>.Clear()
SettableGridViewBase<T2>.Count
SettableGridViewBase<T2>.Item[Int32, Int32]
SettableGridViewBase<T2>.Item[Int32]
Namespace: SadRogue.Primitives.GridViews
Assembly: TheSadRogue.Primitives.dll
Syntax
public abstract class SettableTranslationGridView<T1, T2> : SettableGridViewBase<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.

Remarks

See TranslationGridView<T1, T2>. The use case is the same, except that this class implements ISettableGridView<T> instead, and thus also allows you to specify set-translations via TranslateSet.

Constructors

SettableTranslationGridView(ISettableGridView<T1>)

Constructor. Takes an existing grid view to create a view from.

Declaration
protected SettableTranslationGridView(ISettableGridView<T1> baseGrid)
Parameters
Type Name Description
ISettableGridView<T1> baseGrid

A grid view exposing your underlying map data.

SettableTranslationGridView(ISettableGridView<T1>, ISettableGridView<T2>)

Constructor. Takes an existing grid view to create a view from and applies view data to it.

Declaration
protected SettableTranslationGridView(ISettableGridView<T1> baseGrid, ISettableGridView<T2> overlay)
Parameters
Type Name Description
ISettableGridView<T1> baseGrid

Your underlying map data.

ISettableGridView<T2> overlay

The view data to apply to the grid. Must have identical dimensions to baseGrid.

Remarks

Since this constructor must call TranslateSet to perform its function, do NOT call this constructor if the TranslateSet implementation depends on the derived class's constructor being completed to function properly.

Properties

BaseGrid

The grid view exposing your underlying data.

Declaration
public ISettableGridView<T1> BaseGrid { get; }
Property Value
Type Description
ISettableGridView<T1>

Height

The height of the grid being represented.

Declaration
public override int Height { get; }
Property Value
Type Description
Int32
Overrides
SadRogue.Primitives.GridViews.SettableGridViewBase<T2>.Height

Item[Point]

Given a position, translates and returns/sets the "value" associated with that position.

Declaration
public override T2 this[Point pos] { get; set; }
Parameters
Type Name Description
Point pos

Location to get/set the value for.

Property Value
Type Description
T2

The translated "value" associated with the provided location.

Overrides
SadRogue.Primitives.GridViews.SettableGridViewBase<T2>.Item[SadRogue.Primitives.Point]

Width

The width of the grid being represented.

Declaration
public override int Width { get; }
Property Value
Type Description
Int32
Overrides
SadRogue.Primitives.GridViews.SettableGridViewBase<T2>.Width

Methods

ToString()

Returns a string representation of the grid values.

Declaration
public override string ToString()
Returns
Type Description
String

A string representation of the grid values.

ToString(Func<T2, String>)

Returns a string representation of the grid values, using elementStringifier to determine what string represents each value.

Declaration
public string ToString(Func<T2, string> elementStringifier)
Parameters
Type Name Description
Func<T2, String> elementStringifier

Function determining the string representation of each element.

Returns
Type Description
String

A string representation of the grid view.

ToString(Int32, Func<T2, String>)

Returns a string representation of the grid values, using the function specified to turn elements into strings, and using the "field length" specified.

Declaration
public string ToString(int fieldSize, Func<T2, string> elementStringifier = null)
Parameters
Type Name Description
Int32 fieldSize

The size of the field to give each value. A positive-number right-aligns the text within the field, while a negative number left-aligns the text.

Func<T2, String> elementStringifier

Function to use to convert each element to a string. null defaults to the ToString function of type T.

Returns
Type Description
String

A string representation of the grid values.

Remarks

Each element of type T will have spaces added to cause it to take up exactly fieldSize characters, provided fieldSize is less than the length of the element's string representation.

TranslateGet(T1)

Translates your underlying data into the view type. Takes only a value from the underlying data. If a position is also needed to perform the translation, use TranslateGet(Point, T1) instead.

Declaration
protected virtual T2 TranslateGet(T1 value)
Parameters
Type Name Description
T1 value

The data value from your underlying data.

Returns
Type Description
T2

A value of the mapped data type.

TranslateGet(Point, T1)

Translates your underlying data into the view type. Takes a value from the underlying data and the corresponding position for that value. If a position is not needed to perform the translation, use TranslateGet(T1) instead.

Declaration
protected virtual T2 TranslateGet(Point position, T1 value)
Parameters
Type Name Description
Point position

The position of the given data value from your underlying data structure.

T1 value

The data value from your underlying structure.

Returns
Type Description
T2

A value of the mapped data type.

TranslateSet(T2)

Translates the view type into the appropriate form for your underlying data. Takes only a value from the grid view itself. If a position is also needed to perform the translation, use TranslateSet(Point, T2) instead.

Declaration
protected virtual T1 TranslateSet(T2 value)
Parameters
Type Name Description
T2 value

A value of the mapped data type.

Returns
Type Description
T1

The data value for your underlying representation.

TranslateSet(Point, T2)

Translates the view type into the appropriate form for your underlying data. Takes a value from the underlying data, and it corresponding position. If a position is not needed to perform the translation, use TranslateSet(T2) instead.

Declaration
protected virtual T1 TranslateSet(Point position, T2 value)
Parameters
Type Name Description
Point position

The position of the given mapped data type.

T2 value

A value of the mapped data type.

Returns
Type Description
T1

The data value for your underlying representation.

Implements

ISettableGridView<T>
IGridView<T>

Extension Methods

PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>)
PropertyChangedEventHelpers.SafelySetProperty<TObject, TProperty>(TObject, ref TProperty, TProperty, EventHandler<ValueChangedEventArgs<TProperty>>, EventHandler<ValueChangedEventArgs<TProperty>>)
In This Article
Back to top Generated by DocFX