Class Window
Represents a windowed controls console.
Inheritance
Implements
Inherited Members
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
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
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
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
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
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
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 |