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>.this[int, int]
SettableGridViewBase<T2>.this[int]
object.GetType()
object.MemberwiseClone()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
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

View Source

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.

View Source

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

View Source

BaseGrid

The grid view exposing your underlying data.

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

Height

The height of the grid being represented.

Declaration
public override int Height { get; }
Property Value
Type Description
int
Overrides
SettableGridViewBase<T2>.Height
View Source

this[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
SettableGridViewBase<T2>.this[Point]
View Source

Width

The width of the grid being represented.

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

Methods

View Source

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.

Overrides
object.ToString()
View Source

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.

View Source

ToString(int, 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
int 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.

View Source

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.

View Source

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.

View Source

TranslateSet(Point, T2)

Translates the view type into the appropriate form for your underlying data. Takes a value from the underlying data, and its 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.

View Source

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.

Implements

ISettableGridView<T>
IGridView<T>

Extension Methods

GridViewExtensions.Bounds<T>(IGridView<T>)
GridViewExtensions.Contains<T>(IGridView<T>, Point)
GridViewExtensions.Contains<T>(IGridView<T>, int, int)
GridViewExtensions.ExtendToString<T>(IGridView<T>, int, string, string, Func<T, string>?, string, string, string, string)
GridViewExtensions.ExtendToString<T>(IGridView<T>, string, string, Func<T, string>?, string, string, string, string)
GridViewExtensions.Positions<T>(IGridView<T>)
GridViewExtensions.ApplyOverlay<T>(ISettableGridView<T>, IGridView<T>)
GridViewExtensions.ApplyOverlay<T>(ISettableGridView<T>, Func<Point, T>)
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>>?)
  • View Source
In this article
Back to top Generated by DocFX