Show / Hide Table of Contents

Class UnboundedViewport<T>

Similar to Viewport<T>, except that the view area is in no way bounded to the edges of the underlying grid view. Instead, if you access a position that cannot map to any valid position in the underlying grid view, a (specified) default value is returned.

Inheritance
Object
GridViewBase<T>
UnboundedViewport<T>
Implements
IGridView<T>
Inherited Members
GridViewBase<T>.Count
GridViewBase<T>.Item[Int32, Int32]
GridViewBase<T>.Item[Int32]
Namespace: SadRogue.Primitives.GridViews
Assembly: TheSadRogue.Primitives.dll
Syntax
public class UnboundedViewport<T> : GridViewBase<T>, IGridView<T>
Type Parameters
Name Description
T

The type being exposed by the UnboundedViewport.

Constructors

UnboundedViewport(IGridView<T>, T)

Constructor. Takes the grid view to represent. The viewport will represent the entire given grid view.

Declaration
public UnboundedViewport(IGridView<T> gridView, T defaultValue)
Parameters
Type Name Description
IGridView<T> gridView

The grid view to represent.

T defaultValue

The value to return if a position is accessed that is outside the actual underlying grid view.

UnboundedViewport(IGridView<T>, Rectangle, T)

Constructor. Takes the parent grid view, and the initial subsection of that grid view to represent.

Declaration
public UnboundedViewport(IGridView<T> gridView, Rectangle viewArea, T defaultValue)
Parameters
Type Name Description
IGridView<T> gridView

The grid view being represented.

Rectangle viewArea

The initial subsection of that grid to represent.

T defaultValue

The value to return if a position is accessed that is outside the actual underlying grid view.

Fields

DefaultValue

The value to return if a position is accessed that is outside the actual underlying grid view.

Declaration
public readonly T DefaultValue
Field Value
Type Description
T

Properties

GridView

The grid view that this UnboundedViewport is exposing values from.

Declaration
public IGridView<T> GridView { get; }
Property Value
Type Description
IGridView<T>

Height

The height of the area being represented.

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

Item[Point]

Given a position in relative coordinates, returns the "value" associated with that location in absolute coordinates.

Declaration
public override T this[Point relativePosition] { get; }
Parameters
Type Name Description
Point relativePosition

Viewport-relative position of the location to retrieve the value for.

Property Value
Type Description
T

The "value" associated with the absolute location represented on the underlying grid view, or DefaultValue if the absolute position does not exist in the underlying grid view.

Overrides
SadRogue.Primitives.GridViews.GridViewBase<T>.Item[SadRogue.Primitives.Point]

ViewArea

The area of the base GridView that this Viewport is exposing. Although this property does not explicitly expose a set accessor, it is returning a reference and as such may be assigned to. This viewport is NOT bounded to base map edges -- for this functionality, see the Viewport<T> class.

Declaration
public ref Rectangle ViewArea { get; }
Property Value
Type Description
Rectangle

Width

The width of the area being represented.

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

Methods

ToString()

Returns a string representation of the grid values inside the viewport.

Declaration
public override string ToString()
Returns
Type Description
String

A string representation of the grid values inside the viewport.

ToString(Func<T, String>)

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

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

Function determining the string representation of each element.

Returns
Type Description
String

A string representation of the grid values inside the viewport.

ToString(Int32, Func<T, String>)

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

Declaration
public string ToString(int fieldSize, Func<T, 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<T, 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 inside the viewport.

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.

Implements

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