2019-12-07 00:13:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-01-07 05:44:05 +00:00
|
|
|
|
using System.Reactive;
|
2020-12-07 04:26:02 +00:00
|
|
|
|
using System.Reactive.Linq;
|
|
|
|
|
using System.Reactive.Subjects;
|
2019-12-07 00:13:16 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2019-12-26 23:26:53 +00:00
|
|
|
|
using CefSharp;
|
|
|
|
|
using CefSharp.Wpf;
|
2019-12-07 05:40:57 +00:00
|
|
|
|
using ReactiveUI;
|
2019-12-07 00:13:16 +00:00
|
|
|
|
using ReactiveUI.Fody.Helpers;
|
|
|
|
|
using Wabbajack.Lib;
|
2019-12-19 01:09:45 +00:00
|
|
|
|
using Wabbajack.Lib.LibCefHelpers;
|
2019-12-26 23:26:53 +00:00
|
|
|
|
using Wabbajack.Lib.WebAutomation;
|
2019-12-07 00:13:16 +00:00
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
2020-04-20 22:36:11 +00:00
|
|
|
|
public class WebBrowserVM : ViewModel, IBackNavigatingVM, IDisposable
|
2019-12-07 00:13:16 +00:00
|
|
|
|
{
|
|
|
|
|
[Reactive]
|
|
|
|
|
public string Instructions { get; set; }
|
|
|
|
|
|
2019-12-26 23:26:53 +00:00
|
|
|
|
public IWebBrowser Browser { get; } = new ChromiumWebBrowser();
|
|
|
|
|
public CefSharpWrapper Driver => new CefSharpWrapper(Browser);
|
2019-12-07 00:13:16 +00:00
|
|
|
|
|
2020-01-05 03:06:34 +00:00
|
|
|
|
[Reactive]
|
|
|
|
|
public ViewModel NavigateBackTarget { get; set; }
|
|
|
|
|
|
2019-12-07 05:40:57 +00:00
|
|
|
|
[Reactive]
|
2020-01-07 05:44:05 +00:00
|
|
|
|
public ReactiveCommand<Unit, Unit> BackCommand { get; set; }
|
2019-12-08 19:46:30 +00:00
|
|
|
|
|
2020-12-07 04:26:02 +00:00
|
|
|
|
public Subject<bool> IsBackEnabledSubject { get; } = new Subject<bool>();
|
|
|
|
|
public IObservable<bool> IsBackEnabled { get; }
|
|
|
|
|
|
2019-12-19 01:09:45 +00:00
|
|
|
|
private WebBrowserVM(string url = "http://www.wabbajack.org")
|
2019-12-07 00:13:16 +00:00
|
|
|
|
{
|
2020-12-07 04:26:02 +00:00
|
|
|
|
IsBackEnabled = IsBackEnabledSubject.StartWith(true);
|
2019-12-07 00:13:16 +00:00
|
|
|
|
Instructions = "Wabbajack Web Browser";
|
|
|
|
|
}
|
2019-12-19 01:09:45 +00:00
|
|
|
|
|
|
|
|
|
public static async Task<WebBrowserVM> GetNew(string url = "http://www.wabbajack.org")
|
|
|
|
|
{
|
|
|
|
|
// Make sure libraries are extracted first
|
|
|
|
|
return new WebBrowserVM(url);
|
|
|
|
|
}
|
2020-04-20 22:36:11 +00:00
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Browser.Dispose();
|
|
|
|
|
}
|
2019-12-07 00:13:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|