Interface IDesktopUi
- Namespace
- VpnHood.AppUi.Hosting.Desktop.Abstractions
- Assembly
- VpnHood.AppUi.Hosting.Desktop.Abstractions.dll
Defines a UI a desktop head names, as Avalonia's window, a web view or a fork's own, which the head's host runs.
public interface IDesktopUi
Remarks
The host decides where the app is, and so what it hands over (DesktopUiParams); the UI neither knows nor asks, so one UI serves the app in a service and the app in its own process alike.
Methods
BringToFront(CancellationToken)
Asks for the running UI's window, or its message, to show in front, as for a second launch.
Task BringToFront(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
It may be called from any thread. Before a run has a window, a UI may keep the request for the run's start, as Avalonia's does, or drop it. The task may complete once the request is queued, before the window shows, and the token may not be read; a web UI without its web view may open the page in the browser instead.
ImportAccessKey(string, CancellationToken)
Imports an access key a second launch was given, as a file opened with the app: the key's server becomes the chosen one.
Task ImportAccessKey(string accessKey, CancellationToken cancellationToken)
Parameters
accessKeystringThe access key.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
It may be called from any thread. Before the run has the app, a UI may keep the key for the run's start, as Avalonia's does, or drop it; the task may complete once the request is queued, and the token may not be read. Whether a key that cannot be read is shown or only logged is the UI's.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled, for a UI whose task waits for the import.
QuickLaunch(CancellationToken)
Connects as the UI's Connect button does, for a second launch that is a Quick Launch, the Store edition's own entry in Start, unless the app is connected or on its way.
Task QuickLaunch(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenThe token to monitor for cancellation requests.
Returns
- Task
A task that represents the asynchronous operation.
Remarks
It may be called from any thread. Before the run has the app, a UI may keep the request for the run's start, as Avalonia's does, or drop it; the task may complete once the request is queued, and the token may not be read.
Exceptions
- OperationCanceledException
cancellationTokenwas canceled, for a UI whose task waits for the connect.
Run(DesktopUiParams, CancellationToken)
Runs the UI on the calling thread, the host's main thread, which on Windows must be its STA thread, and returns when the UI ends: its window closed, or its tray's Exit where it keeps a tray.
void Run(DesktopUiParams uiParams, CancellationToken cancellationToken)
Parameters
uiParamsDesktopUiParamsWhat the UI runs against.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests: a cancel asks the UI to end, as at the host's own end, a service manager's signal or a sign-out.
Exceptions
- Win32Exception
Windows refused the UI's window, for a UI that makes a Win32 window.
- OperationCanceledException
cancellationTokenwas canceled while the UI started.- InvalidOperationException
The UI cannot start, as where it is given no content store.
RunMessage(DesktopUiMessageParams, CancellationToken)
Runs one message and a button that closes it, on the calling thread, in place of Run(DesktopUiParams, CancellationToken) where the host has no app to hand over, until the person closes it or the host cancels.
void RunMessage(DesktopUiMessageParams messageParams, CancellationToken cancellationToken)
Parameters
messageParamsDesktopUiMessageParamsThe message.
cancellationTokenCancellationTokenThe token to monitor for cancellation requests: a cancel ends the window.
Remarks
Nothing here calls the app. BringToFront(CancellationToken) reaches this window too.