2024-08-01 23:27:45 +03:00
|
|
|
|
using NAPS2.EtoForms.Ui;
|
2022-06-19 19:45:33 +03:00
|
|
|
|
using NAPS2.Scan;
|
|
|
|
|
|
2022-09-06 07:13:32 +03:00
|
|
|
|
namespace NAPS2.EtoForms;
|
2022-06-19 19:45:33 +03:00
|
|
|
|
|
2022-09-06 07:13:32 +03:00
|
|
|
|
public class EtoDevicePrompt : IDevicePrompt
|
2022-06-19 19:45:33 +03:00
|
|
|
|
{
|
|
|
|
|
private readonly IFormFactory _formFactory;
|
|
|
|
|
|
2024-08-07 07:03:33 +03:00
|
|
|
|
public EtoDevicePrompt(IFormFactory formFactory)
|
2022-06-19 19:45:33 +03:00
|
|
|
|
{
|
|
|
|
|
_formFactory = formFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-02 03:41:44 +03:00
|
|
|
|
public Task<DeviceChoice> PromptForDevice(ScanOptions options, bool allowAlwaysAsk)
|
2022-06-19 19:45:33 +03:00
|
|
|
|
{
|
2024-08-01 23:27:45 +03:00
|
|
|
|
// TODO: Extension method or something to turn InvokeGet into Task<T>?
|
|
|
|
|
return Task.FromResult(Invoker.Current.InvokeGet(() =>
|
2023-02-12 04:46:43 +03:00
|
|
|
|
{
|
2024-08-07 07:31:05 +03:00
|
|
|
|
var deviceForm = _formFactory.Create<ChooseDeviceForm>();
|
2024-08-01 23:27:45 +03:00
|
|
|
|
deviceForm.ScanOptions = options;
|
2024-08-02 03:41:44 +03:00
|
|
|
|
deviceForm.AllowAlwaysAsk = allowAlwaysAsk;
|
2024-08-01 23:27:45 +03:00
|
|
|
|
deviceForm.ShowModal();
|
2024-08-02 03:41:44 +03:00
|
|
|
|
return deviceForm.Choice;
|
2024-08-01 23:27:45 +03:00
|
|
|
|
}));
|
2022-06-19 19:45:33 +03:00
|
|
|
|
}
|
|
|
|
|
}
|