Ejemplo n.º 1
0
        void ShowOverlayWarning(Action <bool> callback)
        {
            var r =
                _dialogManager.MessageBox(
                    new MessageBoxDialogParams("An overlay is open, do you still want to close the application?",
                                               "Overlay open. Are you sure you wish to close?", SixMessageBoxButton.YesNo)
            {
                RememberedState = false
            }).WaitSpecial();

            if (r == SixMessageBoxResult.YesRemember)
            {
                Settings.RememberWarnOnOverlayOpen = true;
                Settings.WarnOnOverlayOpen         = true;
            }
            else if (r == SixMessageBoxResult.NoRemember)
            {
                Settings.RememberWarnOnOverlayOpen = true;
                Settings.WarnOnOverlayOpen         = false;
            }

            if (r.IsYes())
            {
                ShutdownOrMinimize(callback);
            }
        }
Ejemplo n.º 2
0
        public async Task StartGame()
        {
            Exception e;

            try {
                await GetCurrentGame().Launch(_gameLaunchFactory).ConfigureAwait(false);

                return;
            } catch (OperationCanceledException ex) {
                this.Logger().Warn("User cancelled the launch process");
                return;
            } catch (Win32Exception ex) {
                if (ex.NativeErrorCode != Win32ErrorCodes.ERROR_CANCELLED_ELEVATION)
                {
                    throw;
                }
                this.Logger().Warn("User cancelled the elevated launch process");
                return;
            } catch (UserException ex) {
                e = ex;
            }
            const string title = "A user error occurred during launch";

            this.Logger().FormattedWarnException(e, title);
            await _dialogManager.MessageBox(new MessageBoxDialogParams(e.Message, title));
        }
Ejemplo n.º 3
0
        public async Task VisualInit()
        {
            using (this.Bench()) {
                _settings.AppOptions.WhenAnyValue(x => x.ParticipateInCustomerExperienceProgram)
                .Skip(1)
                .Where(x => !x)
                .Select(x => Observable.FromAsync(() => _dialogManager.MessageBox(
                                                      new MessageBoxDialogParams(
                                                          "Please reconsider enabling the Customer Experience Program, it helps us improve the performance, reliability and functionality, anonymously."))))
                .Concat()
                .Subscribe();

                await OnlineInit().ConfigureAwait(false);

                if (_softwareUpdate.NewVersionInstalled && _softwareUpdate.OldVersion != null &&
                    _softwareUpdate.OldVersion.Major == 1 && _softwareUpdate.OldVersion.Minor < 5)
                {
                    await
                    _dialogManager.MessageBox(
                        new MessageBoxDialogParams(
                            "Hi and welcome to this new version of Play withSIX!\n\nBefore you can Play or Update mods, the mods will need to be converted to the new Synq Package format.\nDon't worry, no or very little data will be redownloaded.\n\nThe process starts for each mod the first time you will use it.",
                            "Welcome to the new Play withSIX!")).ConfigureAwait(false);
                }

                /*                _settings.AppOptions.WhenAnyValue(x => x.UseElevatedService)
                 *  .Subscribe(
                 *      x => _prerequisitesInstaller.SharedInstaller.HandleElevatedService(x).ConfigureAwait(false));*/

                _settings.AppOptions.WhenAnyValue(x => x.LaunchWithWindows)
                .Subscribe(SetupLaunchWithWindows);
            }
        }
Ejemplo n.º 4
0
        async Task AddLocalFolder()
        {
            var path = await _dialogManager.BrowseForFolder();

            if (string.IsNullOrWhiteSpace(path))
            {
                return;
            }

            await Task.Run(async() => {
                bool hasAny;
                lock (LibrarySetup.LocalGroup.Children)
                    hasAny = LibrarySetup.GetLocalMissions()
                             .Any(x => Tools.FileUtil.ComparePathsOsCaseSensitive(x.Model.Path, path));
                if (hasAny)
                {
                    await _dialogManager.MessageBox(new MessageBoxDialogParams("You've already added this folder")).ConfigureAwait(false);
                    return;
                }

                if (!GetMissionSubfolders(path).Any(Directory.Exists))
                {
                    await
                    _dialogManager.MessageBox(
                        new MessageBoxDialogParams(
                            "Please select a folder that contains a Missions and/or MPMissions subfolder",
                            "Invalid folder, aborting")).ConfigureAwait(false);
                    return;
                }

                var item = LibrarySetup.CreateLocalItem(Path.GetFileName(path), false, path);
                _missionList.LocalMissionsContainers.AddLocked(item.Model);
                DomainEvilGlobal.Settings.RaiseChanged();
            });
        }
