Table of Contents

Class UserInterfaceServiceExtensions

Namespace
Acuit.Pinpoint.Workstation.Windows
Assembly
Acuit.Pinpoint.Workstation.Abstractions.dll

Extension members for IUserInterfaceService.

public static class UserInterfaceServiceExtensions
Inheritance
UserInterfaceServiceExtensions
Inherited Members

Methods

PerformAsyncActionViaModalWindow(IUserInterfaceService, Func<CancellationToken, Task>, Action<AsyncActionWindow>?)

Performs an asynchronous action while displaying a modal "Please wait..." window. This provides a mechanism for executing asynchronous code from a synchronous context.

public static void PerformAsyncActionViaModalWindow(this IUserInterfaceService userInterfaceService, Func<CancellationToken, Task> action, Action<AsyncActionWindow>? configure = null)

Parameters

userInterfaceService IUserInterfaceService
action Func<CancellationToken, Task>

A delegate for the method that performs the asynchronous action.

configure Action<AsyncActionWindow>

An optional action to configure the modal window properties before it is shown.

Remarks

If the asynchronous action completes synchronously, then the "Please wait..." window will not be shown.

Exceptions

ArgumentNullException

action is null.

Exception

An exception thrown by the asynchronous action. If the action canceled, this will be an OperationCanceledException or an exception derived from OperationCanceledException.

PerformAsyncActionViaModalWindow(IUserInterfaceService, Func<Task>, Action<AsyncActionWindow>?)

Performs an asynchronous action while displaying a modal "Please wait..." window. This provides a mechanism for executing asynchronous code from a synchronous context.

public static void PerformAsyncActionViaModalWindow(this IUserInterfaceService userInterfaceService, Func<Task> action, Action<AsyncActionWindow>? configure = null)

Parameters

userInterfaceService IUserInterfaceService
action Func<Task>

A delegate for the method that performs the asynchronous action.

configure Action<AsyncActionWindow>

An optional action to configure the modal window properties before it is shown.

Remarks

If the asynchronous action completes synchronously, then the "Please wait..." window will not be shown.

Exceptions

ArgumentNullException

action is null.

Exception

An exception thrown by the asynchronous action.

PerformAsyncActionViaModalWindow(IUserInterfaceService, string, Func<CancellationToken, Task>)

Performs an asynchronous action while displaying a modal "Please wait..." window. This provides a mechanism for executing asynchronous code from a synchronous context.

public static void PerformAsyncActionViaModalWindow(this IUserInterfaceService userInterfaceService, string message, Func<CancellationToken, Task> action)

Parameters

userInterfaceService IUserInterfaceService
message string

The message to display in the window.

action Func<CancellationToken, Task>

A delegate for the method that performs the asynchronous action.

Remarks

If the asynchronous action completes synchronously, then the "Please wait..." window will not be shown.

Exceptions

ArgumentNullException

message is null.

ArgumentNullException

action is null.

Exception

An exception thrown by the asynchronous action. If the action canceled, this will be an OperationCanceledException or an exception derived from OperationCanceledException.

PerformAsyncActionViaModalWindow(IUserInterfaceService, string, Func<Task>)

Performs an asynchronous action while displaying a modal "Please wait..." window. This provides a mechanism for executing asynchronous code from a synchronous context.

public static void PerformAsyncActionViaModalWindow(this IUserInterfaceService userInterfaceService, string message, Func<Task> action)

Parameters

userInterfaceService IUserInterfaceService
message string

The message to display in the window.

action Func<Task>

A delegate for the method that performs the asynchronous action.

Remarks

If the asynchronous action completes synchronously, then the "Please wait..." window will not be shown.

Exceptions

ArgumentNullException

message is null.

ArgumentNullException

action is null.

Exception

An exception thrown by the asynchronous action.

PerformAsyncActionViaModalWindow<TResult>(IUserInterfaceService, Func<Task<TResult>>, Action<AsyncActionWindow>?)

