Exemplo n.º 1
0
        public string[] PromptForImage(IntPtr parentWindowHandle, WiaDevice device)
        {
            var    fileName   = Path.GetRandomFileName();
            IntPtr itemHandle = IntPtr.Zero;
            int    fileCount  = 0;

            string[] 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) });
        }
Exemplo n.º 2
0
        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]));
        }
Exemplo n.º 3
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))));
 }