public IEnumerable <WiaDeviceInfo> GetDeviceInfos() { var result = new List <WiaDeviceInfo>(); WiaException.Check(Version == WiaVersion.Wia10 ? NativeWiaMethods.EnumerateDevices1(Handle, x => result.Add(new WiaDeviceInfo(Version, x))) : NativeWiaMethods.EnumerateDevices2(Handle, x => result.Add(new WiaDeviceInfo(Version, x)))); return(result); }
public List <WiaItem> GetSubItems() { var items = new List <WiaItem>(); WiaException.Check(Version == WiaVersion.Wia10 ? NativeWiaMethods.EnumerateItems1(Handle, itemHandle => items.Add(new WiaItem(Version, itemHandle))) : NativeWiaMethods.EnumerateItems2(Handle, itemHandle => items.Add(new WiaItem(Version, itemHandle)))); return(items); }
public WiaDevice PromptForDevice(IntPtr parentWindowHandle) { var hr = Version == WiaVersion.Wia10 ? NativeWiaMethods.SelectDevice1(Handle, parentWindowHandle, SCANNER_DEVICE_TYPE, SELECT_DEVICE_NODEFAULT, out _, out var deviceHandle) : NativeWiaMethods.SelectDevice2(Handle, parentWindowHandle, SCANNER_DEVICE_TYPE, SELECT_DEVICE_NODEFAULT, out _, out deviceHandle); if (hr == 1) { return(null); } WiaException.Check(hr); return(new WiaDevice(Version, deviceHandle));; }
public bool Download() { var hr = Version == WiaVersion.Wia10 ? NativeWiaMethods.Download1(Handle, TransferStatusCallback) : NativeWiaMethods.Download2(Handle, TransferStatusCallback); if (hr == 1) { // User cancelled return(false); } WiaException.Check(hr); return(true); }
public string[] PromptForImage(IntPtr parentWindowHandle, WiaDevice device) { var fileName = Path.GetRandomFileName(); var itemHandle = IntPtr.Zero; var fileCount = 0; var filePaths = new string[10]; var hr = Version == WiaVersion.Wia10 ? NativeWiaMethods.GetImage1(Handle, parentWindowHandle, SCANNER_DEVICE_TYPE, 0, 0, Path.Combine(Paths.Temp, fileName), IntPtr.Zero) : NativeWiaMethods.GetImage2(Handle, 0, device.Id(), parentWindowHandle, Paths.Temp, fileName, ref fileCount, ref filePaths, ref itemHandle); if (hr == 1) { return(null); } WiaException.Check(hr); return(filePaths ?? new[] { Path.Combine(Paths.Temp, fileName) }); }
public WiaItem PromptToConfigure(IntPtr parentWindowHandle) { if (Version == WiaVersion.Wia20) { throw new InvalidOperationException("WIA 2.0 does not support PromptToConfigure. Use WiaDeviceManager.PromptForImage if you want to use the native WIA 2.0 UI."); } int itemCount = 0; IntPtr[] items = null; var hr = NativeWiaMethods.ConfigureDevice1(Handle, parentWindowHandle, 0, 0, ref itemCount, ref items); if (hr == 1) { return(null); } WiaException.Check(hr); return(new WiaItem(Version, items[0])); }
public WiaPropertyCollection(WiaVersion version, IntPtr propertyStorageHandle) : base(version, propertyStorageHandle) { propertyDict = new Dictionary <int, WiaProperty>(); WiaException.Check(NativeWiaMethods.EnumerateProperties(Handle, (id, name, type) => propertyDict.Add(id, new WiaProperty(Handle, id, name, type)))); }