diff --git a/NTwain.Net35/NTwain.Net35.csproj b/NTwain.Net35/NTwain.Net35.csproj index b8d898b..5ebe768 100644 --- a/NTwain.Net35/NTwain.Net35.csproj +++ b/NTwain.Net35/NTwain.Net35.csproj @@ -46,15 +46,15 @@ + + Capabilities.cs + CapabilityReader.cs CapWrapper.cs - - DataSource.Caps.cs - DataSource.cs @@ -79,9 +79,6 @@ DeviceEventArgs.cs - - ICapControl.cs - ICapWrapper.cs diff --git a/NTwain/CapWrapper.cs b/NTwain/CapWrapper.cs index 11496a1..0f0ad73 100644 --- a/NTwain/CapWrapper.cs +++ b/NTwain/CapWrapper.cs @@ -114,7 +114,7 @@ namespace NTwain var srcVersion = _source.ProtocolVersion; if (srcVersion >= ProtocolVersions.GetMinimumVersion(Capability)) { - _supports = _source.CapQuerySupport(Capability); + _supports = _source.Capabilities.QuerySupport(Capability); if (!_supports.HasValue) { @@ -275,7 +275,7 @@ namespace NTwain { if (CanGetDefault) { - return _getConvertRoutine(_source.CapGetDefault(Capability)); + return _getConvertRoutine(_source.Capabilities.GetDefault(Capability)); } return default(TValue); } @@ -288,7 +288,7 @@ namespace NTwain { if (CanGetCurrent) { - return _getConvertRoutine(_source.CapGetCurrent(Capability)); + return _getConvertRoutine(_source.Capabilities.GetCurrent(Capability)); } return default(TValue); } @@ -299,7 +299,7 @@ namespace NTwain /// public IList GetValues() { - return _source.CapGet(Capability).Select(o => _getConvertRoutine(o)).ToList(); + return _source.Capabilities.GetValues(Capability).Select(o => _getConvertRoutine(o)).ToList(); } /// @@ -384,7 +384,7 @@ namespace NTwain /// public ReturnCode Reset() { - return _source.CapReset(Capability); + return _source.Capabilities.Reset(Capability); } /// diff --git a/NTwain/DataSource.Caps.cs b/NTwain/Capabilities.cs similarity index 86% rename from NTwain/DataSource.Caps.cs rename to NTwain/Capabilities.cs index 7ea8dd6..648e063 100644 --- a/NTwain/DataSource.Caps.cs +++ b/NTwain/Capabilities.cs @@ -6,27 +6,37 @@ 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 + /// + /// Exposes capabilities of a data source as properties. + /// + public class Capabilities { - #region low-level cap stuff + IDataSource _source; + + /// + /// Initializes a new instance of the class. + /// + /// The source. + public Capabilities(IDataSource source) + { + if (source == null) { throw new ArgumentNullException("source"); } + _source = source; + } + + + #region non-wrapped cap calls /// /// Gets the actual supported operations for a capability. This is not supported by all sources. /// /// The capability id. /// - public QuerySupports? CapQuerySupport(CapabilityId capabilityId) + public QuerySupports? QuerySupport(CapabilityId capabilityId) { QuerySupports? retVal = null; using (TWCapability cap = new TWCapability(capabilityId)) { - var rc = _session.DGControl.Capability.QuerySupport(cap); + var rc = _source.DGControl.Capability.QuerySupport(cap); if (rc == ReturnCode.Success) { var read = CapabilityReader.ReadValue(cap); @@ -45,11 +55,11 @@ namespace NTwain /// /// The capability id. /// - public object CapGetCurrent(CapabilityId capabilityId) + public object GetCurrent(CapabilityId capabilityId) { using (TWCapability cap = new TWCapability(capabilityId)) { - var rc = _session.DGControl.Capability.GetCurrent(cap); + var rc = _source.DGControl.Capability.GetCurrent(cap); if (rc == ReturnCode.Success) { var read = CapabilityReader.ReadValue(cap); @@ -84,11 +94,11 @@ namespace NTwain /// /// The capability id. /// - public object CapGetDefault(CapabilityId capabilityId) + public object GetDefault(CapabilityId capabilityId) { using (TWCapability cap = new TWCapability(capabilityId)) { - var rc = _session.DGControl.Capability.GetDefault(cap); + var rc = _source.DGControl.Capability.GetDefault(cap); if (rc == ReturnCode.Success) { var read = CapabilityReader.ReadValue(cap); @@ -123,12 +133,12 @@ namespace NTwain /// /// The capability id. /// - public IList CapGet(CapabilityId capabilityId) + public IList GetValues(CapabilityId capabilityId) { var list = new List(); using (TWCapability cap = new TWCapability(capabilityId)) { - var rc = _session.DGControl.Capability.Get(cap); + var rc = _source.DGControl.Capability.Get(cap); if (rc == ReturnCode.Success) { CapabilityReader.ReadValue(cap).PopulateFromCapValues(list); @@ -141,11 +151,11 @@ namespace NTwain /// Resets all values and constraint to power-on defaults. /// /// - public ReturnCode CapResetAll() + public ReturnCode ResetAll() { using (TWCapability cap = new TWCapability(CapabilityId.CapSupportedCaps)) { - var rc = DGControl.Capability.ResetAll(cap); + var rc = _source.DGControl.Capability.ResetAll(cap); return rc; } } @@ -155,11 +165,11 @@ namespace NTwain /// /// The capability id. /// - public ReturnCode CapReset(CapabilityId capabilityId) + public ReturnCode Reset(CapabilityId capabilityId) { using (TWCapability cap = new TWCapability(capabilityId)) { - var rc = DGControl.Capability.Reset(cap); + var rc = _source.DGControl.Capability.Reset(cap); return rc; } } @@ -180,7 +190,7 @@ namespace NTwain { get { - return _audXferMech ?? (_audXferMech = new CapWrapper(this, CapabilityId.ACapXferMech, ValueExtensions.ConvertToEnum, + return _audXferMech ?? (_audXferMech = new CapWrapper(_source, CapabilityId.ACapXferMech, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -207,7 +217,7 @@ namespace NTwain { get { - return _compression ?? (_compression = new CapWrapper(this, CapabilityId.ICapCompression, ValueExtensions.ConvertToEnum, + return _compression ?? (_compression = new CapWrapper(_source, CapabilityId.ICapCompression, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -229,7 +239,7 @@ namespace NTwain { get { - return _pixelType ?? (_pixelType = new CapWrapper(this, CapabilityId.ICapPixelType, ValueExtensions.ConvertToEnum, + return _pixelType ?? (_pixelType = new CapWrapper(_source, CapabilityId.ICapPixelType, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -250,7 +260,7 @@ namespace NTwain { get { - return _imgUnits ?? (_imgUnits = new CapWrapper(this, CapabilityId.ICapUnits, ValueExtensions.ConvertToEnum, + return _imgUnits ?? (_imgUnits = new CapWrapper(_source, CapabilityId.ICapUnits, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -271,7 +281,7 @@ namespace NTwain { get { - return _imgXferMech ?? (_imgXferMech = new CapWrapper(this, CapabilityId.ICapXferMech, ValueExtensions.ConvertToEnum, + return _imgXferMech ?? (_imgXferMech = new CapWrapper(_source, CapabilityId.ICapXferMech, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -294,7 +304,7 @@ namespace NTwain { get { - return _autoBright ?? (_autoBright = new CapWrapper(this, CapabilityId.ICapAutoBright, ValueExtensions.ConvertToEnum, + return _autoBright ?? (_autoBright = new CapWrapper(_source, CapabilityId.ICapAutoBright, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -315,7 +325,7 @@ namespace NTwain { get { - return _brightness ?? (_brightness = new CapWrapper(this, CapabilityId.ICapBrightness, ValueExtensions.ConvertToFix32, + return _brightness ?? (_brightness = new CapWrapper(_source, CapabilityId.ICapBrightness, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -336,7 +346,7 @@ namespace NTwain { get { - return _contrast ?? (_contrast = new CapWrapper(this, CapabilityId.ICapContrast, ValueExtensions.ConvertToFix32, + return _contrast ?? (_contrast = new CapWrapper(_source, CapabilityId.ICapContrast, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -357,7 +367,7 @@ namespace NTwain { get { - return _custHalftone ?? (_custHalftone = new CapWrapper(this, CapabilityId.ICapCustHalftone, ValueExtensions.ConvertToEnum, + return _custHalftone ?? (_custHalftone = new CapWrapper(_source, CapabilityId.ICapCustHalftone, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -378,7 +388,7 @@ namespace NTwain { get { - return _exposureTime ?? (_exposureTime = new CapWrapper(this, CapabilityId.ICapExposureTime, ValueExtensions.ConvertToFix32, + return _exposureTime ?? (_exposureTime = new CapWrapper(_source, CapabilityId.ICapExposureTime, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -399,7 +409,7 @@ namespace NTwain { get { - return _filter ?? (_filter = new CapWrapper(this, CapabilityId.ICapFilter, ValueExtensions.ConvertToEnum, + return _filter ?? (_filter = new CapWrapper(_source, CapabilityId.ICapFilter, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -420,7 +430,7 @@ namespace NTwain { get { - return _gamma ?? (_gamma = new CapWrapper(this, CapabilityId.ICapGamma, ValueExtensions.ConvertToFix32, + return _gamma ?? (_gamma = new CapWrapper(_source, CapabilityId.ICapGamma, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -441,7 +451,7 @@ namespace NTwain { get { - return _halftones ?? (_halftones = new CapWrapper(this, CapabilityId.ICapHalftones, ValueExtensions.ConvertToString, false)); + return _halftones ?? (_halftones = new CapWrapper(_source, CapabilityId.ICapHalftones, ValueExtensions.ConvertToString, false)); } } @@ -457,7 +467,7 @@ namespace NTwain { get { - return _highlight ?? (_highlight = new CapWrapper(this, CapabilityId.ICapHighlight, ValueExtensions.ConvertToFix32, + return _highlight ?? (_highlight = new CapWrapper(_source, CapabilityId.ICapHighlight, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -478,7 +488,7 @@ namespace NTwain { get { - return _fileFormat ?? (_fileFormat = new CapWrapper(this, CapabilityId.ICapImageFileFormat, ValueExtensions.ConvertToEnum, + return _fileFormat ?? (_fileFormat = new CapWrapper(_source, CapabilityId.ICapImageFileFormat, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -500,7 +510,7 @@ namespace NTwain { get { - return _lampState ?? (_lampState = new CapWrapper(this, CapabilityId.ICapLampState, ValueExtensions.ConvertToEnum, + return _lampState ?? (_lampState = new CapWrapper(_source, CapabilityId.ICapLampState, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -521,7 +531,7 @@ namespace NTwain { get { - return _lightSource ?? (_lightSource = new CapWrapper(this, CapabilityId.ICapLightSource, ValueExtensions.ConvertToEnum, + return _lightSource ?? (_lightSource = new CapWrapper(_source, CapabilityId.ICapLightSource, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -542,7 +552,7 @@ namespace NTwain { get { - return _orientation ?? (_orientation = new CapWrapper(this, CapabilityId.ICapOrientation, ValueExtensions.ConvertToEnum, + return _orientation ?? (_orientation = new CapWrapper(_source, CapabilityId.ICapOrientation, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -563,7 +573,7 @@ namespace NTwain { get { - return _physicalWidth ?? (_physicalWidth = new CapWrapper(this, CapabilityId.ICapPhysicalWidth, ValueExtensions.ConvertToFix32, true)); + return _physicalWidth ?? (_physicalWidth = new CapWrapper(_source, CapabilityId.ICapPhysicalWidth, ValueExtensions.ConvertToFix32, true)); } } @@ -579,7 +589,7 @@ namespace NTwain { get { - return _physicalHeight ?? (_physicalHeight = new CapWrapper(this, CapabilityId.ICapPhysicalHeight, ValueExtensions.ConvertToFix32, true)); + return _physicalHeight ?? (_physicalHeight = new CapWrapper(_source, CapabilityId.ICapPhysicalHeight, ValueExtensions.ConvertToFix32, true)); } } @@ -595,7 +605,7 @@ namespace NTwain { get { - return _shadow ?? (_shadow = new CapWrapper(this, CapabilityId.ICapShadow, ValueExtensions.ConvertToFix32, + return _shadow ?? (_shadow = new CapWrapper(_source, CapabilityId.ICapShadow, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -616,12 +626,12 @@ namespace NTwain { get { - return _frames ?? (_frames = new CapWrapper(this, CapabilityId.ICapFrames, ValueExtensions.ConvertToFrame, + return _frames ?? (_frames = new CapWrapper(_source, CapabilityId.ICapFrames, ValueExtensions.ConvertToFrame, value => { using (var cap = new TWCapability(CapabilityId.ICapFrames, value)) { - return DGControl.Capability.Set(cap); + return _source.DGControl.Capability.Set(cap); } })); } @@ -639,7 +649,7 @@ namespace NTwain { get { - return _nativeXRes ?? (_nativeXRes = new CapWrapper(this, CapabilityId.ICapXNativeResolution, ValueExtensions.ConvertToFix32, true)); + return _nativeXRes ?? (_nativeXRes = new CapWrapper(_source, CapabilityId.ICapXNativeResolution, ValueExtensions.ConvertToFix32, true)); } } @@ -655,7 +665,7 @@ namespace NTwain { get { - return _nativeYRes ?? (_nativeYRes = new CapWrapper(this, CapabilityId.ICapYNativeResolution, ValueExtensions.ConvertToFix32, true)); + return _nativeYRes ?? (_nativeYRes = new CapWrapper(_source, CapabilityId.ICapYNativeResolution, ValueExtensions.ConvertToFix32, true)); } } @@ -671,7 +681,7 @@ namespace NTwain { get { - return _xResolution ?? (_xResolution = new CapWrapper(this, CapabilityId.ICapXResolution, ValueExtensions.ConvertToFix32, + return _xResolution ?? (_xResolution = new CapWrapper(_source, CapabilityId.ICapXResolution, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -693,7 +703,7 @@ namespace NTwain { get { - return _yResolution ?? (_yResolution = new CapWrapper(this, CapabilityId.ICapYResolution, ValueExtensions.ConvertToFix32, + return _yResolution ?? (_yResolution = new CapWrapper(_source, CapabilityId.ICapYResolution, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -714,7 +724,7 @@ namespace NTwain { get { - return _maxFrames ?? (_maxFrames = new CapWrapper(this, CapabilityId.ICapMaxFrames, ValueExtensions.ConvertToEnum, + return _maxFrames ?? (_maxFrames = new CapWrapper(_source, CapabilityId.ICapMaxFrames, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -735,7 +745,7 @@ namespace NTwain { get { - return _tiles ?? (_tiles = new CapWrapper(this, CapabilityId.ICapTiles, ValueExtensions.ConvertToEnum, + return _tiles ?? (_tiles = new CapWrapper(_source, CapabilityId.ICapTiles, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -756,7 +766,7 @@ namespace NTwain { get { - return _bitOrder ?? (_bitOrder = new CapWrapper(this, CapabilityId.ICapBitOrder, ValueExtensions.ConvertToEnum, + return _bitOrder ?? (_bitOrder = new CapWrapper(_source, CapabilityId.ICapBitOrder, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -777,7 +787,7 @@ namespace NTwain { get { - return _ccittKFactor ?? (_ccittKFactor = new CapWrapper(this, CapabilityId.ICapCCITTKFactor, ValueExtensions.ConvertToEnum, + return _ccittKFactor ?? (_ccittKFactor = new CapWrapper(_source, CapabilityId.ICapCCITTKFactor, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -798,7 +808,7 @@ namespace NTwain { get { - return _lightPath ?? (_lightPath = new CapWrapper(this, CapabilityId.ICapLightPath, ValueExtensions.ConvertToEnum, + return _lightPath ?? (_lightPath = new CapWrapper(_source, CapabilityId.ICapLightPath, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -819,7 +829,7 @@ namespace NTwain { get { - return _pixelFlavor ?? (_pixelFlavor = new CapWrapper(this, CapabilityId.ICapPixelFlavor, ValueExtensions.ConvertToEnum, + return _pixelFlavor ?? (_pixelFlavor = new CapWrapper(_source, CapabilityId.ICapPixelFlavor, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -840,7 +850,7 @@ namespace NTwain { get { - return _planarChunky ?? (_planarChunky = new CapWrapper(this, CapabilityId.ICapPlanarChunky, ValueExtensions.ConvertToEnum, + return _planarChunky ?? (_planarChunky = new CapWrapper(_source, CapabilityId.ICapPlanarChunky, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -861,7 +871,7 @@ namespace NTwain { get { - return _rotation ?? (_rotation = new CapWrapper(this, CapabilityId.ICapRotation, ValueExtensions.ConvertToFix32, + return _rotation ?? (_rotation = new CapWrapper(_source, CapabilityId.ICapRotation, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -882,7 +892,7 @@ namespace NTwain { get { - return _supportSize ?? (_supportSize = new CapWrapper(this, CapabilityId.ICapSupportedSizes, ValueExtensions.ConvertToEnum, + return _supportSize ?? (_supportSize = new CapWrapper(_source, CapabilityId.ICapSupportedSizes, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -903,7 +913,7 @@ namespace NTwain { get { - return _threshold ?? (_threshold = new CapWrapper(this, CapabilityId.ICapThreshold, ValueExtensions.ConvertToFix32, + return _threshold ?? (_threshold = new CapWrapper(_source, CapabilityId.ICapThreshold, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -924,7 +934,7 @@ namespace NTwain { get { - return _xscaling ?? (_xscaling = new CapWrapper(this, CapabilityId.ICapXScaling, ValueExtensions.ConvertToFix32, + return _xscaling ?? (_xscaling = new CapWrapper(_source, CapabilityId.ICapXScaling, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -945,7 +955,7 @@ namespace NTwain { get { - return _yscaling ?? (_yscaling = new CapWrapper(this, CapabilityId.ICapYScaling, ValueExtensions.ConvertToFix32, + return _yscaling ?? (_yscaling = new CapWrapper(_source, CapabilityId.ICapYScaling, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -966,7 +976,7 @@ namespace NTwain { get { - return _bitorderCodes ?? (_bitorderCodes = new CapWrapper(this, CapabilityId.ICapBitOrderCodes, ValueExtensions.ConvertToEnum, + return _bitorderCodes ?? (_bitorderCodes = new CapWrapper(_source, CapabilityId.ICapBitOrderCodes, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -987,7 +997,7 @@ namespace NTwain { get { - return _pixelFlavorCodes ?? (_pixelFlavorCodes = new CapWrapper(this, CapabilityId.ICapPixelFlavorCodes, ValueExtensions.ConvertToEnum, + return _pixelFlavorCodes ?? (_pixelFlavorCodes = new CapWrapper(_source, CapabilityId.ICapPixelFlavorCodes, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1008,7 +1018,7 @@ namespace NTwain { get { - return _jpegPixelType ?? (_jpegPixelType = new CapWrapper(this, CapabilityId.ICapJpegPixelType, ValueExtensions.ConvertToEnum, + return _jpegPixelType ?? (_jpegPixelType = new CapWrapper(_source, CapabilityId.ICapJpegPixelType, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1029,7 +1039,7 @@ namespace NTwain { get { - return _timeFill ?? (_timeFill = new CapWrapper(this, CapabilityId.ICapTimeFill, ValueExtensions.ConvertToEnum, + return _timeFill ?? (_timeFill = new CapWrapper(_source, CapabilityId.ICapTimeFill, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1050,7 +1060,7 @@ namespace NTwain { get { - return _bitDepth ?? (_bitDepth = new CapWrapper(this, CapabilityId.ICapBitDepth, ValueExtensions.ConvertToEnum, + return _bitDepth ?? (_bitDepth = new CapWrapper(_source, CapabilityId.ICapBitDepth, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1071,7 +1081,7 @@ namespace NTwain { get { - return _bitDepthReduction ?? (_bitDepthReduction = new CapWrapper(this, CapabilityId.ICapBitDepthReduction, ValueExtensions.ConvertToEnum, + return _bitDepthReduction ?? (_bitDepthReduction = new CapWrapper(_source, CapabilityId.ICapBitDepthReduction, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1092,7 +1102,7 @@ namespace NTwain { get { - return _undefinedImgSize ?? (_undefinedImgSize = new CapWrapper(this, CapabilityId.ICapUndefinedImageSize, ValueExtensions.ConvertToEnum, + return _undefinedImgSize ?? (_undefinedImgSize = new CapWrapper(_source, CapabilityId.ICapUndefinedImageSize, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1114,7 +1124,7 @@ namespace NTwain { get { - return _imgDataSet ?? (_imgDataSet = new CapWrapper(this, CapabilityId.ICapImageDataSet, ValueExtensions.ConvertToEnum, + return _imgDataSet ?? (_imgDataSet = new CapWrapper(_source, CapabilityId.ICapImageDataSet, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -1135,7 +1145,7 @@ namespace NTwain { get { - return _extImgInfo ?? (_extImgInfo = new CapWrapper(this, CapabilityId.ICapExtImageInfo, ValueExtensions.ConvertToEnum, + return _extImgInfo ?? (_extImgInfo = new CapWrapper(_source, CapabilityId.ICapExtImageInfo, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1156,7 +1166,7 @@ namespace NTwain { get { - return _minHeight ?? (_minHeight = new CapWrapper(this, CapabilityId.ICapMinimumHeight, ValueExtensions.ConvertToFix32, true)); + return _minHeight ?? (_minHeight = new CapWrapper(_source, CapabilityId.ICapMinimumHeight, ValueExtensions.ConvertToFix32, true)); } } @@ -1172,7 +1182,7 @@ namespace NTwain { get { - return _minWidth ?? (_minWidth = new CapWrapper(this, CapabilityId.ICapMinimumWidth, ValueExtensions.ConvertToFix32, true)); + return _minWidth ?? (_minWidth = new CapWrapper(_source, CapabilityId.ICapMinimumWidth, ValueExtensions.ConvertToFix32, true)); } } @@ -1188,7 +1198,7 @@ namespace NTwain { get { - return _autoDiscBlankPg ?? (_autoDiscBlankPg = new CapWrapper(this, CapabilityId.ICapAutoDiscardBlankPages, ValueExtensions.ConvertToEnum, + return _autoDiscBlankPg ?? (_autoDiscBlankPg = new CapWrapper(_source, CapabilityId.ICapAutoDiscardBlankPages, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1209,7 +1219,7 @@ namespace NTwain { get { - return _flipRotation ?? (_flipRotation = new CapWrapper(this, CapabilityId.ICapFlipRotation, ValueExtensions.ConvertToEnum, + return _flipRotation ?? (_flipRotation = new CapWrapper(_source, CapabilityId.ICapFlipRotation, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1230,7 +1240,7 @@ namespace NTwain { get { - return _barcodeDetectEnabled ?? (_barcodeDetectEnabled = new CapWrapper(this, CapabilityId.ICapBarcodeDetectionEnabled, ValueExtensions.ConvertToEnum, + return _barcodeDetectEnabled ?? (_barcodeDetectEnabled = new CapWrapper(_source, CapabilityId.ICapBarcodeDetectionEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1251,7 +1261,7 @@ namespace NTwain { get { - return _barcodeType ?? (_barcodeType = new CapWrapper(this, CapabilityId.ICapSupportedBarcodeTypes, ValueExtensions.ConvertToEnum, true)); + return _barcodeType ?? (_barcodeType = new CapWrapper(_source, CapabilityId.ICapSupportedBarcodeTypes, ValueExtensions.ConvertToEnum, true)); } } @@ -1267,7 +1277,7 @@ namespace NTwain { get { - return _barcodeMaxPriority ?? (_barcodeMaxPriority = new CapWrapper(this, CapabilityId.ICapBarcodeMaxSearchPriorities, ValueExtensions.ConvertToEnum, + return _barcodeMaxPriority ?? (_barcodeMaxPriority = new CapWrapper(_source, CapabilityId.ICapBarcodeMaxSearchPriorities, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -1288,7 +1298,7 @@ namespace NTwain { get { - return _barcodeSearchPriority ?? (_barcodeSearchPriority = new CapWrapper(this, CapabilityId.ICapBarcodeSearchPriorities, ValueExtensions.ConvertToEnum, + return _barcodeSearchPriority ?? (_barcodeSearchPriority = new CapWrapper(_source, CapabilityId.ICapBarcodeSearchPriorities, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1309,7 +1319,7 @@ namespace NTwain { get { - return _barcodeSearchMode ?? (_barcodeSearchMode = new CapWrapper(this, CapabilityId.ICapBarcodeSearchMode, ValueExtensions.ConvertToEnum, + return _barcodeSearchMode ?? (_barcodeSearchMode = new CapWrapper(_source, CapabilityId.ICapBarcodeSearchMode, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1330,7 +1340,7 @@ namespace NTwain { get { - return _barcodeMaxRetries ?? (_barcodeMaxRetries = new CapWrapper(this, CapabilityId.ICapBarcodeMaxRetries, ValueExtensions.ConvertToEnum, + return _barcodeMaxRetries ?? (_barcodeMaxRetries = new CapWrapper(_source, CapabilityId.ICapBarcodeMaxRetries, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -1351,7 +1361,7 @@ namespace NTwain { get { - return _barcodeTimeout ?? (_barcodeTimeout = new CapWrapper(this, CapabilityId.ICapBarcodeTimeout, ValueExtensions.ConvertToEnum, + return _barcodeTimeout ?? (_barcodeTimeout = new CapWrapper(_source, CapabilityId.ICapBarcodeTimeout, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -1372,7 +1382,7 @@ namespace NTwain { get { - return _zoomFactor ?? (_zoomFactor = new CapWrapper(this, CapabilityId.ICapZoomFactor, ValueExtensions.ConvertToEnum, + return _zoomFactor ?? (_zoomFactor = new CapWrapper(_source, CapabilityId.ICapZoomFactor, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1393,7 +1403,7 @@ namespace NTwain { get { - return _patchcodeDetectEnabled ?? (_patchcodeDetectEnabled = new CapWrapper(this, CapabilityId.ICapPatchCodeDetectionEnabled, ValueExtensions.ConvertToEnum, + return _patchcodeDetectEnabled ?? (_patchcodeDetectEnabled = new CapWrapper(_source, CapabilityId.ICapPatchCodeDetectionEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1414,7 +1424,7 @@ namespace NTwain { get { - return _patchcodeType ?? (_patchcodeType = new CapWrapper(this, CapabilityId.ICapSupportedPatchCodeTypes, ValueExtensions.ConvertToEnum, true)); + return _patchcodeType ?? (_patchcodeType = new CapWrapper(_source, CapabilityId.ICapSupportedPatchCodeTypes, ValueExtensions.ConvertToEnum, true)); } } @@ -1430,7 +1440,7 @@ namespace NTwain { get { - return _patchcodeMaxPriority ?? (_patchcodeMaxPriority = new CapWrapper(this, CapabilityId.ICapPatchCodeMaxSearchPriorities, ValueExtensions.ConvertToEnum, + return _patchcodeMaxPriority ?? (_patchcodeMaxPriority = new CapWrapper(_source, CapabilityId.ICapPatchCodeMaxSearchPriorities, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -1451,7 +1461,7 @@ namespace NTwain { get { - return _patchcodeSearchPriority ?? (_patchcodeSearchPriority = new CapWrapper(this, CapabilityId.ICapPatchCodeSearchPriorities, ValueExtensions.ConvertToEnum, + return _patchcodeSearchPriority ?? (_patchcodeSearchPriority = new CapWrapper(_source, CapabilityId.ICapPatchCodeSearchPriorities, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1472,7 +1482,7 @@ namespace NTwain { get { - return _patchcodeSearchMode ?? (_patchcodeSearchMode = new CapWrapper(this, CapabilityId.ICapPatchCodeSearchMode, ValueExtensions.ConvertToEnum, + return _patchcodeSearchMode ?? (_patchcodeSearchMode = new CapWrapper(_source, CapabilityId.ICapPatchCodeSearchMode, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1493,7 +1503,7 @@ namespace NTwain { get { - return _patchCodeMaxRetries ?? (_patchCodeMaxRetries = new CapWrapper(this, CapabilityId.ICapPatchCodeMaxRetries, ValueExtensions.ConvertToEnum, + return _patchCodeMaxRetries ?? (_patchCodeMaxRetries = new CapWrapper(_source, CapabilityId.ICapPatchCodeMaxRetries, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -1514,7 +1524,7 @@ namespace NTwain { get { - return _patchCodeTimeout ?? (_patchCodeTimeout = new CapWrapper(this, CapabilityId.ICapPatchCodeTimeout, ValueExtensions.ConvertToEnum, + return _patchCodeTimeout ?? (_patchCodeTimeout = new CapWrapper(_source, CapabilityId.ICapPatchCodeTimeout, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -1535,7 +1545,7 @@ namespace NTwain { get { - return _flashUsed2 ?? (_flashUsed2 = new CapWrapper(this, CapabilityId.ICapFlashUsed2, ValueExtensions.ConvertToEnum, + return _flashUsed2 ?? (_flashUsed2 = new CapWrapper(_source, CapabilityId.ICapFlashUsed2, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1556,7 +1566,7 @@ namespace NTwain { get { - return _imgFilter ?? (_imgFilter = new CapWrapper(this, CapabilityId.ICapImageFilter, ValueExtensions.ConvertToEnum, + return _imgFilter ?? (_imgFilter = new CapWrapper(_source, CapabilityId.ICapImageFilter, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1577,7 +1587,7 @@ namespace NTwain { get { - return _noiseFilter ?? (_noiseFilter = new CapWrapper(this, CapabilityId.ICapNoiseFilter, ValueExtensions.ConvertToEnum, + return _noiseFilter ?? (_noiseFilter = new CapWrapper(_source, CapabilityId.ICapNoiseFilter, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1598,7 +1608,7 @@ namespace NTwain { get { - return _overscan ?? (_overscan = new CapWrapper(this, CapabilityId.ICapOverScan, ValueExtensions.ConvertToEnum, + return _overscan ?? (_overscan = new CapWrapper(_source, CapabilityId.ICapOverScan, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1619,7 +1629,7 @@ namespace NTwain { get { - return _borderDetect ?? (_borderDetect = new CapWrapper(this, CapabilityId.ICapAutomaticBorderDetection, ValueExtensions.ConvertToEnum, + return _borderDetect ?? (_borderDetect = new CapWrapper(_source, CapabilityId.ICapAutomaticBorderDetection, ValueExtensions.ConvertToEnum, value => { var rc = ReturnCode.Failure; @@ -1634,7 +1644,7 @@ namespace NTwain rc = ICapUndefinedImageSize.SetValue(value); using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, one)) { - rc = _session.DGControl.Capability.Set(capValue); + rc = _source.DGControl.Capability.Set(capValue); } return rc; @@ -1654,7 +1664,7 @@ namespace NTwain { get { - return _autoDeskew ?? (_autoDeskew = new CapWrapper(this, CapabilityId.ICapAutomaticDeskew, ValueExtensions.ConvertToEnum, + return _autoDeskew ?? (_autoDeskew = new CapWrapper(_source, CapabilityId.ICapAutomaticDeskew, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1675,7 +1685,7 @@ namespace NTwain { get { - return _autoRotate ?? (_autoRotate = new CapWrapper(this, CapabilityId.ICapAutomaticRotate, ValueExtensions.ConvertToEnum, + return _autoRotate ?? (_autoRotate = new CapWrapper(_source, CapabilityId.ICapAutomaticRotate, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1697,7 +1707,7 @@ namespace NTwain get { //TODO: verify - return _jpegQuality ?? (_jpegQuality = new CapWrapper(this, CapabilityId.ICapJpegQuality, ValueExtensions.ConvertToEnum, + return _jpegQuality ?? (_jpegQuality = new CapWrapper(_source, CapabilityId.ICapJpegQuality, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1718,7 +1728,7 @@ namespace NTwain { get { - return _feederType ?? (_feederType = new CapWrapper(this, CapabilityId.ICapFeederType, ValueExtensions.ConvertToEnum, + return _feederType ?? (_feederType = new CapWrapper(_source, CapabilityId.ICapFeederType, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1739,7 +1749,7 @@ namespace NTwain { get { - return _iccProfile ?? (_iccProfile = new CapWrapper(this, CapabilityId.ICapICCProfile, ValueExtensions.ConvertToEnum, + return _iccProfile ?? (_iccProfile = new CapWrapper(_source, CapabilityId.ICapICCProfile, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1760,7 +1770,7 @@ namespace NTwain { get { - return _autoSize ?? (_autoSize = new CapWrapper(this, CapabilityId.ICapAutoSize, ValueExtensions.ConvertToEnum, + return _autoSize ?? (_autoSize = new CapWrapper(_source, CapabilityId.ICapAutoSize, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1781,7 +1791,7 @@ namespace NTwain { get { - return _cropUseFrame ?? (_cropUseFrame = new CapWrapper(this, CapabilityId.ICapAutomaticCropUsesFrame, ValueExtensions.ConvertToEnum, true)); + return _cropUseFrame ?? (_cropUseFrame = new CapWrapper(_source, CapabilityId.ICapAutomaticCropUsesFrame, ValueExtensions.ConvertToEnum, true)); } } @@ -1797,7 +1807,7 @@ namespace NTwain { get { - return _lengthDetect ?? (_lengthDetect = new CapWrapper(this, CapabilityId.ICapAutomaticLengthDetection, ValueExtensions.ConvertToEnum, + return _lengthDetect ?? (_lengthDetect = new CapWrapper(_source, CapabilityId.ICapAutomaticLengthDetection, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1818,7 +1828,7 @@ namespace NTwain { get { - return _autoColor ?? (_autoColor = new CapWrapper(this, CapabilityId.ICapAutomaticColorEnabled, ValueExtensions.ConvertToEnum, + return _autoColor ?? (_autoColor = new CapWrapper(_source, CapabilityId.ICapAutomaticColorEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1839,7 +1849,7 @@ namespace NTwain { get { - return _autoColorNonPixel ?? (_autoColorNonPixel = new CapWrapper(this, CapabilityId.ICapAutomaticColorNonColorPixelType, ValueExtensions.ConvertToEnum, + return _autoColorNonPixel ?? (_autoColorNonPixel = new CapWrapper(_source, CapabilityId.ICapAutomaticColorNonColorPixelType, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1860,7 +1870,7 @@ namespace NTwain { get { - return _colorMgmt ?? (_colorMgmt = new CapWrapper(this, CapabilityId.ICapColorManagementEnabled, ValueExtensions.ConvertToEnum, + return _colorMgmt ?? (_colorMgmt = new CapWrapper(_source, CapabilityId.ICapColorManagementEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1881,7 +1891,7 @@ namespace NTwain { get { - return _imgMerge ?? (_imgMerge = new CapWrapper(this, CapabilityId.ICapImageMerge, ValueExtensions.ConvertToEnum, + return _imgMerge ?? (_imgMerge = new CapWrapper(_source, CapabilityId.ICapImageMerge, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1902,7 +1912,7 @@ namespace NTwain { get { - return _mergeHeight ?? (_mergeHeight = new CapWrapper(this, CapabilityId.ICapImageMergeHeightThreshold, ValueExtensions.ConvertToFix32, + return _mergeHeight ?? (_mergeHeight = new CapWrapper(_source, CapabilityId.ICapImageMergeHeightThreshold, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -1923,7 +1933,7 @@ namespace NTwain { get { - return _supportedExtInfo ?? (_supportedExtInfo = new CapWrapper(this, CapabilityId.ICapSupportedExtImageInfo, ValueExtensions.ConvertToEnum, true)); + return _supportedExtInfo ?? (_supportedExtInfo = new CapWrapper(_source, CapabilityId.ICapSupportedExtImageInfo, ValueExtensions.ConvertToEnum, true)); } } @@ -1939,7 +1949,7 @@ namespace NTwain { get { - return _filmType ?? (_filmType = new CapWrapper(this, CapabilityId.ICapFilmType, ValueExtensions.ConvertToEnum, + return _filmType ?? (_filmType = new CapWrapper(_source, CapabilityId.ICapFilmType, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1960,7 +1970,7 @@ namespace NTwain { get { - return _mirror ?? (_mirror = new CapWrapper(this, CapabilityId.ICapMirror, ValueExtensions.ConvertToEnum, + return _mirror ?? (_mirror = new CapWrapper(_source, CapabilityId.ICapMirror, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -1981,7 +1991,7 @@ namespace NTwain { get { - return _jpegSubSampling ?? (_jpegSubSampling = new CapWrapper(this, CapabilityId.ICapJpegSubsampling, ValueExtensions.ConvertToEnum, + return _jpegSubSampling ?? (_jpegSubSampling = new CapWrapper(_source, CapabilityId.ICapJpegSubsampling, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2008,7 +2018,7 @@ namespace NTwain { get { - return _xferCount ?? (_xferCount = new CapWrapper(this, CapabilityId.CapXferCount, ValueExtensions.ConvertToEnum, + return _xferCount ?? (_xferCount = new CapWrapper(_source, CapabilityId.CapXferCount, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value > 0 ? (uint)value : uint.MaxValue, @@ -2032,12 +2042,12 @@ namespace NTwain { get { - return _author ?? (_author = new CapWrapper(this, CapabilityId.CapAuthor, ValueExtensions.ConvertToString, + return _author ?? (_author = new CapWrapper(_source, CapabilityId.CapAuthor, ValueExtensions.ConvertToString, value => { using (var cap = new TWCapability(CapabilityId.CapAuthor, value, ItemType.String128)) { - return DGControl.Capability.Set(cap); + return _source.DGControl.Capability.Set(cap); } })); } @@ -2056,12 +2066,12 @@ namespace NTwain { get { - return _caption ?? (_caption = new CapWrapper(this, CapabilityId.CapCaption, ValueExtensions.ConvertToString, + return _caption ?? (_caption = new CapWrapper(_source, CapabilityId.CapCaption, ValueExtensions.ConvertToString, value => { using (var cap = new TWCapability(CapabilityId.CapCaption, value, ItemType.String255)) { - return DGControl.Capability.Set(cap); + return _source.DGControl.Capability.Set(cap); } })); } @@ -2079,7 +2089,7 @@ namespace NTwain { get { - return _feederEnabled ?? (_feederEnabled = new CapWrapper(this, CapabilityId.CapFeederEnabled, ValueExtensions.ConvertToEnum, + return _feederEnabled ?? (_feederEnabled = new CapWrapper(_source, CapabilityId.CapFeederEnabled, ValueExtensions.ConvertToEnum, value => { var rc = ReturnCode.Failure; @@ -2096,7 +2106,7 @@ namespace NTwain { using (TWCapability enabled = new TWCapability(CapabilityId.CapFeederEnabled, one)) { - rc = _session.DGControl.Capability.Set(enabled); + rc = _source.DGControl.Capability.Set(enabled); } } // to really use feeder we must also set autofeed or autoscan, but only @@ -2127,7 +2137,7 @@ namespace NTwain { get { - return _feederLoaded ?? (_feederLoaded = new CapWrapper(this, CapabilityId.CapFeederLoaded, ValueExtensions.ConvertToEnum, true)); + return _feederLoaded ?? (_feederLoaded = new CapWrapper(_source, CapabilityId.CapFeederLoaded, ValueExtensions.ConvertToEnum, true)); } } @@ -2143,7 +2153,7 @@ namespace NTwain { get { - return _timedate ?? (_timedate = new CapWrapper(this, CapabilityId.CapTimeDate, ValueExtensions.ConvertToString, true)); + return _timedate ?? (_timedate = new CapWrapper(_source, CapabilityId.CapTimeDate, ValueExtensions.ConvertToString, true)); } } @@ -2159,7 +2169,7 @@ namespace NTwain { get { - return _supportedCaps ?? (_supportedCaps = new CapWrapper(this, CapabilityId.CapSupportedCaps, value => value.ConvertToEnum(false), true)); + return _supportedCaps ?? (_supportedCaps = new CapWrapper(_source, CapabilityId.CapSupportedCaps, value => value.ConvertToEnum(false), true)); } } @@ -2175,7 +2185,7 @@ namespace NTwain { get { - return _extendedCaps ?? (_extendedCaps = new CapWrapper(this, CapabilityId.CapExtendedCaps, value => value.ConvertToEnum(false), + return _extendedCaps ?? (_extendedCaps = new CapWrapper(_source, CapabilityId.CapExtendedCaps, value => value.ConvertToEnum(false), value => new TWOneValue { Item = (uint)value, @@ -2196,7 +2206,7 @@ namespace NTwain { get { - return _autoFeed ?? (_autoFeed = new CapWrapper(this, CapabilityId.CapAutoFeed, ValueExtensions.ConvertToEnum, + return _autoFeed ?? (_autoFeed = new CapWrapper(_source, CapabilityId.CapAutoFeed, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2217,7 +2227,7 @@ namespace NTwain { get { - return _clearPage ?? (_clearPage = new CapWrapper(this, CapabilityId.CapClearPage, ValueExtensions.ConvertToEnum, + return _clearPage ?? (_clearPage = new CapWrapper(_source, CapabilityId.CapClearPage, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2238,7 +2248,7 @@ namespace NTwain { get { - return _feedPage ?? (_feedPage = new CapWrapper(this, CapabilityId.CapFeedPage, ValueExtensions.ConvertToEnum, + return _feedPage ?? (_feedPage = new CapWrapper(_source, CapabilityId.CapFeedPage, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2259,7 +2269,7 @@ namespace NTwain { get { - return _rewindPage ?? (_rewindPage = new CapWrapper(this, CapabilityId.CapRewindPage, ValueExtensions.ConvertToEnum, + return _rewindPage ?? (_rewindPage = new CapWrapper(_source, CapabilityId.CapRewindPage, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2280,7 +2290,7 @@ namespace NTwain { get { - return _indicators ?? (_indicators = new CapWrapper(this, CapabilityId.CapIndicators, ValueExtensions.ConvertToEnum, + return _indicators ?? (_indicators = new CapWrapper(_source, CapabilityId.CapIndicators, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2301,7 +2311,7 @@ namespace NTwain { get { - return _paperDetectable ?? (_paperDetectable = new CapWrapper(this, CapabilityId.CapPaperDetectable, ValueExtensions.ConvertToEnum, true)); + return _paperDetectable ?? (_paperDetectable = new CapWrapper(_source, CapabilityId.CapPaperDetectable, ValueExtensions.ConvertToEnum, true)); } } @@ -2317,7 +2327,7 @@ namespace NTwain { get { - return _uiControllable ?? (_uiControllable = new CapWrapper(this, CapabilityId.CapUIControllable, ValueExtensions.ConvertToEnum, true)); + return _uiControllable ?? (_uiControllable = new CapWrapper(_source, CapabilityId.CapUIControllable, ValueExtensions.ConvertToEnum, true)); } } @@ -2333,7 +2343,7 @@ namespace NTwain { get { - return _devOnline ?? (_devOnline = new CapWrapper(this, CapabilityId.CapDeviceOnline, ValueExtensions.ConvertToEnum, true)); + return _devOnline ?? (_devOnline = new CapWrapper(_source, CapabilityId.CapDeviceOnline, ValueExtensions.ConvertToEnum, true)); } } @@ -2349,7 +2359,7 @@ namespace NTwain { get { - return _autoScan ?? (_autoScan = new CapWrapper(this, CapabilityId.CapAutoScan, ValueExtensions.ConvertToEnum, + return _autoScan ?? (_autoScan = new CapWrapper(_source, CapabilityId.CapAutoScan, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2370,7 +2380,7 @@ namespace NTwain { get { - return _thumbsEnabled ?? (_thumbsEnabled = new CapWrapper(this, CapabilityId.CapThumbnailsEnabled, ValueExtensions.ConvertToEnum, + return _thumbsEnabled ?? (_thumbsEnabled = new CapWrapper(_source, CapabilityId.CapThumbnailsEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2391,7 +2401,7 @@ namespace NTwain { get { - return _duplex ?? (_duplex = new CapWrapper(this, CapabilityId.CapDuplex, ValueExtensions.ConvertToEnum, true)); + return _duplex ?? (_duplex = new CapWrapper(_source, CapabilityId.CapDuplex, ValueExtensions.ConvertToEnum, true)); } } @@ -2407,7 +2417,7 @@ namespace NTwain { get { - return _duplexEnabled ?? (_duplexEnabled = new CapWrapper(this, CapabilityId.CapDuplexEnabled, ValueExtensions.ConvertToEnum, + return _duplexEnabled ?? (_duplexEnabled = new CapWrapper(_source, CapabilityId.CapDuplexEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2428,7 +2438,7 @@ namespace NTwain { get { - return _dsUIonly ?? (_dsUIonly = new CapWrapper(this, CapabilityId.CapEnableDSUIOnly, ValueExtensions.ConvertToEnum, true)); + return _dsUIonly ?? (_dsUIonly = new CapWrapper(_source, CapabilityId.CapEnableDSUIOnly, ValueExtensions.ConvertToEnum, true)); } } @@ -2444,7 +2454,7 @@ namespace NTwain { get { - return _dsData ?? (_dsData = new CapWrapper(this, CapabilityId.CapCustomDSData, ValueExtensions.ConvertToEnum, true)); + return _dsData ?? (_dsData = new CapWrapper(_source, CapabilityId.CapCustomDSData, ValueExtensions.ConvertToEnum, true)); } } @@ -2460,7 +2470,7 @@ namespace NTwain { get { - return _endorser ?? (_endorser = new CapWrapper(this, CapabilityId.CapEndorser, ValueExtensions.ConvertToEnum, + return _endorser ?? (_endorser = new CapWrapper(_source, CapabilityId.CapEndorser, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -2481,7 +2491,7 @@ namespace NTwain { get { - return _jobControl ?? (_jobControl = new CapWrapper(this, CapabilityId.CapJobControl, ValueExtensions.ConvertToEnum, + return _jobControl ?? (_jobControl = new CapWrapper(_source, CapabilityId.CapJobControl, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2502,7 +2512,7 @@ namespace NTwain { get { - return _alarms ?? (_alarms = new CapWrapper(this, CapabilityId.CapAlarms, ValueExtensions.ConvertToEnum, + return _alarms ?? (_alarms = new CapWrapper(_source, CapabilityId.CapAlarms, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2523,7 +2533,7 @@ namespace NTwain { get { - return _alarmVolume ?? (_alarmVolume = new CapWrapper(this, CapabilityId.CapAlarmVolume, ValueExtensions.ConvertToEnum, + return _alarmVolume ?? (_alarmVolume = new CapWrapper(_source, CapabilityId.CapAlarmVolume, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2544,7 +2554,7 @@ namespace NTwain { get { - return _autoCapture ?? (_autoCapture = new CapWrapper(this, CapabilityId.CapAutomaticCapture, ValueExtensions.ConvertToEnum, + return _autoCapture ?? (_autoCapture = new CapWrapper(_source, CapabilityId.CapAutomaticCapture, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2565,7 +2575,7 @@ namespace NTwain { get { - return _timeBeforeCap ?? (_timeBeforeCap = new CapWrapper(this, CapabilityId.CapTimeBeforeFirstCapture, ValueExtensions.ConvertToEnum, + return _timeBeforeCap ?? (_timeBeforeCap = new CapWrapper(_source, CapabilityId.CapTimeBeforeFirstCapture, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2586,7 +2596,7 @@ namespace NTwain { get { - return _timeBetweenCap ?? (_timeBetweenCap = new CapWrapper(this, CapabilityId.CapTimeBetweenCaptures, ValueExtensions.ConvertToEnum, + return _timeBetweenCap ?? (_timeBetweenCap = new CapWrapper(_source, CapabilityId.CapTimeBetweenCaptures, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2607,7 +2617,7 @@ namespace NTwain { get { - return _clearBuff ?? (_clearBuff = new CapWrapper(this, CapabilityId.CapClearBuffers, ValueExtensions.ConvertToEnum, + return _clearBuff ?? (_clearBuff = new CapWrapper(_source, CapabilityId.CapClearBuffers, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2628,7 +2638,7 @@ namespace NTwain { get { - return _maxBatchBuff ?? (_maxBatchBuff = new CapWrapper(this, CapabilityId.CapMaxBatchBuffers, ValueExtensions.ConvertToEnum, + return _maxBatchBuff ?? (_maxBatchBuff = new CapWrapper(_source, CapabilityId.CapMaxBatchBuffers, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -2649,12 +2659,12 @@ namespace NTwain { get { - return _devTimeDate ?? (_devTimeDate = new CapWrapper(this, CapabilityId.CapDeviceTimeDate, ValueExtensions.ConvertToString, + return _devTimeDate ?? (_devTimeDate = new CapWrapper(_source, CapabilityId.CapDeviceTimeDate, ValueExtensions.ConvertToString, value => { using (var cap = new TWCapability(CapabilityId.CapDeviceTimeDate, value, ItemType.String32)) { - return DGControl.Capability.Set(cap); + return _source.DGControl.Capability.Set(cap); } })); } @@ -2672,7 +2682,7 @@ namespace NTwain { get { - return _powerSup ?? (_powerSup = new CapWrapper(this, CapabilityId.CapPowerSupply, ValueExtensions.ConvertToEnum, true)); + return _powerSup ?? (_powerSup = new CapWrapper(_source, CapabilityId.CapPowerSupply, ValueExtensions.ConvertToEnum, true)); } } @@ -2688,7 +2698,7 @@ namespace NTwain { get { - return _camPreviewUI ?? (_camPreviewUI = new CapWrapper(this, CapabilityId.CapCameraPreviewUI, ValueExtensions.ConvertToEnum, true)); + return _camPreviewUI ?? (_camPreviewUI = new CapWrapper(_source, CapabilityId.CapCameraPreviewUI, ValueExtensions.ConvertToEnum, true)); } } @@ -2704,7 +2714,7 @@ namespace NTwain { get { - return _devEvent ?? (_devEvent = new CapWrapper(this, CapabilityId.CapDeviceEvent, ValueExtensions.ConvertToEnum, + return _devEvent ?? (_devEvent = new CapWrapper(_source, CapabilityId.CapDeviceEvent, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2725,7 +2735,7 @@ namespace NTwain { get { - return _serialNo ?? (_serialNo = new CapWrapper(this, CapabilityId.CapSerialNumber, ValueExtensions.ConvertToString, true)); + return _serialNo ?? (_serialNo = new CapWrapper(_source, CapabilityId.CapSerialNumber, ValueExtensions.ConvertToString, true)); } } @@ -2741,7 +2751,7 @@ namespace NTwain { get { - return _printer ?? (_printer = new CapWrapper(this, CapabilityId.CapPrinter, ValueExtensions.ConvertToEnum, + return _printer ?? (_printer = new CapWrapper(_source, CapabilityId.CapPrinter, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2762,7 +2772,7 @@ namespace NTwain { get { - return _printerEnabled ?? (_printerEnabled = new CapWrapper(this, CapabilityId.CapPrinterEnabled, ValueExtensions.ConvertToEnum, + return _printerEnabled ?? (_printerEnabled = new CapWrapper(_source, CapabilityId.CapPrinterEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2783,7 +2793,7 @@ namespace NTwain { get { - return _printerIndex ?? (_printerIndex = new CapWrapper(this, CapabilityId.CapPrinterIndex, ValueExtensions.ConvertToEnum, + return _printerIndex ?? (_printerIndex = new CapWrapper(_source, CapabilityId.CapPrinterIndex, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2804,7 +2814,7 @@ namespace NTwain { get { - return _printerMode ?? (_printerMode = new CapWrapper(this, CapabilityId.CapPrinterMode, ValueExtensions.ConvertToEnum, + return _printerMode ?? (_printerMode = new CapWrapper(_source, CapabilityId.CapPrinterMode, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2826,12 +2836,12 @@ namespace NTwain { get { - return _printerString ?? (_printerString = new CapWrapper(this, CapabilityId.CapPrinterString, ValueExtensions.ConvertToString, + return _printerString ?? (_printerString = new CapWrapper(_source, CapabilityId.CapPrinterString, ValueExtensions.ConvertToString, value => { using (var cap = new TWCapability(CapabilityId.CapPrinterString, value, ItemType.String255)) { - return DGControl.Capability.Set(cap); + return _source.DGControl.Capability.Set(cap); } })); } @@ -2849,12 +2859,12 @@ namespace NTwain { get { - return _printerSuffix ?? (_printerSuffix = new CapWrapper(this, CapabilityId.CapPrinterSuffix, ValueExtensions.ConvertToString, + return _printerSuffix ?? (_printerSuffix = new CapWrapper(_source, CapabilityId.CapPrinterSuffix, ValueExtensions.ConvertToString, value => { using (var cap = new TWCapability(CapabilityId.CapPrinterSuffix, value, ItemType.String255)) { - return DGControl.Capability.Set(cap); + return _source.DGControl.Capability.Set(cap); } })); } @@ -2872,7 +2882,7 @@ namespace NTwain { get { - return _language ?? (_language = new CapWrapper(this, CapabilityId.CapLanguage, ValueExtensions.ConvertToEnum, + return _language ?? (_language = new CapWrapper(_source, CapabilityId.CapLanguage, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2893,7 +2903,7 @@ namespace NTwain { get { - return _feedAlign ?? (_feedAlign = new CapWrapper(this, CapabilityId.CapFeederAlignment, ValueExtensions.ConvertToEnum, + return _feedAlign ?? (_feedAlign = new CapWrapper(_source, CapabilityId.CapFeederAlignment, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2914,7 +2924,7 @@ namespace NTwain { get { - return _feedOrder ?? (_feedOrder = new CapWrapper(this, CapabilityId.CapFeederOrder, ValueExtensions.ConvertToEnum, + return _feedOrder ?? (_feedOrder = new CapWrapper(_source, CapabilityId.CapFeederOrder, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -2935,7 +2945,7 @@ namespace NTwain { get { - return _reacuireAllow ?? (_reacuireAllow = new CapWrapper(this, CapabilityId.CapReacquireAllowed, ValueExtensions.ConvertToEnum, true)); + return _reacuireAllow ?? (_reacuireAllow = new CapWrapper(_source, CapabilityId.CapReacquireAllowed, ValueExtensions.ConvertToEnum, true)); } } @@ -2951,7 +2961,7 @@ namespace NTwain { get { - return _battMinutes ?? (_battMinutes = new CapWrapper(this, CapabilityId.CapBatteryMinutes, ValueExtensions.ConvertToEnum, true)); + return _battMinutes ?? (_battMinutes = new CapWrapper(_source, CapabilityId.CapBatteryMinutes, ValueExtensions.ConvertToEnum, true)); } } @@ -2967,7 +2977,7 @@ namespace NTwain { get { - return _battPercent ?? (_battPercent = new CapWrapper(this, CapabilityId.CapBatteryPercentage, ValueExtensions.ConvertToEnum, true)); + return _battPercent ?? (_battPercent = new CapWrapper(_source, CapabilityId.CapBatteryPercentage, ValueExtensions.ConvertToEnum, true)); } } @@ -2983,7 +2993,7 @@ namespace NTwain { get { - return _camSide ?? (_camSide = new CapWrapper(this, CapabilityId.CapCameraSide, ValueExtensions.ConvertToEnum, + return _camSide ?? (_camSide = new CapWrapper(_source, CapabilityId.CapCameraSide, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3004,7 +3014,7 @@ namespace NTwain { get { - return _segmented ?? (_segmented = new CapWrapper(this, CapabilityId.CapSegmented, ValueExtensions.ConvertToEnum, + return _segmented ?? (_segmented = new CapWrapper(_source, CapabilityId.CapSegmented, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3025,7 +3035,7 @@ namespace NTwain { get { - return _camEnabled ?? (_camEnabled = new CapWrapper(this, CapabilityId.CapCameraEnabled, ValueExtensions.ConvertToEnum, + return _camEnabled ?? (_camEnabled = new CapWrapper(_source, CapabilityId.CapCameraEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3046,7 +3056,7 @@ namespace NTwain { get { - return _camOrder ?? (_camOrder = new CapWrapper(this, CapabilityId.CapCameraOrder, ValueExtensions.ConvertToEnum, + return _camOrder ?? (_camOrder = new CapWrapper(_source, CapabilityId.CapCameraOrder, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3067,7 +3077,7 @@ namespace NTwain { get { - return _micrEnabled ?? (_micrEnabled = new CapWrapper(this, CapabilityId.CapMicrEnabled, ValueExtensions.ConvertToEnum, + return _micrEnabled ?? (_micrEnabled = new CapWrapper(_source, CapabilityId.CapMicrEnabled, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3088,7 +3098,7 @@ namespace NTwain { get { - return _feederPrep ?? (_feederPrep = new CapWrapper(this, CapabilityId.CapFeederPrep, ValueExtensions.ConvertToEnum, + return _feederPrep ?? (_feederPrep = new CapWrapper(_source, CapabilityId.CapFeederPrep, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3109,7 +3119,7 @@ namespace NTwain { get { - return _feedPocket ?? (_feedPocket = new CapWrapper(this, CapabilityId.CapFeederPocket, ValueExtensions.ConvertToEnum, + return _feedPocket ?? (_feedPocket = new CapWrapper(_source, CapabilityId.CapFeederPocket, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3130,7 +3140,7 @@ namespace NTwain { get { - return _autoMedium ?? (_autoMedium = new CapWrapper(this, CapabilityId.CapAutomaticSenseMedium, ValueExtensions.ConvertToEnum, + return _autoMedium ?? (_autoMedium = new CapWrapper(_source, CapabilityId.CapAutomaticSenseMedium, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3151,7 +3161,7 @@ namespace NTwain { get { - return _custGuid ?? (_custGuid = new CapWrapper(this, CapabilityId.CapCustomInterfaceGuid, ValueExtensions.ConvertToString, true)); + return _custGuid ?? (_custGuid = new CapWrapper(_source, CapabilityId.CapCustomInterfaceGuid, ValueExtensions.ConvertToString, true)); } } @@ -3167,7 +3177,7 @@ namespace NTwain { get { - return _supportedCapsUnique ?? (_supportedCapsUnique = new CapWrapper(this, CapabilityId.CapSupportedCapsSegmentUnique, value => value.ConvertToEnum(false), true)); + return _supportedCapsUnique ?? (_supportedCapsUnique = new CapWrapper(_source, CapabilityId.CapSupportedCapsSegmentUnique, value => value.ConvertToEnum(false), true)); } } @@ -3183,7 +3193,7 @@ namespace NTwain { get { - return _supportedDat ?? (_supportedDat = new CapWrapper(this, CapabilityId.CapSupportedDATs, ValueExtensions.ConvertToEnum, true)); + return _supportedDat ?? (_supportedDat = new CapWrapper(_source, CapabilityId.CapSupportedDATs, ValueExtensions.ConvertToEnum, true)); } } @@ -3199,7 +3209,7 @@ namespace NTwain { get { - return _dblFeedDetect ?? (_dblFeedDetect = new CapWrapper(this, CapabilityId.CapDoubleFeedDetection, ValueExtensions.ConvertToEnum, + return _dblFeedDetect ?? (_dblFeedDetect = new CapWrapper(_source, CapabilityId.CapDoubleFeedDetection, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3220,7 +3230,7 @@ namespace NTwain { get { - return _dblFeedLength ?? (_dblFeedLength = new CapWrapper(this, CapabilityId.CapDoubleFeedDetectionLength, ValueExtensions.ConvertToFix32, + return _dblFeedLength ?? (_dblFeedLength = new CapWrapper(_source, CapabilityId.CapDoubleFeedDetectionLength, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -3241,7 +3251,7 @@ namespace NTwain { get { - return _dblFeedSensitivity ?? (_dblFeedSensitivity = new CapWrapper(this, CapabilityId.CapDoubleFeedDetectionSensitivity, ValueExtensions.ConvertToEnum, + return _dblFeedSensitivity ?? (_dblFeedSensitivity = new CapWrapper(_source, CapabilityId.CapDoubleFeedDetectionSensitivity, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3262,7 +3272,7 @@ namespace NTwain { get { - return _dblFeedResp ?? (_dblFeedResp = new CapWrapper(this, CapabilityId.CapDoubleFeedDetectionResponse, ValueExtensions.ConvertToEnum, + return _dblFeedResp ?? (_dblFeedResp = new CapWrapper(_source, CapabilityId.CapDoubleFeedDetectionResponse, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3283,7 +3293,7 @@ namespace NTwain { get { - return _paperHandling ?? (_paperHandling = new CapWrapper(this, CapabilityId.CapPaperHandling, ValueExtensions.ConvertToEnum, + return _paperHandling ?? (_paperHandling = new CapWrapper(_source, CapabilityId.CapPaperHandling, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3304,7 +3314,7 @@ namespace NTwain { get { - return _indicatorMode ?? (_indicatorMode = new CapWrapper(this, CapabilityId.CapIndicatorsMode, ValueExtensions.ConvertToEnum, + return _indicatorMode ?? (_indicatorMode = new CapWrapper(_source, CapabilityId.CapIndicatorsMode, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3325,7 +3335,7 @@ namespace NTwain { get { - return _printVOffset ?? (_printVOffset = new CapWrapper(this, CapabilityId.CapPrinterVerticalOffset, ValueExtensions.ConvertToFix32, + return _printVOffset ?? (_printVOffset = new CapWrapper(_source, CapabilityId.CapPrinterVerticalOffset, ValueExtensions.ConvertToFix32, value => new TWOneValue { Item = (uint)value,// ((uint)dpi) << 16; @@ -3346,7 +3356,7 @@ namespace NTwain { get { - return _powerSaveTime ?? (_powerSaveTime = new CapWrapper(this, CapabilityId.CapPowerSaveTime, ValueExtensions.ConvertToEnum, + return _powerSaveTime ?? (_powerSaveTime = new CapWrapper(_source, CapabilityId.CapPowerSaveTime, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3367,7 +3377,7 @@ namespace NTwain { get { - return _printCharRot ?? (_printCharRot = new CapWrapper(this, CapabilityId.CapPrinterCharRotation, ValueExtensions.ConvertToEnum, + return _printCharRot ?? (_printCharRot = new CapWrapper(_source, CapabilityId.CapPrinterCharRotation, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3388,7 +3398,7 @@ namespace NTwain { get { - return _printFontStyle ?? (_printFontStyle = new CapWrapper(this, CapabilityId.CapPrinterFontStyle, ValueExtensions.ConvertToEnum, false)); + return _printFontStyle ?? (_printFontStyle = new CapWrapper(_source, CapabilityId.CapPrinterFontStyle, ValueExtensions.ConvertToEnum, false)); } } @@ -3405,12 +3415,12 @@ namespace NTwain { get { - return _printerIdxLeadChar ?? (_printerIdxLeadChar = new CapWrapper(this, CapabilityId.CapPrinterIndexLeadChar, ValueExtensions.ConvertToString, + return _printerIdxLeadChar ?? (_printerIdxLeadChar = new CapWrapper(_source, CapabilityId.CapPrinterIndexLeadChar, ValueExtensions.ConvertToString, value => { using (var cap = new TWCapability(CapabilityId.CapPrinterIndexLeadChar, value, ItemType.String32)) { - return DGControl.Capability.Set(cap); + return _source.DGControl.Capability.Set(cap); } })); } @@ -3428,7 +3438,7 @@ namespace NTwain { get { - return _printIdxMax ?? (_printIdxMax = new CapWrapper(this, CapabilityId.CapPrinterIndexMaxValue, ValueExtensions.ConvertToEnum, + return _printIdxMax ?? (_printIdxMax = new CapWrapper(_source, CapabilityId.CapPrinterIndexMaxValue, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = value, @@ -3449,7 +3459,7 @@ namespace NTwain { get { - return _printNumDigit ?? (_printNumDigit = new CapWrapper(this, CapabilityId.CapPrinterIndexNumDigits, ValueExtensions.ConvertToEnum, + return _printNumDigit ?? (_printNumDigit = new CapWrapper(_source, CapabilityId.CapPrinterIndexNumDigits, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3470,7 +3480,7 @@ namespace NTwain { get { - return _printIdxStep ?? (_printIdxStep = new CapWrapper(this, CapabilityId.CapPrinterIndexStep, ValueExtensions.ConvertToEnum, + return _printIdxStep ?? (_printIdxStep = new CapWrapper(_source, CapabilityId.CapPrinterIndexStep, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -3491,7 +3501,7 @@ namespace NTwain { get { - return _printIdxTrig ?? (_printIdxTrig = new CapWrapper(this, CapabilityId.CapPrinterIndexTrigger, ValueExtensions.ConvertToEnum, false)); + return _printIdxTrig ?? (_printIdxTrig = new CapWrapper(_source, CapabilityId.CapPrinterIndexTrigger, ValueExtensions.ConvertToEnum, false)); } } @@ -3507,7 +3517,7 @@ namespace NTwain { get { - return _printPreview ?? (_printPreview = new CapWrapper(this, CapabilityId.CapPrinterStringPreview, ValueExtensions.ConvertToString, true)); + return _printPreview ?? (_printPreview = new CapWrapper(_source, CapabilityId.CapPrinterStringPreview, ValueExtensions.ConvertToString, true)); } } diff --git a/NTwain/DataSource.cs b/NTwain/DataSource.cs index f1dd2cb..ac58a71 100644 --- a/NTwain/DataSource.cs +++ b/NTwain/DataSource.cs @@ -55,10 +55,10 @@ namespace NTwain Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseSource.", Thread.CurrentThread.ManagedThreadId)); rc = _session.DGControl.Identity.CloseDS(); - if (rc == ReturnCode.Success) - { - SupportedCaps = null; - } + //if (rc == ReturnCode.Success) + //{ + // SupportedCaps = null; + //} _session.UpdateCallback(); }); return rc; @@ -158,34 +158,48 @@ namespace NTwain /// public bool IsOpen { get { return _session.IsSourceOpen; } } - static readonly CapabilityId[] _emptyCapList = new CapabilityId[0]; + //static readonly CapabilityId[] _emptyCapList = new CapabilityId[0]; + + //private IList _supportedCapsList; + ///// + ///// Gets the list of supported caps for this source. + ///// + ///// + ///// The supported caps. + ///// + //[Obsolete("Use CapSupportedCaps.Get() instead.")] + //public IList SupportedCaps + //{ + // get + // { + // if (_supportedCapsList == null && _session.State > 3) + // { + // _supportedCapsList = CapSupportedCaps.GetValues(); + // } + // return _supportedCapsList ?? _emptyCapList; + // } + // private set + // { + // _supportedCapsList = value; + // //OnPropertyChanged("SupportedCaps"); + // } + //} + + private Capabilities _caps; - private IList _supportedCapsList; /// - /// Gets the list of supported caps for this source. + /// Gets the capabilities for this data source. /// /// - /// The supported caps. + /// The capabilities. /// - [Obsolete("Use CapSupportedCaps.Get() instead.")] - public IList SupportedCaps + public Capabilities Capabilities { - get - { - if (_supportedCapsList == null && _session.State > 3) - { - _supportedCapsList = CapSupportedCaps.GetValues(); - } - return _supportedCapsList ?? _emptyCapList; - } - private set - { - _supportedCapsList = value; - //OnPropertyChanged("SupportedCaps"); - } + get { return _caps ?? (_caps = new Capabilities(this)); } } + /// /// Gets the triplet operations defined for control data group. /// diff --git a/NTwain/GlobalSuppressions.cs b/NTwain/GlobalSuppressions.cs index f57f138..77ae691 100644 Binary files a/NTwain/GlobalSuppressions.cs and b/NTwain/GlobalSuppressions.cs differ diff --git a/NTwain/ICapControl.cs b/NTwain/ICapControl.cs deleted file mode 100644 index c74a42b..0000000 --- a/NTwain/ICapControl.cs +++ /dev/null @@ -1,54 +0,0 @@ -using NTwain.Data; -using System; -using System.Collections.Generic; -namespace NTwain -{ - /// - /// Interface for providing basic functions at controlling caps. - /// - public interface ICapControl : ITripletControl - { - - /// - /// Gets all the possible values for a capability. - /// - /// The capability identifier. - /// - IList CapGet(CapabilityId capabilityId); - - /// - /// Gets the current value for a capability. - /// - /// The capability identifier. - /// - object CapGetCurrent(CapabilityId capabilityId); - - /// - /// Gets the default value for a capability. - /// - /// The capability identifier. - /// - object CapGetDefault(CapabilityId capabilityId); - - /// - /// Gets the supported operations for a capability. - /// - /// The capability identifier. - /// - QuerySupports? CapQuerySupport(CapabilityId capabilityId); - - /// - /// Resets the current value to power-on default. - /// - /// The capability identifier. - /// - ReturnCode CapReset(CapabilityId capabilityId); - - /// - /// Resets all values and constraints to power-on defaults. - /// - /// - ReturnCode CapResetAll(); - - } -} diff --git a/NTwain/IDataSource.cs b/NTwain/IDataSource.cs index 34b8f8b..2f866d2 100644 --- a/NTwain/IDataSource.cs +++ b/NTwain/IDataSource.cs @@ -6,7 +6,7 @@ namespace NTwain /// /// Represents a TWAIN data source. /// - public interface IDataSource : ICapControl + public interface IDataSource : ITripletControl { /// /// Gets the source's product name. @@ -48,14 +48,6 @@ namespace NTwain /// Version ProtocolVersion { get; } - /// - /// Gets the supported caps for this source. - /// - /// - /// The supported caps. - /// - IList SupportedCaps { get; } - /// /// Gets the source's version information. /// @@ -72,6 +64,14 @@ namespace NTwain /// bool IsOpen { get; } + /// + /// Gets the capabilities for this data source. + /// + /// + /// The capabilities. + /// + Capabilities Capabilities { get; } + /// /// Opens the source for capability negotiation. /// diff --git a/NTwain/Internals/TransferLogic.cs b/NTwain/Internals/TransferLogic.cs index 1a414b9..a976eae 100644 --- a/NTwain/Internals/TransferLogic.cs +++ b/NTwain/Internals/TransferLogic.cs @@ -68,7 +68,7 @@ namespace NTwain.Internals // some DS end up getting none but we will assume it's image if (xferImage) { - var mech = session.CurrentSource.ICapXferMech.GetCurrent(); + var mech = session.CurrentSource.Capabilities.ICapXferMech.GetCurrent(); switch (mech) { @@ -90,7 +90,7 @@ namespace NTwain.Internals } if (xferAudio) { - var mech = session.CurrentSource.ACapXferMech.GetCurrent(); + var mech = session.CurrentSource.Capabilities.ACapXferMech.GetCurrent(); switch (mech) { case XferMech.File: diff --git a/NTwain/NTwain.csproj b/NTwain/NTwain.csproj index 64bcae3..cebbd26 100644 --- a/NTwain/NTwain.csproj +++ b/NTwain/NTwain.csproj @@ -63,7 +63,6 @@ - @@ -108,7 +107,7 @@ - + diff --git a/README.md b/README.md index 199ada4..b87544c 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ myDS.DGImage...; ``` -Additionally, the DataSource class itself has some handy pre-defined wrappers for common capability +Additionally, the DataSource class has a Capabilities property with pre-defined wrappers for capability negotiation. You can use the wrapper properties to see what capabilities or their operations are supported. You also won't have to keep track of what value types to use since the wrapper defines it for you. Most capabilities only require a simple single value to set @@ -107,10 +107,10 @@ and the wrapper makes it easy to do that (see example below): // (note: the name of the wrapper property is the same as the CapabilityId enum) PixelType myValue = PixelType.BlackWhite; -if (myDS.ICapPixelType.CanSet && - myDS.ICapPixelType.GetValues().Contains(myValue)) +if (myDS.Capabilities.ICapPixelType.CanSet && + myDS.Capabilities.ICapPixelType.GetValues().Contains(myValue)) { - myDS.ICapPixelType.SetValue(myValue); + myDS.Capabilities.ICapPixelType.SetValue(myValue); } diff --git a/Tests/Tester.WPF/ViewModels/CapVM.cs b/Tests/Tester.WPF/ViewModels/CapVM.cs index 9544102..557dbdc 100644 --- a/Tests/Tester.WPF/ViewModels/CapVM.cs +++ b/Tests/Tester.WPF/ViewModels/CapVM.cs @@ -24,17 +24,17 @@ namespace Tester.WPF var capName = cap.ToString(); - var wrapProperty = ds.GetType().GetProperty(capName); + var wrapProperty = ds.Capabilities.GetType().GetProperty(capName); if (wrapProperty != null) { - _wrapper = wrapProperty.GetGetMethod().Invoke(ds, null); + _wrapper = wrapProperty.GetGetMethod().Invoke(ds.Capabilities, null); var wrapperType = _wrapper.GetType(); _getMethod = wrapperType.GetMethod("GetValues"); _getCurrentMethod = wrapperType.GetMethod("GetCurrent"); _setMethod = wrapperType.GetMethods().FirstOrDefault(m => m.Name == "SetValue"); } - var supportTest = ds.CapQuerySupport(cap); + var supportTest = ds.Capabilities.QuerySupport(cap); if (supportTest.HasValue) { Supports = supportTest.Value; @@ -55,7 +55,7 @@ namespace Tester.WPF { if (_getMethod == null) { - return _ds.CapGet(Cap); + return _ds.Capabilities.GetValues(Cap); } return _getMethod.Invoke(_wrapper, null) as IEnumerable; } @@ -63,7 +63,7 @@ namespace Tester.WPF { if (_getMethod == null) { - return _ds.CapGetCurrent(Cap); + return _ds.Capabilities.GetCurrent(Cap); } return _getCurrentMethod.Invoke(_wrapper, null); } diff --git a/Tests/Tester.WPF/ViewModels/DataSourceVM.cs b/Tests/Tester.WPF/ViewModels/DataSourceVM.cs index c20e6f0..5521bdc 100644 --- a/Tests/Tester.WPF/ViewModels/DataSourceVM.cs +++ b/Tests/Tester.WPF/ViewModels/DataSourceVM.cs @@ -49,7 +49,7 @@ namespace Tester.WPF //rc = DGControl.Status.Get(dsId, ref stat); if (rc == ReturnCode.Success) { - foreach (var c in DS.CapSupportedCaps.GetValues().Select(o => new CapVM(DS, o))) + foreach (var c in DS.Capabilities.CapSupportedCaps.GetValues().Select(o => new CapVM(DS, o))) { Caps.Add(c); } diff --git a/Tests/Tester.WPF/ViewModels/TwainVM.cs b/Tests/Tester.WPF/ViewModels/TwainVM.cs index 965a786..d24c581 100644 --- a/Tests/Tester.WPF/ViewModels/TwainVM.cs +++ b/Tests/Tester.WPF/ViewModels/TwainVM.cs @@ -120,7 +120,7 @@ namespace Tester.WPF } }, () => { - return _session.State == 4 && _session.CurrentSource.CapEnableDSUIOnly.GetCurrent() == BoolType.True; + return _session.State == 4 && _session.CurrentSource.Capabilities.CapEnableDSUIOnly.GetCurrent() == BoolType.True; })); } } @@ -246,9 +246,9 @@ namespace Tester.WPF void _session_TransferReady(object sender, TransferReadyEventArgs e) { - if (_session.CurrentSource.ICapXferMech.GetCurrent() == XferMech.File) + if (_session.CurrentSource.Capabilities.ICapXferMech.GetCurrent() == XferMech.File) { - var formats = _session.CurrentSource.ICapImageFileFormat.GetValues(); + var formats = _session.CurrentSource.Capabilities.ICapImageFileFormat.GetValues(); var wantFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp; var fileSetup = new TWSetupFileXfer diff --git a/Tests/Tester.Winform/TestForm.cs b/Tests/Tester.Winform/TestForm.cs index 978795b..4458e17 100644 --- a/Tests/Tester.Winform/TestForm.cs +++ b/Tests/Tester.Winform/TestForm.cs @@ -230,7 +230,7 @@ namespace Tester.Winform _stopScan = false; - if (_twain.CurrentSource.CapUIControllable.IsSupported)//.SupportedCaps.Contains(CapabilityId.CapUIControllable)) + if (_twain.CurrentSource.Capabilities.CapUIControllable.IsSupported)//.SupportedCaps.Contains(CapabilityId.CapUIControllable)) { // hide scanner ui if possible if (_twain.CurrentSource.Enable(SourceEnableMode.NoUI, false, this.Handle) == ReturnCode.Success) @@ -301,26 +301,26 @@ namespace Tester.Winform var src = _twain.CurrentSource; _loadingCaps = true; - var test = src.SupportedCaps; + //var test = src.SupportedCaps; - if (groupDepth.Enabled = src.ICapPixelType.IsSupported) + if (groupDepth.Enabled = src.Capabilities.ICapPixelType.IsSupported) { - LoadDepth(src.ICapPixelType); + LoadDepth(src.Capabilities.ICapPixelType); } - if (groupDPI.Enabled = src.ICapXResolution.IsSupported && src.ICapYResolution.IsSupported) + if (groupDPI.Enabled = src.Capabilities.ICapXResolution.IsSupported && src.Capabilities.ICapYResolution.IsSupported) { - LoadDPI(src.ICapXResolution); + LoadDPI(src.Capabilities.ICapXResolution); } // TODO: find out if this is how duplex works or also needs the other option - if (groupDuplex.Enabled = src.CapDuplexEnabled.IsSupported) + if (groupDuplex.Enabled = src.Capabilities.CapDuplexEnabled.IsSupported) { - LoadDuplex(src.CapDuplexEnabled); + LoadDuplex(src.Capabilities.CapDuplexEnabled); } - if (groupSize.Enabled = src.ICapSupportedSizes.IsSupported) + if (groupSize.Enabled = src.Capabilities.ICapSupportedSizes.IsSupported) { - LoadPaperSize(src.ICapSupportedSizes); + LoadPaperSize(src.Capabilities.ICapSupportedSizes); } - btnAllSettings.Enabled = src.CapEnableDSUIOnly.IsSupported; + btnAllSettings.Enabled = src.Capabilities.CapEnableDSUIOnly.IsSupported; _loadingCaps = false; } @@ -380,7 +380,7 @@ namespace Tester.Winform if (!_loadingCaps && _twain.State == 4) { var sel = (SupportedSize)comboSize.SelectedItem; - _twain.CurrentSource.ICapSupportedSizes.SetValue(sel); + _twain.CurrentSource.Capabilities.ICapSupportedSizes.SetValue(sel); } } @@ -389,7 +389,7 @@ namespace Tester.Winform if (!_loadingCaps && _twain.State == 4) { var sel = (PixelType)comboDepth.SelectedItem; - _twain.CurrentSource.ICapPixelType.SetValue(sel); + _twain.CurrentSource.Capabilities.ICapPixelType.SetValue(sel); } } @@ -398,8 +398,8 @@ namespace Tester.Winform if (!_loadingCaps && _twain.State == 4) { var sel = (TWFix32)comboDPI.SelectedItem; - _twain.CurrentSource.ICapXResolution.SetValue(sel); - _twain.CurrentSource.ICapYResolution.SetValue(sel); + _twain.CurrentSource.Capabilities.ICapXResolution.SetValue(sel); + _twain.CurrentSource.Capabilities.ICapYResolution.SetValue(sel); } } @@ -407,7 +407,7 @@ namespace Tester.Winform { if (!_loadingCaps && _twain.State == 4) { - _twain.CurrentSource.CapDuplexEnabled.SetValue(ckDuplex.Checked ? BoolType.True : BoolType.False); + _twain.CurrentSource.Capabilities.CapDuplexEnabled.SetValue(ckDuplex.Checked ? BoolType.True : BoolType.False); } }