Show / Hide Table of Contents

Class Window

Represents a windowed controls console.

Inheritance
object
ScreenObject
ScreenSurface
Console
Window
ColorPickerPopup
GlyphSelectPopup
OtherColorsPopup
Implements
IDisposable
IScreenSurfaceEditable
IScreenSurface
IScreenObject
IPositionable
IComponentHost
ISurface
ISurfaceSettable
IWindowData
Inherited Members
Console.OnFocusLost()
Console.OnFocused()
Console.Cursor
Console.AutoCursorOnFocus
ScreenSurface.IsMouseOver
ScreenSurface.Resize(int, int, int, int, bool)
ScreenSurface.Resize(int, int, bool)
ScreenSurface.UpdateAbsolutePosition()
ScreenSurface.Render(TimeSpan)
ScreenSurface.Update(TimeSpan)
ScreenSurface.OnIsDirtyChanged()
ScreenSurface.OnFontChanged(IFont, Point)
ScreenSurface.OnSurfaceChanged(ICellSurface)
ScreenSurface.OnRendererChanged()
ScreenSurface.CallOnHostUpdated()
ScreenSurface.Dispose(bool)
ScreenSurface.Dispose()
ScreenSurface.OnMouseEnter(MouseScreenObjectState)
ScreenSurface.OnMouseExit(MouseScreenObjectState)
ScreenSurface.OnMouseMove(MouseScreenObjectState)
ScreenSurface.OnMouseLeftClicked(MouseScreenObjectState)
ScreenSurface.OnRightMouseClicked(MouseScreenObjectState)
ScreenSurface.LostMouse(MouseScreenObjectState)
ScreenSurface.ForceRendererRefresh
ScreenSurface.DefaultRendererName
ScreenSurface.Renderer
ScreenSurface.QuietSurfaceHandling
ScreenSurface.Surface
ScreenSurface.IsDirty
ScreenSurface.Font
ScreenSurface.FontSize
ScreenSurface.Tint
ScreenSurface.AbsoluteArea
ScreenSurface.UsePixelPositioning
ScreenSurface.WidthPixels
ScreenSurface.HeightPixels
ScreenSurface.Width
ScreenSurface.Height
ScreenSurface.ViewWidth
ScreenSurface.ViewHeight
ScreenSurface.ViewPosition
ScreenSurface.MoveToFrontOnMouseClick
ScreenSurface.FocusOnMouseClick
ScreenSurface.MouseButtonClicked
ScreenSurface.MouseMove
ScreenSurface.MouseExit
ScreenSurface.MouseEnter
ScreenObject.ComponentsUpdate
ScreenObject.ComponentsRender
ScreenObject.ComponentsMouse
ScreenObject.ComponentsKeyboard
ScreenObject.ComponentsEmpty
ScreenObject.OnParentChanged(IScreenObject, IScreenObject)
ScreenObject.OnPositionChanging(Point, Point)
ScreenObject.OnPositionChanged(Point, Point)
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.UI
Assembly: SadConsole.dll
Syntax
[DataContract]
[JsonObject(MemberSerialization.OptIn)]
public class Window : Console, IDisposable, IScreenSurfaceEditable, IScreenSurface, IScreenObject, IPositionable, IComponentHost, ISurface, ISurfaceSettable, IWindowData

Constructors

Window(ICellSurface, IFont?, Point?)

Creates a new window using the existing surface.

