Class Application
- Namespace
- nanoFramework.UI
- Assembly
- nanoFramework.Graphics.dll
Application base class
public class Application : DispatcherObject, IEventListener
- Inheritance
-
Application
- Implements
- Inherited Members
- Extension Methods
Constructors
Application()
Initializes a new instance of the Application class.
public Application()
Properties
Current
The Current property enables the developer to always get to the application in AppDomain in which they are running.
public static Application Current { get; }
Property Value
MainWindow
The MainWindow property indicates the primary window of the application.
public Window MainWindow { get; set; }
Property Value
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.
public ShutdownMode ShutdownMode { get; set; }
Property Value
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.
public WindowCollection Windows { get; }
Property Value
Methods
InitializeForEventSource()
Initializes the InputProvider for the EventSource.
public void InitializeForEventSource()
OnEvent(BaseEvent)
Provides input processing for BaseEvent objects from the EventSource.
public bool OnEvent(BaseEvent ev)
Parameters
ev
BaseEventThe event to process.
Returns
- 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).
protected virtual void OnExit(EventArgs e)
Parameters
e
EventArgsThe 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.
protected virtual void OnStartup(EventArgs e)
Parameters
e
EventArgsThe 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.
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.
public void Run(Window window)
Parameters
window
WindowWindow 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.
public void Shutdown()
Events
Exit
The Exit event is fired when an application is shutting down. This event is raised by the OnExit method.
public event EventHandler Exit
Event Type
Startup
The Startup event is fired when an application is starting. This event is raised by the OnStartup method.
public event EventHandler Startup