2011-08-16 32 views
7

WIA quét qua FeederWIA quét qua Feeder

Đây là đặc tính điện thoại của tôi:

Document Handling Select = 1 (2 is for flatbed, and 1 is for the feeder.) 

Đây là mục của tôi (trang) thuộc tính:

Horizontal Resolution = 150 
Vertical Resolution = 150 
Horizontal Extent = 500 (I want to get it first to work, then I'll play with the extents.), 
Vertical Extent = 500 
Bits Per Pixel = 8 
Current Intent = 4 

tôi bị tất cả mọi thứ chạy trơn tru nếu Tôi đặt "Chọn Xử lý Tài liệu" thành "2". Khi tôi đặt nó là "1", và chạy nó, ngay trước khi tôi nói item.Transfer() (hoặc item.Transfer (bmp/​​jpeg/pngGuid)) Tôi nhận được ngoại lệ "Giá trị không nằm trong phạm vi dự kiến."

Điều này thật khó chịu, giá trị gì? Tôi đã googled các trang web, và tôi chỉ có thể tìm thấy một ít thông tin nhưng nó không phải là nhiều sự giúp đỡ.

+0

Tôi đã chơi nhiều hơn với nó, và tôi thấy rằng cách duy nhất mà tôi có thể sử dụng các feeder là bằng cách mở hộp thoại thông thường yêu cầu các "mặt hàng". Phương thức trong hộp thoại yêu cầu một thiết bị. Nó đặt các thuộc tính trong thiết bị và trong mục. Tôi đã có một cái nhìn trong các tài sản và nó trông giống như trong các câu hỏi của tôi. Và nó hoạt động. Phải có một cái gì đó tôi không nhìn thấy ... –

+0

Tôi đã có cùng một vấn đề. :-(Tôi giả định rằng phải có một thuộc tính thiết bị khác phải được sửa đổi. –

Trả lời

6

Tôi nghĩ bạn phải đặt thuộc tính thiết bị "Trang" (ID 3096) từ 0 thành 1 để ngăn ngoại lệ. Phải mất một thời gian để tìm ra điều này. Cuối cùng, tôi tìm thấy thuộc tính này bằng cách so sánh các thuộc tính của thiết bị trước và sau cuộc gọi đến CommonDialogClass.ShowSelectItems.

Dưới đây là một số mã:

public enum DeviceDocumentHandling : int 
    { 
     Feeder = 1, 
     FlatBed = 2 
    } 

    const int DEVICE_PROPERTY_DOCUMENT_HANDLING_CAPABILITIES_ID = 3086; 
    const int DEVICE_PROPERTY_DOCUMENT_HANDLING_STATUS_ID = 3087; 
    const int DEVICE_PROPERTY_DOCUMENT_HANDLING_SELECT_ID = 3088; 
    const int DEVICE_PROPERTY_PAGES_ID = 3096; 

    public static Property FindProperty(WIA.Properties properties, 
             int propertyId) 
    { 
     foreach (Property property in properties) 
      if (property.PropertyID == propertyId) 
       return property; 
     return null; 
    } 

    public static void SetDeviceProperty(Device device, int propertyId, 
             object value) 
    { 
     Property property = FindProperty(device.Properties, propertyId); 
     if (property != null) 
      property.set_Value(value); 
    } 

    public static object GetDeviceProperty(Device device, int propertyId) 
    { 
     Property property = FindProperty(device.Properties, propertyId); 
     return property != null ? property.get_Value() : null; 
    } 

    public static void SelectDeviceDocumentHandling(Device device, 
           DeviceDocumentHandling handling) 
    { 
     int requested = (int)handling; 
     int supported = (int)GetDeviceProperty(device, 
       DEVICE_PROPERTY_DOCUMENT_HANDLING_CAPABILITIES_ID); 
     if ((requested & supported) != 0) 
     { 
      if ((requested & (int)DeviceDocumentHandling.Feeder) != 0) 
       SetDeviceProperty(device, DEVICE_PROPERTY_PAGES_ID, 1); 
      SetDeviceProperty(device, 
        DEVICE_PROPERTY_DOCUMENT_HANDLING_SELECT_ID, requested); 
     } 
    } 
Các vấn đề liên quan