mirror of
https://github.com/cyanfish/naps2.git
synced 2024-08-16 10:40:35 +03:00
55b1927a82
This will ensure we don't persist form state from the old design
27 lines
784 B
C#
27 lines
784 B
C#
using NAPS2.EtoForms.Ui;
|
|
using NAPS2.Scan;
|
|
|
|
namespace NAPS2.EtoForms;
|
|
|
|
public class EtoDevicePrompt : IDevicePrompt
|
|
{
|
|
private readonly IFormFactory _formFactory;
|
|
|
|
public EtoDevicePrompt(IFormFactory formFactory)
|
|
{
|
|
_formFactory = formFactory;
|
|
}
|
|
|
|
public Task<DeviceChoice> PromptForDevice(ScanOptions options, bool allowAlwaysAsk)
|
|
{
|
|
// TODO: Extension method or something to turn InvokeGet into Task<T>?
|
|
return Task.FromResult(Invoker.Current.InvokeGet(() =>
|
|
{
|
|
var deviceForm = _formFactory.Create<ChooseDeviceForm>();
|
|
deviceForm.ScanOptions = options;
|
|
deviceForm.AllowAlwaysAsk = allowAlwaysAsk;
|
|
deviceForm.ShowModal();
|
|
return deviceForm.Choice;
|
|
}));
|
|
}
|
|
} |