Skip to content

SelectionSlots

Namespace: SideXP.Selection

public static class SelectionSlots

Numbered slots where selections can be saved and restored later. The slots are personal, and saved on disk after each change.

Properties

Count

public static int Count

The number of slots.

Events

OnChanged

public static Action OnChanged

Called when a slot has been assigned, replaced, cleared or cleaned.

Methods

IsAssigned(int)

public static 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 static 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.

Assign(int)

public static bool Assign(int index)

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

Parameters

  • index: The index of the slot.

Returns

Returns true if the selection has been saved, or false if the current selection is empty.

Exceptions

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

Assign(int, IEnumerable<Object>, Object)

public static bool Assign(int index, IEnumerable<Object> objects, Object activeObject = null)

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

Parameters

  • index: The index of the slot.
  • objects: The objects to save. Null entries and duplicates are ignored.
  • activeObject: The active object of the selection. Ignored if it's not one of the given objects.

Returns

Returns true if the selection has been saved, or false if there's no object to save.

Exceptions

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

Assign(int, SelectionSnapshot)

public static bool Assign(int index, SelectionSnapshot snapshot)

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

Parameters

  • index: The index of the slot.
  • snapshot: The selection to save (for example, an entry of Entries).

Returns

Returns true if the selection has been saved, or false if it's empty.

Exceptions

  • ArgumentNullException: Thrown if the given snapshot is null.
  • ArgumentOutOfRangeException: Thrown if the index is out of range.

Remarks

Objects that can't be resolved (for example, objects in a scene that is not loaded) are saved as well, which is not the case when saving resolved objects with Assign.

Restore(int)

public static bool Restore(int index)

Selects the objects saved in the given slot. Objects that can't be resolved are skipped, and a warning is logged to list them.

Parameters

  • index: The index of the slot.

Returns

Returns true if the selection has been restored, or false if the slot is not assigned or none of its objects can be resolved.

Exceptions

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

AssignOrRestore(int)

public static bool AssignOrRestore(int index)

Restores the selection saved in the given slot if it's assigned, or saves the current selection in it otherwise.

Parameters

  • index: The index of the slot.

Returns

Returns true if the selection has been restored or saved.

Exceptions

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

Clear(int)

public static bool Clear(int index)

Unassigns the given slot.

Parameters

  • index: The index of the slot.

Returns

Returns true if the slot was assigned.

ClearAll()

public static void ClearAll()

Unassigns all the slots.

Clean()

public static 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.

RefreshReferences()

public static void RefreshReferences()

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