using NTwain.Data; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NTwain { // This contains all cap-related methods prefixed with Cap. // It will attempt to have all known cap abilities defined // with a wrapper unless it can only exist as part of another cap // or it's lame & nobody uses it. partial class DataSource : ICapControl { #region low-level cap stuff /// /// Gets the actual supported operations for a capability. /// /// The cap identifier. /// public QuerySupports CapQuerySupport(CapabilityId capId) { QuerySupports retVal = QuerySupports.None; using (TWCapability cap = new TWCapability(capId)) { var rc = _session.DGControl.Capability.QuerySupport(cap); if (rc == ReturnCode.Success) { var read = CapabilityReader.ReadValue(cap); if (read.ContainerType == ContainerType.OneValue) { retVal = read.OneValue.ConvertToEnum(); } } } return retVal; } /// /// Gets the current value for a capability. /// /// The cap id. /// public object CapGetCurrent(CapabilityId capId) { using (TWCapability cap = new TWCapability(capId)) { var rc = _session.DGControl.Capability.GetCurrent(cap); if (rc == ReturnCode.Success) { var read = CapabilityReader.ReadValue(cap); switch (read.ContainerType) { case ContainerType.Enum: if (read.CollectionValues != null && read.CollectionValues.Count > read.EnumCurrentIndex) { return read.CollectionValues[read.EnumCurrentIndex]; } break; case ContainerType.OneValue: return read.OneValue; case ContainerType.Range: return read.RangeCurrentValue; case ContainerType.Array: // no source should ever return an array but anyway if (read.CollectionValues != null) { return read.CollectionValues.FirstOrDefault(); } break; } } } return null; } /// /// Gets the default value for a capability. /// /// The cap id. /// public object CapGetDefault(CapabilityId capId) { using (TWCapability cap = new TWCapability(capId)) { var rc = _session.DGControl.Capability.GetDefault(cap); if (rc == ReturnCode.Success) { var read = CapabilityReader.ReadValue(cap); switch (read.ContainerType) { case ContainerType.Enum: if (read.CollectionValues != null && read.CollectionValues.Count > read.EnumDefaultIndex) { return read.CollectionValues[read.EnumDefaultIndex]; } break; case ContainerType.OneValue: return read.OneValue; case ContainerType.Range: return read.RangeDefaultValue; case ContainerType.Array: // no source should ever return an array but anyway if (read.CollectionValues != null) { return read.CollectionValues.FirstOrDefault(); } break; } } } return null; } /// /// A general method that tries to get capability values from current . /// /// The capability unique identifier. /// public IList CapGet(CapabilityId capabilityId) { var list = new List(); using (TWCapability cap = new TWCapability(capabilityId)) { var rc = _session.DGControl.Capability.Get(cap); if (rc == ReturnCode.Success) { cap.ReadMultiCapValues(list); } } return list; } /// /// Resets all values and constraint to power-on defaults. /// /// public ReturnCode CapResetAll() { using (TWCapability cap = new TWCapability(CapabilityId.CapSupportedCaps)) { var rc = DGControl.Capability.ResetAll(cap); return rc; } } /// /// Resets the current value to power-on default. /// /// The capability identifier. /// public ReturnCode CapReset(CapabilityId capabilityId) { using (TWCapability cap = new TWCapability(capabilityId)) { var rc = DGControl.Capability.Reset(cap); return rc; } } #endregion #region high-level caps stuff #region audio caps private CapWrapper _audXferMech; /// /// Gets the property to work with audio for the current source. /// /// /// The audio xfer mech. /// public ICapWrapper ACapXferMech { get { return _audXferMech ?? (_audXferMech = new CapWrapper(this, CapabilityId.ACapXferMech, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } #endregion #region img caps #region mandatory private CapWrapper _compression; /// /// Gets the property to work with image for the current source. /// /// /// The image compression. /// public ICapWrapper ICapCompression { get { return _compression ?? (_compression = new CapWrapper(this, CapabilityId.ICapCompression, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _pixelType; /// /// Gets the property to work with image for the current source. /// /// /// The image pixel type. /// public ICapWrapper ICapPixelType { get { return _pixelType ?? (_pixelType = new CapWrapper(this, CapabilityId.ICapPixelType, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _imgUnits; /// /// Gets the property to work with image for the current source. /// /// /// The image unit of measure. /// public ICapWrapper ICapUnits { get { return _imgUnits ?? (_imgUnits = new CapWrapper(this, CapabilityId.ICapUnits, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _imgXferMech; /// /// Gets the property to work with image for the current source. /// /// /// The image xfer mech. /// public ICapWrapper ICapXferMech { get { return _imgXferMech ?? (_imgXferMech = new CapWrapper(this, CapabilityId.ICapXferMech, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } #endregion private CapWrapper _autoBright; /// /// Gets the property to work with image auto brightness flag for the current source. /// /// /// The image auto brightness flag. /// public ICapWrapper ICapAutoBright { get { return _autoBright ?? (_autoBright = new CapWrapper(this, CapabilityId.ICapAutoBright, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _brightness; /// /// Gets the property to work with image brightness for the current source. /// /// /// The image brightness. /// public ICapWrapper ICapBrightness { get { return _brightness ?? (_brightness = new CapWrapper(this, CapabilityId.ICapBrightness, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _contrast; /// /// Gets the property to work with image contrast for the current source. /// /// /// The image contrast. /// public ICapWrapper ICapContrast { get { return _contrast ?? (_contrast = new CapWrapper(this, CapabilityId.ICapContrast, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } // TODO: add ICapCustHalftone private CapWrapper _exposureTime; /// /// Gets the property to work with image exposure time (in seconds) for the current source. /// /// /// The image exposure time. /// public ICapWrapper ICapExposureTime { get { return _exposureTime ?? (_exposureTime = new CapWrapper(this, CapabilityId.ICapExposureTime, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _filter; /// /// Gets the property to work with image color filter for the current source. /// /// /// The image color filter type. /// public ICapWrapper ICapFilter { get { return _filter ?? (_filter = new CapWrapper(this, CapabilityId.ICapFilter, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _gamma; /// /// Gets the property to work with image gamma value for the current source. /// /// /// The image gamma. /// public ICapWrapper ICapGamma { get { return _gamma ?? (_gamma = new CapWrapper(this, CapabilityId.ICapGamma, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } // TODO: add ICapHalftones private CapWrapper _highlight; /// /// Gets the property to work with image highlight value for the current source. /// /// /// The image highlight. /// public ICapWrapper ICapHighlight { get { return _highlight ?? (_highlight = new CapWrapper(this, CapabilityId.ICapHighlight, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _fileFormat; /// /// Gets the property to work with image for the current source. /// /// /// The image file format. /// public ICapWrapper ICapImageFileFormat { get { return _fileFormat ?? (_fileFormat = new CapWrapper(this, CapabilityId.ICapImageFileFormat, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _lampState; /// /// Gets the property to work with image lamp state flag for the current source. /// /// /// The image lamp state flag. /// public ICapWrapper ICapLampState { get { return _lampState ?? (_lampState = new CapWrapper(this, CapabilityId.ICapLampState, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _lightSource; /// /// Gets the property to work with image light source for the current source. /// /// /// The image light source. /// public ICapWrapper ICapLightSource { get { return _lightSource ?? (_lightSource = new CapWrapper(this, CapabilityId.ICapLightSource, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _orientation; /// /// Gets the property to work with image orientation for the current source. /// /// /// The image orientation. /// public ICapWrapper ICapOrientation { get { return _orientation ?? (_orientation = new CapWrapper(this, CapabilityId.ICapOrientation, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _physicalWidth; /// /// Gets the property to work with image physical width for the current source. /// /// /// The image physical width. /// public IReadOnlyCapWrapper ICapPhysicalWidth { get { return _physicalWidth ?? (_physicalWidth = new CapWrapper(this, CapabilityId.ICapPhysicalWidth, ValueExtensions.ConvertToFix32)); } } private CapWrapper _physicalHeight; /// /// Gets the property to work with image physical height for the current source. /// /// /// The image physical height. /// public IReadOnlyCapWrapper ICapPhysicalHeight { get { return _physicalHeight ?? (_physicalHeight = new CapWrapper(this, CapabilityId.ICapPhysicalHeight, ValueExtensions.ConvertToFix32)); } } private CapWrapper _shadow; /// /// Gets the property to work with image shadow value for the current source. /// /// /// The image shadow. /// public ICapWrapper ICapShadow { get { return _shadow ?? (_shadow = new CapWrapper(this, CapabilityId.ICapShadow, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } // TODO: add ICapFrames private CapWrapper _nativeXRes; /// /// Gets the property to work with image's native x-axis resolution for the current source. /// /// /// The image's native x-axis resolution. /// public IReadOnlyCapWrapper ICapXNativeResolution { get { return _nativeXRes ?? (_nativeXRes = new CapWrapper(this, CapabilityId.ICapXNativeResolution, ValueExtensions.ConvertToFix32)); } } private CapWrapper _nativeYRes; /// /// Gets the property to work with image's native y-axis resolution for the current source. /// /// /// The image's native y-axis resolution. /// public IReadOnlyCapWrapper ICapYNativeResolution { get { return _nativeYRes ?? (_nativeYRes = new CapWrapper(this, CapabilityId.ICapYNativeResolution, ValueExtensions.ConvertToFix32)); } } private CapWrapper _xResolution; /// /// Gets the property to work with image x-axis resolution for the current source. /// /// /// The image x-axis resolution. /// public ICapWrapper ICapXResolution { get { return _xResolution ?? (_xResolution = new CapWrapper(this, CapabilityId.ICapXResolution, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _yResolution; /// /// Gets the property to work with image y-axis resolution for the current source. /// /// /// The image y-axis resolution. /// public ICapWrapper ICapYResolution { get { return _yResolution ?? (_yResolution = new CapWrapper(this, CapabilityId.ICapYResolution, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _maxFrames; /// /// Gets the property to work with image max frames for the current source. /// /// /// The image max frames. /// public ICapWrapper ICapMaxFrames { get { return _maxFrames ?? (_maxFrames = new CapWrapper(this, CapabilityId.ICapMaxFrames, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _tiles; /// /// Gets the property to work with image tiles flag for the current source. /// /// /// The image tiles flag. /// public ICapWrapper ICapTiles { get { return _tiles ?? (_tiles = new CapWrapper(this, CapabilityId.ICapTiles, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _bitOrder; /// /// Gets the property to work with image for the current source. /// /// /// The image bit order. /// public ICapWrapper ICapBitOrder { get { return _bitOrder ?? (_bitOrder = new CapWrapper(this, CapabilityId.ICapBitOrder, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _ccittKFactor; /// /// Gets the property to work with image CCITT K factor for the current source. /// /// /// The image CCITT K factor. /// public ICapWrapper ICapCCITTKFactor { get { return _ccittKFactor ?? (_ccittKFactor = new CapWrapper(this, CapabilityId.ICapCCITTKFactor, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _lightPath; /// /// Gets the property to work with image light path for the current source. /// /// /// The image light path. /// public ICapWrapper ICapLightPath { get { return _lightPath ?? (_lightPath = new CapWrapper(this, CapabilityId.ICapLightPath, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _pixelFlavor; /// /// Gets the property to work with image pixel flavor for the current source. /// /// /// The image pixel flavor. /// public ICapWrapper ICapPixelFlavor { get { return _pixelFlavor ?? (_pixelFlavor = new CapWrapper(this, CapabilityId.ICapPixelFlavor, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _planarChunky; /// /// Gets the property to work with image color format for the current source. /// /// /// The image color format. /// public ICapWrapper ICapPlanarChunky { get { return _planarChunky ?? (_planarChunky = new CapWrapper(this, CapabilityId.ICapPlanarChunky, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _rotation; /// /// Gets the property to work with image rotation for the current source. /// /// /// The image rotation. /// public ICapWrapper ICapRotation { get { return _rotation ?? (_rotation = new CapWrapper(this, CapabilityId.ICapRotation, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _supportSize; /// /// Gets the property to work with image for the current source. /// /// /// The image supported size. /// public ICapWrapper ICapSupportedSizes { get { return _supportSize ?? (_supportSize = new CapWrapper(this, CapabilityId.ICapSupportedSizes, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _threshold; /// /// Gets the property to work with image threshold for the current source. /// /// /// The image threshold. /// public ICapWrapper ICapThreshold { get { return _threshold ?? (_threshold = new CapWrapper(this, CapabilityId.ICapThreshold, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _xscaling; /// /// Gets the property to work with image x-axis scaling for the current source. /// /// /// The image x-axis scaling. /// public ICapWrapper ICapXScaling { get { return _xscaling ?? (_xscaling = new CapWrapper(this, CapabilityId.ICapXScaling, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _yscaling; /// /// Gets the property to work with image y-axis scaling for the current source. /// /// /// The image y-axis scaling. /// public ICapWrapper ICapYScaling { get { return _yscaling ?? (_yscaling = new CapWrapper(this, CapabilityId.ICapYScaling, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; ItemType = ItemType.Fix32 })); } } private CapWrapper _bitorderCodes; /// /// Gets the property to work with image CCITT compression for the current source. /// /// /// The image bit order for CCITT compression. /// public ICapWrapper ICapBitOrderCodes { get { return _bitorderCodes ?? (_bitorderCodes = new CapWrapper(this, CapabilityId.ICapBitOrderCodes, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _pixelFlavorCodes; /// /// Gets the property to work with image CCITT compression for the current source. /// /// /// The image pixel flavor for CCITT compression. /// public ICapWrapper ICapPixelFlavorCodes { get { return _pixelFlavorCodes ?? (_pixelFlavorCodes = new CapWrapper(this, CapabilityId.ICapPixelFlavorCodes, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _jpegPixelType; /// /// Gets the property to work with image jpeg compression for the current source. /// /// /// The image pixel type for jpeg compression. /// public ICapWrapper ICapJpegPixelType { get { return _jpegPixelType ?? (_jpegPixelType = new CapWrapper(this, CapabilityId.ICapJpegPixelType, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _timeFill; /// /// Gets the property to work with image CCITT time fill for the current source. /// /// /// The image CCITT time fill. /// public ICapWrapper ICapTimeFill { get { return _timeFill ?? (_timeFill = new CapWrapper(this, CapabilityId.ICapTimeFill, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _bitDepth; /// /// Gets the property to work with image bit depth for the current source. /// /// /// The image bit depth. /// public ICapWrapper ICapBitDepth { get { return _bitDepth ?? (_bitDepth = new CapWrapper(this, CapabilityId.ICapBitDepth, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _bitDepthReduction; /// /// Gets the property to work with image bit depth reduction method for the current source. /// /// /// The image bit depth reduction method. /// public ICapWrapper ICapBitDepthReduction { get { return _bitDepthReduction ?? (_bitDepthReduction = new CapWrapper(this, CapabilityId.ICapBitDepthReduction, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _undefinedImgSize; /// /// Gets the property to work with image undefined size flag for the current source. /// /// /// The image undefined size flag. /// public ICapWrapper ICapUndefinedImageSize { get { return _undefinedImgSize ?? (_undefinedImgSize = new CapWrapper(this, CapabilityId.ICapUndefinedImageSize, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } // TODO: add ICAP_IMAGEDATASET private CapWrapper _extImgInfo; /// /// Gets the property to work with ext image info flag for the current source. /// /// /// The ext image info flag. /// public ICapWrapper ICapExtImageInfo { get { return _extImgInfo ?? (_extImgInfo = new CapWrapper(this, CapabilityId.ICapExtImageInfo, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _minHeight; /// /// Gets the property to work with image minimum height for the current source. /// /// /// The image minimumm height. /// public IReadOnlyCapWrapper ICapMinimumHeight { get { return _minHeight ?? (_minHeight = new CapWrapper(this, CapabilityId.ICapMinimumHeight, ValueExtensions.ConvertToFix32)); } } private CapWrapper _minWidth; /// /// Gets the property to work with image minimum width for the current source. /// /// /// The image minimumm width. /// public IReadOnlyCapWrapper ICapMinimumWidth { get { return _minWidth ?? (_minWidth = new CapWrapper(this, CapabilityId.ICapMinimumWidth, ValueExtensions.ConvertToFix32)); } } private CapWrapper _autoDiscBlankPg; /// /// Gets the property to work with image blank page behavior for the current source. /// /// /// The image blank page behavior. /// public ICapWrapper ICapAutoDiscardBlankPages { get { return _autoDiscBlankPg ?? (_autoDiscBlankPg = new CapWrapper(this, CapabilityId.ICapAutoDiscardBlankPages, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Int32 })); } } private CapWrapper _flipRotation; /// /// Gets the property to work with image flip-rotation behavior for the current source. /// /// /// The image flip-rotation behavior. /// public ICapWrapper ICapFlipRotation { get { return _flipRotation ?? (_flipRotation = new CapWrapper(this, CapabilityId.ICapFlipRotation, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Int32 })); } } private CapWrapper _barcodeDetectEnabled; /// /// Gets the property to work with image barcode detection flag for the current source. /// /// /// The image barcode detection flag. /// public ICapWrapper ICapBarcodeDetectionEnabled { get { return _barcodeDetectEnabled ?? (_barcodeDetectEnabled = new CapWrapper(this, CapabilityId.ICapBarcodeDetectionEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _barcodeType; /// /// Gets the property to work with image barcode types for the current source. /// /// /// The image barcode types. /// public IReadOnlyCapWrapper ICapSupportedBarcodeTypes { get { return _barcodeType ?? (_barcodeType = new CapWrapper(this, CapabilityId.ICapSupportedBarcodeTypes, ValueExtensions.ConvertToEnum)); } } private CapWrapper _barcodeMaxPriority; /// /// Gets the property to work with image barcode max search priorities for the current source. /// /// /// The image barcode max search priorities. /// public ICapWrapper ICapBarcodeMaxSearchPriorities { get { return _barcodeMaxPriority ?? (_barcodeMaxPriority = new CapWrapper(this, CapabilityId.ICapBarcodeMaxSearchPriorities, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, ItemType = ItemType.UInt32 })); } } private CapWrapper _barcodeSearchPriority; /// /// Gets the property to work with image barcode search priority for the current source. /// /// /// The image barcode search priority. /// public ICapWrapper ICapBarcodeSearchPriorities { get { return _barcodeSearchPriority ?? (_barcodeSearchPriority = new CapWrapper(this, CapabilityId.ICapBarcodeSearchPriorities, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _barcodeSearchMode; /// /// Gets the property to work with image barcode search direction for the current source. /// /// /// The image barcode search direction. /// public ICapWrapper ICapBarcodeSearchMode { get { return _barcodeSearchMode ?? (_barcodeSearchMode = new CapWrapper(this, CapabilityId.ICapBarcodeSearchMode, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _barcodeMaxRetries; /// /// Gets the property to work with image barcode max search retries for the current source. /// /// /// The image barcode max search retries. /// public ICapWrapper ICapBarcodeMaxRetries { get { return _barcodeMaxRetries ?? (_barcodeMaxRetries = new CapWrapper(this, CapabilityId.ICapBarcodeMaxRetries, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, ItemType = ItemType.UInt32 })); } } private CapWrapper _barcodeTimeout; /// /// Gets the property to work with image barcode max search timeout for the current source. /// /// /// The image barcode max search timeout. /// public ICapWrapper ICapBarcodeTimeout { get { return _barcodeTimeout ?? (_barcodeTimeout = new CapWrapper(this, CapabilityId.ICapBarcodeTimeout, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, ItemType = ItemType.UInt32 })); } } private CapWrapper _zoomFactor; /// /// Gets the property to work with image zoom factor for the current source. /// /// /// The image zoom factor. /// public ICapWrapper ICapZoomFactor { get { return _zoomFactor ?? (_zoomFactor = new CapWrapper(this, CapabilityId.ICapZoomFactor, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _patchcodeDetectEnabled; /// /// Gets the property to work with image patch code detection flag for the current source. /// /// /// The image patch code detection flag. /// public ICapWrapper ICapPatchCodeDetectionEnabled { get { return _patchcodeDetectEnabled ?? (_patchcodeDetectEnabled = new CapWrapper(this, CapabilityId.ICapPatchCodeDetectionEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _patchcodeType; /// /// Gets the property to work with image patch code types for the current source. /// /// /// The image patch code types. /// public IReadOnlyCapWrapper ICapSupportedPatchCodeTypes { get { return _patchcodeType ?? (_patchcodeType = new CapWrapper(this, CapabilityId.ICapSupportedPatchCodeTypes, ValueExtensions.ConvertToEnum)); } } private CapWrapper _patchcodeMaxPriority; /// /// Gets the property to work with image patch code max search priorities for the current source. /// /// /// The image patch code max search priorities. /// public ICapWrapper ICapPatchCodeMaxSearchPriorities { get { return _patchcodeMaxPriority ?? (_patchcodeMaxPriority = new CapWrapper(this, CapabilityId.ICapPatchCodeMaxSearchPriorities, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, ItemType = ItemType.UInt32 })); } } private CapWrapper _patchcodeSearchPriority; /// /// Gets the property to work with image patch code search priority for the current source. /// /// /// The image patch code search priority. /// public ICapWrapper ICapPatchCodeSearchPriorities { get { return _patchcodeSearchPriority ?? (_patchcodeSearchPriority = new CapWrapper(this, CapabilityId.ICapPatchCodeSearchPriorities, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _patchcodeSearchMode; /// /// Gets the property to work with image patch code search direction for the current source. /// /// /// The image patch code search direction. /// public ICapWrapper ICapPatchCodeSearchMode { get { return _patchcodeSearchMode ?? (_patchcodeSearchMode = new CapWrapper(this, CapabilityId.ICapPatchCodeSearchMode, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _patchCodeMaxRetries; /// /// Gets the property to work with image patch code max search retries for the current source. /// /// /// The image patch code max search retries. /// public ICapWrapper ICapPatchCodeMaxRetries { get { return _patchCodeMaxRetries ?? (_patchCodeMaxRetries = new CapWrapper(this, CapabilityId.ICapPatchCodeMaxRetries, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, ItemType = ItemType.UInt32 })); } } private CapWrapper _patchCodeTimeout; /// /// Gets the property to work with image patch code max search timeout for the current source. /// /// /// The image patch code max search timeout. /// public ICapWrapper ICapPatchCodeTimeout { get { return _patchCodeTimeout ?? (_patchCodeTimeout = new CapWrapper(this, CapabilityId.ICapPatchCodeTimeout, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, ItemType = ItemType.UInt32 })); } } private CapWrapper _flashUsed2; /// /// Gets the property to work with flash option for the current source. /// /// /// The flash option. /// public ICapWrapper ICapFlashUsed2 { get { return _flashUsed2 ?? (_flashUsed2 = new CapWrapper(this, CapabilityId.ICapFlashUsed2, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _imgFilter; /// /// Gets the property to work with image enhancement filter for the current source. /// /// /// The image enhancement filter. /// public ICapWrapper ICapImageFilter { get { return _imgFilter ?? (_imgFilter = new CapWrapper(this, CapabilityId.ICapImageFilter, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _noiseFilter; /// /// Gets the property to work with image noise filter for the current source. /// /// /// The image noise filter. /// public ICapWrapper ICapNoiseFilter { get { return _noiseFilter ?? (_noiseFilter = new CapWrapper(this, CapabilityId.ICapNoiseFilter, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _overscan; /// /// Gets the property to work with image overscan option for the current source. /// /// /// The image overscan option. /// public ICapWrapper ICapOverScan { get { return _overscan ?? (_overscan = new CapWrapper(this, CapabilityId.ICapOverScan, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _borderDetect; /// /// Gets the property to work with auto border detection flag for the current source. /// /// /// The auto border detection flag. /// public ICapWrapper ICapAutomaticBorderDetection { get { return _borderDetect ?? (_borderDetect = new CapWrapper(this, CapabilityId.ICapAutomaticBorderDetection, ValueExtensions.ConvertToEnum, value => { var rc = ReturnCode.Failure; var one = new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool }; // this needs to also set undefined size optino rc = ICapUndefinedImageSize.Set(value); using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, one)) { rc = _session.DGControl.Capability.Set(capValue); } return rc; })); } } private CapWrapper _autoDeskew; /// /// Gets the property to work with image auto deskew flag for the current source. /// /// /// The image auto deskew flag. /// public ICapWrapper ICapAutomaticDeskew { get { return _autoDeskew ?? (_autoDeskew = new CapWrapper(this, CapabilityId.ICapAutomaticDeskew, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _autoRotate; /// /// Gets the property to work with image auto rotate flag for the current source. /// /// /// The image auto rotate flag. /// public ICapWrapper ICapAutomaticRotate { get { return _autoRotate ?? (_autoRotate = new CapWrapper(this, CapabilityId.ICapAutomaticRotate, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _jpegQuality; /// /// Gets the property to work with image jpeg quality for the current source. /// /// /// The image jpeg quality. /// public ICapWrapper ICapJpegQuality { get { //TODO: verify return _jpegQuality ?? (_jpegQuality = new CapWrapper(this, CapabilityId.ICapJpegQuality, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Int16 })); } } private CapWrapper _feederType; /// /// Gets the property to work with feeder type for the current source. /// /// /// The feeder type. /// public ICapWrapper ICapFeederType { get { return _feederType ?? (_feederType = new CapWrapper(this, CapabilityId.ICapFeederType, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _iccProfile; /// /// Gets the property to work with image icc profile for the current source. /// /// /// The image icc profile. /// public ICapWrapper ICapICCProfile { get { return _iccProfile ?? (_iccProfile = new CapWrapper(this, CapabilityId.ICapICCProfile, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _autoSize; /// /// Gets the property to work with image auto size option for the current source. /// /// /// The image auto size option. /// public ICapWrapper ICapAutoSize { get { return _autoSize ?? (_autoSize = new CapWrapper(this, CapabilityId.ICapAutoSize, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } #endregion #region general caps #region mandatory private CapWrapper _xferCount; /// /// Gets the property to work with xfer count for the current source. /// /// /// The xfer count. /// public ICapWrapper CapXferCount { get { return _xferCount ?? (_xferCount = new CapWrapper(this, CapabilityId.CapXferCount, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value > 0 ? (uint)value : uint.MaxValue, ItemType = ItemType.UInt16 })); } } #endregion private CapWrapper _duplex; /// /// Gets the property to see what's the duplex mode for the current source. /// /// /// The duplex mode. /// public IReadOnlyCapWrapper CapDuplex { get { return _duplex ?? (_duplex = new CapWrapper(this, CapabilityId.CapDuplex, ValueExtensions.ConvertToEnum)); } } private CapWrapper _duplexEnabled; /// /// Gets the property to work with duplex enabled flag for the current source. /// /// /// The duplex enabled flag. /// public ICapWrapper CapDuplexEnabled { get { return _duplexEnabled ?? (_duplexEnabled = new CapWrapper(this, CapabilityId.CapDuplexEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _feederLoaded; /// /// Gets the property to work with feeder loaded flag for the current source. /// /// /// The feeder loaded flag. /// public IReadOnlyCapWrapper CapFeederLoaded { get { return _feederLoaded ?? (_feederLoaded = new CapWrapper(this, CapabilityId.CapFeederLoaded, ValueExtensions.ConvertToEnum)); } } private CapWrapper _feederEnabled; /// /// Gets the property to work with feeder enabled flag for the current source. /// /// /// The feeder enabled flag. /// public ICapWrapper CapFeederEnabled { get { return _feederEnabled ?? (_feederEnabled = new CapWrapper(this, CapabilityId.CapFeederEnabled, ValueExtensions.ConvertToEnum, value => { var rc = ReturnCode.Failure; var one = new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool }; // we will never set feeder off, only autofeed and autoscan // but if it is true then enable feeder needs to be set first if (value == BoolType.True) { using (TWCapability enabled = new TWCapability(CapabilityId.CapFeederEnabled, one)) { rc = _session.DGControl.Capability.Set(enabled); } } // to really use feeder we must also set autofeed or autoscan, but only // for one of them since setting autoscan also sets autofeed if (SupportedCaps.Contains(CapabilityId.CapAutoScan)) { using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoScan, one)) { rc = _session.DGControl.Capability.Set(autoScan); } } else if (SupportedCaps.Contains(CapabilityId.CapAutoFeed)) { using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoFeed, one)) { rc = _session.DGControl.Capability.Set(autoScan); } } return rc; })); } } private CapWrapper _clearPage; /// /// Gets the property to work with clear page flag for the current source. /// /// /// The clear page flag. /// public ICapWrapper CapClearPage { get { return _clearPage ?? (_clearPage = new CapWrapper(this, CapabilityId.CapClearPage, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _feedPage; /// /// Gets the property to work with feed page flag for the current source. /// /// /// The feed page flag. /// public ICapWrapper CapFeedPage { get { return _feedPage ?? (_feedPage = new CapWrapper(this, CapabilityId.CapFeedPage, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _rewindPage; /// /// Gets the property to work with rewind page flag for the current source. /// /// /// The rewind page flag. /// public ICapWrapper CapRewindPage { get { return _rewindPage ?? (_rewindPage = new CapWrapper(this, CapabilityId.CapRewindPage, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _indicators; /// /// Gets the property to work with indicators flag for the current source. /// /// /// The indicators flag. /// public ICapWrapper CapIndicators { get { return _indicators ?? (_indicators = new CapWrapper(this, CapabilityId.CapIndicators, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _paperDetectable; /// /// Gets the property to work with paper sensor flag for the current source. /// /// /// The paper sensor flag. /// public IReadOnlyCapWrapper CapPaperDetectable { get { return _paperDetectable ?? (_paperDetectable = new CapWrapper(this, CapabilityId.CapPaperDetectable, ValueExtensions.ConvertToEnum)); } } private CapWrapper _uiControllable; /// /// Gets the property to work with UI controllable flag for the current source. /// /// /// The UI controllable flag. /// public IReadOnlyCapWrapper CapUIControllable { get { return _uiControllable ?? (_uiControllable = new CapWrapper(this, CapabilityId.CapUIControllable, ValueExtensions.ConvertToEnum)); } } private CapWrapper _devOnline; /// /// Gets the property to work with devince online flag for the current source. /// /// /// The devince online flag. /// public IReadOnlyCapWrapper CapDeviceOnline { get { return _devOnline ?? (_devOnline = new CapWrapper(this, CapabilityId.CapDeviceOnline, ValueExtensions.ConvertToEnum)); } } private CapWrapper _thumbsEnabled; /// /// Gets the property to work with thumbnails enabled flag for the current source. /// /// /// The thumbnails enabled flag. /// public ICapWrapper CapThumbnailsEnabled { get { return _thumbsEnabled ?? (_thumbsEnabled = new CapWrapper(this, CapabilityId.CapThumbnailsEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Bool })); } } private CapWrapper _dsUIonly; /// /// Gets the property to see whether device supports UI only flag (no transfer). /// /// /// The UI only flag. /// public IReadOnlyCapWrapper CapEnableDSUIOnly { get { return _dsUIonly ?? (_dsUIonly = new CapWrapper(this, CapabilityId.CapEnableDSUIOnly, ValueExtensions.ConvertToEnum)); } } private CapWrapper _dsData; /// /// Gets the property to see whether device supports custom data triplets. /// /// /// The custom data flag. /// public IReadOnlyCapWrapper CapCustomDSData { get { return _dsData ?? (_dsData = new CapWrapper(this, CapabilityId.CapCustomDSData, ValueExtensions.ConvertToEnum)); } } private CapWrapper _jobControl; /// /// Gets the property to work with job control option for the current source. /// /// /// The job control option. /// public ICapWrapper CapJobControl { get { return _jobControl ?? (_jobControl = new CapWrapper(this, CapabilityId.CapJobControl, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 })); } } private CapWrapper _alarmVolume; /// /// Gets the property to work with alarm volume for the current source. /// /// /// The alarm volume. /// public ICapWrapper CapAlarmVolume { get { return _alarmVolume ?? (_alarmVolume = new CapWrapper(this, CapabilityId.CapAlarmVolume, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, ItemType = ItemType.Int32 })); } } //private CapWrapper _autoCapture; ///// ///// Gets the property to work with auto capture count for the current source. ///// ///// ///// The auto capture count. ///// //public ICapWrapper CapAutomaticCapture //{ // get // { // return _autoCapture ?? (_autoCapture = new CapWrapper(this, CapabilityId.CapAutomaticCapture, ValueExtensions.ConvertToEnum, // new TWCapability(CapabilityId.CapAutomaticCapture, new TWOneValue // { // Item = (uint)value, // ItemType = ItemType.Int32 // })); // } //} #endregion #endregion } }