ScreenObject Class
Definition
Section titled “Definition”A generic object processed by SadConsole. Provides parent/child, components, and position.
[DataContract][JsonObject(MemberSerialization.OptIn)]public class ScreenObject : IScreenObject, IPositionable, IComponentHostInheritance object
Implements IScreenObject, SadRogue.Primitives.IPositionable, IComponentHost
Constructors
Section titled “Constructors”ScreenObject()
Section titled “ScreenObject()”Creates a new instance of this class.
public ScreenObject()Fields
Section titled “Fields”ComponentsUpdate
Section titled “ComponentsUpdate”A filtered list from SadComponents where IsUpdate is true.
protected List<IComponent> ComponentsUpdateComponentsRender
Section titled “ComponentsRender”A filtered list from SadComponents where IsRender is true.
protected List<IComponent> ComponentsRenderComponentsMouse
Section titled “ComponentsMouse”A filtered list from SadComponents where IsMouse is true.
protected List<IComponent> ComponentsMouseComponentsKeyboard
Section titled “ComponentsKeyboard”A filtered list from SadComponents where IsKeyboard is true.
protected List<IComponent> ComponentsKeyboardComponentsEmpty
Section titled “ComponentsEmpty”A filtered list from SadComponents that is not set for update, render, mouse, or keyboard.
protected List<IComponent> ComponentsEmptyProperties
Section titled “Properties”SortOrder
Section titled “SortOrder”Indicates the sorting order this object should use when parented. Sorting is a manual operation on the Children collection.
[DataMember]public uint SortOrder { get; set; }Children
Section titled “Children”The child objects of this instance.
public ScreenObjectCollection Children { get; protected set; }Parent
Section titled “Parent”The parent object that this instance is a child of.
public IScreenObject? Parent { get; set; }Position
Section titled “Position”A position that is based on the current Position and Parent position, in pixels.
public Point Position { get; set; }AbsolutePosition
Section titled “AbsolutePosition”A position that’s based on the current SadRogue.Primitives.IPositionable.Position, as interpreted by the implementing class, in pixels.
public Point AbsolutePosition { get; protected set; }Remarks
Section titled “Remarks”Most objects will implement this property based on SadRogue.Primitives.IPositionable.Position which usually depends on the Parent object’s position.
IgnoreParentPosition
Section titled “IgnoreParentPosition”When true, this object should ignore it’s parent position when calculating AbsolutePosition; otherwise false.
[DataMember]public bool IgnoreParentPosition { get; set; }IsVisible
Section titled “IsVisible”Gets or sets the visibility of this object.
[DataMember]public bool IsVisible { get; set; }IsEnabled
Section titled “IsEnabled”Gets or sets the visibility of this object.
[DataMember]public bool IsEnabled { get; set; }IsFocused
Section titled “IsFocused”Gets or sets this console as the focused object for input.
public bool IsFocused { get; set; }FocusedMode
Section titled “FocusedMode”How the object should handle becoming active.
[DataMember]public FocusBehavior FocusedMode { get; set; }IsExclusiveMouse
Section titled “IsExclusiveMouse”Gets or sets whether or not this object has exclusive access to the mouse events.
[DataMember]public bool IsExclusiveMouse { get; set; }UseKeyboard
Section titled “UseKeyboard”When true, this object will use the keyboard; otherwise false.
[DataMember]public bool UseKeyboard { get; set; }UseMouse
Section titled “UseMouse”When true, this object will use the mouse; otherwise false.
[DataMember]public bool UseMouse { get; set; }SadComponents
Section titled “SadComponents”A collection of components processed by this console.
public ObservableCollection<IComponent> SadComponents { get; protected set; }Methods
Section titled “Methods”Render(TimeSpan)
Section titled “Render(TimeSpan)”Draws all SadComponents and Children.
public virtual void Render(TimeSpan delta)Parameters
Section titled “Parameters”delta TimeSpan
The time that has elapsed since the last call.
Remarks
Section titled “Remarks”Only processes if IsVisible is true.
Update(TimeSpan)
Section titled “Update(TimeSpan)”Updates all SadComponents and Children.
public virtual void Update(TimeSpan delta)Parameters
Section titled “Parameters”delta TimeSpan
The time that has elapsed since the last call.
Remarks
Section titled “Remarks”Only processes if IsEnabled is true.
ProcessKeyboard(Keyboard)
Section titled “ProcessKeyboard(Keyboard)”Called by the engine to process the keyboard.
public virtual bool ProcessKeyboard(Keyboard keyboard)Parameters
Section titled “Parameters”keyboard Keyboard
Keyboard information.
Returns
Section titled “Returns”bool
True when the keyboard had data and this console did something with it.
ProcessMouse(MouseScreenObjectState)
Section titled “ProcessMouse(MouseScreenObjectState)”Processes the mouse.
public virtual bool ProcessMouse(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
The mouse state related to this object.
Returns
Section titled “Returns”bool
True when this object should halt further mouse processing..
LostMouse(MouseScreenObjectState)
Section titled “LostMouse(MouseScreenObjectState)”Called when the mouse is being used by something else.
public virtual void LostMouse(MouseScreenObjectState state)Parameters
Section titled “Parameters”state MouseScreenObjectState
The current state of the mouse based on this object.
OnFocusLost()
Section titled “OnFocusLost()”Called when this object’s focus has been lost.
public virtual void OnFocusLost()OnFocused()
Section titled “OnFocused()”Called when this object is focused.
public virtual void OnFocused()OnParentChanged(IScreenObject?, IScreenObject?)
Section titled “OnParentChanged(IScreenObject?, IScreenObject?)”Raises the ParentChanged event.
protected virtual void OnParentChanged(IScreenObject? oldParent, IScreenObject? newParent)Parameters
Section titled “Parameters”oldParent IScreenObject
The previous parent.
newParent IScreenObject
The new parent.
OnPositionChanging(Point, Point)
Section titled “OnPositionChanging(Point, Point)”Raises the PositionChanging event.
protected virtual void OnPositionChanging(Point oldPosition, Point newPosition)Parameters
Section titled “Parameters”oldPosition SadRogue.Primitives.Point
The previous position.
newPosition SadRogue.Primitives.Point
The new position.
OnPositionChanged(Point, Point)
Section titled “OnPositionChanged(Point, Point)”Raises the PositionChanged event.
protected virtual void OnPositionChanged(Point oldPosition, Point newPosition)Parameters
Section titled “Parameters”oldPosition SadRogue.Primitives.Point
The previous position.
newPosition SadRogue.Primitives.Point
The new position.
OnVisibleChanged()
Section titled “OnVisibleChanged()”Called when the visibility of the object changes.
protected virtual void OnVisibleChanged()OnEnabledChanged()
Section titled “OnEnabledChanged()”Called when the paused status of the object changes.
protected virtual void OnEnabledChanged()UpdateAbsolutePosition()
Section titled “UpdateAbsolutePosition()”Sets a value for AbsolutePosition based on the SadRogue.Primitives.IPositionable.Position of this instance and the Parent instance.
public virtual void UpdateAbsolutePosition()ToString()
Section titled “ToString()”Returns the value “ScreenObject”.
public override string ToString()Returns
Section titled “Returns”string
The string “ScreenObject”.
GetSadComponents<TComponent>()
Section titled “GetSadComponents<TComponent>()”Gets components of the specified types.
public IEnumerable<TComponent> GetSadComponents<TComponent>() where TComponent : class, IComponentReturns
Section titled “Returns”IEnumerable<TComponent>
The components found.
GetSadComponent<TComponent>()
Section titled “GetSadComponent<TComponent>()”Gets the first component of the specified type.
public TComponent? GetSadComponent<TComponent>() where TComponent : class, IComponentReturns
Section titled “Returns”TComponent
The component if found, otherwise null.
HasSadComponent<TComponent>(out TComponent?)
Section titled “HasSadComponent<TComponent>(out TComponent?)”Indicates whether or not the component exists in the SadComponents collection.
public bool HasSadComponent<TComponent>(out TComponent? component) where TComponent : class, IComponentParameters
Section titled “Parameters”component TComponent
Returns
Section titled “Returns”bool
true when the component exists; otherwise false.
OnSadComponentAdded(IComponent)
Section titled “OnSadComponentAdded(IComponent)”Called when a component is added to the SadComponents collection.
protected virtual void OnSadComponentAdded(IComponent component)Parameters
Section titled “Parameters”component IComponent
The component added.
OnSadComponentRemoved(IComponent)
Section titled “OnSadComponentRemoved(IComponent)”Called when a component is removed from the SadComponents collection.
protected virtual void OnSadComponentRemoved(IComponent component)Parameters
Section titled “Parameters”component IComponent
The component removed.
SortComponents()
Section titled “SortComponents()”Sorts the components based on the SortOrder value.
public void SortComponents()Components_FilterAddItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)
Section titled “Components_FilterAddItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)”Adds a component to the provided collections, based on its configuration.
public static void Components_FilterAddItem(IComponent component, List<IComponent> componentsRender, List<IComponent> componentsUpdate, List<IComponent> componentsKeyboard, List<IComponent> componentsMouse, List<IComponent> componentsEmpty)Parameters
Section titled “Parameters”component IComponent
The component.
componentsRender List<IComponent>
The render collection.
componentsUpdate List<IComponent>
The update collection.
componentsKeyboard List<IComponent>
The keyboard collection.
componentsMouse List<IComponent>
The mouse collection.
componentsEmpty List<IComponent>
The empty collection.
Components_FilterRemoveItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)
Section titled “Components_FilterRemoveItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)”Removes a component to the provided collections, based on its configuration.
public static void Components_FilterRemoveItem(IComponent component, List<IComponent> componentsRender, List<IComponent> componentsUpdate, List<IComponent> componentsKeyboard, List<IComponent> componentsMouse, List<IComponent> componentsEmpty)Parameters
Section titled “Parameters”component IComponent
The component.
componentsRender List<IComponent>
The render collection.
componentsUpdate List<IComponent>
The update collection.
componentsKeyboard List<IComponent>
The keyboard collection.
componentsMouse List<IComponent>
The mouse collection.
componentsEmpty List<IComponent>
The empty collection.
Components_Sort(List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)
Section titled “Components_Sort(List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)”Helper to sort the components in the split collections.
public static void Components_Sort(List<IComponent> componentsRender, List<IComponent> componentsUpdate, List<IComponent> componentsKeyboard, List<IComponent> componentsMouse, List<IComponent> componentsEmpty)Parameters
Section titled “Parameters”componentsRender List<IComponent>
The render collection.
componentsUpdate List<IComponent>
The update collection.
componentsKeyboard List<IComponent>
The keyboard collection.
componentsMouse List<IComponent>
The mouse collection.
componentsEmpty List<IComponent>
The empty collection.
OnSerializingMethod(StreamingContext)
Section titled “OnSerializingMethod(StreamingContext)”Nothing.
[OnSerializing]protected void OnSerializingMethod(StreamingContext context)Parameters
Section titled “Parameters”context StreamingContext
Nothing.
Events
Section titled “Events”ParentChanged
Section titled “ParentChanged”Raised when the Parent property changes.
public event EventHandler<ValueChangedEventArgs<IScreenObject?>>? ParentChangedEvent Type
Section titled “Event Type”EventHandler<ValueChangedEventArgs<IScreenObject>>
PositionChanged
Section titled “PositionChanged”public event EventHandler<ValueChangedEventArgs<Point>>? PositionChangedEvent Type
Section titled “Event Type”EventHandler<ValueChangedEventArgs<Point>>
PositionChanging
Section titled “PositionChanging”public event EventHandler<ValueChangedEventArgs<Point>>? PositionChangingEvent Type
Section titled “Event Type”EventHandler<ValueChangedEventArgs<Point>>
IsVisibleChanged
Section titled “IsVisibleChanged”Raised when the IsVisible property changes.
public event EventHandler? IsVisibleChangedEvent Type
Section titled “Event Type”IsEnabledChanged
Section titled “IsEnabledChanged”Raised when the IsEnabled property changes.
public event EventHandler? IsEnabledChangedEvent Type
Section titled “Event Type”FocusLost
Section titled “FocusLost”Raised when the IsFocused property is false.
public event EventHandler? FocusLostEvent Type
Section titled “Event Type”Focused
Section titled “Focused”Raised when the IsFocused property is true.
public event EventHandler? Focused