Skip to content

CellSurface Class

An array of ColoredGlyphBase objects used to represent a 2D surface.

C#
[DataContract]
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class CellSurface : ICellSurface, IGridView<ColoredGlyphBase>, IEnumerable<ColoredGlyphBase>, IEnumerable, ISurface, ICellSurfaceResize, ICellSurfaceSettable

Inheritance object

Implements ICellSurface, IGridView<ColoredGlyphBase>, IEnumerable<ColoredGlyphBase>, IEnumerable, ISurface, ICellSurfaceResize, ICellSurfaceSettable

Creates a new surface with the specified width and height, with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.

C#
public CellSurface(int width, int height)

width int
The width of the surface in cells.

height int
The height of the surface in cells.

Creates a new surface with the specified width and height, with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.

C#
public CellSurface(int width, int height, ColoredGlyphBase[] initialCells)

width int
The width of the surface in cells.

height int
The height of the surface in cells.

initialCells ColoredGlyphBase[]
The cells to seed the surface with. If null, creates the cell array for you.

Creates a new surface with the specified width and height, with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.

C#
public CellSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight)

viewWidth int
The visible width of the surface in cells.

viewHeight int
The visible height of the surface in cells.

totalWidth int
The total width of the surface in cells.

totalHeight int
The total height of the surface in cells.

CellSurface(int, int, int, int, ColoredGlyphBase[]?)

Section titled “CellSurface(int, int, int, int, ColoredGlyphBase[]?)”

Creates a new surface with the specified width and height, with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.

C#
public CellSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight, ColoredGlyphBase[]? initialCells)

viewWidth int
The width of the surface in cells.

viewHeight int
The height of the surface in cells.

totalWidth int
The total width of the surface in cells.

totalHeight int
The total height of the surface in cells.

initialCells ColoredGlyphBase[]
The cells to seed the surface with. If null, creates the cell array for you.

CellSurface(IGridView<ColoredGlyphBase>, int, int)

Section titled “CellSurface(IGridView<ColoredGlyphBase>, int, int)”

Creates a new surface from a grid view with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.

C#
public CellSurface(IGridView<ColoredGlyphBase> surface, int visibleWidth = 0, int visibleHeight = 0)

surface IGridView<ColoredGlyphBase>
The surface to use as the source of cells.

visibleWidth int
Optional view width. If 0, the view width matches the width of the surface.

visibleHeight int
Optional view height. If 0, the view width matches the height of the surface.

The width and height of the surface along with the viewable area.

C#
[DataMember(Name = "AreaBounds")]
protected BoundedRectangle _viewArea

A variable that tracks how many times this editor shifted the surface down.

C#
[DataMember]
public int TimesShiftedDown { get; set; }

A variable that tracks how many times this editor shifted the surface right.

C#
[DataMember]
public int TimesShiftedRight { get; set; }

A variable that tracks how many times this editor shifted the surface left.

C#
[DataMember]
public int TimesShiftedLeft { get; set; }

A variable that tracks how many times this editor shifted the surface up.

C#
[DataMember]
public int TimesShiftedUp { get; set; }

When true, the Parser is used to generate a ColoredString before printing.

C#
[DataMember]
public bool UsePrintProcessor { get; set; }

Returns this object.

C#
[IgnoreDataMember]
public ICellSurface Surface { get; }

Processes the effects added to cells with CellSurfaceEditor.SetEffect*.

C#
[IgnoreDataMember]
public EffectsManager Effects { get; protected set; }

Indicates the surface has changed and needs to be rendered.

C#
public bool IsDirty { get; set; }

The default foreground for glyphs on this surface.

C#
[DataMember]
public Color DefaultForeground { get; set; }

The default background for glyphs on this surface.

C#
[DataMember]
public Color DefaultBackground { get; set; }

The default glyph used in clearing and erasing.

C#
[DataMember]
public int DefaultGlyph { get; set; }

The visible portion of the surface.

C#
public Rectangle View { get; set; }

Gets or sets the visible width of the surface in cells.

C#
public int ViewWidth { get; set; }

Gets or sets the visible height of the surface in cells.

C#
public int ViewHeight { get; set; }

Returns a rectangle that represents the entire size of the surface.

C#
public Rectangle Area { get; }

The total width of the surface.

C#
public int Width { get; }

The total height of the surface.

C#
public int Height { get; }

Returns true when the View width or height is different from Area; otherwise false.

C#
public bool IsScrollable { get; }

The position of the view within the buffer.

C#
public Point ViewPosition { get; set; }
C#
[DataMember]
public ColoredGlyphBase[] Cells { get; protected set; }

The count of glyphs this surface contains.

C#
public int Count { get; }
C#
public ColoredGlyphBase this[int x, int y] { get; protected set; }
C#
public ColoredGlyphBase this[int index] { get; protected set; }
C#
public ColoredGlyphBase this[Point position] { get; protected set; }

Given a position, returns the “value” associated with that location.

C#
public Span<ColoredGlyphBase> this[Range range] { get; }

Resizes the surface and view to the specified width and height. This can destroy the original backing array.

C#
public void Resize(int viewWidth, int viewHeight, bool clear)

viewWidth int

viewHeight int

clear bool
When true, indicates each cell should be reset to the default values.

Resizes the surface to the specified width and height. This can destroy the original backing array.

C#
public void Resize(int viewWidth, int viewHeight, int totalWidth, int totalHeight, bool clear)

viewWidth int
The viewable width of the surface.

viewHeight int
The viewable height of the surface.

totalWidth int
The maximum width of the surface.

totalHeight int
The maximum height of the surface.

clear bool
When true, indicates each cell should be reset to the default values.

Remaps the cells of this surface to a view of the surface.

C#
public void SetSurface(ICellSurface surface, Rectangle view = default)

surface ICellSurface
The target surface to map cells from.

view SadRogue.Primitives.Rectangle
A view rectangle of the target surface.

SetSurface(ColoredGlyphBase[], int, int, int, int)

Section titled “SetSurface(ColoredGlyphBase[], int, int, int, int)”

Changes the cells of the surface to the provided array.

C#
public void SetSurface(ColoredGlyphBase[] cells, int width, int height, int bufferWidth, int bufferHeight)

cells ColoredGlyphBase[]
The cells to replace in this surface.

width int
The viewable width of the surface.

height int
The viewable height of the surface.

bufferWidth int
The maximum width of the surface.

bufferHeight int
The maximum height of the surface.

Sets IsDirty to true without triggering OnIsDirtyChanged().

C#
protected void SetIsDirtySafe()

Called when the IsDirty property changes.

C#
protected virtual void OnIsDirtyChanged()

Called when the Cells property is reset.

C#
protected virtual void OnCellsReset()

Gets an enumerator for Cells.

C#
public IEnumerator<ColoredGlyphBase> GetEnumerator()

IEnumerator<ColoredGlyphBase>
An enumerator for Cells.

An event that is raised when IsDirty changes.

C#
public event EventHandler? IsDirtyChanged

EventHandler