Class Application
Implements base functionality for a SAF WPF application.
Inheritance
Namespace: Sartorius.SAF.Presentation
Assembly: Sartorius.SAF.Presentation.Application.dll
Syntax
public abstract class Application : Application, IQueryAmbient, IProgressNotification, IDisposable
Remarks
Base functionality are:
- Bootstrapping the application.
- Managing single / multiple instances of the application (process).
- Managing application behavior on windows user switches.
- Managing the application shutdown mode.
- Managing application restart processed by a user.
- Saving UI settings when application exits.
Properties
View SourceConfigurationRoot
Gets the Microsoft.Extensions.Configuration.IConfigurationRoot.
Declaration
protected IConfigurationRoot ConfigurationRoot { get; }
Property Value
Type | Description |
---|---|
Microsoft.Extensions.Configuration.IConfigurationRoot |
ExceptionHandlingFacade
Gets the IExceptionHandlingFacade of the application.
Declaration
protected IExceptionHandlingFacade ExceptionHandlingFacade { get; set; }
Property Value
Type | Description |
---|---|
IExceptionHandlingFacade |
LockConfiguration
Gets the LockConfiguration.
Declaration
protected LockConfiguration LockConfiguration { get; }
Property Value
Type | Description |
---|---|
LockConfiguration |
UseLoginDialog
Indicates whether to use an implementation of the ILoginDialog for user login.
Declaration
protected bool UseLoginDialog { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
View SourceAllWindowsClosed()
Tries to close all windows.
Declaration
[Obsolete("Use TryCloseWindows")]
protected virtual bool AllWindowsClosed()
Returns
Type | Description |
---|---|
System.Boolean | True if all windows have been closed, otherwise false. |
CanStartShell()
Check whether a Shell can be started. A SAF Application can be defined as a single instance.
Declaration
protected virtual bool CanStartShell()
Returns
Type | Description |
---|---|
System.Boolean | TRUE if a application can be started, otherwise FALSE |
CloseSplashScreen()
Close the async splash screen.
Declaration
public void CloseSplashScreen()
CreateBootstrapper()
Creates the ApplicationBootstrapper.
Declaration
protected virtual ApplicationBootstrapper CreateBootstrapper()
Returns
Type | Description |
---|---|
ApplicationBootstrapper | The created instance. |
CreateSplashScreen()
Creates the splash screen.
Declaration
protected virtual Window CreateSplashScreen()
Returns
Type | Description |
---|---|
System.Windows.Window | A new instance of the splash screen. |
Remarks
Override the GetNumberOfAdditionalProgressSteps() method to extend the splash screen with additional progress steps
Examples
This example illustrates how to activate the 'splash screen' functionality by overriding the CreateSplashScreen() method. Thereby 'splash screen' functionality means to show an application specific window during application startup and initialization process informing on actually processed steps.
protected override Window CreateSplashScreen()
{
var mySplashScreen = new Window {Title = "SplashScreen"};
return mySplashScreen;
}
View Source
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public void Dispose()
Dispose(Boolean)
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Indicates disposing. |
GetNumberOfAdditionalProgressSteps()
Gets the number of additional progress steps that occurs during application initialization.
Declaration
protected virtual int GetNumberOfAdditionalProgressSteps()
Returns
Type | Description |
---|---|
System.Int32 | The number of additional progress steps; default 0 |
Examples
This example illustrates how increase the number of additional progress steps shown in the splash screen during application initialization
protected override Int32 GetNumberOfAdditionalProgressSteps()
{
return 3;
}
View Source
InitializeApplication(StartupEventArgs)
Initializes the application.
Declaration
protected virtual void InitializeApplication(StartupEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.StartupEventArgs | e | Contain the startup arguments for an application. |
OnCompositionCompleted(CompositionContainer)
Occurs when the composition of the System.ComponentModel.Composition.Hosting.CompositionContainer has been completed.
Declaration
protected virtual void OnCompositionCompleted(CompositionContainer compositionContainer)
Parameters
Type | Name | Description |
---|---|---|
System.ComponentModel.Composition.Hosting.CompositionContainer | compositionContainer | The System.ComponentModel.Composition.Hosting.CompositionContainer. |
OnEventsThreadShutdown(Object, EventArgs)
Occurs before the thread that listens for system events is terminated.
Declaration
protected virtual void OnEventsThreadShutdown(object sender, EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | A sender of this event. |
System.EventArgs | args | Provide data for this event. |
OnExit(ExitEventArgs)
Clean up the resources.
Declaration
protected override void OnExit(ExitEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.ExitEventArgs | e | Event arguments for Exit event. |
Overrides
OnRestartingApplication()
Restarts the entire application.
Declaration
protected virtual void OnRestartingApplication()
Remarks
- The current main window is closed.
- A dummy window is set to the current main window to have a dispatcher.
- All private members are reset.
- All EventHandlers are detached
- The OnStartup method is called for a clean restated.
OnSendException(Object, SendExceptionEventArgs)
Occurs when the SendException event is invoked.
Declaration
protected virtual void OnSendException(object sender, SendExceptionEventArgs sendExceptionEventArgs)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | The sender. |
SendExceptionEventArgs | sendExceptionEventArgs |
Remarks
If overridden in a derived class, the send button of the Sartorius.SAF.Presentation.Controls.ExceptionDialog.ExceptionDialog becomes visible.
Examples
This example illustrates how to activate the 'Send' functionality of the exception dialog by overriding the OnSendException(Object, SendExceptionEventArgs) method, using the Sartorius.SAF.MAPI implementation to send the email with the default email client.
protected override void OnSendException(Object sender, SendExceptionEventArgs sendExceptionEventArgs)
{
if (sendExceptionEventArgs == null)
{
throw new ArgumentNullException(nameof(sendExceptionEventArgs));
}
IMAPI mapi = new MAPI.MAPI();
var textExceptionFormatter = new TextExceptionFormatter();
var body = textExceptionFormatter.Format(sendExceptionEventArgs.Exception);
mapi.OpenMail("someone@example.com", body);
}
View Source
OnSessionEnding(SessionEndingCancelEventArgs)
Occurs when the user ends the Windows session by logging off or shutting down the operating system.
Declaration
protected override void OnSessionEnding(SessionEndingCancelEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.SessionEndingCancelEventArgs | e |
Overrides
OnSessionSwitch(Object, SessionSwitchEventArgs)
Occurs when the currently logged-in user has changed.
Declaration
protected virtual void OnSessionSwitch(object sender, SessionSwitchEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
System.Object | sender | A sender of this event. |
Microsoft.Win32.SessionSwitchEventArgs | args | Provide data for this event. |
OnStartup(StartupEventArgs)
Starts the application.
Declaration
protected override void OnStartup(StartupEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
System.Windows.StartupEventArgs | e | Contain the startup arguments for an application. |
Overrides
Remarks
Do NOT override this method. Override InitializeApplication(StartupEventArgs).
ProgressChanged(ProgressNotificationArgs)
Handler for async notification about progress changes.
Declaration
public void ProgressChanged(ProgressNotificationArgs args)
Parameters
Type | Name | Description |
---|---|---|
ProgressNotificationArgs | args |
ProgressChanged(String)
Handler for async notification about progress changes.
Declaration
public void ProgressChanged(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text |
RegisterSystemEventHandler()
Register a SystemEvents.
Declaration
protected virtual void RegisterSystemEventHandler()
RunBootstrapper()
Runs the bootstrapping process of the application.
Declaration
protected virtual void RunBootstrapper()
SetDefaultSkin()
Sets the default skin of the application.
Declaration
protected virtual void SetDefaultSkin()
Remarks
If not overridden in a derived class, the default skin is set in the following order:
- The skin defined in the app.config is set.
- If no default skin is defined in the app.config, the HID skin is applied if the file 'Sartorius.SAF.Skins.Hid.dll' exists in the output directory.
- If no HID skin is found, no skin is applied.
SetShutdownMode()
Sets the shut-down mode for the application.
Declaration
protected virtual void SetShutdownMode()
TryCloseWindows()
Tries to close all windows.
Declaration
protected virtual bool TryCloseWindows()
Returns
Type | Description |
---|---|
System.Boolean | True if all windows have been closed, otherwise false. |
UnregisterSystemEventHandler()
Remove SystemEvents.
Declaration
protected virtual void UnregisterSystemEventHandler()
Events
View SourceLoadingCompleted
not functionality here.
Declaration
public event Action LoadingCompleted
Event Type
Type | Description |
---|---|
System.Action |