Ejemplo n.º 5
0
        public async Task ModUninstall(IMod mod)
        {
            if (mod == null)
            {
                throw new ArgumentNullException(nameof(mod));
            }

            LibraryVM.ActiveItem = mod;

            var report =
                !(await _dialogManager.MessageBox(
                      new MessageBoxDialogParams($"You are about to uninstall {mod.Name}\nare you sure?", "Are you sure you want to uninstall the Modification?", SixMessageBoxButton.YesNo)
            {
                IgnoreContent = false,
                GreenContent = "delete",
                RedContent = "keep"
            })).IsYes();

            if (report)
            {
                return;
            }

            try {
                await _updateManager.Value.HandleUninstall().ConfigureAwait(false);
            } catch (BusyStateHandler.BusyException) {
                _dialogManager.BusyDialog();
            }
        }
Ejemplo n.º 6
0
        async Task QAction()
        {
            var servers = _settings.ServerOptions.QuickPlayApplyServerFilters
                ? GetFilteredServers()
                : ServerList.Items.ToArray();

            if (!servers.Any())
            {
                await
                _dialogManager.MessageBox(new MessageBoxDialogParams("No servers found, adjust your filters?"));

                return;
            }

            var theServer = servers
                            .Where(x => !x.PasswordRequired)
                            .FirstOrDefault(
                server =>
                server.NumPlayers > _settings.ServerOptions.MinNumPlayers &&
                server.FreeSlots > _settings.ServerOptions.MinFreeSlots);

            if (theServer == null)
            {
                await
                _dialogManager.MessageBox(
                    new MessageBoxDialogParams("No matching server found, adjust your filters?"));

                return;
            }

            LibraryVM.ActiveItem = theServer;
            await _launchManager.JoinServer().ConfigureAwait(false);
        }
Ejemplo n.º 7
0
 public async Task Unpublish(CollectionLibraryItemViewModel item)
 {
     if (
         (await _dialogManager.MessageBox(
              new MessageBoxDialogParams(
                  "Are you sure you want to stop sharing this Collection?",
                  "Stop sharing collection?", SixMessageBoxButton.YesNo))).IsYes())
     {
         await _mediator.RequestAsyncWrapped(new UnpublishCollectionCommand(item.Model.Id));
     }
 }
Ejemplo n.º 8
0
        Task <SixMessageBoxResult> CustomRepoDialog(CustomCollection customCollection) => _dialogManager.MessageBox(
            new MessageBoxDialogParams(
                @"Warning !!!

You are about to publish a collection that is linked to the following Custom Repository:

" + customCollection.CustomRepo.Name + "(" + customCollection.CustomRepoUrl + ")" + @"

Dependent on the publish state, the custom repository will be available publicly.

Are you authorized to publish the custom repository?",
                "Are you authorized to publish this custom repository?", SixMessageBoxButton.YesNo));
Ejemplo n.º 9
0
        public async Task <bool> TryWithUacFallback(Task task, string info)
        {
            if (!Tools.UacHelper.CheckUac())
            {
                await task.ConfigureAwait(false);

                return(false);
            }
            Exception e;

            try {
                await task.ConfigureAwait(false);

                return(false);
            } catch (UnauthorizedAccessException ex) {
                e = ex;
            }
            var report =
                await
                _dialogManager.MessageBox(
                    new MessageBoxDialogParams(
                        $"The application failed to write to the path, probably indicating permission issues\nWould you like to restart the application Elevated?\n\n {info}\n{e.Message}",
                        "Restart the application elevated?", SixMessageBoxButton.YesNo)).ConfigureAwait(false) ==
                SixMessageBoxResult.Yes;

            if (!report)
            {
                throw e;
            }
            RestartWithUacInclEnvironmentCommandLine();
            return(true);
        }
