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
userInterfaceServiceIUserInterfaceServiceactionFunc<CancellationToken, Task>A delegate for the method that performs the asynchronous action.
configureAction<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
actionis 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
userInterfaceServiceIUserInterfaceServiceactionFunc<Task>A delegate for the method that performs the asynchronous action.
configureAction<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
actionis 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
userInterfaceServiceIUserInterfaceServicemessagestringThe message to display in the window.
actionFunc<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
messageis null.- ArgumentNullException
actionis 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
userInterfaceServiceIUserInterfaceServicemessagestringThe message to display in the window.
actionFunc<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
messageis null.- ArgumentNullException
actionis 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
userInterfaceServiceIUserInterfaceServiceactionFunc<Task<TResult>>A delegate for the method that performs the asynchronous action.
configureAction<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
TResultThe 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
actionis 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
userInterfaceServiceIUserInterfaceServicemessagestringThe message to display in the window.
actionFunc<CancellationToken, Task<TResult>>A delegate for the method that performs the asynchronous action.
Returns
- TResult
The value returned by the asynchronous action.
Type Parameters
TResultThe 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
messageis null.- ArgumentNullException
actionis 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
userInterfaceServiceIUserInterfaceServicemessagestringThe message to display in the window.
actionFunc<Task<TResult>>A delegate for the method that performs the asynchronous action.
Returns
- TResult
The value returned by the asynchronous action.
Type Parameters
TResultThe 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
messageis null.- ArgumentNullException
actionis 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
userInterfaceServiceIUserInterfaceServiceexceptionExceptionThe exception for which to display the error message.
Returns
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
exceptionis 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
userInterfaceServiceIUserInterfaceServicemessageTextstringThe message text.
Returns
- MessageBoxResult
The message box result.
Exceptions
- ArgumentNullException
messageTextis 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
userInterfaceServiceIUserInterfaceServicealarmsManagerIAlarmsManagerThe IAlarmsManager service.
workstationStateIWorkstationStateThe IWorkstationState service.
exceptionExceptionThe exception for which to display the error message.
alarmContextstringAn 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
alarmsManageris null.- ArgumentNullException
workstationStateis null.- ArgumentNullException
exceptionis 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
userInterfaceServiceIUserInterfaceServicealarmsManagerIAlarmsManagerThe IAlarmsManager service.
workstationStateIWorkstationStateThe IWorkstationState service.
messageTextstringThe message text.
alarmContextstringAn 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
alarmsManageris null.- ArgumentNullException
workstationStateis null.- ArgumentNullException
messageTextis 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
userInterfaceServiceIUserInterfaceServicemessageTextstringThe message text.
Returns
- MessageBoxResult
The message box result.
Exceptions
- ArgumentNullException
messageTextis 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
userInterfaceServiceIUserInterfaceServiceiconMessageBoxImageThe message box icon.
messageTextstringThe message text.
Returns
- MessageBoxResult
The message box result.
Exceptions
- ArgumentNullException
messageTextis null.