Table of Contents

Interface IUserInterfaceService

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

Provides user interface services.

public interface IUserInterfaceService
Extension Methods

Properties

ActiveWindow

Gets the active window, which will either be the main application window or a nested modal dialog box window.

Window ActiveWindow { get; }

Property Value

Window

Remarks

This returns the active window from the perspective of the application, irrespective of whether the application is activated (i.e., has focus). Any active message box has no effect on this property (though message boxes will by default use the window specified by this property as their parent window). A dialog box is currently being displayed if ActiveWindow does not equal MainWindow.

This will only be accurate if all dialogs and message boxes are invoked via the members of this interface.

IsDialogOrMessageBoxShown

Gets whether a modal dialog or message box is currently open.

bool IsDialogOrMessageBoxShown { get; }

Property Value

bool

Remarks

This will only be accurate if all dialogs and message boxes are invoked via the members of this interface.

IsMessageBoxShown

Gets whether a message box is currently open.

bool IsMessageBoxShown { get; }

Property Value

bool

Remarks

This will only be accurate if all dialogs and message boxes are invoked via the members of this interface.

MainWindow

Gets the main application window.

Window MainWindow { get; }

Property Value

Window

Methods

GetKeypadInput(string, int?, bool)

Gets keypad input from the operator.

string? GetKeypadInput(string prompt, int? maxInputLength = null, bool isPasswordMode = false)

Parameters

prompt string

The prompt to display to the user in the keypad window.

maxInputLength int?

The maximum length, in characters, of the input value, or null or 0 to not limit the input length.

isPasswordMode bool

Whether to use password mode, where characters typed are not displayed.

Returns

string

The input value, or null if the operator canceled the input.

Exceptions

ArgumentNullException

prompt is null.

ArgumentOutOfRangeException

maxInputLength is less than zero.

InvokeAutomationElementAsync(string)

Invokes an automation element.

Task<bool> InvokeAutomationElementAsync(string automationId)

Parameters

automationId string

The automation id of the element to invoke.

Returns

Task<bool>

The task object representing the asynchronous operation.

Remarks

Once the operation completes, the Result property on the returned task object contains true if the element was invoked, or false if no invokable element with the specified id was found.

Exceptions

ArgumentNullException

automationId is null.

PerformAsyncActionViaModalWindow<TResult>(Func<CancellationToken, 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.

TResult PerformAsyncActionViaModalWindow<TResult>(Func<CancellationToken, Task<TResult>> action, Action<AsyncActionWindow>? configure = null)

Parameters

action Func<CancellationToken, 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. If the action canceled, this will be an OperationCanceledException or an exception derived from OperationCanceledException.

ShowDialog(Window, object?)

Displays a dialog box.

bool? ShowDialog(Window view, object? viewModel = null)

Parameters

view Window

The window to use as the dialog box.

viewModel object

The optional object to use as the view model. If this is not null, the DataContext property of view will be set to this object.

Returns

bool?

The result of DialogResult before the dialog closed.

Remarks

The view and/or the view model can implement IDialogAware to raise close requests, providing a value for DialogResult. If viewModel is null, but the provided view has a value for its DataContext property, that object will be used as the view model.

ShowDialog<TView>(object?, IServiceProvider?)

Displays a dialog box.

bool? ShowDialog<TView>(object? viewModel = null, IServiceProvider? serviceProvider = null) where TView : Window

Parameters

viewModel object

The optional object to use as the view model. If this is not null, the DataContext property of the created view will be set to this object.

serviceProvider IServiceProvider

The optional service provider to use for injecting dependencies. If this is null, the base Acuit Pinpoint Workstation service provider will be used (which will not include any services registered by any plug-ins).

Returns

bool?

The result of DialogResult before the dialog closed.

Type Parameters

TView

The view type to use as the dialog box window, which must derive from Window.

Remarks

This will create a new instance of TView, injecting dependencies into the constructor as needed. After the dialog is closed, if the view implements IDisposable, it will be disposed.

ShowMessageBox(MessageBoxImage, MessageBoxButton, string)

Displays a message box.

MessageBoxResult ShowMessageBox(MessageBoxImage icon, MessageBoxButton button, string messageText)

Parameters

icon MessageBoxImage

The message box icon.

button MessageBoxButton

The message box button(s) to show.

messageText string

The message text.

Returns

MessageBoxResult

The message box result.

Exceptions

ArgumentNullException

messageText is null.

WaitCursor()

Gets a disposable object that shows a wait cursor and removes it when the object is disposed.

IDisposable WaitCursor()

Returns

IDisposable

A disposable object that shows and hides a wait cursor.