Class ScreenSurface
An object that renders a ICellSurface.
Inheritance
Implements
Inherited Members
Namespace: SadConsole
Assembly: SadConsole.dll
Syntax
[DataContract]
[JsonObject(MemberSerialization.OptIn)]
public class ScreenSurface : ScreenObject, IDisposable, IScreenSurfaceEditable, IScreenSurface, IScreenObject, IPositionable, IComponentHost, ISurface, ISurfaceSettable
Constructors
ScreenSurface(ICellSurface, IFont?, Point?)
Creates a new screen object wrapping an existing surface.
Declaration
[JsonConstructor]
public ScreenSurface(ICellSurface surface, IFont? font = null, Point? fontSize = null)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | surface | The surface. |
IFont | font | The font to use with the surface. |
Point? | fontSize | The font size. |
ScreenSurface(IGridView<ColoredGlyphBase>, int, int)
Creates a new surface from a grid view. The cells between this object and the grid view are shared.
Declaration
public ScreenSurface(IGridView<ColoredGlyphBase> surface, int visibleWidth = 0, int visibleHeight = 0)
Parameters
Type | Name | Description |
---|---|---|
IGridView<ColoredGlyphBase> | surface | The surface to use as the source of cells. |
int | visibleWidth | Optional view width. If |
int | visibleHeight | Optional view height. If |
ScreenSurface(int, int)
Creates a new screen object that can render a surface.
Declaration
public ScreenSurface(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
int | width | The width in cells of the surface. |
int | height | The height in cells of the surface. |
ScreenSurface(int, int, ColoredGlyphBase[])
Creates a new screen object that can render a surface. Uses the specified cells to generate the surface.
Declaration
public ScreenSurface(int width, int height, ColoredGlyphBase[] initialCells)
Parameters
Type | Name | Description |
---|---|---|
int | width | The width in cells of the surface. |
int | height | The height in cells of the surface. |
ColoredGlyphBase[] | initialCells | The initial cells to seed the surface. |
ScreenSurface(int, int, int, int)
Creates a new surface with the specified width and height, with Transparent for the background and White for the foreground.
Declaration
public ScreenSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight)
Parameters
Type | Name | Description |
---|---|---|
int | viewWidth | The visible width of the surface in cells. |
int | viewHeight | The visible height of the surface in cells. |
int | totalWidth | The total width of the surface in cells. |
int | totalHeight | The total height of the surface in cells. |
ScreenSurface(int, int, int, int, ColoredGlyphBase[]?)
Creates a new surface with the specified width and height, with Transparent for the background and White for the foreground.
Declaration
public ScreenSurface(int viewWidth, int viewHeight, int totalWidth, int totalHeight, ColoredGlyphBase[]? initialCells)
Parameters
Type | Name | Description |
---|---|---|
int | viewWidth | The width of the surface in cells to show. |
int | viewHeight | The height of the surface in cells to show. |
int | totalWidth | The total width of the surface in cells. |
int | totalHeight | The total height of the surface in cells. |
ColoredGlyphBase[] | initialCells | The cells to seed the surface with. If null, creates the cell array for you. |
Fields
IsMouseOver
Indicates that the mouse is currently over this console.
Declaration
protected bool IsMouseOver
Field Value
Type | Description |
---|---|
bool |
Properties
AbsoluteArea
The pixel area on the screen this surface occupies.
Declaration
public Rectangle AbsoluteArea { get; }
Property Value
Type | Description |
---|---|
Rectangle |
DefaultRendererName
The name of the default renderer for this object.
Declaration
public virtual string DefaultRendererName { get; }
Property Value
Type | Description |
---|---|
string |
FocusOnMouseClick
When true, this object will set IsFocused to true when the mouse is clicked.
Declaration
[DataMember]
public bool FocusOnMouseClick { get; set; }
Property Value
Type | Description |
---|---|
bool |
Font
Font used with rendering.
Declaration
public IFont Font { get; set; }
Property Value
Type | Description |
---|---|
IFont |
FontSize
The size of the Font cells applied to the object when rendering.
Declaration
public Point FontSize { get; set; }
Property Value
Type | Description |
---|---|
Point |
ForceRendererRefresh
Declaration
public bool ForceRendererRefresh { get; set; }
Property Value
Type | Description |
---|---|
bool |
Height
The total height of the console.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
int |
HeightPixels
The height of the surface in pixels.
Declaration
public int HeightPixels { get; }
Property Value
Type | Description |
---|---|
int |
IsDirty
Declaration
public bool IsDirty { get; set; }
Property Value
Type | Description |
---|---|
bool |
MoveToFrontOnMouseClick
When true, this object will move to the front of its parent object when the mouse is clicked.
Declaration
[DataMember]
public bool MoveToFrontOnMouseClick { get; set; }
Property Value
Type | Description |
---|---|
bool |
QuietSurfaceHandling
When true, prevents the Surface property from raising events and virtual methods when the surface changes.
Declaration
[DataMember]
public bool QuietSurfaceHandling { get; set; }
Property Value
Type | Description |
---|---|
bool |
Renderer
The renderer used to draw this surface.
Declaration
[DataMember]
[JsonConverter(typeof(RendererJsonConverter))]
public IRenderer? Renderer { get; protected set; }
Property Value
Type | Description |
---|---|
IRenderer |
Surface
The surface this screen object represents.
Declaration
public ICellSurface Surface { get; set; }
Property Value
Type | Description |
---|---|
ICellSurface |
Tint
A tint used in rendering.
Declaration
public Color Tint { get; set; }
Property Value
Type | Description |
---|---|
Color |
UsePixelPositioning
Treats the Position of the object as if it is pixels and not cells.
Declaration
public bool UsePixelPositioning { get; set; }
Property Value
Type | Description |
---|---|
bool |
ViewHeight
Gets or sets the visible height of the surface in cells.
Declaration
public int ViewHeight { get; set; }
Property Value
Type | Description |
---|---|
int |
ViewPosition
The position of the view within the console.
Declaration
public Point ViewPosition { get; set; }
Property Value
Type | Description |
---|---|
Point |
ViewWidth
Gets or sets the visible width of the surface in cells.
Declaration
public int ViewWidth { get; set; }
Property Value
Type | Description |
---|---|
int |
Width
The total width of the console.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
int |
WidthPixels
The width of the surface in pixels.
Declaration
public int WidthPixels { get; }
Property Value
Type | Description |
---|---|
int |
Methods
CallOnHostUpdated()
Calls the OnHostUpdated method on components, renderer, and rendersteps.
Declaration
public void CallOnHostUpdated()
Dispose()
Declaration
public void Dispose()
Dispose(bool)
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
bool | disposing |
~ScreenSurface()
Disposes Renderer.
Declaration
protected ~ScreenSurface()
LostMouse(MouseScreenObjectState)
Called when the mouse is being used by something else.
Declaration
public override void LostMouse(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | The current state of the mouse based on this object. |
Overrides
OnFontChanged(IFont, Point)
Declaration
protected virtual void OnFontChanged(IFont oldFont, Point oldFontSize)
Parameters
Type | Name | Description |
---|---|---|
IFont | oldFont | The font prior to the change. |
Point | oldFontSize | The font size prior to the change. |
OnIsDirtyChanged()
Called when the IsDirty property changes.
Declaration
protected virtual void OnIsDirtyChanged()
OnMouseEnter(MouseScreenObjectState)
Raises the MouseEnter event.
Declaration
protected virtual void OnMouseEnter(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | Current mouse state in relation to this console. |
OnMouseExit(MouseScreenObjectState)
Raises the MouseExit event.
Declaration
protected virtual void OnMouseExit(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | Current mouse state in relation to this console. |
OnMouseLeftClicked(MouseScreenObjectState)
Raises the MouseButtonClicked event. Possibly moves the console to the top of it's parent's children collection.
Declaration
protected virtual void OnMouseLeftClicked(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | Current mouse state in relation to this console. |
OnMouseMove(MouseScreenObjectState)
Raises the MouseMove event.
Declaration
protected virtual void OnMouseMove(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | Current mouse state in relation to this console. |
OnRendererChanged()
Called when the Renderer property is changed.
Declaration
protected virtual void OnRendererChanged()
OnRightMouseClicked(MouseScreenObjectState)
Raises the MouseButtonClicked event.
Declaration
protected virtual void OnRightMouseClicked(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | Current mouse state in relation to this console. |
OnSurfaceChanged(ICellSurface)
Called when the Surface property is changed.
Declaration
protected virtual void OnSurfaceChanged(ICellSurface oldSurface)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | oldSurface | The previous surface. |
ProcessMouse(MouseScreenObjectState)
Processes the mouse.
Declaration
public override bool ProcessMouse(MouseScreenObjectState state)
Parameters
Type | Name | Description |
---|---|---|
MouseScreenObjectState | state | The mouse state related to this object. |
Returns
Type | Description |
---|---|
bool | True when this object should halt further mouse processing.. |
Overrides
Render(TimeSpan)
Draws the Surface and all SadComponents and Children.
Declaration
public override void Render(TimeSpan delta)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | delta | The time that has elapsed since the last call. |
Overrides
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 viewable width of the surface. |
int | height | The viewable height of the surface. |
bool | clear | When true, resets every cell to the DefaultForeground, DefaultBackground and glyph 0. |
Resize(int, int, int, int, bool)
Resizes the surface to the specified width and height.
Declaration
public void Resize(int width, int height, int bufferWidth, int bufferHeight, bool clear)
Parameters
Type | Name | Description |
---|---|---|
int | width | The viewable width of the surface. |
int | height | The viewable height of the surface. |
int | bufferWidth | The maximum width of the surface. |
int | bufferHeight | The maximum height of the surface. |
bool | clear | When true, resets every cell to the DefaultForeground, DefaultBackground and glyph 0. |
ToString()
Returns the value "ScreenSurface".
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string "ScreenSurface". |
Overrides
Update(TimeSpan)
Updates the Surface effects and all SadComponents and Children.
Declaration
public override void Update(TimeSpan delta)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | delta | The time that has elapsed since this method was last called. |
Overrides
UpdateAbsolutePosition()
Sets a value for AbsolutePosition based on the Position of this instance and the Parent instance.
Declaration
public override void UpdateAbsolutePosition()
Overrides
Events
MouseButtonClicked
Raised when the a mouse button is clicked on this object.
Declaration
public event EventHandler<MouseScreenObjectState>? MouseButtonClicked
Event Type
Type | Description |
---|---|
EventHandler<MouseScreenObjectState> |
MouseEnter
Raised when the mouse enters this object.
Declaration
public event EventHandler<MouseScreenObjectState>? MouseEnter
Event Type
Type | Description |
---|---|
EventHandler<MouseScreenObjectState> |
MouseExit
Raised when the mouse exits this object.
Declaration
public event EventHandler<MouseScreenObjectState>? MouseExit
Event Type
Type | Description |
---|---|
EventHandler<MouseScreenObjectState> |
MouseMove
Raised when the mouse moves around the this object.
Declaration
public event EventHandler<MouseScreenObjectState>? MouseMove
Event Type
Type | Description |
---|---|
EventHandler<MouseScreenObjectState> |