2022-12-11 01:58:48 +03:00
|
|
|
|
using NAPS2.EtoForms;
|
|
|
|
|
using NAPS2.EtoForms.Ui;
|
|
|
|
|
|
2023-02-19 00:04:18 +03:00
|
|
|
|
namespace NAPS2.Pdf;
|
2022-12-11 01:58:48 +03:00
|
|
|
|
|
|
|
|
|
public class EtoPdfPasswordProvider : IPdfPasswordProvider
|
|
|
|
|
{
|
|
|
|
|
private readonly IFormFactory _formFactory;
|
|
|
|
|
|
|
|
|
|
public EtoPdfPasswordProvider(IFormFactory formFactory)
|
|
|
|
|
{
|
|
|
|
|
_formFactory = formFactory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool ProvidePassword(string fileName, int attemptCount, out string password)
|
|
|
|
|
{
|
|
|
|
|
(password, var result) = Invoker.Current.InvokeGet(() =>
|
|
|
|
|
{
|
|
|
|
|
var passwordForm = _formFactory.Create<PdfPasswordForm>();
|
|
|
|
|
passwordForm.FileName = fileName;
|
|
|
|
|
passwordForm.ShowModal();
|
|
|
|
|
return (passwordForm.Password!, passwordForm.Result);
|
|
|
|
|
});
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|