Declaration
public Window(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.

Window(int, int)

Creates a new window.

Declaration
public Window(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.

Window(int, int, ColoredGlyphBase[]?)

Creates a new screen object that can render a surface. Uses the specified cells to generate the surface.

Declaration
public Window(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.

Window(int, int, int, int)

Creates a new window with the specified width and height, with Transparent for the background and White for the foreground.

Declaration
public Window(int width, int height, int bufferWidth, int bufferHeight)
Parameters
Type Name Description
int width

The visible width of the window in cells.

int height

The visible height of the window in cells.

int bufferWidth

The total width of the window in cells.

int bufferHeight

The total height of the window in cells.

Window(int, int, int, int, ColoredGlyphBase[]?)

Creates a window with the specified width and height, with Transparent for the background and White for the foreground.

Declaration
public Window(int width, int height, int bufferWidth, int bufferHeight, ColoredGlyphBase[]? initialCells)
Parameters
Type Name Description
int width

The width of the window in cells.

int height

The height of the window in cells.

int bufferWidth

The total width of the window in cells.

int bufferHeight

The total height of the window in cells.

ColoredGlyphBase[] initialCells

The cells to seed the window with. If null, creates the cells for you.

Fields

PreviousMouseLeftButtonDown

The mouse state of the previous update frame.

Declaration
protected bool PreviousMouseLeftButtonDown
Field Value
Type Description
bool

Properties

AddedToParent

When true, indicates that the window has been added to a parent; otherwise false.

Declaration
[IgnoreDataMember]
protected bool AddedToParent { get; set; }
Property Value
Type Description
bool

BorderLineStyle

The line style for the border.

Declaration
[DataMember]
public int[] BorderLineStyle { get; set; }
Property Value
Type Description
int[]

CanDrag

Gets or sets whether or not this window can be moved with the mouse.

Declaration
[DataMember]
public bool CanDrag { get; set; }
Property Value
Type Description
bool

CellAtDragPosition

The position of the cell that the window drag started at.

Declaration
[IgnoreDataMember]
protected Point CellAtDragPosition { get; set; }
Property Value
Type Description
Point

CloseOnEscKey

Gets or sets whether or not this window can be closed when the escape key is pressed.

Declaration
[DataMember]
public bool CloseOnEscKey { get; set; }
Property Value
Type Description
bool

Controls

The controls host holding all the controls.

Declaration
public ControlHost Controls { get; }
Property Value
Type Description
ControlHost

DialogResult

Gets or set the dialog result status of the window.

Declaration
[DataMember]
public bool DialogResult { get; set; }
Property Value
Type Description
bool

IsDragging

When true, indicates that the window is being dragged; otherwise false.

Declaration
[IgnoreDataMember]
protected bool IsDragging { get; set; }
Property Value
Type Description
bool

IsModal

Gets the whether or not the window is being shown as modal.

Declaration
[IgnoreDataMember]
public bool IsModal { get; }
Property Value
Type Description
bool

IsModalDefault

Indicates that when this window is shown by the Show() method or by setting the IsVisible property to true, the window will be shown as modal.

Declaration
[DataMember]
public bool IsModalDefault { get; set; }
Property Value
Type Description
bool

PreviousMouseExclusiveDrag

Temporary value to hold the state of IsExclusiveMouse prior to dragging.

Declaration
[IgnoreDataMember]
protected bool PreviousMouseExclusiveDrag { get; set; }
Property Value
Type Description
bool

Title

Gets or sets the title displayed on the window.

Declaration
public string Title { get; set; }
Property Value
Type Description
string

TitleAlignment

Gets or sets the alignment of the window title.

Declaration
[DataMember]
public HorizontalAlignment TitleAlignment { get; set; }
Property Value
Type Description
HorizontalAlignment

TitleAreaLength

The width of the title drawing area. This is automatically set by the theme.

Declaration
[DataMember]
public int TitleAreaLength { get; set; }
Property Value
Type Description
int

TitleAreaX

The X coordinate of the title drawing area. This is automatically set by the theme.

Declaration
[DataMember]
public int TitleAreaX { get; set; }
Property Value
Type Description
int

TitleAreaY

The Y coordinate of the title drawing area. This can be set to any value > 0 and < the height.

Declaration
[DataMember]
public int TitleAreaY { get; set; }
Property Value
Type Description
int

Methods

Ask(ColoredString, string, string, Action<bool, string>?, Validator?, string?, Colors?)

Displays a window with an input box and an optional validator, using a ColoredString as the prompt text.

Declaration
public static void Ask(ColoredString message, string acceptPrompt, string cancelPrompt, Action<bool, string>? closedCallback, StringValidation.Validator? validator = null, string? defaultValue = null, Colors? colors = null)
Parameters
Type Name Description
ColoredString message

The message to print in the window.

string acceptPrompt

The text of the accept button.

string cancelPrompt

The text of the cancel button.

Action<bool, string> closedCallback

A delegate called when the window is closed.

StringValidation.Validator validator

An optional validator to validate the input text.

string defaultValue

An optional default value of the input text box.

Colors colors

An optional set of colors to apply to the window.

Ask(string, string, string, Action<bool, string>?, Validator?, string?, Colors?)

Displays a window with an input box and an optional validator with a text prompt.

Declaration
public static void Ask(string message, string acceptPrompt, string cancelPrompt, Action<bool, string>? closedCallback, StringValidation.Validator? validator = null, string? defaultValue = null, Colors? colors = null)
Parameters
Type Name Description
string message

The message to print in the window.

string acceptPrompt

The text of the accept button.

string cancelPrompt

The text of the cancel button.

Action<bool, string> closedCallback

A delegate called when the window is closed.

StringValidation.Validator validator

An optional validator to validate the input text.

string defaultValue

An optional default value of the input text box.

Colors colors

An optional set of colors to apply to the window.

Center()

Centers the window within the bounds of RenderWidth and RenderHeight

Declaration
public void Center()

DrawBorder()

Declaration
protected virtual void DrawBorder()

Hide()

Hides the window.

Declaration
public virtual void Hide()

Message(ColoredString, string, Action?, Colors?)

Displays a dialog to the user with a specific message.

Declaration
public static void Message(ColoredString message, string closeButtonText, Action? closedCallback = null, Colors? colors = null)
Parameters
Type Name Description
ColoredString message

The message. (background color is ignored)

string closeButtonText

The text of the dialog's close button.

Action closedCallback

A callback indicating the message was dismissed.

Colors colors

The colors to apply for the message box and buttons. If null.

Message(string, string, Action?, Colors?)

Displays a dialog to the user with a specific message.

Declaration
public static void Message(string message, string closeButtonText, Action? closedCallback = null, Colors? colors = null)
Parameters
Type Name Description
string message

The message.

string closeButtonText

The text of the dialog's close button.

Action closedCallback

A callback indicating the message was dismissed.

Colors colors

The colors to apply for the message box and buttons. If null.

OnHidden()

User-definable code called when the window is hidden.

Declaration
protected virtual void OnHidden()

OnShown()

User-definable code called when the window is shown.

Declaration
protected virtual void OnShown()

OnVisibleChanged()

Depending on if the window is visible, calls Show(bool) or Hide().

Declaration
protected override void OnVisibleChanged()
Overrides
Console.OnVisibleChanged()

ProcessKeyboard(Keyboard)

Processes the keyboard looking for the ESC key press to close the window, if required. Otherwise the base ControlsConsole will process the keyboard.

Declaration
public override bool ProcessKeyboard(Keyboard info)
Parameters
Type Name Description
Keyboard info

Keyboard state.

Returns
Type Description
bool
Overrides
ScreenObject.ProcessKeyboard(Keyboard)

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

Prompt(ColoredString, string, string, Action<bool>?, Colors?)

Shows a window prompt with two buttons for the user to click.

Declaration
public static void Prompt(ColoredString message, string yesPrompt, string noPrompt, Action<bool>? closedCallback, Colors? colors = null)
Parameters
Type Name Description
ColoredString message

The text to display. (background color is ignored)

string yesPrompt

The yes button's text.

string noPrompt

The no button's text.

Action<bool> closedCallback

Callback with the yes (true) or no (false) result.

Colors colors

The colors to apply for the message box and buttons. If null.

Prompt(string, string, string, Action<bool>?, Colors?)

Shows a window prompt with two buttons for the user to click.

Declaration
public static void Prompt(string message, string yesPrompt, string noPrompt, Action<bool>? closedCallback, Colors? colors = null)
Parameters
Type Name Description
string message

The text to display.

string yesPrompt

The yes button's text.

string noPrompt

The no button's text.

Action<bool> closedCallback

Callback with the yes (true) or no (false) result.

Colors colors

The colors to apply for the message box and buttons. If null.

Show()

Displays this window using the modal value of the IsModalDefault property.

Declaration
public void Show()

Show(bool)

Displays this window.

Declaration
public virtual void Show(bool modal)
Parameters
Type Name Description
bool modal

When true, the window will be displayed as modal; otherwise false.

ToString()

Returns the value "Window".

Declaration
public override string ToString()
Returns
Type Description
string

The string "Window".

Overrides
Console.ToString()

Events

Closed

Raised when the window is closed.

Declaration
public event EventHandler? Closed
Event Type
Type Description
EventHandler

Shown

Raised when the window is shown.

Declaration
public event EventHandler? Shown
Event Type
Type Description
EventHandler

Implements

IDisposable
IScreenSurfaceEditable
IScreenSurface
IScreenObject
IPositionable
IComponentHost
ISurface
ISurfaceSettable
IWindowData

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