mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
37 lines
956 B
C#
37 lines
956 B
C#
using System;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.Toolkit.Win32.UI.Controls.Interop.WinRT;
|
|
using Microsoft.Toolkit.Wpf.UI.Controls;
|
|
|
|
namespace Wabbajack.Lib.WebAutomation
|
|
{
|
|
public class WebAutomationWindowViewModel : ViewModel
|
|
{
|
|
private WebAutomationWindow _window;
|
|
|
|
private WebView Browser => _window.WebView;
|
|
|
|
public WebAutomationWindowViewModel(WebAutomationWindow window)
|
|
{
|
|
_window = window;
|
|
}
|
|
|
|
public Task<Uri> NavigateTo(Uri uri)
|
|
{
|
|
var tcs = new TaskCompletionSource<Uri>();
|
|
|
|
EventHandler<WebViewControlNavigationCompletedEventArgs> handler = null;
|
|
handler = (s, e) =>
|
|
{
|
|
Browser.NavigationCompleted -= handler;
|
|
tcs.SetResult(uri);
|
|
};
|
|
Browser.NavigationCompleted += handler;
|
|
Browser.Source = uri;
|
|
return tcs.Task;
|
|
}
|
|
|
|
|
|
}
|
|
}
|