protected override bool QueryEncryptionPasswords() { Job.Passwords.PdfOwnerPassword = Job.Profile.PdfSettings.Security.OwnerPassword; Job.Passwords.PdfUserPassword = Job.Profile.PdfSettings.Security.UserPassword; var askOwnerPw = string.IsNullOrEmpty(Job.Profile.PdfSettings.Security.OwnerPassword); var askUserPw = Job.Profile.PdfSettings.Security.RequireUserPassword && string.IsNullOrEmpty(Job.Profile.PdfSettings.Security.UserPassword); if (askOwnerPw || askUserPw) //overwrite values with value from form { var pwWindow = new EncryptionPasswordsWindow(EncryptionPasswordMiddleButton.Skip, askOwnerPw, askUserPw); pwWindow.ShowDialogTopMost(); if (pwWindow.Response == EncryptionPasswordResponse.OK) { if (askOwnerPw) { Job.Passwords.PdfOwnerPassword = pwWindow.OwnerPassword; } if (askUserPw) { Job.Passwords.PdfUserPassword = pwWindow.UserPassword; } } else if (pwWindow.Response == EncryptionPasswordResponse.Skip) { Job.Profile.PdfSettings.Security.Enabled = false; Logger.Info("User skipped encryption password dialog. Encryption disabled."); return(true); } else { Cancel = true; Logger.Warn("Cancelled the PDF password dialog. No PDF will be created."); WorkflowStep = WorkflowStep.AbortedByUser; return(false); } } return(true); }
private void SecurityPasswordsButton_OnClick(object sender, RoutedEventArgs e) { var askUserPassword = ViewModel.CurrentProfile.PdfSettings.Security.RequireUserPassword; var pwWindow = new EncryptionPasswordsWindow(EncryptionPasswordMiddleButton.Remove, true, askUserPassword); pwWindow.OwnerPassword = ViewModel.CurrentProfile.PdfSettings.Security.OwnerPassword; pwWindow.UserPassword = ViewModel.CurrentProfile.PdfSettings.Security.UserPassword; pwWindow.ShowDialogTopMost(); if (pwWindow.Response == EncryptionPasswordResponse.OK) { ViewModel.CurrentProfile.PdfSettings.Security.OwnerPassword = pwWindow.OwnerPassword; ViewModel.CurrentProfile.PdfSettings.Security.UserPassword = pwWindow.UserPassword; } else if (pwWindow.Response == EncryptionPasswordResponse.Remove) { ViewModel.CurrentProfile.PdfSettings.Security.UserPassword = ""; ViewModel.CurrentProfile.PdfSettings.Security.OwnerPassword = ""; } }