Ejemplo n.º 10
0
 public void RestartWithDiagnostics()
 {
     if (
         _dialogManager.MessageBox(
             new MessageBoxDialogParams("Restarting the client in diagnostic logging mode, are you sure?",
                                        "Restart to enable diagnostics?", SixMessageBoxButton.YesNo)).WaitSpecial().IsYes())
     {
         _restarter.RestartWithoutElevation(
             Environment.GetCommandLineArgs().Skip(1).Concat(new[] { "--verbose" }).ToArray());
     }
 }
Ejemplo n.º 11
0
        async Task AddRepo()
        {
            if (RepoURL == null)
            {
                await _dialogManager.MessageBox(new MessageBoxDialogParams("Repository URI must not be blank.",
                                                                           "Repository URI Error"));

                return;
            }
            if (!SixRepo.URLSchemes.Contains(RepoURL.Scheme))
            {
                await _dialogManager.MessageBox(
                    new MessageBoxDialogParams(
                        "Repository URI must start with 'pws://' (or one of the other supported protocols)",
                        "Repository URI Error"));

                return;
            }
            await _contentManager.HandlePwsUrl(RepoURL.ToString()).ConfigureAwait(false);
        }
Ejemplo n.º 12
0
        public void DeleteProfile(ProfileDataModel profile)
        {
            ShowProfilesMenu = false;
            var result = _dialogManager.MessageBox(new MessageBoxDialogParams(
                                                       $"Are you sure you want to delete the profile '{profile.Name}'?",
                                                       "Confirm delete profile", SixMessageBoxButton.YesNo)).WaitSpecial();

            if (result.IsYes())
            {
                _mediator.Send(new DeleteProfileCommand(profile.Id));
            }
        }
Ejemplo n.º 13
0
        public bool UpdateAndExitIfNotBusy(bool force = false)
        {
            if (!SU.ExistsAndIsValid(Common.Paths.EntryLocation))
            {
                return(false);
            }

            if (Common.AppCommon.IsBusy)
            {
                _dialogManager.MessageBox(new MessageBoxDialogParams(
                                              "A software update has been downloaded (v" + (SU.RemoteVersion ?? String.Empty) +
                                              ") but the application appears to be busy.\nIf you would like to install the update after finished, please restart the application.\n" +
                                              SU.Destination,
                                              "Software Update available")).WaitSpecial();
                return(false);
            }

            if (!_settings.AppOptions.ShowDialogWhenUpdateDownloaded)
            {
                return(force && TryRunUpdaterIfValid(Common.Flags.FullStartupParameters));
            }

            var r =
                _dialogManager.MessageBox(
                    new MessageBoxDialogParams(
                        "A software update has been downloaded (v" + (SU.RemoteVersion ?? String.Empty) +
                        "), would you like to restart to install it?\n" + SU.Destination,
                        "Software Update available", SixMessageBoxButton.YesNo)
            {
                IgnoreContent = false,
                GreenContent  = "update and restart",
                RedContent    = "cancel"
            }).Result;

            return(r.IsYes() && TryRunUpdaterIfValid(Common.Flags.FullStartupParameters));
        }
