Show / Hide Table of Contents

# Class Application

The application driver for gui.cs

##### Inheritance

System.Object
Application

###### Namespace: Terminal

###### Assembly: Terminal.dll

##### Syntax

    public class Application

##### Remarks

You can hook up to the Iteration event to have your method invoked on each iteration of the mainloop.

Creates a mainloop to process input events, handle timers and other sources of data. It is accessible via the MainLoop property.

When invoked sets the SynchronizationContext to one that is tied to the mainloop, allowing user code to use async/await.

### Constructors

#### Application()

##### Declaration

    public Application ();

### Fields

#### Driver

The current Console Driver in use.

##### Declaration

    public static Terminal.ConsoleDriver Driver;

##### Field Value

Type | Description
--- | ---
ConsoleDriver | To be added.

#### RootMouseEvent

Merely a debugging aid to see the raw mouse events

##### Declaration

    public static Action<Terminal.MouseEvent> RootMouseEvent;

##### Field Value

Type | Description
--- | ---
System.Action<MouseEvent> | To be added.

### Properties

#### Current

The current toplevel object. This is updated when Application.Run enters and leaves and points to the current toplevel.

##### Declaration

    public static Terminal.Toplevel Current { get; }

##### Property Value

Type | Description
--- | ---
Toplevel | The current.

#### MainLoop

The mainloop driver for the applicaiton

##### Declaration

    public static Mono.Terminal.MainLoop MainLoop { get; }

##### Property Value

Type | Description
--- | ---
MainLoop | The main loop.

#### Top

The Toplevel object used for the application on startup.

##### Declaration

    public static Terminal.Toplevel Top { get; }

##### Property Value

Type | Description
--- | ---
Toplevel | The top.

### Methods

#### Begin(Toplevel)

##### Declaration

    public static Terminal.Application.RunState Begin (Terminal.Toplevel toplevel);

##### Parameters

Type | Name | Description
--- | --- | ---
Toplevel | toplevel | To be added.

##### Returns

Type | Description
--- | ---
| To be added.

#### End(Application+RunState)

##### Declaration

    public static void End (Terminal.Application.RunState rs);

##### Parameters

Type | Name | Description
--- | --- | ---
| rs | To be added.

#### GrabMouse(View)

Grabs the mouse, forcing all mouse events to be routed to the specified view until UngrabMouse is called.

##### Declaration

    public static void GrabMouse (Terminal.View view);

##### Parameters

Type | Name | Description
--- | --- | ---
View | view | View that will receive all mouse events until UngrabMouse is invoked.

#### Init()

Initializes the Application

##### Declaration

    public static void Init ();

#### MakeCenteredRect(Size)

Returns a rectangle that is centered in the screen for the provided size.

##### Declaration

    public static Terminal.Rect MakeCenteredRect (Terminal.Size size);

##### Parameters

Type | Name | Description
--- | --- | ---
Size | size | Size for the rectangle.

##### Returns

Type | Description
--- | ---
Rect | The centered rect.

#### Refresh()

Triggers a refresh of the entire display.

##### Declaration

    public static void Refresh ();

#### RequestStop()

Stops running the most recent toplevel

##### Declaration

    public static void RequestStop ();

#### Run()

Runs the application with the built-in toplevel view

##### Declaration

    public static void Run ();

#### Run(Toplevel)

Runs the main loop on the given container.

##### Declaration

    public static void Run (Terminal.Toplevel view);

##### Parameters

Type | Name | Description
--- | --- | ---
Toplevel | view | To be added.

##### Remarks

This method is used to start processing events for the main application, but it is also used to run modal dialog boxes.

To make a toplevel stop execution, set the "Running" property to false.

#### RunLoop(Application+RunState, Boolean)

Runs the main loop for the created dialog

##### Declaration

    public static void RunLoop (Terminal.Application.RunState state, bool wait = true);

##### Parameters

Type | Name | Description
--- | --- | ---
| state | To be added.
System.Boolean | wait | To be added.

##### Remarks

Use the wait parameter to control whether this is a blocking or non-blocking call.

#### UngrabMouse()

Releases the mouse grab, so mouse events will be routed to the view on which the mouse is.

##### Declaration

    public static void UngrabMouse ();

### Events

#### Iteration

This event is raised on each iteration of the main loop.

##### Declaration

    public static event EventHandler Iteration;

##### Event Type

Type | Description
--- | ---
System.EventHandler | To be added.

##### Remarks

See also System.Threading.Timeout