Class CellSurface
An array of ColoredGlyphBase objects used to represent a 2D surface.
Implements
Inherited Members
Namespace: SadConsole
Assembly: SadConsole.dll
Syntax
[DataContract]
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class CellSurface : ICellSurface, IGridView<ColoredGlyphBase>, IEnumerable<ColoredGlyphBase>, IEnumerable, ISurface, ICellSurfaceResize, ICellSurfaceSettable
Constructors
CellSurface(IGridView<ColoredGlyphBase>, int, int)
Creates a new surface from a grid view with Transparent for the background and White for the foreground.
Declaration
public CellSurface(IGridView<ColoredGlyphBase> surface, int visibleWidth = 0, int visibleHeight = 0)
Parameters
Type | Name | Description |
---|---|---|
IGridView<ColoredGlyphBase> | surface | The surface to use as the source of cells. |
int | visibleWidth | Optional view width. If |
int | visibleHeight | Optional view height. If |
CellSurface(int, int)
Creates a new surface with the specified width and height, with Transparent for the background and White for the foreground.
Declaration
public CellSurface(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
int | width | The width of the surface in cells. |
int | height | The height of the surface in cells. |
CellSurface(int, int, ColoredGlyphBase[])
Creates a new surface with the specified width and height, with Transparent for the background and White for the foreground.
Declaration
public CellSurface(int width, int height, ColoredGlyphBase[] initialCells)
Parameters
Type | Name | Description |
---|---|---|
int | width | The width of the surface in cells. |
int | height | The height of the surface in cells. |
ColoredGlyphBase[] | initialCells | The cells to seed the surface with. If null, creates the cell array for you. |
CellSurface(int, int, int, int)
Creates a new surface with the specified width and height, with Transparent for the background and White for the foreground.
Declaration
public CellSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight)
Parameters
Type | Name | Description |
---|---|---|
int | viewWidth | The visible width of the surface in cells. |
int | viewHeight | The visible height of the surface in cells. |
int | totalWidth | The total width of the surface in cells. |
int | totalHeight | The total height of the surface in cells. |
CellSurface(int, int, int, int, ColoredGlyphBase[]?)
Creates a new surface with the specified width and height, with Transparent for the background and White for the foreground.
Declaration
public CellSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight, ColoredGlyphBase[]? initialCells)
Parameters
Type | Name | Description |
---|---|---|
int | viewWidth | The width of the surface in cells. |
int | viewHeight | The height of the surface in cells. |
int | totalWidth | The total width of the surface in cells. |
int | totalHeight | The total height of the surface in cells. |
ColoredGlyphBase[] | initialCells | The cells to seed the surface with. If null, creates the cell array for you. |
Properties
Area
Returns a rectangle that represents the entire size of the surface.
Declaration
public Rectangle Area { get; }
Property Value
Type | Description |
---|---|
Rectangle |
Cells
Declaration
[DataMember]
public ColoredGlyphBase[] Cells { get; protected set; }
Property Value
Type | Description |
---|---|
ColoredGlyphBase[] |
Count
The count of glyphs this surface contains.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
DefaultBackground
The default background for glyphs on this surface.
Declaration
[DataMember]
public Color DefaultBackground { get; set; }
Property Value
Type | Description |
---|---|
Color |
DefaultForeground
The default foreground for glyphs on this surface.
Declaration
[DataMember]
public Color DefaultForeground { get; set; }
Property Value
Type | Description |
---|---|
Color |
DefaultGlyph
The default glyph used in clearing and erasing.
Declaration
[DataMember]
public int DefaultGlyph { get; set; }
Property Value
Type | Description |
---|---|
int |
Effects
Processes the effects added to cells with CellSurfaceEditor.SetEffect*.
Declaration
[IgnoreDataMember]
public EffectsManager Effects { get; protected set; }
Property Value
Type | Description |
---|---|
EffectsManager |
Height
The total height of the surface.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
int |
IsDirty
Indicates the surface has changed and needs to be rendered.
Declaration
public bool IsDirty { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsScrollable
Declaration
public bool IsScrollable { get; }
Property Value
Type | Description |
---|---|
bool |
this[Point]
Declaration
public ColoredGlyphBase this[Point position] { get; protected set; }
Parameters
Type | Name | Description |
---|---|---|
Point | position |
Property Value
Type | Description |
---|---|
ColoredGlyphBase |
this[int]
Declaration
public ColoredGlyphBase this[int index] { get; protected set; }
Parameters
Type | Name | Description |
---|---|---|
int | index |
Property Value
Type | Description |
---|---|
ColoredGlyphBase |
this[int, int]
Declaration
public ColoredGlyphBase this[int x, int y] { get; protected set; }
Parameters
Property Value
Type | Description |
---|---|
ColoredGlyphBase |
this[Range]
Given a position, returns the "value" associated with that location.
Declaration
public Span<ColoredGlyphBase> this[Range range] { get; }
Parameters
Type | Name | Description |
---|---|---|
Range | range | The cells to return from the array. |
Property Value
Type | Description |
---|---|
Span<ColoredGlyphBase> | The cells associated with the specified range. |
Surface
Returns this object.
Declaration
[IgnoreDataMember]
public ICellSurface Surface { get; }
Property Value
Type | Description |
---|---|
ICellSurface |
TimesShiftedDown
A variable that tracks how many times this editor shifted the surface down.
Declaration
[DataMember]
public int TimesShiftedDown { get; set; }
Property Value
Type | Description |
---|---|
int |
TimesShiftedLeft
A variable that tracks how many times this editor shifted the surface left.
Declaration
[DataMember]
public int TimesShiftedLeft { get; set; }
Property Value
Type | Description |
---|---|
int |
TimesShiftedRight
A variable that tracks how many times this editor shifted the surface right.
Declaration
[DataMember]
public int TimesShiftedRight { get; set; }
Property Value
Type | Description |
---|---|
int |
TimesShiftedUp
A variable that tracks how many times this editor shifted the surface up.
Declaration
[DataMember]
public int TimesShiftedUp { get; set; }
Property Value
Type | Description |
---|---|
int |
UsePrintProcessor
When true, the Parser is used to generate a ColoredString before printing.
Declaration
[DataMember]
public bool UsePrintProcessor { get; set; }
Property Value
Type | Description |
---|---|
bool |
View
The visible portion of the surface.
Declaration
public Rectangle View { get; set; }
Property Value
Type | Description |
---|---|
Rectangle |
ViewHeight
Gets or sets the visible height of the surface in cells.
Declaration
public int ViewHeight { get; set; }
Property Value
Type | Description |
---|---|
int |
ViewPosition
The position of the view within the buffer.
Declaration
public Point ViewPosition { get; set; }
Property Value
Type | Description |
---|---|
Point |
ViewWidth
Gets or sets the visible width of the surface in cells.
Declaration
public int ViewWidth { get; set; }
Property Value
Type | Description |
---|---|
int |
Width
The total width of the surface.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
int |
Methods
GetEnumerator()
Gets an enumerator for Cells.
Declaration
public IEnumerator<ColoredGlyphBase> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<ColoredGlyphBase> | An enumerator for Cells. |
OnCellsReset()
Called when the Cells property is reset.
Declaration
protected virtual void OnCellsReset()
OnIsDirtyChanged()
Called when the IsDirty property changes.
Declaration
protected virtual void OnIsDirtyChanged()
Resize(int, int, bool)
Resizes the surface and view to the specified width and height.
Declaration
public void Resize(int viewWidth, int viewHeight, bool clear)
Parameters
Type | Name | Description |
---|---|---|
int | viewWidth | |
int | viewHeight | |
bool | clear | When true, indicates each cell should be reset to the default values. |
Resize(int, int, int, int, bool)
Resizes the surface to the specified width and height.
Declaration
public void Resize(int viewWidth, int viewHeight, int bufferWidth, int bufferHeight, bool clear)
Parameters
Type | Name | Description |
---|---|---|
int | viewWidth | The viewable width of the surface. |
int | viewHeight | The viewable height of the surface. |
int | bufferWidth | The maximum width of the surface. |
int | bufferHeight | The maximum height of the surface. |
bool | clear | When true, indicates each cell should be reset to the default values. |
SetIsDirtySafe()
Sets IsDirty to true without triggering OnIsDirtyChanged().
Declaration
protected void SetIsDirtySafe()
SetSurface(ColoredGlyphBase[], int, int, int, int)
Changes the cells of the surface to the provided array.
Declaration
public void SetSurface(ColoredGlyphBase[] cells, int width, int height, int bufferWidth, int bufferHeight)
Parameters
Type | Name | Description |
---|---|---|
ColoredGlyphBase[] | cells | The cells to replace in this surface. |
int | width | The viewable width of the surface. |
int | height | The viewable height of the surface. |
int | bufferWidth | The maximum width of the surface. |
int | bufferHeight | The maximum height of the surface. |
SetSurface(ICellSurface, Rectangle)
Remaps the cells of this surface to a view of the surface
.
Declaration
public void SetSurface(ICellSurface surface, Rectangle view = default)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | surface | The target surface to map cells from. |
Rectangle | view | A view rectangle of the target surface. |
Events
IsDirtyChanged
An event that is raised when IsDirty changes.
Declaration
public event EventHandler? IsDirtyChanged
Event Type
Type | Description |
---|---|
EventHandler |