Window Class
Definition
Section titled “Definition”Represents a windowed controls console.
[DataContract][JsonObject(MemberSerialization.OptIn)]public class Window : Console, IDisposable, IScreenSurfaceEditable, IScreenSurface, IScreenObject, IPositionable, IComponentHost, ISurface, ISurfaceSettable, ICellSurfaceResize, IWindowDataInheritance object → ScreenObject → ScreenSurface → Console
Implements IDisposable, IScreenSurfaceEditable, IScreenSurface, IScreenObject, SadRogue.Primitives.IPositionable, IComponentHost, ISurface, ISurfaceSettable, ICellSurfaceResize, IWindowData
Constructors
Section titled “Constructors”Window(int, int)
Section titled “Window(int, int)”Creates a new window.
public Window(int width, int height)Parameters
Section titled “Parameters”width int
The width in cells of the surface.
height int
The height in cells of the surface.
Window(int, int, ColoredGlyphBase[]?)
Section titled “Window(int, int, ColoredGlyphBase[]?)”Creates a new screen object that can render a surface. Uses the specified cells to generate the surface.
public Window(int width, int height, ColoredGlyphBase[]? initialCells)Parameters
Section titled “Parameters”width int
The width in cells of the surface.
height int
The height in cells of the surface.
initialCells ColoredGlyphBase[]
The initial cells to seed the surface.
Window(int, int, int, int)
Section titled “Window(int, int, int, int)”Creates a new window with the specified width and height, with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.
public Window(int width, int height, int bufferWidth, int bufferHeight)Parameters
Section titled “Parameters”width int
The visible width of the window in cells.
height int
The visible height of the window in cells.
bufferWidth int
The total width of the window in cells.
bufferHeight int
The total height of the window in cells.
Window(int, int, int, int, ColoredGlyphBase[]?)
Section titled “Window(int, int, int, int, ColoredGlyphBase[]?)”Creates a window with the specified width and height, with SadRogue.Primitives.Color.Transparent for the background and SadRogue.Primitives.Color.White for the foreground.
public Window(int width, int height, int bufferWidth, int bufferHeight, ColoredGlyphBase[]? initialCells)Parameters
Section titled “Parameters”width int
The width of the window in cells.
height int
The height of the window in cells.
bufferWidth int
The total width of the window in cells.
bufferHeight int
The total height of the window in cells.
initialCells ColoredGlyphBase[]
The cells to seed the window with. If null, creates the cells for you.
Window(ICellSurface, IFont?, Point?)
Section titled “Window(ICellSurface, IFont?, Point?)”Creates a new window using the existing surface.
public Window(ICellSurface surface, IFont? font = null, Point? fontSize = null)Parameters
Section titled “Parameters”surface ICellSurface
The surface.
font IFont
The font to use with the surface.
fontSize System.NullableSadRogue.Primitives.Point
The font size.
Fields
Section titled “Fields”PreviousMouseLeftButtonDown
Section titled “PreviousMouseLeftButtonDown”The mouse state of the previous update frame.
protected bool PreviousMouseLeftButtonDownProperties
Section titled “Properties”Controls
Section titled “Controls”The controls host holding all the controls.
public ControlHost Controls { get; }TitleAreaY
Section titled “TitleAreaY”The Y coordinate of the title drawing area. This can be set to any value > 0 and < the height.
[DataMember]public int TitleAreaY { get; set; }TitleAreaX
Section titled “TitleAreaX”The X coordinate of the title drawing area. This is automatically set by the theme.
[DataMember]public int TitleAreaX { get; set; }TitleAreaLength
Section titled “TitleAreaLength”The width of the title drawing area. This is automatically set by the theme.
[DataMember]public int TitleAreaLength { get; set; }BorderLineStyle
Section titled “BorderLineStyle”The line style for the border.
[DataMember]public int[] BorderLineStyle { get; set; }CellAtDragPosition
Section titled “CellAtDragPosition”The position of the cell that the window drag started at.
[IgnoreDataMember]protected Point CellAtDragPosition { get; set; }PreviousMouseExclusiveDrag
Section titled “PreviousMouseExclusiveDrag”Temporary value to hold the state of IsExclusiveMouse prior to dragging.
[IgnoreDataMember]protected bool PreviousMouseExclusiveDrag { get; set; }AddedToParent
Section titled “AddedToParent”When true, indicates that the window has been added to a parent; otherwise false.
[IgnoreDataMember]protected bool AddedToParent { get; set; }IsDragging
Section titled “IsDragging”When true, indicates that the window is being dragged; otherwise false.
[IgnoreDataMember]protected bool IsDragging { get; set; }TitleAlignment
Section titled “TitleAlignment”Gets or sets the alignment of the window title.
[DataMember]public HorizontalAlignment TitleAlignment { get; set; }IsModal
Section titled “IsModal”Gets the whether or not the window is being shown as modal.
[IgnoreDataMember]public bool IsModal { get; }CanDrag
Section titled “CanDrag”Gets or sets whether or not this window can be moved with the mouse.
[DataMember]public bool CanDrag { get; set; }CloseOnEscKey
Section titled “CloseOnEscKey”Gets or sets whether or not this window can be closed when the escape key is pressed.
[DataMember]public bool CloseOnEscKey { get; set; }DialogResult
Section titled “DialogResult”Gets or set the dialog result status of the window.
[DataMember]public bool DialogResult { get; set; }IsModalDefault
Section titled “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.
[DataMember]public bool IsModalDefault { get; set; }Gets or sets the title displayed on the window.
public string Title { get; set; }Methods
Section titled “Methods”ProcessMouse(MouseScreenObjectState)
Section titled “ProcessMouse(MouseScreenObjectState)”Processes the mouse.
public override 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..
DrawBorder()
Section titled “DrawBorder()”protected virtual void DrawBorder()ProcessKeyboard(Keyboard)
Section titled “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.
public override bool ProcessKeyboard(Keyboard info)Parameters
Section titled “Parameters”info Keyboard
Keyboard state.
Returns
Section titled “Returns”OnVisibleChanged()
Section titled “OnVisibleChanged()”Depending on if the window is visible, calls Show(bool) or Hide().
protected override void OnVisibleChanged()OnShown()
Section titled “OnShown()”User-definable code called when the window is shown.
protected virtual void OnShown()OnHidden()
Section titled “OnHidden()”User-definable code called when the window is hidden.
protected virtual void OnHidden()Show()
Section titled “Show()”Displays this window using the modal value of the IsModalDefault property.
public void Show()Show(bool)
Section titled “Show(bool)”Displays this window.
public virtual void Show(bool modal)Parameters
Section titled “Parameters”modal bool
When true, the window will be displayed as modal; otherwise false.
Hide()
Section titled “Hide()”Hides the window.
public virtual void Hide()Center()
Section titled “Center()”Centers the window within the bounds of RenderWidth and RenderHeight
public void Center()ToString()
Section titled “ToString()”Returns the value “Window”.
public override string ToString()Returns
Section titled “Returns”string
The string “Window”.
Ask(string, string, string, Action<bool, string>?, Validator?, string?, Colors?)
Section titled “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.
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
Section titled “Parameters”message string
The message to print in the window.
acceptPrompt string
The text of the accept button.
cancelPrompt string
The text of the cancel button.
closedCallback Action<bool, string>
A delegate called when the window is closed.
validator StringValidation.Validator
An optional validator to validate the input text.
defaultValue string
An optional default value of the input text box.
colors Colors
An optional set of colors to apply to the window.
Ask(ColoredString, string, string, Action<bool, string>?, Validator?, string?, Colors?)
Section titled “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.
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
Section titled “Parameters”message ColoredString
The message to print in the window.
acceptPrompt string
The text of the accept button.
cancelPrompt string
The text of the cancel button.
closedCallback Action<bool, string>
A delegate called when the window is closed.
validator StringValidation.Validator
An optional validator to validate the input text.
defaultValue string
An optional default value of the input text box.
colors Colors
An optional set of colors to apply to the window.
Prompt(string, string, string, Action<bool>?, Colors?)
Section titled “Prompt(string, string, string, Action<bool>?, Colors?)”Shows a window prompt with two buttons for the user to click.
public static void Prompt(string message, string yesPrompt, string noPrompt, Action<bool>? closedCallback, Colors? colors = null)Parameters
Section titled “Parameters”message string
The text to display.
yesPrompt string
The yes button’s text.
noPrompt string
The no button’s text.
closedCallback Action<bool>
Callback with the yes (true) or no (false) result.
colors Colors
The colors to apply for the message box and buttons. If null.
Prompt(ColoredString, string, string, Action<bool>?, Colors?)
Section titled “Prompt(ColoredString, string, string, Action<bool>?, Colors?)”Shows a window prompt with two buttons for the user to click.
public static void Prompt(ColoredString message, string yesPrompt, string noPrompt, Action<bool>? closedCallback, Colors? colors = null)Parameters
Section titled “Parameters”message ColoredString
The text to display. (background color is ignored)
yesPrompt string
The yes button’s text.
noPrompt string
The no button’s text.
closedCallback Action<bool>
Callback with the yes (true) or no (false) result.
colors Colors
The colors to apply for the message box and buttons. If null.
Message(string, string, Action?, Colors?)
Section titled “Message(string, string, Action?, Colors?)”Displays a dialog to the user with a specific message.
public static void Message(string message, string closeButtonText, Action? closedCallback = null, Colors? colors = null)Parameters
Section titled “Parameters”message string
The message.
closeButtonText string
The text of the dialog’s close button.
closedCallback Action
A callback indicating the message was dismissed.
colors Colors
The colors to apply for the message box and buttons. If null.
Message(ColoredString, string, Action?, Colors?)
Section titled “Message(ColoredString, string, Action?, Colors?)”Displays a dialog to the user with a specific message.
public static void Message(ColoredString message, string closeButtonText, Action? closedCallback = null, Colors? colors = null)Parameters
Section titled “Parameters”message ColoredString
The message. (background color is ignored)
closeButtonText string
The text of the dialog’s close button.
closedCallback Action
A callback indicating the message was dismissed.
colors Colors
The colors to apply for the message box and buttons. If null.
Events
Section titled “Events”Closed
Section titled “Closed”Raised when the window is closed.
public event EventHandler? ClosedEvent Type
Section titled “Event Type”Raised when the window is shown.
public event EventHandler? Shown