Skip to content

SelectionSlotCollection

Namespace: SideXP.Selection

public class SelectionSlotCollection

Fixed-size list of numbered slots, each one containing a saved selection or being unassigned.

Constructors

SelectionSlotCollection()

public SelectionSlotCollection()

Creates a collection with DefaultCount unassigned slots.

SelectionSlotCollection(int)

public SelectionSlotCollection(int count)

Creates a collection with the given number of unassigned slots.

Parameters

  • count: The number of slots.

Fields

DefaultCount

public const int DefaultCount = 10

The default number of slots, matching the number keys of a keyboard.

Properties

Count

public int Count

The number of slots.

Methods

IsAssigned(int)

public bool IsAssigned(int index)

Checks if a selection is saved in the given slot.

Parameters

  • index: The index of the slot.

Returns

Returns true if the slot is assigned.

Exceptions

  • ArgumentOutOfRangeException: Thrown if the index is out of range.

Get(int)

public SelectionSnapshot Get(int index)

Gets the selection saved in the given slot.

Parameters

  • index: The index of the slot.

Returns

Returns the saved selection, or null if the slot is not assigned.

Exceptions

  • ArgumentOutOfRangeException: Thrown if the index is out of range.

Set(int, SelectionSnapshot)

public void Set(int index, SelectionSnapshot snapshot)

Saves a selection in the given slot, replacing the previous one if any.

Parameters

  • index: The index of the slot.
  • snapshot: The selection to save. If null or empty, the slot is unassigned.

Returns

Returns true if the slot is assigned.

Exceptions

  • ArgumentOutOfRangeException: Thrown if the index is out of range.

Clear(int)

public bool Clear(int index)

Unassigns the given slot.

Parameters

  • index: The index of the slot.

Returns

Returns true if the slot was assigned.

Exceptions

  • ArgumentOutOfRangeException: Thrown if the index is out of range.

ClearAll()

public void ClearAll()

Unassigns all the slots.

Resize(int)

public void Resize(int count)

Changes the number of slots. New slots are unassigned, and the last slots are discarded if the collection is shrunk.

Parameters

  • count: The new number of slots. Negative values are considered as 0.

Clean()

public bool Clean()

Removes the objects that don't exist anymore from the saved selections. A slot that becomes empty is unassigned.

Returns

Returns true if at least one object has been removed.

Remarks

The objects that don't have a stable id but are still resolved are refreshed, so they get one if possible (for example, an object selected in play mode that also exists in edit mode).

Refresh()

public void Refresh()

Captures again the identifiers of the objects that are still alive in all the slots.

Returns

Returns true if the identifiers have been captured again.

Remarks

Does nothing in play mode, so the stable ids captured in edit mode are not lost.