CellSurface Class
Definition
Section titled “Definition”An array of ColoredGlyphBase objects used to represent a 2D surface.
[DataContract][JsonObject(MemberSerialization = MemberSerialization.OptIn)]public class CellSurface : ICellSurface, IGridView<ColoredGlyphBase>, IEnumerable<ColoredGlyphBase>, IEnumerable, ISurface, ICellSurfaceResize, ICellSurfaceSettableInheritance object
Implements ICellSurface, IGridView<ColoredGlyphBase>, IEnumerable<ColoredGlyphBase>, IEnumerable, ISurface, ICellSurfaceResize, ICellSurfaceSettable
Constructors
Section titled “Constructors”CellSurface(int, int)
Section titled “CellSurface(int, int)”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.
public CellSurface(int width, int height)Parameters
Section titled “Parameters”width int
The width of the surface in cells.
height int
The height of the surface in cells.
CellSurface(int, int, ColoredGlyphBase[])
Section titled “CellSurface(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.
public CellSurface(int width, int height, ColoredGlyphBase[] initialCells)Parameters
Section titled “Parameters”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.
CellSurface(int, int, int, int)
Section titled “CellSurface(int, int, int, int)”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.
public CellSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight)Parameters
Section titled “Parameters”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.
public CellSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight, ColoredGlyphBase[]? initialCells)Parameters
Section titled “Parameters”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.
public CellSurface(IGridView<ColoredGlyphBase> surface, int visibleWidth = 0, int visibleHeight = 0)Parameters
Section titled “Parameters”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.
Fields
Section titled “Fields”_viewArea
Section titled “_viewArea”The width and height of the surface along with the viewable area.
[DataMember(Name = "AreaBounds")]protected BoundedRectangle _viewAreaProperties
Section titled “Properties”TimesShiftedDown
Section titled “TimesShiftedDown”A variable that tracks how many times this editor shifted the surface down.
[DataMember]public int TimesShiftedDown { get; set; }TimesShiftedRight
Section titled “TimesShiftedRight”A variable that tracks how many times this editor shifted the surface right.
[DataMember]public int TimesShiftedRight { get; set; }TimesShiftedLeft
Section titled “TimesShiftedLeft”A variable that tracks how many times this editor shifted the surface left.
[DataMember]public int TimesShiftedLeft { get; set; }TimesShiftedUp
Section titled “TimesShiftedUp”A variable that tracks how many times this editor shifted the surface up.
[DataMember]public int TimesShiftedUp { get; set; }UsePrintProcessor
Section titled “UsePrintProcessor”When true, the Parser is used to generate a ColoredString before printing.
[DataMember]public bool UsePrintProcessor { get; set; }Surface
Section titled “Surface”Returns this object.
[IgnoreDataMember]public ICellSurface Surface { get; }Effects
Section titled “Effects”Processes the effects added to cells with CellSurfaceEditor.SetEffect*.
[IgnoreDataMember]public EffectsManager Effects { get; protected set; }IsDirty
Section titled “IsDirty”Indicates the surface has changed and needs to be rendered.
public bool IsDirty { get; set; }DefaultForeground
Section titled “DefaultForeground”The default foreground for glyphs on this surface.
[DataMember]public Color DefaultForeground { get; set; }DefaultBackground
Section titled “DefaultBackground”The default background for glyphs on this surface.
[DataMember]public Color DefaultBackground { get; set; }DefaultGlyph
Section titled “DefaultGlyph”The default glyph used in clearing and erasing.
[DataMember]public int DefaultGlyph { get; set; }The visible portion of the surface.
public Rectangle View { get; set; }ViewWidth
Section titled “ViewWidth”Gets or sets the visible width of the surface in cells.
public int ViewWidth { get; set; }ViewHeight
Section titled “ViewHeight”Gets or sets the visible height of the surface in cells.
public int ViewHeight { get; set; }Returns a rectangle that represents the entire size of the surface.
public Rectangle Area { get; }The total width of the surface.
public int Width { get; }Height
Section titled “Height”The total height of the surface.
public int Height { get; }IsScrollable
Section titled “IsScrollable”Returns true when the View width or height is different from Area; otherwise false.
public bool IsScrollable { get; }ViewPosition
Section titled “ViewPosition”The position of the view within the buffer.
public Point ViewPosition { get; set; }[DataMember]public ColoredGlyphBase[] Cells { get; protected set; }The count of glyphs this surface contains.
public int Count { get; }this[int, int]
Section titled “this[int, int]”public ColoredGlyphBase this[int x, int y] { get; protected set; }this[int]
Section titled “this[int]”public ColoredGlyphBase this[int index] { get; protected set; }this[Point]
Section titled “this[Point]”public ColoredGlyphBase this[Point position] { get; protected set; }this[Range]
Section titled “this[Range]”Given a position, returns the “value” associated with that location.
public Span<ColoredGlyphBase> this[Range range] { get; }Methods
Section titled “Methods”Resize(int, int, bool)
Section titled “Resize(int, int, bool)”Resizes the surface and view to the specified width and height. This can destroy the original backing array.
public void Resize(int viewWidth, int viewHeight, bool clear)Parameters
Section titled “Parameters”viewWidth int
viewHeight int
clear bool
When true, indicates each cell should be reset to the default values.
Resize(int, int, int, int, bool)
Section titled “Resize(int, int, int, int, bool)”Resizes the surface to the specified width and height. This can destroy the original backing array.
public void Resize(int viewWidth, int viewHeight, int totalWidth, int totalHeight, bool clear)Parameters
Section titled “Parameters”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.
SetSurface(ICellSurface, Rectangle)
Section titled “SetSurface(ICellSurface, Rectangle)”Remaps the cells of this surface to a view of the surface.
public void SetSurface(ICellSurface surface, Rectangle view = default)Parameters
Section titled “Parameters”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.
public void SetSurface(ColoredGlyphBase[] cells, int width, int height, int bufferWidth, int bufferHeight)Parameters
Section titled “Parameters”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.
SetIsDirtySafe()
Section titled “SetIsDirtySafe()”Sets IsDirty to true without triggering OnIsDirtyChanged().
protected void SetIsDirtySafe()OnIsDirtyChanged()
Section titled “OnIsDirtyChanged()”Called when the IsDirty property changes.
protected virtual void OnIsDirtyChanged()OnCellsReset()
Section titled “OnCellsReset()”Called when the Cells property is reset.
protected virtual void OnCellsReset()GetEnumerator()
Section titled “GetEnumerator()”Gets an enumerator for Cells.
public IEnumerator<ColoredGlyphBase> GetEnumerator()Returns
Section titled “Returns”IEnumerator<ColoredGlyphBase>
An enumerator for Cells.
Events
Section titled “Events”IsDirtyChanged
Section titled “IsDirtyChanged”An event that is raised when IsDirty changes.
public event EventHandler? IsDirtyChanged