private void SetPasswordExecute(object obj) { var sb = new StringBuilder(); sb.AppendLine(Translator.GetTranslation("pdfforge.PDFCreator.UI.Views.ActionControls.EmailClientActionControl", "RecipientsText.Text")); sb.AppendLine(EmailSmtpSettings.Recipients); var title = Translator.GetTranslation("EmailClientActionSettings", "SmtpPasswordTitle"); var description = Translator.GetTranslation("EmailClientActionSettings", "SmtpPasswordDescription"); var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, title, description); interaction.Password = EmailSmtpSettings.Password; interaction.IntroText = sb.ToString(); _interactionInvoker.Invoke(interaction); if (interaction.Result == PasswordResult.StorePassword) { EmailSmtpSettings.Password = interaction.Password; } else if (interaction.Result == PasswordResult.StorePassword) { EmailSmtpSettings.Password = ""; } }
private string QueryProfileName(string proposedName) { var title = Translation.ProfileName; var questionText = Translation.EnterProfileName; var inputInteraction = new InputInteraction(title, questionText, ProfilenameIsValid); if (proposedName != null) { inputInteraction.InputText = proposedName; } else { inputInteraction.InputText = Translation.NewProfile; } _interactionInvoker.Invoke(inputInteraction); if (!inputInteraction.Success) { return(null); } return(inputInteraction.InputText); }
private void SetPasswordExecute(object obj) { var sb = new StringBuilder(); sb.AppendLine(Translation.RecipientsText); sb.AppendLine(EmailSmtpSettings.Recipients); var title = Translation.SmtpPasswordTitle; var description = Translation.SmtpPasswordDescription; var interaction = new PasswordInteraction(PasswordMiddleButton.Remove, title, description); interaction.Password = EmailSmtpSettings.Password; interaction.IntroText = sb.ToString(); _interactionInvoker.Invoke(interaction); if (interaction.Result == PasswordResult.StorePassword) { EmailSmtpSettings.Password = interaction.Password; } else if (interaction.Result == PasswordResult.StorePassword) { EmailSmtpSettings.Password = ""; } }
private MessageResponse ShowMessage(string message, string title, MessageOptions buttons, MessageIcon icon) { var interaction = new MessageInteraction(message, title, buttons, icon); _invoker.Invoke(interaction); return(interaction.Response); }
private string QueryProfileName(string proposedName) { var title = _translator.GetTranslation("ProfileSettingsWindow", "ProfileName"); var questionText = _translator.GetTranslation("ProfileSettingsWindow", "EnterProfileName"); var inputInteraction = new InputInteraction(title, questionText, ProfilenameIsValid); if (proposedName != null) { inputInteraction.InputText = proposedName; } else { inputInteraction.InputText = _translator.GetTranslation("ProfileSettingsWindow", "NewProfile"); } _interactionInvoker.Invoke(inputInteraction); if (!inputInteraction.Success) { return(null); } return(inputInteraction.InputText); }
private QueryResult <OutputFilenameResult> InvokeInteraction(SaveFileInteraction interaction, OutputFormat outputFormat, bool canChangeFormat) { var result = new QueryResult <OutputFilenameResult> { Success = false }; _interactionInvoker.Invoke(interaction); if (!interaction.Success) { return(result); } if (canChangeFormat) { outputFormat = (OutputFormat)interaction.FilterIndex - 1; } var outputFile = interaction.FileName; var outputFormatHelper = new OutputFormatHelper(); if (!outputFormatHelper.HasValidExtension(outputFile, outputFormat)) { outputFile = outputFormatHelper.EnsureValidExtension(outputFile, outputFormat); } result.Success = true; result.Data = new OutputFilenameResult(outputFile, outputFormat); return(result); }
private bool TrySetJobPasswords(Job job, ConversionProfile profile) { if (!string.IsNullOrWhiteSpace(profile.EmailSmtpSettings.Password)) { job.Passwords.SmtpPassword = profile.EmailSmtpSettings.Password; return(true); } var sb = new StringBuilder(); sb.AppendLine(_translation.RecipientsText); sb.AppendLine(profile.EmailSmtpSettings.Recipients); var title = _translation.SmtpPasswordTitle; var description = _translation.SmtpPasswordDescription; var interaction = new PasswordInteraction(PasswordMiddleButton.None, title, description, false); interaction.IntroText = sb.ToString(); _interactionInvoker.Invoke(interaction); if (interaction.Result != PasswordResult.StorePassword) { return(false); } job.Passwords.SmtpPassword = interaction.Password; return(true); }
private void OfflineActivationCommandExecute(object obj) { var interaction = new OfflineActivationInteraction(_lastActivationKey); _interactionInvoker.Invoke(interaction); if (interaction.Success) { _lastActivationKey = interaction.LicenseKey; Activation activation; try { activation = _activationHelper.ActivateOfflineActivationStringFromLicenseServer(interaction.LicenseServerAnswer); } catch (FormatException) { activation = new Activation(); activation.Key = interaction.LicenseKey; } UpdateActivation(activation); IsCheckingLicense = false; LicenseCheckFinishedEvent.Set(); } }
private void DisplayInvalidSettingsWarning() { var message = _translation.InvalidSettingsWarning; var caption = _translation.InvalidSettings; var interaction = new MessageInteraction(message, caption, MessageOptions.OK, MessageIcon.Error); _interactionInvoker.Invoke(interaction); }
private void DisplayNoClientFoundMessage() { var caption = Translator.GetTranslation("EmailClientActionSettings", "CheckMailClient"); var message = Translator.GetTranslation("EmailClientActionSettings", "NoMapiClientFound"); var interaction = new MessageInteraction(message, caption, MessageOptions.OK, MessageIcon.Warning); _interactionInvoker.Invoke(interaction); }
private void DisplayNoClientFoundMessage() { var caption = Translation.CheckMailClient; var message = Translation.NoMapiClientFound; var interaction = new MessageInteraction(message, caption, MessageOptions.OK, MessageIcon.Warning); _interactionInvoker.Invoke(interaction); }
private void DisplayInvalidSettingsWarning() { var message = _translator.GetTranslation("ApplicationSettingsWindow", "InvalidSettingsWarning"); var caption = _translator.GetTranslation("ApplicationSettingsWindow", "InvalidSettings"); var interaction = new MessageInteraction(message, caption, MessageOptions.OK, MessageIcon.Error); _interactionInvoker.Invoke(interaction); }
public void WhenPasswordInteractionIsCancelled_DoesNotSendMail() { //_interactionRequest.RegisterInteractionHandler<PasswordOverlayInteraction>(interaction => interaction.Result = PasswordResult.Cancel); _interactionInvoker.Invoke(Arg.Do <PasswordOverlayInteraction>(i => i.Result = PasswordResult.Cancel)); var assistant = BuildAssistant(); assistant.SendTestMail(_profile, _accounts); _smtpAction.DidNotReceive().ProcessJob(Arg.Any <Job>()); }
public void LaunchUpdate(ApplicationVersion version) { var caption = _translation.GetFormattedTitle(_applicationNameProvider.ApplicationName); try { var done = false; while (!done) { var interaction = new UpdateDownloadInteraction(version.DownloadUrl); _interactionInvoker.Invoke(interaction); var result = interaction.Success; if (result != true) { done = true; continue; } if (_hashUtil.VerifyFileMd5(interaction.DownloadedFile, version.FileHash)) { done = true; _threadManager.UpdateAfterShutdownAction = () => Process.Start(interaction.DownloadedFile); continue; } var message = _translation.DownloadHashErrorMessage; var res = ShowMessage(message, caption, MessageOptions.YesNo, MessageIcon.Warning); if (res != MessageResponse.No) { continue; } _threadManager.UpdateAfterShutdownAction = () => Process.Start(interaction.DownloadedFile); done = true; } } catch (Exception) { var message = _translation.DownloadErrorMessage; var res = ShowMessage(message, caption, MessageOptions.YesNo, MessageIcon.PDFCreator); if (res == MessageResponse.Yes) { Process.Start(version.DownloadUrl); } } }
private void ExecuteShowLogFile(object o) { if (_fileWrap.Exists(LoggingHelper.LogFile)) { _processStarter.Start(LoggingHelper.LogFile); } else { var caption = Translator.GetTranslation("ApplicationSettingsWindow", "NoLogFile"); var message = Translator.GetTranslation("ApplicationSettingsWindow", "NoLogFileAvailable"); var interaction = new MessageInteraction(message, caption, MessageOptions.OK, MessageIcon.Warning); _invoker.Invoke(interaction); } }
public void OnJobFinished(object sender, EventArgs eventArgs) { if (_plusHintHelper.QueryDisplayHint()) { _interactionInvoker.Invoke(new PlusHintInteraction(_plusHintHelper.CurrentJobCounter)); } }
public void ShowSharedLinks(DropboxFileMetaData sharedLinks) { _logger.Debug("DropboxSharedLinks started"); var interaction = new DropboxSharedLinksInteraction(sharedLinks); _interactionInvoker.Invoke(interaction); }
private PasswordInteraction CreateAndInvokeInteraction(Job job, bool retype) { var sb = new StringBuilder(); sb.AppendLine(_translator.GetTranslation("pdfforge.PDFCreator.UI.Views.ActionControls.EmailClientActionControl", "RecipientsText.Text")); sb.AppendLine(job.Profile.EmailSmtpSettings.Recipients); if (retype) { sb.AppendLine(); sb.AppendLine(_translator.GetTranslation("InteractiveWorkflow", "RetypeSmtpPwMessage")); } var title = _translator.GetTranslation("EmailClientActionSettings", "SmtpPasswordTitle"); var description = _translator.GetTranslation("EmailClientActionSettings", "SmtpPasswordDescription"); var button = retype ? PasswordMiddleButton.None : PasswordMiddleButton.Skip; var interaction = new PasswordInteraction(button, title, description, false) { Password = job.Passwords.SmtpPassword, IntroText = sb.ToString() }; _interactionInvoker.Invoke(interaction); return(interaction); }
private void ShowPrintDialog(Job job) { if (job.Profile.SkipPrintDialog) { return; } var interaction = new PrintJobInteraction(job.JobInfo, job.Profile); _interactionInvoker.Invoke(interaction); if (interaction.PrintJobAction == PrintJobAction.Cancel) { throw new AbortWorkflowException("Cancelled the PrintJob dialog."); } if (interaction.PrintJobAction == PrintJobAction.ManagePrintJobs) { throw new ManagePrintJobsException(); } job.Profile = interaction.Profile.Copy(); _jobDataUpdater.UpdateTokensAndMetadata(job); if (interaction.PrintJobAction != PrintJobAction.EMail) { return; } job.SkipSaveFileDialog = true; job.Profile.EmailClientSettings.Enabled = true; job.Profile.AutoSave.Enabled = false; job.Profile.OpenViewer = false; }
public void CheckAll() { _logger.Trace("Checking installation..."); foreach (var startupCondition in _startupConditions) { _logger.Trace("Checking " + startupCondition.GetType().Name); var result = startupCondition.Check(); if (result.IsSuccessful) { continue; } if (result.ShowMessage) { _interactionInvoker.Invoke(new MessageInteraction(result.Message, "PDFCreator", MessageOptions.OK, MessageIcon.Error)); } if (!string.IsNullOrWhiteSpace(result.Message)) { _logger.Error(result.Message); } throw new StartupConditionFailedException(result.ExitCode, result.Message); } }
public void Setup() { _smtpTestAccount = new SmtpAccount(); _smtpTestAccount.AccountId = "SmtpTestAccountId"; _profile = new ConversionProfile(); //Attention _profile.EmailSmtpSettings.AccountId = _smtpTestAccount.AccountId; //The AccountAssosiation is mocked below. The _smtpTestAccount is always used. _accounts = new Accounts(); _accounts.SmtpAccounts.Add(_smtpTestAccount); _interactionRequest = new UnitTestInteractionRequest(); _interactionInvoker = Substitute.For <IInteractionInvoker>(); _interactionInvoker.Invoke(Arg.Do <PasswordOverlayInteraction>(i => i.Result = PasswordResult.StorePassword)); _interactionRequest.RegisterInteractionHandler <PasswordOverlayInteraction>(interaction => interaction.Result = PasswordResult.StorePassword); _file = Substitute.For <IFile>(); _path = Substitute.For <IPath>(); _smtpAction = Substitute.For <ISmtpMailAction>(); _smtpAction.Check(Arg.Any <ConversionProfile>(), _accounts, Arg.Any <CheckLevel>()).Returns(x => new ActionResult()); _smtpAction.ProcessJob(Arg.Any <Job>()).Returns(x => new ActionResult()); //_smtpAction.GetSmtpAccount(_profile, _accounts).Returns(_smtpTestAccount); _mailSignatureHelper = Substitute.For <IMailSignatureHelper>(); _mailSignatureHelper.ComposeMailSignature().Returns(_mailSignature); _tokenReplacer = new TokenReplacer(); _tokenReplacerFactory = Substitute.For <ITokenReplacerFactory>(); _tokenReplacerFactory.BuildTokenReplacerWithOutputfiles(Arg.Any <Job>()).Returns(_tokenReplacer); _translation = new SmtpTranslation(); }
private void ChooseStampColorExecute(object obj) { var interaction = new ColorInteraction(); interaction.Color = CurrentProfile.Stamping.Color; _interactionInvoker.Invoke(interaction); if (!interaction.Success) { return; } CurrentProfile.Stamping.Color = interaction.Color; RaisePropertyChanged(nameof(CurrentProfile)); }
private void OpenWithArchictectExecute(object obj) { if (!CurrentProfile.OpenWithPdfArchitect) { return; } if (_pdfArchitectCheck.IsInstalled()) { return; } const string caption = "PDF Architect"; var message = Translator.GetTranslation("OpenViewerSettings", "ArchitectNotInstalled"); var interaction = new MessageInteraction(message, caption, MessageOptions.YesNo, MessageIcon.PDFForge); _interactionInvoker.Invoke(interaction); if (interaction.Response == MessageResponse.Yes) { _processStarter.Start(Urls.ArchitectDownloadUrl); } CurrentProfile.OpenWithPdfArchitect = false; RaisePropertyChanged(nameof(CurrentProfile)); }
private bool QuerySaveModifiedSettings() { if (!AppSettingsAreModified()) { return(true); //No changes -> proceed } var message = Translation.AskSaveModifiedSettings; var caption = Translation.AppSettings; var interaction = new MessageInteraction(message, caption, MessageOptions.YesNo, MessageIcon.Question); _invoker.Invoke(interaction); var response = interaction.Response; if (response == MessageResponse.Yes) //Proceed with saved settings { SaveAppSettings(); return(true); } if (response == MessageResponse.No) //Proceed with old settings { return(true); } return(false); //Cancel Testprinting }
private PasswordInteraction CreateAndInvokeInteraction(Job job, bool retype) { var sb = new StringBuilder(); sb.AppendLine(_translation.RecipientsText); sb.AppendLine(job.Profile.EmailSmtpSettings.Recipients); if (retype) { sb.AppendLine(); sb.AppendLine(_translation.RetypeSmtpPwMessage); } var title = _translation.SmtpPasswordTitle; var description = _translation.SmtpPasswordDescription; var button = retype ? PasswordMiddleButton.None : PasswordMiddleButton.Skip; var interaction = new PasswordInteraction(button, title, description, false) { Password = job.Passwords.SmtpPassword, IntroText = sb.ToString() }; _interactionInvoker.Invoke(interaction); return(interaction); }
public StartupConditionResult Check() { RenewActivation(); if (_activationHelper.IsLicenseValid) { return(StartupConditionResult.BuildSuccess()); } _logger.Error("Invalid or expired license."); var editionWithVersionNumber = _applicationNameProvider.ApplicationName + " " + _versionHelper.FormatWithThreeDigits(); _settingsManager.LoadAllSettings(); var settingsProvider = _settingsManager.GetSettingsProvider(); if (settingsProvider.GpoSettings.HideLicenseTab) { var errorMessage = _translator.GetFormattedTranslation("Program", "LicenseInvalidGpoHideLicenseTab", editionWithVersionNumber); return(StartupConditionResult.BuildErrorWithMessage((int)ExitCode.LicenseInvalidAndHiddenWithGpo, errorMessage)); } var caption = _applicationNameProvider.ApplicationName; var message = _translator.GetFormattedTranslation("Program", "LicenseInvalid", editionWithVersionNumber); var result = ShowMessage(message, caption, MessageOptions.YesNo, MessageIcon.Exclamation); if (result != MessageResponse.Yes) { return(StartupConditionResult.BuildErrorWithMessage((int)ExitCode.LicenseInvalidAndNotReactivated, "The license is invalid!", showMessage: false)); } var interaction = new LicenseInteraction(); _interactionInvoker.Invoke(interaction); //Check latest edition for validity _activationHelper.LoadActivation(); if (_activationHelper.IsLicenseValid) { return(StartupConditionResult.BuildSuccess()); } return(StartupConditionResult.BuildErrorWithMessage((int)ExitCode.LicenseInvalidAfterReactivation, _translator.GetFormattedTranslation("Program", "LicenseInvalidAfterReactivation", _applicationNameProvider.ApplicationName))); }
private void LaunchNewUpdateForm(UpdateEventArgs eventArgs) { var interaction = new UpdateAvailableInteraction(Urls.PDFCreatorWhatsNewUrl, OnlineVersion.Version.ToString()); _interactionInvoker.Invoke(interaction); switch (interaction.Response) { case UpdateAvailableResponse.Install: _updateLauncher.LaunchUpdate(OnlineVersion); break; case UpdateAvailableResponse.Skip: eventArgs.SkipVersion = true; break; } }
protected override void ExecuteWelcomeAction() { if (_welcomeSettingsHelper.IsFirstRun()) { _welcomeSettingsHelper.SetCurrentApplicationVersionAsWelcomeVersionInRegistry(); _interactionInvoker.Invoke(new WelcomeInteraction()); } }
public StartupConditionResult Check() { var activation = RenewActivation(); if (activation.Exists(a => a.IsActivationStillValid())) { return(StartupConditionResult.BuildSuccess()); } _logger.Error("Invalid or expired license."); var editionWithVersionNumber = _applicationNameProvider.ApplicationNameWithEdition + " " + _versionHelper.FormatWithThreeDigits(); if (_gpoSettings.HideLicenseTab) { var errorMessage = _translation.GetFormattedLicenseInvalidGpoHideLicenseTab(editionWithVersionNumber); return(StartupConditionResult.BuildErrorWithMessage((int)ExitCode.LicenseInvalidAndHiddenWithGpo, errorMessage)); } var caption = _applicationNameProvider.ApplicationName; var message = _translation.GetFormattedLicenseInvalidTranslation(editionWithVersionNumber); var result = ShowMessage(message, caption, MessageOptions.YesNo, MessageIcon.Exclamation); if (result != MessageResponse.Yes) { return(StartupConditionResult.BuildErrorWithMessage((int)ExitCode.LicenseInvalidAndNotReactivated, "The license is invalid!", showMessage: false)); } var interaction = new LicenseInteraction(); _interactionInvoker.Invoke(interaction); //Check latest edition for validity activation = _licenseChecker.GetSavedActivation(); if (activation.Exists(a => a.IsActivationStillValid())) { return(StartupConditionResult.BuildSuccess()); } return(StartupConditionResult.BuildErrorWithMessage((int)ExitCode.LicenseInvalidAfterReactivation, _translation.GetFormattedLicenseInvalidAfterReactivationTranslation(_applicationNameProvider.ApplicationNameWithEdition))); }
private void MainWindowLaunchThreadMethod() { try { _interactionInvoker.Invoke(new MainWindowInteraction()); } finally { _mainWindowThread = null; } }