private void InitializeWia() { if (_mySettings._settings.wiaVersion == 0) { return; } _wiaVersion = (WiaVersion)_mySettings._settings.wiaVersion; _wiaAvailable = WiaSession.IsAvailable(_wiaVersion); if (_wiaAvailable) { _wiaSession = new WiaSession(); _wiaSession.Startup(_wiaVersion); _miWiaSelectSource.Enabled = true; // Set the default acquire path for file transfer to My Documents folder. string myDocumentsPath; HelperFunctions.GetFormatFilterAndExtension(); myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); _wiaAcquireOptions.FileName = string.Format("{0}{1}{2}", myDocumentsPath, "\\WiaTest.", HelperFunctions.Extension); if (_wiaProperties.DataTransfer.TransferMode == WiaTransferMode.None) // GetProperties() method not called yet. { _wiatransferMode = WiaTransferMode.Memory; } else { _wiatransferMode = _wiaProperties.DataTransfer.TransferMode; } _wiaSession.AcquireEvent += new EventHandler <WiaAcquireEventArgs>(_wiaSession_AcquireEvent); } else { _miWiaSelectSource.Enabled = false; } _wiaerrorList = new ArrayList(); _enumeratedItemsList = new ArrayList(); _capabilitiesList = new ArrayList(); _formatsList = new ArrayList(); _flagValuesStrings = new ArrayList(); _wiaSourceSelected = _mySettings._settings.wiaSelectedDevice != null; if (_wiaSourceSelected) { try { _wiaSession.SelectDevice(_mySettings._settings.wiaSelectedDevice); } catch { _wiaSourceSelected = false; } } }
void _wiaSession_EnumFormatsEvent(object sender, Leadtools.Wia.WiaEnumFormatsEventArgs e) { if (e.FormatsCount > 0) { MyFormat myFormat = MyFormat.Empty; myFormat.Format = WiaSession.GetFormatGuid(e.Format); myFormat.FormatCLSID = myFormat.Format.ToString(); myFormat.FormatName = e.Format.ToString(); myFormat.TransferMode = e.TransferMode; myFormat.TransferModeString = e.TransferMode.ToString(); FrmMain._formatsList.Add(myFormat); } }
public static int GetFormatNameString(System.Guid guidFormat) { foreach (WiaSupportedFormatsInfo i in _wiaFormatsInfo) { Guid formatGuid = WiaSession.GetFormatGuid(i.Format); if (formatGuid == guidFormat) { _formatName = i.Format.ToString(); return(1); } } return(0); }
public static void FindRelevantPropName(WiaPropertyId propertyId, object value) { if (propertyId == WiaPropertyId.ScannerDeviceDocumentHandlingSelect) { UInt32 val = Convert.ToUInt32(value); if ((val & (int)WiaScanningModeFlags.Feeder) == (int)WiaScanningModeFlags.Feeder || (val & (int)WiaScanningModeFlags.Flatbed) == (int)WiaScanningModeFlags.Flatbed) { _propertyName = "Paper Source"; } } else { _propertyName = WiaSession.GetPropertyIdString(propertyId); } }
public static int GetFormatNameString(System.Guid guidFormat) { foreach (WiaSupportedFormatsInfo i in _wiaFormatsInfo) { Guid formatGuid = Guid.Empty; #if !LEADTOOLS_V17_OR_LATER WiaSession.GetFormatGuid(i.Format); formatGuid = WiaSession.FormatGuid; #else formatGuid = WiaSession.GetFormatGuid(i.Format); #endif //#if !LEADTOOLS_V17_OR_LATER if (formatGuid == guidFormat) { _formatName = i.Format.ToString(); return(1); } } return(0); }
private void MainForm_Load(object sender, System.EventArgs e) { // initialize the codecs object _codecs = new RasterCodecs(); _wiaAvailable = WiaSession.IsAvailable(_wiaVersion); if (_wiaAvailable) { _wiaSession = new WiaSession(); _wiaSession.Startup(_wiaVersion); _miWiaSelectSource.Enabled = true; // Set the default acquire path for file transfer to My Documents folder. string myDocumentsPath; HelperFunctions.GetFormatFilterAndExtension(); myDocumentsPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); _wiaAcquireOptions.FileName = string.Format("{0}{1}{2}", myDocumentsPath, "\\" + DemosGlobalization.GetResxString(GetType(), "Resx_WiaTest") + ".", HelperFunctions.Extension); if (_wiaProperties.DataTransfer.TransferMode == WiaTransferMode.None) // GetProperties() method not called yet. { _transferMode = WiaTransferMode.Memory; } else { _transferMode = _wiaProperties.DataTransfer.TransferMode; } _wiaSession.AcquireEvent += new EventHandler <WiaAcquireEventArgs>(_wiaSession_AcquireEvent); } else { _miWiaSelectSource.Enabled = false; } EnableMenuItems(false); _errorList = new ArrayList(); _capabilitiesList = new ArrayList(); _formatsList = new ArrayList(); _flagValuesStrings = new ArrayList(); }
void _wiaSession_EnumFormatsEvent(object sender, Leadtools.Wia.WiaEnumFormatsEventArgs e) { if (e.FormatsCount > 0) { MyFormat myFormat = MyFormat.Empty; #if !LEADTOOLS_V17_OR_LATER WiaSession.GetFormatGuid(e.Format); myFormat.Format = WiaSession.FormatGuid; myFormat.FormatCLSID = WiaSession.FormatGuid.ToString(); #else myFormat.Format = WiaSession.GetFormatGuid(e.Format); myFormat.FormatCLSID = myFormat.Format.ToString(); #endif //#if !LEADTOOLS_V17_OR_LATER myFormat.FormatName = e.Format.ToString(); myFormat.TransferMode = e.TransferMode; myFormat.TransferModeString = e.TransferMode.ToString(); MainForm._formatsList.Add(myFormat); } }
private DialogResult SelectAcquireSource() { if (_wiaSession.SelectedDeviceType == WiaDeviceType.Scanner) { Object rootItem = _wiaSession.GetRootItem(null); if (_wiaVersion == WiaVersion.Version1) { int longValue = _wiaSession.GetPropertyLong(rootItem, null, WiaPropertyId.ScannerDeviceDocumentHandlingCapabilities); if (((longValue & (int)WiaDocumentHandlingCapabilitiesFlags.Feeder) == (int)WiaDocumentHandlingCapabilitiesFlags.Feeder) && ((longValue & (int)WiaDocumentHandlingCapabilitiesFlags.Flatbed) == (int)WiaDocumentHandlingCapabilitiesFlags.Flatbed)) // scanner with multiple sources. { using (AcquireSourceForm AcquireSourceDlg = new AcquireSourceForm()) { if (AcquireSourceDlg.ShowDialog() != DialogResult.OK) { return(DialogResult.Cancel); } } if (_acquireFromFeeder) { longValue = (int)WiaScanningModeFlags.Feeder; } else { longValue = (int)WiaScanningModeFlags.Flatbed; } _wiaSession.SetPropertyLong(rootItem, null, WiaPropertyId.ScannerDeviceDocumentHandlingSelect, longValue); } } else { // Enable the enumerate items event. _wiaSession.EnumItemsEvent += new EventHandler <WiaEnumItemsEventArgs>(_wiaSession_EnumItemsEvent); _wiaSession.EnumChildItems(rootItem); // Disable the enumerate items event. _wiaSession.EnumItemsEvent -= new EventHandler <WiaEnumItemsEventArgs>(_wiaSession_EnumItemsEvent); if (_enumeratedItemsList.Count > 1) // scanner with multiple sources. { using (AcquireSourceForm AcquireSourceDlg = new AcquireSourceForm()) { if (AcquireSourceDlg.ShowDialog() != DialogResult.OK) { _enumeratedItemsList.Clear(); return(DialogResult.Cancel); } } if (_acquireFromFeeder) { foreach (object item in _enumeratedItemsList) { Guid guidCategory = FrmMain._wiaSession.GetPropertyGuid(item, null, WiaPropertyId.ItemCategory); Guid guidValue = WiaSession.GetCategoryGuid(WiaCategories.Feeder); if (guidValue == guidCategory) { _sourceItem = item; break; } guidValue = WiaSession.GetCategoryGuid(WiaCategories.FeederBack); if (guidValue == guidCategory) { _sourceItem = item; break; } guidValue = WiaSession.GetCategoryGuid(WiaCategories.FeederFront); if (guidValue == guidCategory) { _sourceItem = item; break; } } } else { foreach (object item in _enumeratedItemsList) { Guid guidValue = FrmMain._wiaSession.GetPropertyGuid(item, null, WiaPropertyId.ItemCategory); Guid guidCategory = WiaSession.GetCategoryGuid(WiaCategories.Flatbed); if (guidValue == guidCategory) { _sourceItem = item; break; } } } if (_enumeratedItemsList.Count > 0) { _enumeratedItemsList.Clear(); } } } } return(DialogResult.OK); }