コード例 #1
0
        private void SignaturePasswordButton_OnClick(object sender, RoutedEventArgs e)
        {
            var certificationFile = CertificationFileTextBox.Text;

            if (!File.Exists(certificationFile))
            {
                var message = TranslationHelper.TranslatorInstance.GetTranslation("ProfileSettingsWindow",
                                                                                  "CertificateDoesNotExist",
                                                                                  "The certificate file does not exist.");
                var caption = TranslationHelper.TranslatorInstance.GetTranslation("ProfileSettingsWindow",
                                                                                  "PDFSignature",
                                                                                  "PDF Signature");
                MessageWindow.ShowTopMost(message, caption, MessageWindowButtons.OK, MessageWindowIcon.Error);
                return;
            }

            var pwWindow = new SignaturePasswordWindow(PasswordMiddleButton.Remove, certificationFile);

            pwWindow.Password = ViewModel.CurrentProfile.PdfSettings.Signature.SignaturePassword;

            pwWindow.ShowDialog();
            if (pwWindow.SignaturePasswordViewModel.Result == SignaturePasswordResult.StorePassword)
            {
                ViewModel.CurrentProfile.PdfSettings.Signature.SignaturePassword = pwWindow.Password;
            }
            else if (pwWindow.SignaturePasswordViewModel.Result == SignaturePasswordResult.RemovePassword)
            {
                ViewModel.CurrentProfile.PdfSettings.Signature.SignaturePassword = "";
            }
        }
コード例 #2
0
        protected override bool QuerySignaturePassword()
        {
            if (!string.IsNullOrEmpty(Job.Profile.PdfSettings.Signature.SignaturePassword))
            {
                Job.Passwords.PdfSignaturePassword = Job.Profile.PdfSettings.Signature.SignaturePassword;
                return(true);
            }

            var passwordWindow = new SignaturePasswordWindow(PasswordMiddleButton.Skip, Job.Profile.PdfSettings.Signature.CertificateFile);

            TopMostHelper.ShowDialogTopMost(passwordWindow, true);

            if (passwordWindow.SignaturePasswordViewModel.Result == SignaturePasswordResult.StorePassword)
            {
                Job.Passwords.PdfSignaturePassword = passwordWindow.Password;
                return(true);
            }
            if (passwordWindow.SignaturePasswordViewModel.Result == SignaturePasswordResult.Skip)
            {
                Job.Profile.PdfSettings.Signature.Enabled = false;
                Logger.Info("User skipped Signature Password. Signing disabled.");
                return(true);
            }

            Cancel = true;
            Logger.Warn("Cancelled the signature password dialog. No PDF will be created.");
            WorkflowStep = WorkflowStep.AbortedByUser;
            return(false);
        }