Performs an asynchronous action while displaying a modal "Please wait..." window. This provides a mechanism for executing asynchronous code from a synchronous context.

public static TResult PerformAsyncActionViaModalWindow<TResult>(this IUserInterfaceService userInterfaceService, Func<Task<TResult>> action, Action<AsyncActionWindow>? configure = null)

Parameters

userInterfaceService IUserInterfaceService
action Func<Task<TResult>>

A delegate for the method that performs the asynchronous action.

configure Action<AsyncActionWindow>

An optional action to configure the modal window properties before it is shown.

Returns

TResult

The value returned by the asynchronous action.

Type Parameters

TResult

The type of the result returned by the asynchronous action.

Remarks

If the asynchronous action completes synchronously, then the "Please wait..." window will not be shown.

Exceptions

ArgumentNullException

action is null.

Exception

An exception thrown by the asynchronous action.

PerformAsyncActionViaModalWindow<TResult>(IUserInterfaceService, string, Func<CancellationToken, Task<TResult>>)

Performs an asynchronous action while displaying a modal "Please wait..." window. This provides a mechanism for executing asynchronous code from a synchronous context.

public static TResult PerformAsyncActionViaModalWindow<TResult>(this IUserInterfaceService userInterfaceService, string message, Func<CancellationToken, Task<TResult>> action) where TResult : notnull

Parameters

userInterfaceService IUserInterfaceService
message string

The message to display in the window.

action Func<CancellationToken, Task<TResult>>

A delegate for the method that performs the asynchronous action.

Returns

TResult

The value returned by the asynchronous action.

Type Parameters

TResult

The type of the result returned by the asynchronous action.

Remarks

If the asynchronous action completes synchronously, then the "Please wait..." window will not be shown.

Exceptions

ArgumentNullException

message is null.

ArgumentNullException

action is null.

Exception

An exception thrown by the asynchronous action. If the action canceled, this will be an OperationCanceledException or an exception derived from OperationCanceledException.

PerformAsyncActionViaModalWindow<TResult>(IUserInterfaceService, string, Func<Task<TResult>>)

Performs an asynchronous action while displaying a modal "Please wait..." window. This provides a mechanism for executing asynchronous code from a synchronous context.

public static TResult PerformAsyncActionViaModalWindow<TResult>(this IUserInterfaceService userInterfaceService, string message, Func<Task<TResult>> action) where TResult : notnull

Parameters

userInterfaceService IUserInterfaceService
message string

The message to display in the window.

action Func<Task<TResult>>

A delegate for the method that performs the asynchronous action.

Returns

TResult

The value returned by the asynchronous action.

Type Parameters

TResult

The type of the result returned by the asynchronous action.

Remarks

If the asynchronous action completes synchronously, then the "Please wait..." window will not be shown.

Exceptions

ArgumentNullException

message is null.

ArgumentNullException

action is null.

Exception

An exception thrown by the asynchronous action.

ShowErrorMessageBox(IUserInterfaceService, Exception)

Displays a message box with an error message. The message box will have the error icon and a single OK button.

public static MessageBoxResult ShowErrorMessageBox(this IUserInterfaceService userInterfaceService, Exception exception)

Parameters

userInterfaceService IUserInterfaceService
exception Exception

The exception for which to display the error message.

Returns

MessageBoxResult

Remarks

The error message will contain the exception message, along with the messages from the inner exception hierarchy on separate lines (see MessagesHierarchyAsMultipleLines(Exception) for details).

Exceptions

ArgumentNullException

exception is null.

ShowErrorMessageBox(IUserInterfaceService, string)

Displays a message box with an error message. The message box will have the error icon and a single OK button.

public static MessageBoxResult ShowErrorMessageBox(this IUserInterfaceService userInterfaceService, string messageText)

Parameters

userInterfaceService IUserInterfaceService
messageText string

The message text.

Returns

MessageBoxResult

The message box result.

Exceptions

ArgumentNullException

messageText is null.

ShowErrorMessageBoxOrAddAlarmIfAutomatedStation(IUserInterfaceService, IAlarmsManager, IWorkstationState, Exception, string?)

