Show / Hide Table of Contents

Class ScreenSurface

An object that renders a ICellSurface.

Inheritance
object
ScreenObject
ScreenSurface
Console
LayeredScreenSurface
Ansi1
PCBoot
Simple
Border
Implements
IDisposable
IScreenSurfaceEditable
IScreenSurface
IScreenObject
IPositionable
IComponentHost
ISurface
ISurfaceSettable
Inherited Members
ScreenObject.ComponentsUpdate
ScreenObject.ComponentsRender
ScreenObject.ComponentsMouse
ScreenObject.ComponentsKeyboard
ScreenObject.ComponentsEmpty
ScreenObject.ProcessKeyboard(Keyboard)
ScreenObject.OnFocusLost()
ScreenObject.OnFocused()
ScreenObject.OnParentChanged(IScreenObject, IScreenObject)
ScreenObject.OnPositionChanging(Point, Point)
ScreenObject.OnPositionChanged(Point, Point)
ScreenObject.OnVisibleChanged()
ScreenObject.OnEnabledChanged()
ScreenObject.GetSadComponents<TComponent>()
ScreenObject.GetSadComponent<TComponent>()
ScreenObject.HasSadComponent<TComponent>(out TComponent)
ScreenObject.OnSadComponentAdded(IComponent)
ScreenObject.OnSadComponentRemoved(IComponent)
ScreenObject.SortComponents()
ScreenObject.Components_FilterAddItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)
ScreenObject.Components_FilterRemoveItem(IComponent, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)
ScreenObject.Components_Sort(List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>, List<IComponent>)
ScreenObject.OnSerializingMethod(StreamingContext)
ScreenObject.SortOrder
ScreenObject.Children
ScreenObject.Parent
ScreenObject.Position
ScreenObject.AbsolutePosition
ScreenObject.IgnoreParentPosition
ScreenObject.IsVisible
ScreenObject.IsEnabled
ScreenObject.IsFocused
ScreenObject.FocusedMode
ScreenObject.IsExclusiveMouse
ScreenObject.UseKeyboard
ScreenObject.UseMouse
ScreenObject.SadComponents
ScreenObject.ParentChanged
ScreenObject.PositionChanged
ScreenObject.PositionChanging
ScreenObject.IsVisibleChanged
ScreenObject.IsEnabledChanged
ScreenObject.FocusLost
ScreenObject.Focused
object.GetType()
object.MemberwiseClone()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
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 0, the view width matches the width of the surface.

int visibleHeight

Optional view height. If 0, the view width matches the height of the surface.

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

When true, forces the Renderer to refresh the backing texture with the latest state of the object.

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

When true, indicates that the Surface needs to be redrawn; otherwise false.

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
ScreenObject.LostMouse(MouseScreenObjectState)

OnFontChanged(IFont, Point)

Called when the Font or FontSize property changes.

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
ScreenObject.ProcessMouse(MouseScreenObjectState)

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
ScreenObject.Render(TimeSpan)

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
ScreenObject.ToString()

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
ScreenObject.Update(TimeSpan)

UpdateAbsolutePosition()

Sets a value for AbsolutePosition based on the Position of this instance and the Parent instance.

Declaration
public override void UpdateAbsolutePosition()
Overrides
ScreenObject.UpdateAbsolutePosition()

Events

MouseButtonClicked

Raised when 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>

Implements

IDisposable
IScreenSurfaceEditable
IScreenSurface
IScreenObject
IPositionable
IComponentHost
ISurface
ISurfaceSettable

Extension Methods

