Show / Hide Table of Contents

Class CellSurface

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

Inheritance
object
CellSurface
Implements
ICellSurface
IGridView<ColoredGlyphBase>
IEnumerable<ColoredGlyphBase>
IEnumerable
ISurface
ICellSurfaceResize
ICellSurfaceSettable
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
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 0, the view width matches the width of the surface.

int visibleHeight

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

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

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

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
Type Name Description
int x
int y
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

Implements

ICellSurface
IGridView<T>
IEnumerable<T>
IEnumerable
ISurface
ICellSurfaceResize
ICellSurfaceSettable

Extension Methods

CellSurfaceEditor.PrintTheDraw(ICellSurface, int, int, string, TheDrawFont)
CellSurfaceEditor.PrintTheDraw(ICellSurface, int, string, TheDrawFont, HorizontalAlignment, int)
CellSurfaceEditor.AddDecorator(ISurface, Point, params CellDecorator[])
CellSurfaceEditor.AddDecorator(ISurface, int, params CellDecorator[]?)
CellSurfaceEditor.AddDecorator(ISurface, int, int, params CellDecorator[])
CellSurfaceEditor.AddDecorator(ISurface, int, int, int, params CellDecorator[])
CellSurfaceEditor.Clear(ISurface)
CellSurfaceEditor.Clear(ISurface, Rectangle)
CellSurfaceEditor.Clear(ISurface, IEnumerable<Point>)
CellSurfaceEditor.Clear(ISurface, int, int)
CellSurfaceEditor.Clear(ISurface, int, int, int)
CellSurfaceEditor.ClearDecorators(ISurface, int, int)
CellSurfaceEditor.ClearDecorators(ISurface, int, int, int)
CellSurfaceEditor.ClearShiftValues(ISurface)
CellSurfaceEditor.ConnectLines(ISurface)
CellSurfaceEditor.ConnectLines(ISurface, int[])
CellSurfaceEditor.ConnectLines(ISurface, int[], Rectangle)
CellSurfaceEditor.Copy(ISurface, ICellSurface)
CellSurfaceEditor.Copy(ISurface, ICellSurface, int, int)
CellSurfaceEditor.Copy(ISurface, Rectangle, ICellSurface, int, int)
CellSurfaceEditor.Copy(ISurface, int, int, int, int, ICellSurface, int, int)
CellSurfaceEditor.DrawBox(ISurface, Rectangle, ShapeParameters)
CellSurfaceEditor.DrawCircle(ISurface, Rectangle, ShapeParameters)
CellSurfaceEditor.DrawLine(ISurface, Point, Point, int?, Color?, Color?, Mirror?)
CellSurfaceEditor.Erase(ISurface)
CellSurfaceEditor.Erase(ISurface, int, int)
CellSurfaceEditor.Erase(ISurface, int, int, int)
CellSurfaceEditor.Fill(ISurface, ColoredGlyphBase)
CellSurfaceEditor.Fill(ISurface, Rectangle, Color?, Color?, int?, Mirror?)
CellSurfaceEditor.Fill(ISurface, int, int, int, Color?, Color?, int?, Mirror?)
CellSurfaceEditor.Fill(ISurface, Color?, Color?, int?, Mirror?)
CellSurfaceEditor.FillWithRandomGarbage(ISurface, IFont)
CellSurfaceEditor.FillWithRandomGarbage(ISurface, int)
CellSurfaceEditor.FillWithRandomGarbage(ISurface, int, Rectangle)
CellSurfaceEditor.GetBackground(ISurface, int, int)
CellSurfaceEditor.GetCellAppearance(ISurface, int, int)
CellSurfaceEditor.GetCells(ISurface, Rectangle)
CellSurfaceEditor.GetEffect(ISurface, int)
CellSurfaceEditor.GetEffect(ISurface, int, int)
CellSurfaceEditor.GetForeground(ISurface, int, int)
CellSurfaceEditor.GetGlyph(ISurface, int, int)
CellSurfaceEditor.GetMirror(ISurface, int, int)
CellSurfaceEditor.GetString(ISurface, int, int)
CellSurfaceEditor.GetString(ISurface, int, int, int)
CellSurfaceEditor.GetStringColored(ISurface, int, int)
CellSurfaceEditor.GetStringColored(ISurface, int, int, int)
CellSurfaceEditor.GetSubSurface(ISurface)
CellSurfaceEditor.GetSubSurface(ISurface, Rectangle)
CellSurfaceEditor.IsValidCell(ISurface, int)
CellSurfaceEditor.IsValidCell(ISurface, int, int)
CellSurfaceEditor.IsValidCell(ISurface, int, int, out int)
CellSurfaceEditor.Print(ISurface, int, int, ColoredGlyphBase[])
CellSurfaceEditor.Print(ISurface, int, int, ColoredString)
CellSurfaceEditor.Print(ISurface, int, int, IEnumerable<ColoredGlyphBase>)
CellSurfaceEditor.Print(ISurface, int, int, string)
CellSurfaceEditor.Print(ISurface, int, int, string, ColoredGlyphBase, ICellEffect?)
CellSurfaceEditor.Print(ISurface, int, int, string, Mirror)
CellSurfaceEditor.Print(ISurface, int, int, string, Color)
CellSurfaceEditor.Print(ISurface, int, int, string, Color, Color)
CellSurfaceEditor.Print(ISurface, int, int, string, Color, Color, Mirror)
CellSurfaceEditor.Print(ISurface, int, int, string, Color, Color, Mirror, CellDecorator[])
CellSurfaceEditor.RemoveDecorator(ISurface, Point, params CellDecorator[])
CellSurfaceEditor.RemoveDecorator(ISurface, int, params CellDecorator[])
CellSurfaceEditor.RemoveDecorator(ISurface, int, int, params CellDecorator[])
CellSurfaceEditor.RemoveDecorator(ISurface, int, int, int, params CellDecorator[])
CellSurfaceEditor.SetBackground(ISurface, int, int, Color)
CellSurfaceEditor.SetCellAppearance(ISurface, int, int, ColoredGlyphBase)
CellSurfaceEditor.SetDecorator(ISurface, Point, params CellDecorator[]?)
CellSurfaceEditor.SetDecorator(ISurface, int, params CellDecorator[]?)
CellSurfaceEditor.SetDecorator(ISurface, int, int, params CellDecorator[]?)
CellSurfaceEditor.SetDecorator(ISurface, int, int, int, params CellDecorator[]?)
CellSurfaceEditor.SetEffect(ISurface, ColoredGlyphBase, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, IEnumerable<ColoredGlyphBase>, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, IEnumerable<Point>, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, IEnumerable<int>, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, int, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, int, int, ICellEffect?)
CellSurfaceEditor.SetForeground(ISurface, int, int, Color)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int, Color)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int, Color, Color)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int, Color, Color, Mirror)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int, Color, Color, Mirror, IEnumerable<CellDecorator>)
CellSurfaceEditor.SetMirror(ISurface, int, int, Mirror)
CellSurfaceEditor.SetPixels(ISurface, Color[])
CellSurfaceEditor.SetPixels(ISurface, Rectangle, Color[])
CellSurfaceEditor.ShiftColumn(ISurface, int, int, bool)
CellSurfaceEditor.ShiftColumn(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftColumnDown(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftColumnDownUnchecked(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftColumnUp(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftColumnUpUnchecked(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftDown(ISurface)
CellSurfaceEditor.ShiftDown(ISurface, int, bool)
CellSurfaceEditor.ShiftLeft(ISurface)
CellSurfaceEditor.ShiftLeft(ISurface, int, bool)
CellSurfaceEditor.ShiftRight(ISurface)
CellSurfaceEditor.ShiftRight(ISurface, int, bool)
CellSurfaceEditor.ShiftRow(ISurface, int, int, bool)
CellSurfaceEditor.ShiftRow(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftRowLeft(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftRowLeftUnchecked(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftRowRight(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftRowRightUnchecked(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftUp(ISurface)
CellSurfaceEditor.ShiftUp(ISurface, int, bool)
ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX