From 88a54c95d92e0fbacc5aaef97159f04186867164 Mon Sep 17 00:00:00 2001 From: soukoku Date: Fri, 7 Nov 2014 20:22:58 -0500 Subject: [PATCH] Added more wrapped caps. --- NTwain.Net35/NTwain.Net35.csproj | 3 + NTwain/CapWrapper.cs | 11 +- NTwain/Data/TwainValues.cs | 1 + NTwain/DataSource.Caps.cs | 533 ++++++++++++++++++++++------ NTwain/ICapControl.cs | 18 +- NTwain/ICapWrapper.cs | 155 ++++++++ NTwain/NTwain.csproj | 1 + NTwain/Properties/VersionInfo.cs | 2 +- Tests/Tester.WPF/MainWindow.xaml.cs | 32 +- Tests/Tester.Winform/TestForm.cs | 8 +- 10 files changed, 602 insertions(+), 162 deletions(-) create mode 100644 NTwain/ICapWrapper.cs diff --git a/NTwain.Net35/NTwain.Net35.csproj b/NTwain.Net35/NTwain.Net35.csproj index cdd8352..444e373 100644 --- a/NTwain.Net35/NTwain.Net35.csproj +++ b/NTwain.Net35/NTwain.Net35.csproj @@ -81,6 +81,9 @@ ICapControl.cs + + ICapWrapper.cs + IDataSource.cs diff --git a/NTwain/CapWrapper.cs b/NTwain/CapWrapper.cs index 0654422..0db258a 100644 --- a/NTwain/CapWrapper.cs +++ b/NTwain/CapWrapper.cs @@ -13,7 +13,7 @@ namespace NTwain /// Wrapped class for reading/writing a TWAIN capability associated with a . /// /// The TWAIN type of the value. - public class CapWrapper + public class CapWrapper : NTwain.ICapWrapper { /// /// Routine that does nothing. @@ -340,15 +340,6 @@ namespace NTwain #region set methods - /// - /// Resets all values and constraints to power-on defaults. - /// - /// - public ReturnCode ResetAll() - { - return _source.CapResetAll(Capability); - } - /// /// Resets the current value to power-on default. /// diff --git a/NTwain/Data/TwainValues.cs b/NTwain/Data/TwainValues.cs index b43a4db..3c3da21 100644 --- a/NTwain/Data/TwainValues.cs +++ b/NTwain/Data/TwainValues.cs @@ -1792,6 +1792,7 @@ namespace NTwain.Data ICapCustHalftone = 0x1104, ICapExposureTime = 0x1105, ICapFilter = 0x1106, + [Obsolete("Use ICapFlashUsed2 instead.")] ICapFlashUsed = 0x1107, ICapGamma = 0x1108, ICapHalftones = 0x1109, diff --git a/NTwain/DataSource.Caps.cs b/NTwain/DataSource.Caps.cs index 6ba98ed..23e0faa 100644 --- a/NTwain/DataSource.Caps.cs +++ b/NTwain/DataSource.Caps.cs @@ -140,14 +140,10 @@ namespace NTwain /// /// Resets all values and constraint to power-on defaults. /// - /// The capability identifier. /// - public ReturnCode CapResetAll(CapabilityId capabilityId) + public ReturnCode CapResetAll() { - using (TWCapability cap = new TWCapability(capabilityId) - { - ContainerType = ContainerType.DoNotCare - }) + using (TWCapability cap = new TWCapability(CapabilityId.CapSupportedCaps)) { var rc = DGControl.Capability.ResetAll(cap); return rc; @@ -161,10 +157,7 @@ namespace NTwain /// public ReturnCode CapReset(CapabilityId capabilityId) { - using (TWCapability cap = new TWCapability(capabilityId) - { - ContainerType = ContainerType.DoNotCare - }) + using (TWCapability cap = new TWCapability(capabilityId)) { var rc = DGControl.Capability.Reset(cap); return rc; @@ -185,7 +178,7 @@ namespace NTwain /// /// The audio xfer mech. /// - public CapWrapper CapAudioXferMech + public ICapWrapper CapAudioXferMech { get { @@ -202,6 +195,51 @@ namespace NTwain #region img caps + #region mandatory + + private CapWrapper _compression; + + /// + /// Gets the property to work with image for the current source. + /// + /// + /// The image compression. + /// + public ICapWrapper CapImageCompression + { + get + { + return _compression ?? (_compression = new CapWrapper(this, CapabilityId.ICapCompression, ValueExtensions.ConvertToEnum, + value => new TWCapability(CapabilityId.ICapCompression, new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + }))); + } + } + + + private CapWrapper _pixelType; + + /// + /// Gets the property to work with image for the current source. + /// + /// + /// The image pixel type. + /// + public ICapWrapper CapImagePixelType + { + get + { + return _pixelType ?? (_pixelType = new CapWrapper(this, CapabilityId.ICapPixelType, ValueExtensions.ConvertToEnum, + value => new TWCapability(CapabilityId.ICapPixelType, new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + }))); + } + } + private CapWrapper _imgUnits; /// @@ -210,7 +248,7 @@ namespace NTwain /// /// The image unit of measure. /// - public CapWrapper CapImageUnits + public ICapWrapper CapImageUnits { get { @@ -231,7 +269,7 @@ namespace NTwain /// /// The image xfer mech. /// - public CapWrapper CapImageXferMech + public ICapWrapper CapImageXferMech { get { @@ -244,21 +282,110 @@ namespace NTwain } } + #endregion - private CapWrapper _compression; + + private CapWrapper _autoBright; /// - /// Gets the property to work with image for the current source. + /// Gets the property to work with image auto brightness flag for the current source. /// /// - /// The image compression. + /// The image auto brightness flag. /// - public CapWrapper CapImageCompression + public ICapWrapper CapImageAutoBright { get { - return _compression ?? (_compression = new CapWrapper(this, CapabilityId.ICapCompression, ValueExtensions.ConvertToEnum, - value => new TWCapability(CapabilityId.ICapCompression, new TWOneValue + return _autoBright ?? (_autoBright = new CapWrapper(this, CapabilityId.ICapAutoBright, ValueExtensions.ConvertToEnum, value => + new TWCapability(CapabilityId.ICapAutoBright, new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Bool + }))); + } + } + + private CapWrapper _brightness; + + /// + /// Gets the property to work with image brightness for the current source. + /// + /// + /// The image brightness. + /// + public ICapWrapper CapImageBrightness + { + get + { + return _brightness ?? (_brightness = new CapWrapper(this, CapabilityId.ICapBrightness, ValueExtensions.ConvertToFix32, + value => new TWCapability(CapabilityId.ICapBrightness, new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + }))); + } + } + + private CapWrapper _contrast; + + /// + /// Gets the property to work with image contrast for the current source. + /// + /// + /// The image contrast. + /// + public ICapWrapper CapImageContrast + { + get + { + return _contrast ?? (_contrast = new CapWrapper(this, CapabilityId.ICapContrast, ValueExtensions.ConvertToFix32, + value => new TWCapability(CapabilityId.ICapContrast, new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + }))); + } + } + + // TODO: add ICapCustHalftone + + private CapWrapper _exposureTime; + + /// + /// Gets the property to work with image exposure time (in seconds) for the current source. + /// + /// + /// The image exposure time. + /// + public ICapWrapper CapImageExposureTime + { + get + { + return _exposureTime ?? (_exposureTime = new CapWrapper(this, CapabilityId.ICapExposureTime, ValueExtensions.ConvertToFix32, + value => new TWCapability(CapabilityId.ICapExposureTime, new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + }))); + } + } + + + private CapWrapper _imgFilter; + + /// + /// Gets the property to work with image for the current source. + /// + /// + /// The image filter type. + /// + public ICapWrapper CapImageFilter + { + get + { + return _imgFilter ?? (_imgFilter = new CapWrapper(this, CapabilityId.ICapFilter, ValueExtensions.ConvertToEnum, + value => new TWCapability(CapabilityId.ICapFilter, new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 @@ -266,6 +393,50 @@ namespace NTwain } } + private CapWrapper _gamma; + + /// + /// Gets the property to work with image gamma value for the current source. + /// + /// + /// The image gamma. + /// + public ICapWrapper CapImageGamma + { + get + { + return _gamma ?? (_gamma = new CapWrapper(this, CapabilityId.ICapGamma, ValueExtensions.ConvertToFix32, + value => new TWCapability(CapabilityId.ICapGamma, new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + }))); + } + } + + // TODO: add ICapHalftones + + private CapWrapper _highlight; + + /// + /// Gets the property to work with image highlight value for the current source. + /// + /// + /// The image highlight. + /// + public ICapWrapper CapImageHighlight + { + get + { + return _highlight ?? (_highlight = new CapWrapper(this, CapabilityId.ICapHighlight, ValueExtensions.ConvertToFix32, + value => new TWCapability(CapabilityId.ICapHighlight, new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + }))); + } + } + private CapWrapper _fileFormat; @@ -275,7 +446,7 @@ namespace NTwain /// /// The image file format. /// - public CapWrapper CapImageFileFormat + public ICapWrapper CapImageFileFormat { get { @@ -289,20 +460,42 @@ namespace NTwain } - private CapWrapper _pixelType; + private CapWrapper _lampState; /// - /// Gets the property to work with image for the current source. + /// Gets the property to work with image lamp state flag for the current source. /// /// - /// The image pixel type. + /// The image lamp state flag. /// - public CapWrapper CapImagePixelType + public ICapWrapper CapImageLameState { get { - return _pixelType ?? (_pixelType = new CapWrapper(this, CapabilityId.ICapPixelType, ValueExtensions.ConvertToEnum, - value => new TWCapability(CapabilityId.ICapPixelType, new TWOneValue + return _lampState ?? (_lampState = new CapWrapper(this, CapabilityId.ICapLampState, ValueExtensions.ConvertToEnum, value => + new TWCapability(CapabilityId.ICapLampState, new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Bool + }))); + } + } + + + private CapWrapper _lightSource; + + /// + /// Gets the property to work with image light source for the current source. + /// + /// + /// The image light source. + /// + public ICapWrapper CapImageLightSource + { + get + { + return _lightSource ?? (_lightSource = new CapWrapper(this, CapabilityId.ICapLightSource, ValueExtensions.ConvertToEnum, value => + new TWCapability(CapabilityId.ICapLightSource, new TWOneValue { Item = (uint)value, ItemType = ItemType.UInt16 @@ -311,6 +504,158 @@ namespace NTwain } + private CapWrapper _orientation; + + /// + /// Gets the property to work with image orientation for the current source. + /// + /// + /// The image orientation. + /// + public ICapWrapper CapImageOrientation + { + get + { + return _orientation ?? (_orientation = new CapWrapper(this, CapabilityId.ICapOrientation, ValueExtensions.ConvertToEnum, value => + new TWCapability(CapabilityId.ICapOrientation, new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + }))); + } + } + + private CapWrapper _physicalWidth; + + /// + /// Gets the property to work with image physical width for the current source. + /// + /// + /// The image physical width. + /// + public IReadOnlyCapWrapper CapImagePhysicalWidth + { + get + { + return _physicalWidth ?? (_physicalWidth = new CapWrapper(this, CapabilityId.ICapPhysicalWidth, ValueExtensions.ConvertToFix32)); + } + } + + private CapWrapper _physicalHeight; + + /// + /// Gets the property to work with image physical height for the current source. + /// + /// + /// The image physical height. + /// + public IReadOnlyCapWrapper CapImagePhysicalHeight + { + get + { + return _physicalHeight ?? (_physicalHeight = new CapWrapper(this, CapabilityId.ICapPhysicalHeight, ValueExtensions.ConvertToFix32)); + } + } + + private CapWrapper _shadow; + + /// + /// Gets the property to work with image shadow value for the current source. + /// + /// + /// The image shadow. + /// + public ICapWrapper CapImageShadow + { + get + { + return _shadow ?? (_shadow = new CapWrapper(this, CapabilityId.ICapShadow, ValueExtensions.ConvertToFix32, + value => new TWCapability(CapabilityId.ICapShadow, new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + }))); + } + } + + // TODO: add ICapFrames + + private CapWrapper _nativeXRes; + + /// + /// Gets the property to work with image's native x-axis resolution for the current source. + /// + /// + /// The image's native x-axis resolution. + /// + public IReadOnlyCapWrapper CapImageXNativeResolution + { + get + { + return _nativeXRes ?? (_nativeXRes = new CapWrapper(this, CapabilityId.ICapXNativeResolution, ValueExtensions.ConvertToFix32)); + } + } + + private CapWrapper _nativeYRes; + + /// + /// Gets the property to work with image's native y-axis resolution for the current source. + /// + /// + /// The image's native y-axis resolution. + /// + public IReadOnlyCapWrapper CapImageYNativeResolution + { + get + { + return _nativeYRes ?? (_nativeYRes = new CapWrapper(this, CapabilityId.ICapYNativeResolution, ValueExtensions.ConvertToFix32)); + } + } + + + private CapWrapper _xResolution; + + /// + /// Gets the property to work with image x-axis resolution for the current source. + /// + /// + /// The image x-axis resolution. + /// + public ICapWrapper CapImageXResolution + { + get + { + return _xResolution ?? (_xResolution = new CapWrapper(this, CapabilityId.ICapXResolution, ValueExtensions.ConvertToFix32, + value => new TWCapability(CapabilityId.ICapXResolution, new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + }))); + } + } + + + private CapWrapper _yResolution; + + /// + /// Gets the property to work with image y-axis resolution for the current source. + /// + /// + /// The image y-axis resolution. + /// + public ICapWrapper CapImageYResolution + { + get + { + return _yResolution ?? (_yResolution = new CapWrapper(this, CapabilityId.ICapYResolution, ValueExtensions.ConvertToFix32, + value => new TWCapability(CapabilityId.ICapYResolution, new TWOneValue + { + Item = (uint)value,// ((uint)dpi) << 16; + ItemType = ItemType.Fix32 + }))); + } + } + private CapWrapper _supportSize; /// @@ -319,7 +664,7 @@ namespace NTwain /// /// The image supported size. /// - public CapWrapper CapImageSupportedSize + public ICapWrapper CapImageSupportedSize { get { @@ -341,7 +686,7 @@ namespace NTwain /// /// The image auto deskew flag. /// - public CapWrapper CapImageAutoDeskew + public ICapWrapper CapImageAutoDeskew { get { @@ -363,7 +708,7 @@ namespace NTwain /// /// The image auto rotate flag. /// - public CapWrapper CapImageAutoRotate + public ICapWrapper CapImageAutoRotate { get { @@ -377,50 +722,6 @@ namespace NTwain } - private CapWrapper _xResolution; - - /// - /// Gets the property to work with image horizontal resolution for the current source. - /// - /// - /// The image horizontal resolution. - /// - public CapWrapper CapImageXResolution - { - get - { - return _xResolution ?? (_xResolution = new CapWrapper(this, CapabilityId.ICapXResolution, ValueExtensions.ConvertToFix32, - value => new TWCapability(CapabilityId.ICapXResolution, new TWOneValue - { - Item = (uint)value,// ((uint)dpi) << 16; - ItemType = ItemType.Fix32 - }))); - } - } - - - private CapWrapper _yResolution; - - /// - /// Gets the property to work with image vertical resolution for the current source. - /// - /// - /// The image vertical resolution. - /// - public CapWrapper CapImageYResolution - { - get - { - return _yResolution ?? (_yResolution = new CapWrapper(this, CapabilityId.ICapYResolution, ValueExtensions.ConvertToFix32, - value => new TWCapability(CapabilityId.ICapYResolution, new TWOneValue - { - Item = (uint)value,// ((uint)dpi) << 16; - ItemType = ItemType.Fix32 - }))); - } - } - - private CapWrapper _borderDetect; /// @@ -429,7 +730,7 @@ namespace NTwain /// /// The auto border detection flag. /// - public CapWrapper CapImageAutomaticBorderDetection + public ICapWrapper CapImageAutomaticBorderDetection { get { @@ -459,7 +760,33 @@ namespace NTwain #endregion - #region other caps + #region general caps + + #region mandatory + + private CapWrapper _xferCount; + + /// + /// Gets the property to work with xfer count for the current source. + /// + /// + /// The xfer count. + /// + public ICapWrapper CapXferCount + { + get + { + return _xferCount ?? (_xferCount = new CapWrapper(this, CapabilityId.CapXferCount, ValueExtensions.ConvertToEnum, value => + new TWCapability(CapabilityId.CapXferCount, new TWOneValue + { + Item = value > 0 ? (uint)value : uint.MaxValue, + ItemType = ItemType.UInt16 + }))); + } + } + + #endregion + private CapWrapper _duplex; @@ -469,7 +796,7 @@ namespace NTwain /// /// The duplex mode. /// - public CapWrapper CapDuplex + public IReadOnlyCapWrapper CapDuplex { get { @@ -485,7 +812,7 @@ namespace NTwain /// /// The duplex enabled flag. /// - public CapWrapper CapDuplexEnabled + public ICapWrapper CapDuplexEnabled { get { @@ -498,28 +825,6 @@ namespace NTwain } } - - private CapWrapper _xferCount; - - /// - /// Gets the property to work with xfer count for the current source. - /// - /// - /// The xfer count. - /// - public CapWrapper CapXferCount - { - get - { - return _xferCount ?? (_xferCount = new CapWrapper(this, CapabilityId.CapXferCount, ValueExtensions.ConvertToEnum, value => - new TWCapability(CapabilityId.CapXferCount, new TWOneValue - { - Item = value > 0 ? (uint)value : uint.MaxValue, - ItemType = ItemType.UInt16 - }))); - } - } - private CapWrapper _feederLoaded; /// @@ -528,7 +833,7 @@ namespace NTwain /// /// The feeder loaded flag. /// - public CapWrapper CapFeederLoaded + public IReadOnlyCapWrapper CapFeederLoaded { get { @@ -544,7 +849,7 @@ namespace NTwain /// /// The feeder enabled flag. /// - public CapWrapper CapFeederEnabled + public ICapWrapper CapFeederEnabled { get { @@ -597,7 +902,7 @@ namespace NTwain /// /// The clear page flag. /// - public CapWrapper CapClearPage + public ICapWrapper CapClearPage { get { @@ -618,7 +923,7 @@ namespace NTwain /// /// The feed page flag. /// - public CapWrapper CapFeedPage + public ICapWrapper CapFeedPage { get { @@ -639,7 +944,7 @@ namespace NTwain /// /// The rewind page flag. /// - public CapWrapper CapRewindPage + public ICapWrapper CapRewindPage { get { @@ -660,7 +965,7 @@ namespace NTwain /// /// The indicators flag. /// - public CapWrapper CapIndicators + public ICapWrapper CapIndicators { get { @@ -681,7 +986,7 @@ namespace NTwain /// /// The paper sensor flag. /// - public CapWrapper CapPaperDetectable + public IReadOnlyCapWrapper CapPaperDetectable { get { @@ -697,7 +1002,7 @@ namespace NTwain /// /// The UI controllable flag. /// - public CapWrapper CapUIControllable + public IReadOnlyCapWrapper CapUIControllable { get { @@ -713,7 +1018,7 @@ namespace NTwain /// /// The devince online flag. /// - public CapWrapper CapDeviceOnline + public IReadOnlyCapWrapper CapDeviceOnline { get { @@ -729,7 +1034,7 @@ namespace NTwain /// /// The thumbnails enabled flag. /// - public CapWrapper CapThumbnailsEnabled + public ICapWrapper CapThumbnailsEnabled { get { @@ -750,7 +1055,7 @@ namespace NTwain /// /// The UI only flag. /// - public CapWrapper CapEnableDSUIOnly + public IReadOnlyCapWrapper CapEnableDSUIOnly { get { @@ -766,7 +1071,7 @@ namespace NTwain /// /// The custom data flag. /// - public CapWrapper CapCustomDSData + public IReadOnlyCapWrapper CapCustomDSData { get { @@ -782,7 +1087,7 @@ namespace NTwain /// /// The job control option. /// - public CapWrapper CapJobControl + public ICapWrapper CapJobControl { get { @@ -803,7 +1108,7 @@ namespace NTwain /// /// The alarm volume. /// - public CapWrapper CapAlarmVolume + public ICapWrapper CapAlarmVolume { get { @@ -824,7 +1129,7 @@ namespace NTwain ///// ///// The auto capture count. ///// - //public CapWrapper CapAutomaticCapture + //public ICapWrapper CapAutomaticCapture //{ // get // { diff --git a/NTwain/ICapControl.cs b/NTwain/ICapControl.cs index b03b24a..105ebba 100644 --- a/NTwain/ICapControl.cs +++ b/NTwain/ICapControl.cs @@ -47,24 +47,8 @@ namespace NTwain /// /// Resets all values and constraints to power-on defaults. /// - /// The capability identifier. /// - ReturnCode CapResetAll(CapabilityId capabilityId); + ReturnCode CapResetAll(); - - //CapabilityControl CapAudioXferMech { get; } - //CapabilityControl CapDuplexEnabled { get; } - //CapabilityControl CapFeederEnabled { get; } - //CapabilityControl CapImageAutoDeskew { get; } - //CapabilityControl CapImageAutomaticBorderDetection { get; } - //CapabilityControl CapImageAutoRotate { get; } - //CapabilityControl CapImageCompression { get; } - //CapabilityControl CapImageFileFormat { get; } - //CapabilityControl CapImagePixelType { get; } - //CapabilityControl CapImageSupportedSize { get; } - //CapabilityControl CapImageXferMech { get; } - //CapabilityControl CapImageXResolution { get; } - //CapabilityControl CapImageYResolution { get; } - //CapabilityControl CapXferCount { get; } } } diff --git a/NTwain/ICapWrapper.cs b/NTwain/ICapWrapper.cs new file mode 100644 index 0000000..540d11a --- /dev/null +++ b/NTwain/ICapWrapper.cs @@ -0,0 +1,155 @@ +using System; +namespace NTwain +{ + + /// + /// Interface for reading a TWAIN capability associated with a . + /// + /// The TWAIN type of the value. + public interface IReadOnlyCapWrapper + { + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can get values; otherwise, false. + /// + bool CanGet { get; } + + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can get default value; otherwise, false. + /// + bool CanGetCurrent { get; } + + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can get current value; otherwise, false. + /// + bool CanGetDefault { get; } + + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can get help; otherwise, false. + /// + bool CanGetHelp { get; } + + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can get label; otherwise, false. + /// + bool CanGetLabel { get; } + + /// + /// Gets a value indicating whether is supported. + /// + /// + /// true if this capability can get label enum; otherwise, false. + /// + bool CanGetLabelEnum { get; } + + /// + /// Gets the capability. + /// + /// + /// The capability. + /// + NTwain.Data.CapabilityId Capability { get; } + + /// + /// Gets all the possible values of this capability. + /// + /// + System.Collections.Generic.IList Get(); + + /// + /// Gets the current value of this capability. + /// + /// + TValue GetCurrent(); + + /// + /// Gets the default value of this capability. + /// + /// + TValue GetDefault(); + + /// + /// [Experimental] Gets the help value of this capability. + /// + /// + string GetHelp(); + + /// + /// [Experimental] Gets the label value of this capability. + /// + /// + string GetLabel(); + + /// + /// [Experimental] Gets the display names for possible values of this capability. + /// + /// + System.Collections.Generic.IList GetLabelEnum(); + + /// + /// Gets a value indicating whether this capability is supported. + /// + /// + /// true if this capability is supported; otherwise, false. + /// + bool IsSupported { get; } + + /// + /// Gets the supported actions. + /// + /// + /// The supported actions. + /// + NTwain.Data.QuerySupports SupportedActions { get; } + } + + /// + /// Interface for reading/writing a TWAIN capability associated with a . + /// + /// 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; } + + /// + /// Resets the current value to power-on default. + /// + /// + NTwain.Data.ReturnCode Reset(); + + /// + /// Sets the current value of this capability. + /// + /// The value. + /// + NTwain.Data.ReturnCode Set(TValue value); + } +} diff --git a/NTwain/NTwain.csproj b/NTwain/NTwain.csproj index 3475538..2dc6d56 100644 --- a/NTwain/NTwain.csproj +++ b/NTwain/NTwain.csproj @@ -78,6 +78,7 @@ + diff --git a/NTwain/Properties/VersionInfo.cs b/NTwain/Properties/VersionInfo.cs index 4238b8b..798c05d 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.0"; // change this for each nuget release + public const string Build = "3.1.1"; // change this for each nuget release } diff --git a/Tests/Tester.WPF/MainWindow.xaml.cs b/Tests/Tester.WPF/MainWindow.xaml.cs index ed3f4af..36de105 100644 --- a/Tests/Tester.WPF/MainWindow.xaml.cs +++ b/Tests/Tester.WPF/MainWindow.xaml.cs @@ -357,7 +357,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapAutoBright: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageAutoBright.Get(); break; case CapabilityId.ICapAutoDiscardBlankPages: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -417,7 +417,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapBrightness: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageBrightness.Get(); break; case CapabilityId.ICapCCITTKFactor: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -429,13 +429,13 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageCompression.Get(); break; case CapabilityId.ICapContrast: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageContrast.Get(); break; case CapabilityId.ICapCustHalftone: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapExposureTime: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageExposureTime.Get(); break; case CapabilityId.ICapExtImageInfo: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -453,7 +453,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapFlashUsed2: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapFlipRotation: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -462,13 +462,13 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapGamma: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageGamma.Get(); break; case CapabilityId.ICapHalftones: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapHighlight: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageHighlight.Get(); break; case CapabilityId.ICapICCProfile: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -480,7 +480,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageFileFormat.Get(); break; case CapabilityId.ICapImageFilter: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageFilter.Get(); break; case CapabilityId.ICapImageMerge: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -498,13 +498,13 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapLampState: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageLameState.Get(); break; case CapabilityId.ICapLightPath: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapLightSource: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageLightSource.Get(); break; case CapabilityId.ICapMaxFrames: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -522,7 +522,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapOrientation: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageOrientation.Get(); break; case CapabilityId.ICapOverScan: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -547,10 +547,10 @@ namespace Tester.WPF break; // TODO phys size are twfix32 case CapabilityId.ICapPhysicalHeight: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImagePhysicalHeight.Get(); break; case CapabilityId.ICapPhysicalWidth: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImagePhysicalWidth.Get(); break; case CapabilityId.ICapPixelFlavor: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -568,7 +568,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.ICapShadow: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageShadow.Get(); break; case CapabilityId.ICapSupportedBarcodeTypes: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -601,7 +601,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageXferMech.Get(); break; case CapabilityId.ICapXNativeResolution: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageXNativeResolution.Get(); break; case CapabilityId.ICapXResolution: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageXResolution.Get(); @@ -610,7 +610,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.ICapYNativeResolution: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageYNativeResolution.Get(); break; case CapabilityId.ICapYResolution: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapImageYResolution.Get(); diff --git a/Tests/Tester.Winform/TestForm.cs b/Tests/Tester.Winform/TestForm.cs index bfe4a4f..0a158a1 100644 --- a/Tests/Tester.Winform/TestForm.cs +++ b/Tests/Tester.Winform/TestForm.cs @@ -307,7 +307,7 @@ namespace Tester.Winform _loadingCaps = false; } - private void LoadPaperSize(CapWrapper cap) + private void LoadPaperSize(ICapWrapper cap) { var list = cap.Get(); comboSize.DataSource = list; @@ -324,13 +324,13 @@ namespace Tester.Winform } - private void LoadDuplex(CapWrapper cap) + private void LoadDuplex(ICapWrapper cap) { ckDuplex.Checked = cap.GetCurrent() == BoolType.True; } - private void LoadDPI(CapWrapper cap) + private void LoadDPI(ICapWrapper cap) { // only allow dpi of certain values for those source that lists everything var list = cap.Get().Where(dpi => (dpi % 50) == 0).ToList(); @@ -342,7 +342,7 @@ namespace Tester.Winform } } - private void LoadDepth(CapWrapper cap) + private void LoadDepth(ICapWrapper cap) { var list = cap.Get(); comboDepth.DataSource = list;