public static List<ScannedImage> Scan(ScanProfile settings, ScanDevice device, IWin32Window pForm, IFormFactory formFactory) { var tw = new Twain(); if (!tw.Init(pForm.Handle)) { throw new DeviceNotFoundException(); } if (!tw.SelectByName(device.ID)) { throw new DeviceNotFoundException(); } var form = formFactory.Create<FTwainGui>(); var mf = new TwainMessageFilter(settings, tw, form); form.ShowDialog(pForm); return mf.Bitmaps; }
public static List <ScannedImage> Scan(ScanProfile settings, ScanDevice device, IWin32Window pForm, IFormFactory formFactory) { var tw = new Twain(); if (!tw.Init(pForm.Handle)) { throw new DeviceNotFoundException(); } if (!tw.SelectByName(device.ID)) { throw new DeviceNotFoundException(); } var form = formFactory.Create <FTwainGui>(); var mf = new TwainMessageFilter(settings, tw, form); form.ShowDialog(pForm); return(mf.Bitmaps); }
public static void Scan(ScanProfile settings, ScanDevice device, IWin32Window pForm, IFormFactory formFactory, ScannedImageSource.Concrete source) { var tw = new Twain(); if (!tw.Init(pForm.Handle)) { throw new DeviceNotFoundException(); } if (!tw.SelectByName(device.ID)) { throw new DeviceNotFoundException(); } var form = formFactory.Create <FTwainGui>(); var mf = new TwainMessageFilter(settings, tw, form); form.ShowDialog(pForm); foreach (var b in mf.Bitmaps) { source.Put(b); } }
public static void Scan(ScanProfile settings, ScanDevice device, IWin32Window pForm, IFormFactory formFactory, ScannedImageSource.Concrete source) { var tw = new Twain(); var windowHandle = (Invoker.Current as Form)?.Handle ?? pForm.Handle; if (!tw.Init(windowHandle)) { throw new DeviceNotFoundException(); } if (!tw.SelectByName(device.Id)) { throw new DeviceNotFoundException(); } var form = Invoker.Current.InvokeGet(formFactory.Create <FTwainGui>); var mf = new TwainMessageFilter(settings, tw, form); Invoker.Current.Invoke(() => form.ShowDialog(pForm)); foreach (var b in mf.Bitmaps) { source.Put(b); } }