Class WindowsWebViewUi
Provides the app's web UI in a Win32 window over WebView2, as a desktop head names its UI: the page the app's web host serves, at the address the host hands over, with the window's look read from the app and the UI's content.
public class WindowsWebViewUi : IDesktopUi
- Inheritance
-
WindowsWebViewUi
- Implements
- Inherited Members
Remarks
It runs the window's message loop on the host's STA main thread until the window closes or the run is canceled. It keeps no tray, so a start in the tray ends at once. It uses no UI framework: Windows' own window, message box and taskbar.
Constructors
WindowsWebViewUi(DesktopWindowFitOptions)
Provides the app's web UI in a Win32 window over WebView2, as a desktop head names its UI: the page the app's web host serves, at the address the host hands over, with the window's look read from the app and the UI's content.
public WindowsWebViewUi(DesktopWindowFitOptions windowFit)
Parameters
windowFitDesktopWindowFitOptionsThe shape the web UI's layout needs of the window, which a page cannot state.
Remarks
It runs the window's message loop on the host's STA main thread until the window closes or the run is canceled. It keeps no tray, so a start in the tray ends at once. It uses no UI framework: Windows' own window, message box and taskbar.
Methods
BringToFront(CancellationToken)
Asks for the running UI's window, or its message, to show in front, as for a second launch.
public 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.
public 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.- OperationCanceledException
cancellationTokenwas canceled.
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.
public 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.- OperationCanceledException
cancellationTokenwas canceled.
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.
public 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.
Remarks
A start in the tray, or a token canceled before the call, returns at once, as it keeps no tray. An access key the launch was given is imported before the window is made, and a Quick Launch connects beside it; a failure of either is logged. A cancel closes the window.
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.
- InvalidOperationException
The window's icon could not be made.
- Win32Exception
Windows refused the window.
- OperationCanceledException
cancellationTokenwas canceled while the launch's access key was imported or the window's look was read.
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.
public 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.