2022-03-13 22:47:30 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Reactive;
|
|
|
|
|
using System.Reactive.Subjects;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using ReactiveUI;
|
|
|
|
|
using ReactiveUI.Fody.Helpers;
|
|
|
|
|
using Wabbajack.Messages;
|
|
|
|
|
using Wabbajack.Models;
|
|
|
|
|
|
|
|
|
|
namespace Wabbajack
|
|
|
|
|
{
|
|
|
|
|
public class WebBrowserVM : ViewModel, IBackNavigatingVM, IDisposable
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger<WebBrowserVM> _logger;
|
|
|
|
|
private readonly CefService _cefService;
|
|
|
|
|
|
|
|
|
|
[Reactive]
|
|
|
|
|
public string Instructions { get; set; }
|
|
|
|
|
|
2022-03-13 23:08:27 +00:00
|
|
|
|
public dynamic Browser { get; }
|
|
|
|
|
public dynamic Driver { get; set; }
|
2022-03-13 22:47:30 +00:00
|
|
|
|
|
|
|
|
|
[Reactive]
|
|
|
|
|
public ViewModel NavigateBackTarget { get; set; }
|
|
|
|
|
|
|
|
|
|
[Reactive]
|
|
|
|
|
public ReactiveCommand<Unit, Unit> BackCommand { get; set; }
|
|
|
|
|
|
|
|
|
|
public Subject<bool> IsBackEnabledSubject { get; } = new Subject<bool>();
|
|
|
|
|
public IObservable<bool> IsBackEnabled { get; }
|
|
|
|
|
|
|
|
|
|
public WebBrowserVM(ILogger<WebBrowserVM> logger, CefService cefService)
|
|
|
|
|
{
|
|
|
|
|
// CefService is required so that Cef is initalized
|
|
|
|
|
_logger = logger;
|
|
|
|
|
_cefService = cefService;
|
|
|
|
|
Instructions = "Wabbajack Web Browser";
|
|
|
|
|
|
|
|
|
|
BackCommand = ReactiveCommand.Create(NavigateBack.Send);
|
2022-03-13 23:08:27 +00:00
|
|
|
|
//Browser = cefService.CreateBrowser();
|
|
|
|
|
//Driver = new CefSharpWrapper(_logger, Browser, cefService);
|
2022-03-13 22:47:30 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
{
|
|
|
|
|
Browser.Dispose();
|
|
|
|
|
base.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|