Class LayeredSurface
Manages a set of surface layers.
Implements
Inherited Members
Namespace: SadConsole.Components
Assembly: SadConsole.dll
Syntax
[DataContract]
public class LayeredSurface : UpdateComponent, IComponent, IList<ICellSurface>, ICollection<ICellSurface>, IEnumerable<ICellSurface>, IEnumerable, ICellSurfaceResize
Constructors
LayeredSurface()
Declaration
public LayeredSurface()
Fields
RenderStep
Internal use only
Declaration
public IRenderStep? RenderStep
Field Value
| Type | Description |
|---|---|
| IRenderStep |
_layers
The layers.
Declaration
[DataMember(Name = "Layers")]
protected List<ICellSurface> _layers
Field Value
| Type | Description |
|---|---|
| List<ICellSurface> |
_screen
The parent screen hosting this component.
Declaration
protected IScreenSurface? _screen
Field Value
| Type | Description |
|---|---|
| IScreenSurface |
_screenCachedView
A cached copy of the View of the hosting screen surface.
Declaration
protected Rectangle _screenCachedView
Field Value
| Type | Description |
|---|---|
| Rectangle |
Properties
Count
The numbers of layers.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
DefaultBackground
The default color to clear the rendering surface. This is used instead of the individual layer's default background.
Declaration
public Color DefaultBackground { get; set; }
Property Value
| Type | Description |
|---|---|
| Color |
IsAttached
Indicates that the entity renderer has been added to a parent object.
Declaration
protected bool IsAttached { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
IsReadOnly
Always returns false.
Declaration
public bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| bool |
this[int]
Gets or sets a layer by index.
Declaration
public ICellSurface this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the layer to get or set. |
Property Value
| Type | Description |
|---|---|
| ICellSurface | The layer. |
View
The visible portion of the surface layers.
Declaration
public Rectangle View { get; set; }
Property Value
| Type | Description |
|---|---|
| Rectangle |
Methods
Add(ICellSurface)
Adds a layer to this component.
Declaration
public void Add(ICellSurface layer)
Parameters
| Type | Name | Description |
|---|---|---|
| ICellSurface | layer | The layer to add. |
AddRange(IEnumerable<ICellSurface>)
Adds a collection if layers to this component.
Declaration
public void AddRange(IEnumerable<ICellSurface> layers)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ICellSurface> | layers | The layers to add. |
Clear()
Removes all layers.
Declaration
public void Clear()
Clear(ICellSurface)
Removes all layers and adds the initialLayer parameter as the first layer.
Declaration
public void Clear(ICellSurface initialLayer)
Parameters
| Type | Name | Description |
|---|---|---|
| ICellSurface | initialLayer | The new first layer. |
Contains(ICellSurface)
Declaration
public bool Contains(ICellSurface layer)
Parameters
| Type | Name | Description |
|---|---|---|
| ICellSurface | layer |
Returns
| Type | Description |
|---|---|
| bool |
CopyTo(ICellSurface[], int)
Declaration
public void CopyTo(ICellSurface[] array, int arrayIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| ICellSurface[] | array | |
| int | arrayIndex |
Create()
Adds a new layer. The layer is based on the first layer's width and height.
Declaration
public CellSurface Create()
Returns
| Type | Description |
|---|---|
| CellSurface |
Exceptions
| Type | Condition |
|---|---|
| Exception |
GetEnumerator()
Declaration
public IEnumerator<ICellSurface> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<ICellSurface> |
IndexOf(ICellSurface)
Returns the index of the specified layer.
Declaration
public int IndexOf(ICellSurface layer)
Parameters
| Type | Name | Description |
|---|---|---|
| ICellSurface | layer | The layer to search for. |
Returns
| Type | Description |
|---|---|
| int | The index of the layer. |
Insert(int, ICellSurface)
Inserts the layer at the specified index.
Declaration
public void Insert(int index, ICellSurface layer)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index to insert at. |
| ICellSurface | layer | The layer to insert. |
OnAdded(IScreenObject)
Called when the component is added to a host.
Declaration
public override void OnAdded(IScreenObject host)
Parameters
| Type | Name | Description |
|---|---|---|
| IScreenObject | host | The host that added the component. |
Overrides
OnRemoved(IScreenObject)
Called when the component is removed from the host.
Declaration
public override void OnRemoved(IScreenObject host)
Parameters
| Type | Name | Description |
|---|---|---|
| IScreenObject | host | The host that removed the component. |
Overrides
Remove(ICellSurface)
Removes a layer from this component.
Declaration
public bool Remove(ICellSurface layer)
Parameters
| Type | Name | Description |
|---|---|---|
| ICellSurface | layer | The layer to remove. |
Returns
| Type | Description |
|---|---|
| bool |
RemoveAt(int)
Removes a layer at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the layer to remove. |
Replace(ICellSurface, ICellSurface)
Replaces a layer with a new instance.
Declaration
public void Replace(ICellSurface oldLayer, ICellSurface newLayer)
Parameters
| Type | Name | Description |
|---|---|---|
| ICellSurface | oldLayer | The layer to remove. |
| ICellSurface | newLayer | The layer to add. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown when the old layer doesn't exist in this collection. - or - Thrown when the new layer already exists in this collection. - or - Thrown when the new layer isn't the same size as the other layers. |
Resize(int, int, bool)
Resizes the surface and view to the specified width and height.
Declaration
public void Resize(int width, int height, bool clear)
Parameters
| Type | Name | Description |
|---|---|---|
| int | width | The width of the surface and view. |
| int | height | The height of the surface and view. |
| bool | clear | When true, resets every cell to the DefaultForeground, DefaultBackground and glyph 0. |
Resize(int, int, int, int, bool)
Resizes each layer to the specified width and height.
Declaration
public void Resize(int viewWidth, int viewHeight, int totalWidth, int totalHeight, bool clear)
Parameters
| Type | Name | Description |
|---|---|---|
| int | viewWidth | The viewable width of the surface. |
| int | viewHeight | The viewable height of the surface. |
| int | totalWidth | The maximum width of the surface. |
| int | totalHeight | The maximum height of the surface. |
| bool | clear | When true, resets every cell to the DefaultForeground, DefaultBackground and glyph 0. |
Update(IScreenObject, TimeSpan)
Called by a host on the update frame.
Declaration
public override void Update(IScreenObject host, TimeSpan delta)
Parameters
| Type | Name | Description |
|---|---|---|
| IScreenObject | host | The host calling the component. |
| TimeSpan | delta | The time that has elapsed since this method was last called. |