Keyboard.RemoveKeyboardHook(IScreenObject, Func<IScreenObject, Keyboard, bool>)
Keyboard.RemoveKeyboardHooks(IScreenObject)
Keyboard.WithKeyboard(IScreenObject, Func<IScreenObject, Keyboard, bool>)
Mouse.RemoveMouseHook(IScreenObject, Func<IScreenObject, MouseScreenObjectState, bool>)
Mouse.RemoveMouseHooks(IScreenObject)
Mouse.WithMouse(IScreenObject, Func<IScreenObject, MouseScreenObjectState, bool>)
Update.RemoveUpdateHook(IScreenObject, Action<IScreenObject, TimeSpan>)
Update.RemoveUpdateHooks(IScreenObject)
Update.WithUpdate(IScreenObject, Action<IScreenObject, TimeSpan>)
CellSurfaceEditor.AddDecorator(ISurface, Point, params CellDecorator[])
CellSurfaceEditor.AddDecorator(ISurface, int, params CellDecorator[]?)
CellSurfaceEditor.AddDecorator(ISurface, int, int, params CellDecorator[])
CellSurfaceEditor.AddDecorator(ISurface, int, int, int, params CellDecorator[])
CellSurfaceEditor.Clear(ISurface)
CellSurfaceEditor.Clear(ISurface, Rectangle)
CellSurfaceEditor.Clear(ISurface, IEnumerable<Point>)
CellSurfaceEditor.Clear(ISurface, int, int)
CellSurfaceEditor.Clear(ISurface, int, int, int)
CellSurfaceEditor.ClearDecorators(ISurface, int, int)
CellSurfaceEditor.ClearDecorators(ISurface, int, int, int)
CellSurfaceEditor.ClearShiftValues(ISurface)
CellSurfaceEditor.ConnectLines(ISurface)
CellSurfaceEditor.ConnectLines(ISurface, int[])
CellSurfaceEditor.ConnectLines(ISurface, int[], Rectangle)
CellSurfaceEditor.Copy(ISurface, ICellSurface)
CellSurfaceEditor.Copy(ISurface, ICellSurface, int, int)
CellSurfaceEditor.Copy(ISurface, Rectangle, ICellSurface, int, int)
CellSurfaceEditor.Copy(ISurface, int, int, int, int, ICellSurface, int, int)
CellSurfaceEditor.DrawBox(ISurface, Rectangle, ShapeParameters)
CellSurfaceEditor.DrawCircle(ISurface, Rectangle, ShapeParameters)
CellSurfaceEditor.DrawLine(ISurface, Point, Point, int?, Color?, Color?, Mirror?)
CellSurfaceEditor.Erase(ISurface)
CellSurfaceEditor.Erase(ISurface, int, int)
CellSurfaceEditor.Erase(ISurface, int, int, int)
CellSurfaceEditor.Fill(ISurface, ColoredGlyphBase)
CellSurfaceEditor.Fill(ISurface, Rectangle, Color?, Color?, int?, Mirror?)
CellSurfaceEditor.Fill(ISurface, int, int, int, Color?, Color?, int?, Mirror?)
CellSurfaceEditor.Fill(ISurface, Color?, Color?, int?, Mirror?)
CellSurfaceEditor.FillWithRandomGarbage(ISurface, IFont)
CellSurfaceEditor.FillWithRandomGarbage(ISurface, int)
CellSurfaceEditor.FillWithRandomGarbage(ISurface, int, Rectangle)
CellSurfaceEditor.GetBackground(ISurface, int, int)
CellSurfaceEditor.GetCellAppearance(ISurface, int, int)
CellSurfaceEditor.GetCells(ISurface, Rectangle)
CellSurfaceEditor.GetEffect(ISurface, int)
CellSurfaceEditor.GetEffect(ISurface, int, int)
CellSurfaceEditor.GetForeground(ISurface, int, int)
CellSurfaceEditor.GetGlyph(ISurface, int, int)
CellSurfaceEditor.GetMirror(ISurface, int, int)
CellSurfaceEditor.GetString(ISurface, int, int)
CellSurfaceEditor.GetString(ISurface, int, int, int)
CellSurfaceEditor.GetStringColored(ISurface, int, int)
CellSurfaceEditor.GetStringColored(ISurface, int, int, int)
CellSurfaceEditor.GetSubSurface(ISurface)
CellSurfaceEditor.GetSubSurface(ISurface, Rectangle)
CellSurfaceEditor.IsValidCell(ISurface, int)
CellSurfaceEditor.IsValidCell(ISurface, int, int)
CellSurfaceEditor.IsValidCell(ISurface, int, int, out int)
CellSurfaceEditor.Print(ISurface, int, int, ColoredGlyphBase[])
CellSurfaceEditor.Print(ISurface, int, int, ColoredString)
CellSurfaceEditor.Print(ISurface, int, int, IEnumerable<ColoredGlyphBase>)
CellSurfaceEditor.Print(ISurface, int, int, string)
CellSurfaceEditor.Print(ISurface, int, int, string, ColoredGlyphBase, ICellEffect?)
CellSurfaceEditor.Print(ISurface, int, int, string, Mirror)
CellSurfaceEditor.Print(ISurface, int, int, string, Color)
CellSurfaceEditor.Print(ISurface, int, int, string, Color, Color)
CellSurfaceEditor.Print(ISurface, int, int, string, Color, Color, Mirror)
CellSurfaceEditor.Print(ISurface, int, int, string, Color, Color, Mirror, CellDecorator[])
CellSurfaceEditor.RemoveDecorator(ISurface, Point, params CellDecorator[])
CellSurfaceEditor.RemoveDecorator(ISurface, int, params CellDecorator[])
CellSurfaceEditor.RemoveDecorator(ISurface, int, int, params CellDecorator[])
CellSurfaceEditor.RemoveDecorator(ISurface, int, int, int, params CellDecorator[])
CellSurfaceEditor.SetBackground(ISurface, int, int, Color)
CellSurfaceEditor.SetCellAppearance(ISurface, int, int, ColoredGlyphBase)
CellSurfaceEditor.SetDecorator(ISurface, Point, params CellDecorator[]?)
CellSurfaceEditor.SetDecorator(ISurface, int, params CellDecorator[]?)
CellSurfaceEditor.SetDecorator(ISurface, int, int, params CellDecorator[]?)
CellSurfaceEditor.SetDecorator(ISurface, int, int, int, params CellDecorator[]?)
CellSurfaceEditor.SetEffect(ISurface, ColoredGlyphBase, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, IEnumerable<ColoredGlyphBase>, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, IEnumerable<Point>, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, IEnumerable<int>, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, int, ICellEffect?)
CellSurfaceEditor.SetEffect(ISurface, int, int, ICellEffect?)
CellSurfaceEditor.SetForeground(ISurface, int, int, Color)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int, Color)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int, Color, Color)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int, Color, Color, Mirror)
CellSurfaceEditor.SetGlyph(ISurface, int, int, int, Color, Color, Mirror, IEnumerable<CellDecorator>)
CellSurfaceEditor.SetMirror(ISurface, int, int, Mirror)
CellSurfaceEditor.SetPixels(ISurface, Color[])
CellSurfaceEditor.SetPixels(ISurface, Rectangle, Color[])
CellSurfaceEditor.ShiftColumn(ISurface, int, int, bool)
CellSurfaceEditor.ShiftColumn(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftColumnDown(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftColumnDownUnchecked(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftColumnUp(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftColumnUpUnchecked(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftDown(ISurface)
CellSurfaceEditor.ShiftDown(ISurface, int, bool)
CellSurfaceEditor.ShiftLeft(ISurface)
CellSurfaceEditor.ShiftLeft(ISurface, int, bool)
CellSurfaceEditor.ShiftRight(ISurface)
CellSurfaceEditor.ShiftRight(ISurface, int, bool)
CellSurfaceEditor.ShiftRow(ISurface, int, int, bool)
CellSurfaceEditor.ShiftRow(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftRowLeft(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftRowLeftUnchecked(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftRowRight(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftRowRightUnchecked(ISurface, int, int, int, int, bool)
CellSurfaceEditor.ShiftUp(ISurface)
CellSurfaceEditor.ShiftUp(ISurface, int, bool)
ExtensionsSystem.GetDebuggerDisplayValue(object)
In this article

Back to top

Back to top Generated by DocFX