Displays an error message via a message box if the station is not automated, or via an alarm if the station is automated.

public static void ShowErrorMessageBoxOrAddAlarmIfAutomatedStation(this IUserInterfaceService userInterfaceService, IAlarmsManager alarmsManager, IWorkstationState workstationState, Exception exception, string? alarmContext = null)

Parameters

userInterfaceService IUserInterfaceService
alarmsManager IAlarmsManager

The IAlarmsManager service.

workstationState IWorkstationState

The IWorkstationState service.

exception Exception

The exception for which to display the error message.

alarmContext string

An optional context that will be prefixed to the error message to form the alarm message if the error is raised as an alarm.

Remarks

If the station is not running as an automated station, then the station is presumed to be attended by an operator, so the error message will be displayed via a message box with the error icon and a single OK button. In this case, alarmContext will be ignored, as it is assumed that the operator will know the context since the error was initiated by an action by the operator. The error message will contain the exception message, along with the messages from the inner exception hierarchy on separate lines (see MessagesHierarchyAsMultipleLines(Exception) for details).

If the station is running as an automated station, then a modal message box could disrupt the automated operation of the station, so instead the error message will be raised as an alarm via the supplied IAlarmsManager. The error message will contain the exception message, along with the messages from the inner exception hierarchy separated by spaces (see MessagesHierarchyAsSingleLine(Exception) for details). If alarmContext is not null or empty, then the alarm message will be formatted like "{alarmContext}: {messageText}".

Exceptions

ArgumentNullException

alarmsManager is null.

ArgumentNullException

workstationState is null.

ArgumentNullException

exception is null.

ShowErrorMessageBoxOrAddAlarmIfAutomatedStation(IUserInterfaceService, IAlarmsManager, IWorkstationState, string, string?)

Displays an error message via a message box if the station is not automated, or via an alarm if the station is automated.

public static void ShowErrorMessageBoxOrAddAlarmIfAutomatedStation(this IUserInterfaceService userInterfaceService, IAlarmsManager alarmsManager, IWorkstationState workstationState, string messageText, string? alarmContext = null)

Parameters

userInterfaceService IUserInterfaceService
alarmsManager IAlarmsManager

The IAlarmsManager service.

workstationState IWorkstationState

The IWorkstationState service.

messageText string

The message text.

alarmContext string

An optional context that will be prefixed to the error message to form the alarm message if the error is raised as an alarm.

Remarks

If the station is not running as an automated station, then the station is presumed to be attended by an operator, so the error message will be displayed via a message box with the error icon and a single OK button. In this case, alarmContext will be ignored, as it is assumed that the operator will know the context since the error was initiated by an action by the operator.

If the station is running as an automated station, then a modal message box could disrupt the automated operation of the station, so instead the error message will be raised as an alarm via the supplied IAlarmsManager. If alarmContext is not null or empty, then the alarm message will be formatted like "{alarmContext}: {messageText}".

Exceptions

ArgumentNullException

alarmsManager is null.

ArgumentNullException

workstationState is null.

ArgumentNullException

messageText is null.

ShowMessageBox(IUserInterfaceService, string)

Displays a message box with no message box icon and a single OK button.

public static MessageBoxResult ShowMessageBox(this IUserInterfaceService userInterfaceService, string messageText)

Parameters

userInterfaceService IUserInterfaceService
messageText string

The message text.

Returns

MessageBoxResult

The message box result.

Exceptions

ArgumentNullException

messageText is null.

ShowMessageBox(IUserInterfaceService, MessageBoxImage, string)

Displays a message box with a single OK button.

public static MessageBoxResult ShowMessageBox(this IUserInterfaceService userInterfaceService, MessageBoxImage icon, string messageText)

Parameters

userInterfaceService IUserInterfaceService
icon MessageBoxImage

The message box icon.

messageText string

The message text.

Returns

MessageBoxResult

The message box result.

Exceptions

ArgumentNullException

messageText is null.