Show / Hide Table of Contents

Class ScreenObjectCollection<TScreenObject>

Manages the parent and children relationship for IScreenObject.

Inheritance
object
ScreenObjectCollection<TScreenObject>
ScreenObjectCollection
Implements
IReadOnlyList<TScreenObject>
IReadOnlyCollection<TScreenObject>
IEnumerable<TScreenObject>
IEnumerable
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
public class ScreenObjectCollection<TScreenObject> : IReadOnlyList<TScreenObject>, IReadOnlyCollection<TScreenObject>, IEnumerable<TScreenObject>, IEnumerable where TScreenObject : class, IScreenObject
Type Parameters
Name Description
TScreenObject Manages the parent and children relationship for .

Constructors

ScreenObjectCollection(IScreenObject)

Creates a new object collection and parents it to the owner object.

Declaration
public ScreenObjectCollection(IScreenObject owner)
Parameters
Type Name Description
IScreenObject owner

The owning object of this collection.

Fields

_objects

Internal list of objects.

Declaration
protected List<TScreenObject> _objects
Field Value
Type Description
List<TScreenObject>

_owningObject

The parent object.

Declaration
protected IScreenObject _owningObject
Field Value
Type Description
IScreenObject

Properties

Count

Returns the total number of objects in this collection.

Declaration
public int Count { get; }
Property Value
Type Description
int

IsLocked

When true, the collection cannot be modified.

Declaration
public bool IsLocked { get; set; }
Property Value
Type Description
bool

this[int]

Gets or sets a child object for this collection.

Declaration
public TScreenObject this[int index] { get; set; }
Parameters
Type Name Description
int index

The index of the child object.

Property Value
Type Description
TScreenObject

The wanted object.

Methods

Add(TScreenObject)

Adds a new child object to this collection.

Declaration
public void Add(TScreenObject obj)
Parameters
Type Name Description
TScreenObject obj

The child object.

Exceptions
Type Condition
Exception

Thrown when the IsLocked property is set to true.

Clear()

Removes all consoles.

Declaration
public void Clear()

Contains(TScreenObject)

Returns true if this console list contains the specified obj.

Declaration
public bool Contains(TScreenObject obj)
Parameters
Type Name Description
TScreenObject obj

The console to search for.

Returns
Type Description
bool

GetEnumerator()

Declaration
public IEnumerator<TScreenObject> GetEnumerator()
Returns
Type Description
IEnumerator<TScreenObject>

IndexOf(TScreenObject)

Gets the 0-based index of the obj.

Declaration
public int IndexOf(TScreenObject obj)
Parameters
Type Name Description
TScreenObject obj

The child object.

Returns
Type Description
int

Insert(int, TScreenObject)

Inserts a child object at the specified index.

Declaration
public void Insert(int index, TScreenObject obj)
Parameters
Type Name Description
int index

The 0-based index to insert the object at.

TScreenObject obj

The child object.

Exceptions
Type Condition
Exception

Thrown when the IsLocked property is set to true.

IsBottom(TScreenObject)

When true, indicates that the obj is at the bottom of the collection stack.

Declaration
public bool IsBottom(TScreenObject obj)
Parameters
Type Name Description
TScreenObject obj

The obj object to check.

Returns
Type Description
bool

True when the object is on the bottom.

IsTop(TScreenObject)

When true, indicates that the obj is at the top of the collection stack.

Declaration
public bool IsTop(TScreenObject obj)
Parameters
Type Name Description
TScreenObject obj

The obj object to check.

Returns
Type Description
bool

True when the object is on the top.

MoveToBottom(TScreenObject)

Moves the specified obj to the bottom of the collection.

Declaration
public void MoveToBottom(TScreenObject obj)
Parameters
Type Name Description
TScreenObject obj

The child object.

MoveToTop(TScreenObject)

Moves the specified obj to the top of the collection.

Declaration
public void MoveToTop(TScreenObject obj)
Parameters
Type Name Description
TScreenObject obj

The child object.

Remove(TScreenObject)

Removes a new child object from this collection.

Declaration
public void Remove(TScreenObject obj)
Parameters
Type Name Description
TScreenObject obj

The child object.

Exceptions
Type Condition
Exception

Thrown when the IsLocked property is set to true.

Sort(IComparer<IScreenObject>)

Sorts the collection based on SortOrder.

Declaration
public void Sort(IComparer<IScreenObject> comparer)
Parameters
Type Name Description
IComparer<IScreenObject> comparer

The comparer to use

Exceptions
Type Condition
Exception

Thrown when the IsLocked property is set to true.

ToArray()

Copies the collections item to an array.

Declaration
public TScreenObject[] ToArray()
Returns
Type Description
TScreenObject[]

A new array consisting of all of the objects in this collection.

Events

CollectionChanged

Raised when the items in this collection are added, removed, or repositioned.

Declaration
public event EventHandler? CollectionChanged
Event Type
Type Description
EventHandler

Implements

IReadOnlyList<T>
IReadOnlyCollection<T>
IEnumerable<T>
IEnumerable

Extension Methods

ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX