diff --git a/NTwain/CapWrapper.cs b/NTwain/CapWrapper.cs index d5ab39e..111723d 100644 --- a/NTwain/CapWrapper.cs +++ b/NTwain/CapWrapper.cs @@ -397,6 +397,24 @@ namespace NTwain return rc; } + /// + /// A version of Set that uses an enumeration. + /// + /// The value. + /// + public ReturnCode Set(TWEnumeration value) + { + ReturnCode rc = ReturnCode.Failure; + if (CanSet) + { + using (var cap = new TWCapability(Capability, value)) + { + rc = _source.DGControl.Capability.Set(cap); + } + } + return rc; + } + /// /// Sets the constraint value of this capability. /// diff --git a/NTwain/DataSource.Caps.cs b/NTwain/DataSource.Caps.cs index 76890c0..c942d8c 100644 --- a/NTwain/DataSource.Caps.cs +++ b/NTwain/DataSource.Caps.cs @@ -166,8 +166,6 @@ namespace NTwain #endregion - #region high-level caps stuff - #region audio caps private CapWrapper _audXferMech; @@ -347,7 +345,26 @@ namespace NTwain } } - // TODO: add ICapCustHalftone + private CapWrapper _custHalftone; + + /// + /// Gets the property to work with image square-cell halftone for the current source. + /// + /// + /// The image square-cell halftone. + /// + public ICapWrapper ICapCustHalftone + { + get + { + return _custHalftone ?? (_custHalftone = new CapWrapper(this, CapabilityId.ICapCustHalftone, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = value, + ItemType = ItemType.UInt8 + })); + } + } private CapWrapper _exposureTime; @@ -1697,6 +1714,227 @@ namespace NTwain } } + private CapWrapper _cropUseFrame; + + /// + /// Gets the property to work with image auto crop flag for the current source. + /// + /// + /// The image auto crop flag. + /// + public IReadOnlyCapWrapper ICapAutomaticCropUsesFrame + { + get + { + return _cropUseFrame ?? (_cropUseFrame = new CapWrapper(this, CapabilityId.ICapAutomaticCropUsesFrame, ValueExtensions.ConvertToEnum)); + } + } + + private CapWrapper _lengthDetect; + + /// + /// Gets the property to work with image auto length detection flag for the current source. + /// + /// + /// The image auto length detection flag. + /// + public ICapWrapper ICapAutomaticLengthDetection + { + get + { + return _lengthDetect ?? (_lengthDetect = new CapWrapper(this, CapabilityId.ICapAutomaticLengthDetection, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Bool + })); + } + } + + private CapWrapper _autoColor; + + /// + /// Gets the property to work with image auto color detection flag for the current source. + /// + /// + /// The image auto color detection flag. + /// + public ICapWrapper ICapAutomaticColorEnabled + { + get + { + return _autoColor ?? (_autoColor = new CapWrapper(this, CapabilityId.ICapAutomaticColorEnabled, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Bool + })); + } + } + + private CapWrapper _autoColorNonPixel; + + /// + /// Gets the property to work with image auto non-color pixel type for the current source. + /// + /// + /// The image auto non-color pixel type. + /// + public ICapWrapper ICapAutomaticColorNonColorPixelType + { + get + { + return _autoColorNonPixel ?? (_autoColorNonPixel = new CapWrapper(this, CapabilityId.ICapAutomaticColorNonColorPixelType, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + + private CapWrapper _colorMgmt; + + /// + /// Gets the property to work with image color management flag for the current source. + /// + /// + /// The image color management flag. + /// + public ICapWrapper ICapColorManagementEnabled + { + get + { + return _colorMgmt ?? (_colorMgmt = new CapWrapper(this, CapabilityId.ICapColorManagementEnabled, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Bool + })); + } + } + + private CapWrapper _imgMerge; + + /// + /// Gets the property to work with image merge option for the current source. + /// + /// + /// The image merge option. + /// + public ICapWrapper ICapImageMerge + { + get + { + return _imgMerge ?? (_imgMerge = new CapWrapper(this, CapabilityId.ICapImageMerge, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + + private CapWrapper _mergeHeight; + + /// + /// Gets the property to work with image merge height threshold for the current source. + /// + /// + /// The image merge height threshold. + /// + public ICapWrapper ICapImageMergeHeightThreshold + { + get + { + return _mergeHeight ?? (_mergeHeight = new CapWrapper(this, CapabilityId.ICapImageMergeHeightThreshold, ValueExtensions.ConvertToFix32, + value => new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + })); + } + } + + private CapWrapper _supportedExtInfo; + + /// + /// Gets the property to get supported ext image info for the current source. + /// + /// + /// The supported ext image info. + /// + public IReadOnlyCapWrapper ICapSupportedExtImageInfo + { + get + { + return _supportedExtInfo ?? (_supportedExtInfo = new CapWrapper(this, CapabilityId.ICapSupportedExtImageInfo, ValueExtensions.ConvertToEnum)); + } + } + + private CapWrapper _filmType; + + /// + /// Gets the property to work with image film type for the current source. + /// + /// + /// The image film type. + /// + public ICapWrapper ICapFilmType + { + get + { + return _filmType ?? (_filmType = new CapWrapper(this, CapabilityId.ICapFilmType, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + + private CapWrapper _mirror; + + /// + /// Gets the property to work with image mirror option for the current source. + /// + /// + /// The image mirror option. + /// + public ICapWrapper ICapMirror + { + get + { + return _mirror ?? (_mirror = new CapWrapper(this, CapabilityId.ICapMirror, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + + private CapWrapper _jpegSubSampling; + + /// + /// Gets the property to work with image jpeg sub sampling for the current source. + /// + /// + /// The image jpeg sub sampling. + /// + public ICapWrapper ICapJpegSubsampling + { + get + { + return _jpegSubSampling ?? (_jpegSubSampling = new CapWrapper(this, CapabilityId.ICapJpegSubsampling, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + #endregion #region general caps @@ -2085,7 +2323,5 @@ namespace NTwain #endregion - #endregion - } } diff --git a/NTwain/ICapWrapper.cs b/NTwain/ICapWrapper.cs index a4906f8..fc712fd 100644 --- a/NTwain/ICapWrapper.cs +++ b/NTwain/ICapWrapper.cs @@ -169,6 +169,13 @@ namespace NTwain /// ReturnCode Set(TWArray value); + /// + /// A version of Set that uses an enumeration. + /// + /// The value. + /// + ReturnCode Set(TWEnumeration value); + /// /// Sets the constraint value of this capability. /// diff --git a/Tests/Tester.WPF/MainWindow.xaml.cs b/Tests/Tester.WPF/MainWindow.xaml.cs index 48298cf..3db6fc6 100644 --- a/Tests/Tester.WPF/MainWindow.xaml.cs +++ b/Tests/Tester.WPF/MainWindow.xaml.cs @@ -366,19 +366,19 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticBorderDetection.Get(); break; case CapabilityId.ICapAutomaticColorEnabled: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticColorEnabled.Get(); break; case CapabilityId.ICapAutomaticColorNonColorPixelType: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticColorNonColorPixelType.Get(); break; case CapabilityId.ICapAutomaticCropUsesFrame: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticCropUsesFrame.Get(); break; case CapabilityId.ICapAutomaticDeskew: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticDeskew.Get(); break; case CapabilityId.ICapAutomaticLengthDetection: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticLengthDetection.Get(); break; case CapabilityId.ICapAutomaticRotate: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapAutomaticRotate.Get(); @@ -423,7 +423,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapCCITTKFactor.Get(); break; case CapabilityId.ICapColorManagementEnabled: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapColorManagementEnabled.Get(); break; case CapabilityId.ICapCompression: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapCompression.Get(); @@ -432,7 +432,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapContrast.Get(); break; case CapabilityId.ICapCustHalftone: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapCustHalftone.Get(); break; case CapabilityId.ICapExposureTime: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapExposureTime.Get(); @@ -441,10 +441,10 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapExtImageInfo.Get(); break; case CapabilityId.ICapFeederType: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapFeederType.Get(); break; case CapabilityId.ICapFilmType: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapFilmType.Get(); break; case CapabilityId.ICapFilter: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapFilter.Get(); @@ -480,13 +480,13 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapImageFileFormat.Get(); break; case CapabilityId.ICapImageFilter: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapImageFilter.Get(); break; case CapabilityId.ICapImageMerge: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapImageMerge.Get(); break; case CapabilityId.ICapImageMergeHeightThreshold: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapImageMergeHeightThreshold.Get(); break; case CapabilityId.ICapJpegPixelType: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapJpegPixelType.Get(); @@ -495,7 +495,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapJpegQuality.Get(); break; case CapabilityId.ICapJpegSubsampling: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapJpegSubsampling.Get(); break; case CapabilityId.ICapLampState: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapLampState.Get(); @@ -516,7 +516,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapMinimumWidth.Get(); break; case CapabilityId.ICapMirror: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapMirror.Get(); break; case CapabilityId.ICapNoiseFilter: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapNoiseFilter.Get(); @@ -574,7 +574,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapSupportedBarcodeTypes.Get(); break; case CapabilityId.ICapSupportedExtImageInfo: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapSupportedExtImageInfo.Get(); break; case CapabilityId.ICapSupportedPatchCodeTypes: CapDetailList.ItemsSource = _twainVM.CurrentSource.ICapSupportedPatchCodeTypes.Get();