Class Application
Application base class
Implements
Inherited Members
Namespace: nanoFramework.UI
Assembly: nanoFramework.Graphics.dll
Syntax
public class Application : DispatcherObject, IEventListener
Constructors
Application()
Initializes a new instance of the Application class.
Declaration
public Application()
Properties
Current
The Current property enables the developer to always get to the application in AppDomain in which they are running.
Declaration
public static Application Current { get; }
Property Value
Type | Description |
---|---|
Application |
MainWindow
The MainWindow property indicates the primary window of the application.
Declaration
public Window MainWindow { get; set; }
Property Value
Type | Description |
---|---|
Window |
Remarks
By default - MainWindow will be set to the first window opened in the application. However the MainWindow may be set programmatically to indicate "this is my main window". It is a recommended programming style to refer to MainWindow in code instead of Windows[0].
ShutdownMode
The ShutdownMode property is called to set the shutdown specific mode of the application. Setting this property controls the way in which an application will shutdown. The three values for the ShutdownMode enum are : OnLastWindowClose OnMainWindowClose OnExplicitShutdown
OnLastWindowClose - this mode will shutdown the application when the
last window is closed, or an explicit call is made
to Application.Shutdown(). This is the default mode.
OnMainWindowClose - this mode will shutdown the application when the main
window has been closed, or Application.Shutdown() is
called. Note that if the MainWindow property has not
been set - this mode is equivalent to OnExplicitOnly.
OnExplicitShutdown- this mode will shutdown the application only when an
explicit call to OnShutdown() has been made.
Declaration
public ShutdownMode ShutdownMode { get; set; }
Property Value
Type | Description |
---|---|
ShutdownMode |
Windows
The Windows property exposes a WindowCollection object, from which a developer can iterate over all the windows that have been opened in the current application.
Declaration
public WindowCollection Windows { get; }
Property Value
Type | Description |
---|---|
WindowCollection |
Methods
InitializeForEventSource()
Initializes the InputProvider for the EventSource.
Declaration
public void InitializeForEventSource()
OnEvent(BaseEvent)
Provides input processing for BaseEvent objects from the EventSource.
Declaration
public bool OnEvent(BaseEvent ev)
Parameters
Type | Name | Description |
---|---|---|
BaseEvent | ev | The event to process. |
Returns
Type | Description |
---|---|
bool | Returns true if the event was successfully processed, otherwise returns false. |
OnExit(EventArgs)
OnExit is called to raise the Exit event. The developer will typically override this method if they want to take action when the application exits ( or they may choose to attach an event).
Declaration
protected virtual void OnExit(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
EventArgs | e | The event args that will be passed to the Exit event |
Remarks
This method follows the .Net programming guideline of having a protected virtual method that raises an event, to provide a convenience for developers that subclass the event. If you override this method - you need to call Base.OnExit(...) for the corresponding event to be raised.
OnStartup(EventArgs)
OnStartup is called to raise the Startup event. The developer will typically override this method if they want to take action at startup time ( or they may choose to attach an event). This method will be called once when the application begins, once that application's Run() method has been called.
Declaration
protected virtual void OnStartup(EventArgs e)
Parameters
Type | Name | Description |
---|---|---|
EventArgs | e | The event args that will be passed to the Startup event |
Remarks
This method follows the .Net programming guideline of having a protected virtual method that raises an event, to provide a convenience for developers that subclass the event. If you override this method - you need to call Base.OnStartup(...) for the corresponding event to be raised.
Run()
Run is called to start an application.
Typically a developer will do some setting of properties/attaching to events after instantiating an application object, and then call Run() to start the application.
Declaration
public void Run()
Remarks
Once run has been called - an application's OnStartup override and Startup event is called immediately afterwards.
Run(Window)
Run is called to start an application.
Typically a developer will do some setting of properties/attaching to events after instantiating an application object, and then call Run() to start the application.
Declaration
public void Run(Window window)
Parameters
Type | Name | Description |
---|---|---|
Window | window | Window that will be added to the Windows property and made the MainWindow of the Applcation. The passed Window must be created on the same thread as the Application object. Furthermore, this Window is shown once the Application is run. |
Remarks
Once run has been called - an application's OnStartup override and Startup event is called immediately afterwards.
Shutdown()
Shutdown is called to programmatically shutdown an application.
Once shutdown() is called, the application gets called with the OnShutdown method to raise the Shutdown event.
Declaration
public void Shutdown()
Events
Exit
The Exit event is fired when an application is shutting down. This event is raised by the OnExit method.
Declaration
public event EventHandler Exit
Event Type
Type | Description |
---|---|
EventHandler |
Startup
The Startup event is fired when an application is starting. This event is raised by the OnStartup method.
Declaration
public event EventHandler Startup
Event Type
Type | Description |
---|---|
EventHandler |