示例#1
0
        private BethesdaNetLoginVM()
        {
            Instructions     = "Login to Bethesda.NET in-game...";
            LoginViaSkyrimSE = ReactiveCommand.CreateFromTask(async() =>
            {
                LoggingIn.OnNext(true);
                Instructions = "Starting Skyrim Special Edition...";
                await BethesdaNetDownloader.Login(Game.SkyrimSpecialEdition);
                LoggingIn.OnNext(false);
                await BackCommand.Execute();
            }, Game.SkyrimSpecialEdition.MetaData().IsInstalled
                ? LoggingIn.Select(e => !e).StartWith(true)
                : Observable.Return(false));

            LoginViaFallout4 = ReactiveCommand.CreateFromTask(async() =>
            {
                LoggingIn.OnNext(true);
                Instructions = "Starting Fallout 4...";
                await BethesdaNetDownloader.Login(Game.Fallout4);
                LoggingIn.OnNext(false);
                await BackCommand.Execute();
            }, Game.Fallout4.MetaData().IsInstalled
                ? LoggingIn.Select(e => !e).StartWith(true)
                : Observable.Return(false));
        }
示例#2
0
        public async Task Handle(IUserIntervention msg)
        {
            switch (msg)
            {
            case RequestNexusAuthorization c:
                await WrapBrowserJob(msg, async (vm, cancel) =>
                {
                    await vm.Driver.WaitForInitialized();
                    var key = await NexusApiClient.SetupNexusLogin(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
                    c.Resume(key);
                });

                break;

            case RequestBethesdaNetLogin c:
                var data = await BethesdaNetDownloader.Login();

                c.Resume(data);
                break;

            case AbstractNeedsLoginDownloader.RequestSiteLogin c:
                await WrapBrowserJob(msg, async (vm, cancel) =>
                {
                    await vm.Driver.WaitForInitialized();
                    var data = await c.Downloader.GetAndCacheCookies(new CefSharpWrapper(vm.Browser), m => vm.Instructions = m, cancel.Token);
                    c.Resume(data);
                });

                break;

            case YesNoIntervention c:
                var result = MessageBox.Show(c.ExtendedDescription, c.ShortDescription, MessageBoxButton.YesNo,
                                             MessageBoxImage.Question);
                if (result == MessageBoxResult.Yes)
                {
                    c.Confirm();
                }
                else
                {
                    c.Cancel();
                }
                break;

            case CriticalFailureIntervention c:
                MessageBox.Show(c.ExtendedDescription, c.ShortDescription, MessageBoxButton.OK,
                                MessageBoxImage.Error);
                c.Cancel();
                break;

            case ConfirmationIntervention c:
                break;

            default:
                throw new NotImplementedException($"No handler for {msg}");
            }
        }
 public AbstractDownloadState Infer(Uri uri)
 {
     return(BethesdaNetDownloader.StateFromUrl(uri));
 }
示例#4
0
 public async Task <AbstractDownloadState?> Infer(Uri uri)
 {
     return(BethesdaNetDownloader.StateFromUrl(uri));
 }