Ejemplo n.º 14
0
        async Task <RecoveryOptionResult> BasicMessageHandler(UserError userError, Window window)
        {
            MainLog.Logger.Error(userError.InnerException.Format());
            //var id = Guid.Empty;

            Report(userError.InnerException);
            // NOTE: this code really shouldn't throw away the MessageBoxResult
            var message = userError.ErrorCauseOrResolution +
                          "\n\nWe've been notified about the problem." +
                          "\n\nPlease make sure you are running the latest version of the software.\n\nIf the problem persists, please contact Support: http://community.withsix.com";
            var title  = userError.ErrorMessage ?? "An error has occured while trying to process the action";
            var result =
                await
                _dialogManager.MessageBox(new MessageBoxDialogParams(message, title) { Owner = window })
                .ConfigureAwait(false);

            return(RecoveryOptionResult.CancelOperation);
        }
        async Task Close()
        {
            if (_localFile != null)
            {
                Exception e;
                try {
                    await
                    _mediator.SendAsync(new UploadNewCollectionImageCommand(Content.Id,
                                                                            _localFile)).ConfigureAwait(false);

                    TryClose(true);
                    return;
                } catch (SizeExtensions.UnsupportedFileSizeException ex) {
                    e = ex;
                }
                await
                _dialogManager.MessageBox(new MessageBoxDialogParams(e.Message, "The file size is not supported"))
                .ConfigureAwait(false);

                return;
            }

            TryClose(true);
        }
        async Task <bool> InstallIronFront()
        {
            try {
                if (_ifService.IsIronFrontInstalled(DomainEvilGlobal.SelectedGame.ActiveGame))
                {
                    return(true);
                }

                if (await _dialogManager.MessageBox(new MessageBoxDialogParams(
                                                        @"Please confirm the installation of Iron Front in Arma by clicking OK.

Note: The conversion and patching process will take several minutes - please be patient.",
                                                        "Iron Front in Arma setup", SixMessageBoxButton.OKCancel)) == SixMessageBoxResult.Cancel)
                {
                    return(false);
                }
                _ifService.InstallIronFrontArma(DomainEvilGlobal.SelectedGame.ActiveGame);
            } catch (OaIronfrontNotFoundException) {
                await _dialogManager.MessageBox(new MessageBoxDialogParams("OA/IronFront not found?"));

                return(false);
            } catch (DestinationDriveFullException ddex) {
                await _dialogManager.MessageBox(new MessageBoxDialogParams(
                                                    "You have not enough space on the destination drive, you need at least " +
                                                    Tools.FileUtil.GetFileSize(ddex.RequiredSpace) + " free space on " +
                                                    ddex.Path));

                return(false);
            } catch (TemporaryDriveFullException tdex) {
                await _dialogManager.MessageBox(new MessageBoxDialogParams(
                                                    "You have not enough space on the temp drive, you need at least " +
                                                    Tools.FileUtil.GetFileSize(tdex.RequiredSpace) + " free space on " +
                                                    tdex.Path));

                return(false);
            } catch (ElevationRequiredException erex) {
                if (await _dialogManager.MessageBox(new MessageBoxDialogParams(
                                                        "The IronFront conversion process needs to run as administrator, restarting now, please start the process again after restarted")) ==
                    SixMessageBoxResult.Cancel)
                {
                    return(false);
                }
                _restarter.RestartWithUacInclEnvironmentCommandLine();
                return(false);
            } catch (UnsupportedIFAVersionException e) {
                await _dialogManager.MessageBox(new MessageBoxDialogParams(
                                                    "Unsupported Iron Front version. Must either be 1.0, 1.03, 1.04, or 1.05\nFound: " +
                                                    e.Message));

                return(false);
            }
            return(true);
        }
Ejemplo n.º 17
0
 public static void BusyDialog(this IDialogManager dialogManager)
 {
     dialogManager.MessageBox(new MessageBoxDialogParams(
                                  "Cannot perform action; already busy.\nPlease wait until current action has completed",
                                  "Warning, cannot perform action while already busy")).WaitSpecial();
 }
Ejemplo n.º 18
0
 async Task <bool> ModPathChangedDialog(IAbsoluteDirectoryPath oldModsPath, IAbsoluteDirectoryPath newModPath) => (await _dialogManager.MessageBox(new MessageBoxDialogParams(
                                                                                                                                                       $"Mod path changed, do you want to move existing data?\nFrom: {oldModsPath} to {newModPath}", "Move existing data?", SixMessageBoxButton.YesNo)))
 == SixMessageBoxResult.Yes;
Ejemplo n.º 19
0
        public async Task <Unit> Handle(DialogMessageCommand request)
        {
            await _dialogManager.MessageBox(new MessageBoxDialogParams(request.Message, request.Title)).ConfigureAwait(false);

            return(Unit.Value);
        }