Window - ahatornn/clforms GitHub Wiki
ClForms.Elements.Window
Specifies the basic functionality of Window
public class Window: WindowContentControl, IElementStyle<Window>Inheritance Control -> ContentControl -> SingleContentControl -> WindowContentControl -> Window
Derived IElementStyle<Window>
The following example creates a new instance of a Form and calls the ShowDialog method to display the form as a dialog box.
public partial class MazeDimensionWindow: Window
{
public MazeDimensionWindow()
{
OnKeyPressed += KeyPressed;
}
…
private void KeyPressed(object sender, KeyPressedEventArgs e)
{
if (e.KeyInfo.Key == ConsoleKey.DownArrow)
{
…
}
…
}
…
}
…
var dialogWnd = new MazeDimensionWindow();
if (dialogWnd.ShowDialog() == DialogResult.OK)
{
…
}You can find more examples of using the TextBox in this project
A Window is a representation of any window displayed in your application. Using the properties available in the Window class, you can determine the appearance, size, color or dialog box you are creating. The Title property allows you to specify the caption of the window in the title bar.
In addition to properties, you can use the methods of the class to manipulate a form. For example, you can use the ShowDialog method to show a form as a modal dialog box.
| Syntax | Description |
|---|---|
| Window() | Initialize a new Window instance |
| Name | Type | Description |
|---|---|---|
| AutoSize | bool | Gets or sets a value indicating whether the control is resized in accordance with its contents |
| Background | Color | Gets or sets a brush that describes the background of a control |
| BackgroundIsTransparent | bool | Gets a value indicating whether the Background has Color.NotSet
|
| Bounds | Rect | Gets the size and location of the control including its nonclient elements, in points, relative to the parent control |
| Content | Control | Child control |
| DesiredSize | Size | Gets the size that this element computed during the measure pass of the layout process |
| DialogResult | DialogResult | Gets or sets the dialog result value, which is the value that is returned from the ShowDialog() method |
| DrawingContext | IDrawingContext | Gets a value of the drawing context |
| FocusableControl | IFocusableControl | Gets focused control |
| Foreground | Color | Gets or sets a brush that describes the text of a control |
| ForegroundIsTransparent | bool | Gets a value indicating whether the Foreground has Color.NotSet
|
| Height | int? | Gets or sets the height of the control |
| HideTitle | bool | Gets or sets a value that indicates whether a window should hide title text in the top |
| Id | long | Gets a value of the control's identifier |
| IsMeasureValid | bool | Gets a value indicating whether component sizing was performed |
| IsVisualValid | bool | Gets a value indicating whether the component is being re-rendered |
| Location | Point | Gets or sets the coordinates of the upper-left corner of the control relative to the upper-left corner of its container |
| MainMenu | MainMenu | Gets or sets the main menu of window |
| Margin | Thickness | Gets or sets the outer margin of an element |
| Padding | Thickness | Gets or sets a Thickness value that describes the amount of space between a control and its child element |
| Parent | ContentControl | Gets or sets the parent container of the control |
| Showing | bool | Indicates that the window was showing on a screen |
| StatusBar | StatusBar | Gets or sets the status bar of window |
| Tag | object | Gets or sets the object that contains data about the control |
| Title | string | Gets or sets a window's title |
| WasClosed | bool | Indicates that the Close() method has been called |
| Width | int? | Gets or sets the width of the control |
| WindowState | ControlState | Gets or sets a value that indicates whether a window is minimized or maximized |
| Syntax | Description |
|---|---|
| AddContent(Control content) | Adds the specified control to the control collection |
| Arrange(Rect) | Positions child elements and determines a size for a Control. Parent elements call this method from their Arrange(Rect) implementation to form a recursive layout update |
| Close() | Manually closes a Window |
| InvalidateMeasure() | Invalidates the measurement state (layout) for the element |
| InvalidateMeasureIfAutoSize() | Invalidates the measurement state (layout) for the element if AutoSize property is true otherwise invalidates the rendering of the element |
| InvalidateVisual() | Invalidates the rendering of the element, and forces a complete new layout pass. OnRender(IDrawingContext) is called after the layout cycle is completed |
| Measure(Size) | Updates DesiredSize of a Control. Parent elements call this method from their own Measure(Size) implementations to form a recursive layout update |
| OnRender(IDrawingContext) | Filling a pseudographics drawing context |
| ParentWindow() | Gets the form the control is in |
| RemoveContent(Control content) | Remove the specified control to the control collection |
| SetStyle(Action) | Defines actions with an element style |
| Show() | Opens a window and returns without waiting for the newly opened window to close |
| ShowDialog() | Opens a window and returns only when the newly opened window is closed |
| Event | Description |
|---|---|
| OnActivated | Occurs when the window showing on screen or after setting active window |
| OnAutoSizeChanged | Occurs when the value of the AutoSize property changes |
| OnBackgroundChanged | Occurs when the value of the Background property changes |
| OnClosed | Occurs when the window was close |
| OnClosing | Occurs when the window try closing |
| OnDialogResultChanged | Occurs when the value of the DialogResult property changes |
| OnForegroundChanged | Occurs when the value of the Foreground property changes |
| OnHeightChanged | Occurs when the value of the Height property changes |
| OnHideTitleChanged | Occurs when the value of the HideTitle property changes |
| OnKeyPressed | Occurs when the key was pressed |
| OnMainMenuChanged | Occurs when the value of the MainMenu property changes |
| OnMarginChanged | Occurs when the value of the Margin property changes |
| OnPaddingChanged | Occurs when the value of the Padding property changes |
| OnParentChanged | Occurs when the value of the Parent property changes |
| OnStatusBarChanged | Occurs when the value of the StatusBar property changes |
| OnTagChanged | Occurs when the value of the Tag property changes |
| OnTitleChanged | Occurs when the value of the Title property changes |
| OnWidthChanged | Occurs when the value of the Width property changes |
| OnWindowStateChanged | Occurs when the value of the WindowState property changes |