From 852a055e5a4e486918bdb7181ad60723701af8ac Mon Sep 17 00:00:00 2001 From: soukoku Date: Sun, 9 Nov 2014 13:23:06 -0500 Subject: [PATCH] More ICaps --- NTwain/CapWrapper.cs | 23 + NTwain/Data/TwainTypesExtended.cs | 46 +- NTwain/Data/TwainValues.cs | 2 +- NTwain/DataSource.Caps.cs | 907 +++++++++++++++++++++++-- NTwain/ICapWrapper.cs | 68 +- NTwain/Properties/VersionInfo.cs | 2 +- Tests/Tester.WPF/MainWindow.xaml.cs | 144 ++-- Tests/Tester.WPF/ViewModels/TwainVM.cs | 10 +- Tests/Tester.Winform/TestForm.cs | 20 +- 9 files changed, 1033 insertions(+), 189 deletions(-) diff --git a/NTwain/CapWrapper.cs b/NTwain/CapWrapper.cs index 224adf7..d5ab39e 100644 --- a/NTwain/CapWrapper.cs +++ b/NTwain/CapWrapper.cs @@ -354,6 +354,7 @@ namespace NTwain /// /// The value. /// + /// Simple Set() is not defined for this capability. public ReturnCode Set(TValue value) { ReturnCode rc = ReturnCode.Failure; @@ -370,6 +371,28 @@ namespace NTwain rc = _source.DGControl.Capability.Set(cap); } } + else + { + throw new InvalidOperationException("Simple Set() is not defined for this capability."); + } + } + return rc; + } + + /// + /// A version of Set that uses an array. + /// + /// The value. + /// + public ReturnCode Set(TWArray value) + { + ReturnCode rc = ReturnCode.Failure; + if (CanSet) + { + using (var cap = new TWCapability(Capability, value)) + { + rc = _source.DGControl.Capability.Set(cap); + } } return rc; } diff --git a/NTwain/Data/TwainTypesExtended.cs b/NTwain/Data/TwainTypesExtended.cs index 5f8c9ff..ff0bea8 100644 --- a/NTwain/Data/TwainTypesExtended.cs +++ b/NTwain/Data/TwainTypesExtended.cs @@ -654,7 +654,6 @@ namespace NTwain.Data public TWCapability(CapabilityId capability, TWOneValue value, IMemoryManager memoryManager) { Capability = capability; - ContainerType = ContainerType.OneValue; SetOneValue(value, memoryManager); } @@ -675,7 +674,6 @@ namespace NTwain.Data public TWCapability(CapabilityId capability, TWEnumeration value, IMemoryManager memoryManager) { Capability = capability; - ContainerType = ContainerType.Enum; SetEnumValue(value, memoryManager); } @@ -696,9 +694,28 @@ namespace NTwain.Data public TWCapability(CapabilityId capability, TWRange value, IMemoryManager memoryManager) { Capability = capability; - ContainerType = ContainerType.Range; SetRangeValue(value, memoryManager); } + + /// + /// Initializes a new instance of the class. + /// + /// The capability. + /// The value. + public TWCapability(CapabilityId capability, TWArray value) + : this(capability, value, PlatformInfo.Current.MemoryManager) { } + + /// + /// Initializes a new instance of the class. + /// + /// The capability. + /// The value. + /// The memory manager. + public TWCapability(CapabilityId capability, TWArray value, IMemoryManager memoryManager) + { + Capability = capability; + SetArrayValue(value, memoryManager); + } #endregion #region properties @@ -759,7 +776,6 @@ namespace NTwain.Data memoryManager.Unlock(baseAddr); } - void SetRangeValue(TWRange value, IMemoryManager memoryManager) { if (value == null) { throw new ArgumentNullException("value"); } @@ -774,6 +790,28 @@ namespace NTwain.Data Marshal.StructureToPtr(value, _hContainer, false); } } + + void SetArrayValue(TWArray value, IMemoryManager memoryManager) + { + if (value == null) { throw new ArgumentNullException("value"); } + ContainerType = ContainerType.Array; + + Int32 valueSize = 6 + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType); + + int offset = 0; + _hContainer = memoryManager.Allocate((uint)valueSize); + IntPtr baseAddr = memoryManager.Lock(_hContainer); + + // can't safely use StructureToPtr here so write it our own + WriteValue(baseAddr, ref offset, ItemType.UInt16, value.ItemType); + WriteValue(baseAddr, ref offset, ItemType.UInt32, (uint)value.ItemList.Length); + foreach (var item in value.ItemList) + { + WriteValue(baseAddr, ref offset, value.ItemType, item); + } + memoryManager.Unlock(baseAddr); + } + #endregion #region writes diff --git a/NTwain/Data/TwainValues.cs b/NTwain/Data/TwainValues.cs index 3c3da21..d434481 100644 --- a/NTwain/Data/TwainValues.cs +++ b/NTwain/Data/TwainValues.cs @@ -225,7 +225,7 @@ namespace NTwain.Data /// Corresponds to TWBP_* values. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] - public enum BlankPage : short + public enum BlankPage //: short { Invalid = 0, Disable = -2, diff --git a/NTwain/DataSource.Caps.cs b/NTwain/DataSource.Caps.cs index 7528a6b..76890c0 100644 --- a/NTwain/DataSource.Caps.cs +++ b/NTwain/DataSource.Caps.cs @@ -178,7 +178,7 @@ namespace NTwain /// /// The audio xfer mech. /// - public ICapWrapper CapAudioXferMech + public ICapWrapper ACapXferMech { get { @@ -205,7 +205,7 @@ namespace NTwain /// /// The image compression. /// - public ICapWrapper CapImageCompression + public ICapWrapper ICapCompression { get { @@ -227,7 +227,7 @@ namespace NTwain /// /// The image pixel type. /// - public ICapWrapper CapImagePixelType + public ICapWrapper ICapPixelType { get { @@ -248,7 +248,7 @@ namespace NTwain /// /// The image unit of measure. /// - public ICapWrapper CapImageUnits + public ICapWrapper ICapUnits { get { @@ -269,7 +269,7 @@ namespace NTwain /// /// The image xfer mech. /// - public ICapWrapper CapImageXferMech + public ICapWrapper ICapXferMech { get { @@ -292,7 +292,7 @@ namespace NTwain /// /// The image auto brightness flag. /// - public ICapWrapper CapImageAutoBright + public ICapWrapper ICapAutoBright { get { @@ -313,7 +313,7 @@ namespace NTwain /// /// The image brightness. /// - public ICapWrapper CapImageBrightness + public ICapWrapper ICapBrightness { get { @@ -334,7 +334,7 @@ namespace NTwain /// /// The image contrast. /// - public ICapWrapper CapImageContrast + public ICapWrapper ICapContrast { get { @@ -357,7 +357,7 @@ namespace NTwain /// /// The image exposure time. /// - public ICapWrapper CapImageExposureTime + public ICapWrapper ICapExposureTime { get { @@ -369,20 +369,20 @@ namespace NTwain })); } } - - private CapWrapper _imgFilter; + + private CapWrapper _filter; /// - /// Gets the property to work with image for the current source. + /// Gets the property to work with image color filter for the current source. /// /// - /// The image filter type. + /// The image color filter type. /// - public ICapWrapper CapImageFilter + public ICapWrapper ICapFilter { get { - return _imgFilter ?? (_imgFilter = new CapWrapper(this, CapabilityId.ICapFilter, ValueExtensions.ConvertToEnum, + return _filter ?? (_filter = new CapWrapper(this, CapabilityId.ICapFilter, ValueExtensions.ConvertToEnum, value => new TWOneValue { Item = (uint)value, @@ -399,7 +399,7 @@ namespace NTwain /// /// The image gamma. /// - public ICapWrapper CapImageGamma + public ICapWrapper ICapGamma { get { @@ -422,7 +422,7 @@ namespace NTwain /// /// The image highlight. /// - public ICapWrapper CapImageHighlight + public ICapWrapper ICapHighlight { get { @@ -434,7 +434,7 @@ namespace NTwain })); } } - + private CapWrapper _fileFormat; /// @@ -443,7 +443,7 @@ namespace NTwain /// /// The image file format. /// - public ICapWrapper CapImageFileFormat + public ICapWrapper ICapImageFileFormat { get { @@ -465,7 +465,7 @@ namespace NTwain /// /// The image lamp state flag. /// - public ICapWrapper CapImageLameState + public ICapWrapper ICapLampState { get { @@ -477,7 +477,7 @@ namespace NTwain })); } } - + private CapWrapper _lightSource; /// @@ -486,7 +486,7 @@ namespace NTwain /// /// The image light source. /// - public ICapWrapper CapImageLightSource + public ICapWrapper ICapLightSource { get { @@ -498,7 +498,7 @@ namespace NTwain })); } } - + private CapWrapper _orientation; /// @@ -507,7 +507,7 @@ namespace NTwain /// /// The image orientation. /// - public ICapWrapper CapImageOrientation + public ICapWrapper ICapOrientation { get { @@ -528,7 +528,7 @@ namespace NTwain /// /// The image physical width. /// - public IReadOnlyCapWrapper CapImagePhysicalWidth + public IReadOnlyCapWrapper ICapPhysicalWidth { get { @@ -544,7 +544,7 @@ namespace NTwain /// /// The image physical height. /// - public IReadOnlyCapWrapper CapImagePhysicalHeight + public IReadOnlyCapWrapper ICapPhysicalHeight { get { @@ -560,7 +560,7 @@ namespace NTwain /// /// The image shadow. /// - public ICapWrapper CapImageShadow + public ICapWrapper ICapShadow { get { @@ -583,7 +583,7 @@ namespace NTwain /// /// The image's native x-axis resolution. /// - public IReadOnlyCapWrapper CapImageXNativeResolution + public IReadOnlyCapWrapper ICapXNativeResolution { get { @@ -599,14 +599,14 @@ namespace NTwain /// /// The image's native y-axis resolution. /// - public IReadOnlyCapWrapper CapImageYNativeResolution + public IReadOnlyCapWrapper ICapYNativeResolution { get { return _nativeYRes ?? (_nativeYRes = new CapWrapper(this, CapabilityId.ICapYNativeResolution, ValueExtensions.ConvertToFix32)); } } - + private CapWrapper _xResolution; /// @@ -615,7 +615,7 @@ namespace NTwain /// /// The image x-axis resolution. /// - public ICapWrapper CapImageXResolution + public ICapWrapper ICapXResolution { get { @@ -637,7 +637,7 @@ namespace NTwain /// /// The image y-axis resolution. /// - public ICapWrapper CapImageYResolution + public ICapWrapper ICapYResolution { get { @@ -649,7 +649,7 @@ namespace NTwain })); } } - + private CapWrapper _maxFrames; /// @@ -658,7 +658,7 @@ namespace NTwain /// /// The image max frames. /// - public ICapWrapper CapImageMaxFrames + public ICapWrapper ICapMaxFrames { get { @@ -670,7 +670,7 @@ namespace NTwain })); } } - + private CapWrapper _tiles; /// @@ -679,7 +679,7 @@ namespace NTwain /// /// The image tiles flag. /// - public ICapWrapper CapImageTiles + public ICapWrapper ICapTiles { get { @@ -700,7 +700,7 @@ namespace NTwain /// /// The image bit order. /// - public ICapWrapper CapImageBitOrder + public ICapWrapper ICapBitOrder { get { @@ -712,7 +712,7 @@ namespace NTwain })); } } - + private CapWrapper _ccittKFactor; /// @@ -721,7 +721,7 @@ namespace NTwain /// /// The image CCITT K factor. /// - public ICapWrapper CapImageCCITTKFactor + public ICapWrapper ICapCCITTKFactor { get { @@ -742,7 +742,7 @@ namespace NTwain /// /// The image light path. /// - public ICapWrapper CapImageLightPath + public ICapWrapper ICapLightPath { get { @@ -763,7 +763,7 @@ namespace NTwain /// /// The image pixel flavor. /// - public ICapWrapper CapImagePixelFlavor + public ICapWrapper ICapPixelFlavor { get { @@ -784,7 +784,7 @@ namespace NTwain /// /// The image color format. /// - public ICapWrapper CapImagePlanarChunky + public ICapWrapper ICapPlanarChunky { get { @@ -805,7 +805,7 @@ namespace NTwain /// /// The image rotation. /// - public ICapWrapper CapImageRotation + public ICapWrapper ICapRotation { get { @@ -818,7 +818,6 @@ namespace NTwain } } - private CapWrapper _supportSize; /// @@ -827,7 +826,7 @@ namespace NTwain /// /// The image supported size. /// - public ICapWrapper CapImageSupportedSize + public ICapWrapper ICapSupportedSizes { get { @@ -840,20 +839,208 @@ namespace NTwain } } - - private CapWrapper _autoDeskew; + private CapWrapper _threshold; /// - /// Gets the property to work with image auto deskew flag for the current source. + /// Gets the property to work with image threshold for the current source. /// /// - /// The image auto deskew flag. + /// The image threshold. /// - public ICapWrapper CapImageAutoDeskew + public ICapWrapper ICapThreshold { get { - return _autoDeskew ?? (_autoDeskew = new CapWrapper(this, CapabilityId.ICapAutomaticDeskew, ValueExtensions.ConvertToEnum, + 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, @@ -862,28 +1049,491 @@ namespace NTwain } } + // TODO: add ICAP_IMAGEDATASET - private CapWrapper _autoRotate; + private CapWrapper _extImgInfo; /// - /// Gets the property to work with image auto rotate flag for the current source. + /// Gets the property to work with ext image info flag for the current source. /// /// - /// The image auto rotate flag. + /// The ext image info flag. /// - public ICapWrapper CapImageAutoRotate + public ICapWrapper ICapExtImageInfo { get { - return _autoRotate ?? (_autoRotate = new CapWrapper(this, CapabilityId.ICapAutomaticRotate, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); + 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; @@ -893,7 +1543,7 @@ namespace NTwain /// /// The auto border detection flag. /// - public ICapWrapper CapImageAutomaticBorderDetection + public ICapWrapper ICapAutomaticBorderDetection { get { @@ -908,10 +1558,8 @@ namespace NTwain ItemType = ItemType.Bool }; - using (TWCapability capValue = new TWCapability(CapabilityId.ICapUndefinedImageSize, one)) - { - rc = _session.DGControl.Capability.Set(capValue); - } + // 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); @@ -922,6 +1570,133 @@ namespace NTwain } } + 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 diff --git a/NTwain/ICapWrapper.cs b/NTwain/ICapWrapper.cs index 4f9b10f..a4906f8 100644 --- a/NTwain/ICapWrapper.cs +++ b/NTwain/ICapWrapper.cs @@ -1,5 +1,6 @@ using NTwain.Data; using System; +using System.Collections.Generic; namespace NTwain { @@ -57,19 +58,44 @@ namespace NTwain /// bool CanGetLabelEnum { get; } + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can reset; otherwise, false. + /// + bool CanReset { get; } + + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can set; otherwise, false. + /// + bool CanSet { get; } + + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can set constraint; otherwise, false. + /// + bool CanSetConstraint { get; } + + /// /// Gets the capability. /// /// /// The capability. /// - NTwain.Data.CapabilityId Capability { get; } + CapabilityId Capability { get; } /// /// Gets all the possible values of this capability. /// /// - System.Collections.Generic.IList Get(); + IList Get(); /// /// Gets the current value of this capability. @@ -99,7 +125,7 @@ namespace NTwain /// [Experimental] Gets the display names for possible values of this capability. /// /// - System.Collections.Generic.IList GetLabelEnum(); + IList GetLabelEnum(); /// /// Gets a value indicating whether this capability is supported. @@ -115,7 +141,7 @@ namespace NTwain /// /// The supported actions. /// - NTwain.Data.QuerySupports SupportedActions { get; } + QuerySupports SupportedActions { get; } } /// @@ -124,42 +150,24 @@ namespace NTwain /// The TWAIN type of the value. public interface ICapWrapper : IReadOnlyCapWrapper { - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can reset; otherwise, false. - /// - bool CanReset { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can set; otherwise, false. - /// - bool CanSet { get; } - - /// - /// Gets a value indicating whether is supported. - /// - /// - /// true if this capability can set constraint; otherwise, false. - /// - bool CanSetConstraint { get; } - /// /// Resets the current value to power-on default. /// /// - NTwain.Data.ReturnCode Reset(); + ReturnCode Reset(); /// /// Simplified version that sets the current value of this capability. /// /// The value. /// - NTwain.Data.ReturnCode Set(TValue value); + ReturnCode Set(TValue value);/// + /// + /// A version of Set that uses an array. + /// + /// The value. + /// + ReturnCode Set(TWArray value); /// /// Sets the constraint value of this capability. diff --git a/NTwain/Properties/VersionInfo.cs b/NTwain/Properties/VersionInfo.cs index 798c05d..e632e58 100644 --- a/NTwain/Properties/VersionInfo.cs +++ b/NTwain/Properties/VersionInfo.cs @@ -23,7 +23,7 @@ namespace NTwain /// /// The build release version number. /// - public const string Build = "3.1.1"; // change this for each nuget release + public const string Build = "3.2.0"; // change this for each nuget release } diff --git a/Tests/Tester.WPF/MainWindow.xaml.cs b/Tests/Tester.WPF/MainWindow.xaml.cs index 6fa7ac6..48298cf 100644 --- a/Tests/Tester.WPF/MainWindow.xaml.cs +++ b/Tests/Tester.WPF/MainWindow.xaml.cs @@ -126,7 +126,7 @@ namespace Tester.WPF switch (cap) { case CapabilityId.ACapXferMech: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapAudioXferMech.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ACapXferMech.Get(); break; case CapabilityId.CapAlarms: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapAlarmVolume.Get(); @@ -357,13 +357,13 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapAutoBright: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageAutoBright.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutoBright.Get(); break; case CapabilityId.ICapAutoDiscardBlankPages: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutoDiscardBlankPages.Get(); break; case CapabilityId.ICapAutomaticBorderDetection: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageAutomaticBorderDetection.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticBorderDetection.Get(); break; case CapabilityId.ICapAutomaticColorEnabled: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -375,70 +375,70 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapAutomaticDeskew: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageAutoDeskew.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticDeskew.Get(); break; case CapabilityId.ICapAutomaticLengthDetection: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapAutomaticRotate: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageAutoRotate.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticRotate.Get(); break; case CapabilityId.ICapAutoSize: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutoSize.Get(); break; case CapabilityId.ICapBarcodeDetectionEnabled: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBarcodeDetectionEnabled.Get(); break; case CapabilityId.ICapBarcodeMaxRetries: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBarcodeMaxRetries.Get(); break; case CapabilityId.ICapBarcodeMaxSearchPriorities: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBarcodeSearchPriorities.Get(); break; case CapabilityId.ICapBarcodeSearchMode: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBarcodeSearchMode.Get(); break; case CapabilityId.ICapBarcodeSearchPriorities: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBarcodeSearchPriorities.Get(); break; case CapabilityId.ICapBarcodeTimeout: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBarcodeTimeout.Get(); break; case CapabilityId.ICapBitDepth: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBitDepth.Get(); break; case CapabilityId.ICapBitDepthReduction: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBitDepthReduction.Get(); break; case CapabilityId.ICapBitOrder: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageBitOrder.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBitOrder.Get(); break; case CapabilityId.ICapBitOrderCodes: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBitOrderCodes.Get(); break; case CapabilityId.ICapBrightness: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageBrightness.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapBrightness.Get(); break; case CapabilityId.ICapCCITTKFactor: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageCCITTKFactor.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapCCITTKFactor.Get(); break; case CapabilityId.ICapColorManagementEnabled: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapCompression: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageCompression.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapCompression.Get(); break; case CapabilityId.ICapContrast: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageContrast.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapContrast.Get(); break; case CapabilityId.ICapCustHalftone: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapExposureTime: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageExposureTime.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapExposureTime.Get(); break; case CapabilityId.ICapExtImageInfo: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapExtImageInfo.Get(); break; case CapabilityId.ICapFeederType: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -447,40 +447,40 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapFilter: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapFilter.Get(); break; case CapabilityId.ICapFlashUsed: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapFlashUsed2: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapFlashUsed2.Get(); break; case CapabilityId.ICapFlipRotation: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapFlipRotation.Get(); break; case CapabilityId.ICapFrames: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapGamma: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageGamma.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapGamma.Get(); break; case CapabilityId.ICapHalftones: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapHighlight: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageHighlight.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapHighlight.Get(); break; case CapabilityId.ICapICCProfile: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapICCProfile.Get(); break; case CapabilityId.ICapImageDataSet: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapImageFileFormat: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageFileFormat.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapImageFileFormat.Get(); break; case CapabilityId.ICapImageFilter: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageFilter.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapImageMerge: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -489,137 +489,137 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapJpegPixelType: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapJpegPixelType.Get(); break; case CapabilityId.ICapJpegQuality: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapJpegQuality.Get(); break; case CapabilityId.ICapJpegSubsampling: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapLampState: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageLameState.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapLampState.Get(); break; case CapabilityId.ICapLightPath: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageLightPath.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapLightPath.Get(); break; case CapabilityId.ICapLightSource: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageLightSource.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapLightSource.Get(); break; case CapabilityId.ICapMaxFrames: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageMaxFrames.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapMaxFrames.Get(); break; case CapabilityId.ICapMinimumHeight: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapMinimumHeight.Get(); break; case CapabilityId.ICapMinimumWidth: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapMinimumWidth.Get(); break; case CapabilityId.ICapMirror: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapNoiseFilter: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapNoiseFilter.Get(); break; case CapabilityId.ICapOrientation: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageOrientation.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapOrientation.Get(); break; case CapabilityId.ICapOverScan: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapOverScan.Get(); break; case CapabilityId.ICapPatchCodeDetectionEnabled: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPatchCodeDetectionEnabled.Get(); break; case CapabilityId.ICapPatchCodeMaxRetries: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPatchCodeMaxRetries.Get(); break; case CapabilityId.ICapPatchCodeMaxSearchPriorities: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPatchCodeMaxSearchPriorities.Get(); break; case CapabilityId.ICapPatchCodeSearchMode: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPatchCodeSearchMode.Get(); break; case CapabilityId.ICapPatchCodeSearchPriorities: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPatchCodeSearchPriorities.Get(); break; case CapabilityId.ICapPatchCodeTimeout: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPatchCodeTimeout.Get(); break; // TODO phys size are twfix32 case CapabilityId.ICapPhysicalHeight: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImagePhysicalHeight.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPhysicalHeight.Get(); break; case CapabilityId.ICapPhysicalWidth: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImagePhysicalWidth.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPhysicalWidth.Get(); break; case CapabilityId.ICapPixelFlavor: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImagePixelFlavor.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPixelFlavor.Get(); break; case CapabilityId.ICapPixelFlavorCodes: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPixelFlavorCodes.Get(); break; case CapabilityId.ICapPixelType: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImagePixelType.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPixelType.Get(); break; case CapabilityId.ICapPlanarChunky: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImagePlanarChunky.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapPlanarChunky.Get(); break; case CapabilityId.ICapRotation: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageRotation.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapRotation.Get(); break; case CapabilityId.ICapShadow: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageShadow.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapShadow.Get(); break; case CapabilityId.ICapSupportedBarcodeTypes: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapSupportedBarcodeTypes.Get(); break; case CapabilityId.ICapSupportedExtImageInfo: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapSupportedPatchCodeTypes: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapSupportedPatchCodeTypes.Get(); break; case CapabilityId.ICapSupportedSizes: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageSupportedSize.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapSupportedSizes.Get(); break; case CapabilityId.ICapThreshold: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapThreshold.Get(); break; case CapabilityId.ICapTiles: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageTiles.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapTiles.Get(); break; case CapabilityId.ICapTimeFill: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapTimeFill.Get(); break; case CapabilityId.ICapUndefinedImageSize: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapUndefinedImageSize.Get(); break; case CapabilityId.ICapUnits: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageUnits.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapUnits.Get(); break; case CapabilityId.ICapXferMech: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageXferMech.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapXferMech.Get(); break; case CapabilityId.ICapXNativeResolution: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageXNativeResolution.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapXNativeResolution.Get(); break; case CapabilityId.ICapXResolution: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageXResolution.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapXResolution.Get(); break; case CapabilityId.ICapXScaling: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapXScaling.Get(); break; case CapabilityId.ICapYNativeResolution: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageYNativeResolution.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapYNativeResolution.Get(); break; case CapabilityId.ICapYResolution: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageYResolution.Get(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapYResolution.Get(); break; case CapabilityId.ICapYScaling: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapYScaling.Get(); break; case CapabilityId.ICapZoomFactor: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapZoomFactor.Get(); break; default: if (cap > CapabilityId.CustomBase) diff --git a/Tests/Tester.WPF/ViewModels/TwainVM.cs b/Tests/Tester.WPF/ViewModels/TwainVM.cs index 8ae3976..c9b449c 100644 --- a/Tests/Tester.WPF/ViewModels/TwainVM.cs +++ b/Tests/Tester.WPF/ViewModels/TwainVM.cs @@ -72,7 +72,7 @@ namespace Tester.WPF if (this.CurrentSource.CapGetCurrent(CapabilityId.ICapXferMech).ConvertToEnum() == XferMech.File) { - var formats = this.CurrentSource.CapImageFileFormat.Get(); + var formats = this.CurrentSource.ICapImageFileFormat.Get(); var wantFormat = formats.Contains(FileFormat.Tiff) ? FileFormat.Tiff : FileFormat.Bmp; var fileSetup = new TWSetupFileXfer @@ -123,14 +123,14 @@ namespace Tester.WPF { if (State == 4) { - if (this.CurrentSource.CapImagePixelType.Get().Contains(PixelType.BlackWhite)) + if (this.CurrentSource.ICapPixelType.Get().Contains(PixelType.BlackWhite)) { - this.CurrentSource.CapImagePixelType.Set(PixelType.BlackWhite); + this.CurrentSource.ICapPixelType.Set(PixelType.BlackWhite); } - if (this.CurrentSource.CapImageXferMech.Get().Contains(XferMech.File)) + if (this.CurrentSource.ICapXferMech.Get().Contains(XferMech.File)) { - this.CurrentSource.CapImageXferMech.Set(XferMech.File); + this.CurrentSource.ICapXferMech.Set(XferMech.File); } var rc = this.CurrentSource.Enable(SourceEnableMode.NoUI, false, hwnd); diff --git a/Tests/Tester.Winform/TestForm.cs b/Tests/Tester.Winform/TestForm.cs index 0a158a1..dd2a27e 100644 --- a/Tests/Tester.Winform/TestForm.cs +++ b/Tests/Tester.Winform/TestForm.cs @@ -286,22 +286,22 @@ namespace Tester.Winform var src = _twain.CurrentSource; var caps = src.SupportedCaps; _loadingCaps = true; - if (groupDepth.Enabled = src.CapImagePixelType.IsSupported) + if (groupDepth.Enabled = src.ICapPixelType.IsSupported) { - LoadDepth(src.CapImagePixelType); + LoadDepth(src.ICapPixelType); } - if (groupDPI.Enabled = src.CapImageXResolution.IsSupported && src.CapImageYResolution.IsSupported) + if (groupDPI.Enabled = src.ICapXResolution.IsSupported && src.ICapYResolution.IsSupported) { - LoadDPI(src.CapImageXResolution); + LoadDPI(src.ICapXResolution); } // TODO: find out if this is how duplex works or also needs the other option if (groupDuplex.Enabled = src.CapDuplexEnabled.IsSupported) { LoadDuplex(src.CapDuplexEnabled); } - if (groupSize.Enabled = src.CapImageSupportedSize.IsSupported) + if (groupSize.Enabled = src.ICapSupportedSizes.IsSupported) { - LoadPaperSize(src.CapImageSupportedSize); + LoadPaperSize(src.ICapSupportedSizes); } btnAllSettings.Enabled = caps.Contains(CapabilityId.CapEnableDSUIOnly); _loadingCaps = false; @@ -363,7 +363,7 @@ namespace Tester.Winform if (!_loadingCaps && _twain.State == 4) { var sel = (SupportedSize)comboSize.SelectedItem; - _twain.CurrentSource.CapImageSupportedSize.Set(sel); + _twain.CurrentSource.ICapSupportedSizes.Set(sel); } } @@ -372,7 +372,7 @@ namespace Tester.Winform if (!_loadingCaps && _twain.State == 4) { var sel = (PixelType)comboDepth.SelectedItem; - _twain.CurrentSource.CapImagePixelType.Set(sel); + _twain.CurrentSource.ICapPixelType.Set(sel); } } @@ -381,8 +381,8 @@ namespace Tester.Winform if (!_loadingCaps && _twain.State == 4) { var sel = (TWFix32)comboDPI.SelectedItem; - _twain.CurrentSource.CapImageXResolution.Set(sel); - _twain.CurrentSource.CapImageYResolution.Set(sel); + _twain.CurrentSource.ICapXResolution.Set(sel); + _twain.CurrentSource.ICapYResolution.Set(sel); } }