diff --git a/NTwain/DataSource.Caps.cs b/NTwain/DataSource.Caps.cs index c942d8c..9572145 100644 --- a/NTwain/DataSource.Caps.cs +++ b/NTwain/DataSource.Caps.cs @@ -1964,59 +1964,7 @@ namespace NTwain #endregion - - private CapWrapper _duplex; - - /// - /// Gets the property to see what's the duplex mode for the current source. - /// - /// - /// The duplex mode. - /// - public IReadOnlyCapWrapper CapDuplex - { - get - { - return _duplex ?? (_duplex = new CapWrapper(this, CapabilityId.CapDuplex, ValueExtensions.ConvertToEnum)); - } - } - - private CapWrapper _duplexEnabled; - - /// - /// Gets the property to work with duplex enabled flag for the current source. - /// - /// - /// The duplex enabled flag. - /// - public ICapWrapper CapDuplexEnabled - { - get - { - return _duplexEnabled ?? (_duplexEnabled = new CapWrapper(this, CapabilityId.CapDuplexEnabled, ValueExtensions.ConvertToEnum, - value => new TWOneValue - { - Item = (uint)value, - ItemType = ItemType.Bool - })); - } - } - - private CapWrapper _feederLoaded; - - /// - /// Gets the property to work with feeder loaded flag for the current source. - /// - /// - /// The feeder loaded flag. - /// - public IReadOnlyCapWrapper CapFeederLoaded - { - get - { - return _feederLoaded ?? (_feederLoaded = new CapWrapper(this, CapabilityId.CapFeederLoaded, ValueExtensions.ConvertToEnum)); - } - } + // TODO: add CAP_AUTHOR,CAP_CAPTION private CapWrapper _feederEnabled; @@ -2052,19 +2000,13 @@ namespace NTwain } // to really use feeder we must also set autofeed or autoscan, but only // for one of them since setting autoscan also sets autofeed - if (SupportedCaps.Contains(CapabilityId.CapAutoScan)) + if (CapAutoScan.CanSet) { - using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoScan, one)) - { - rc = _session.DGControl.Capability.Set(autoScan); - } + rc = CapAutoScan.Set(value); } - else if (SupportedCaps.Contains(CapabilityId.CapAutoFeed)) + else if (CapAutoFeed.CanSet) { - using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoFeed, one)) - { - rc = _session.DGControl.Capability.Set(autoScan); - } + rc = CapAutoFeed.Set(value); } return rc; @@ -2072,6 +2014,82 @@ namespace NTwain } } + private CapWrapper _feederLoaded; + + /// + /// Gets the property to work with feeder loaded flag for the current source. + /// + /// + /// The feeder loaded flag. + /// + public IReadOnlyCapWrapper CapFeederLoaded + { + get + { + return _feederLoaded ?? (_feederLoaded = new CapWrapper(this, CapabilityId.CapFeederLoaded, ValueExtensions.ConvertToEnum)); + } + } + + // TODO: add CAP_TIMEDATE + + private CapWrapper _supportedCaps; + + /// + /// Gets the supported caps for the current source. + /// + /// + /// The supported caps. + /// + public IReadOnlyCapWrapper CapSupportedCaps + { + get + { + return _supportedCaps ?? (_supportedCaps = new CapWrapper(this, CapabilityId.CapSupportedCaps, ValueExtensions.ConvertToEnum)); + } + } + + private CapWrapper _extendedCaps; + + /// + /// Gets the extended caps for the current source. + /// + /// + /// The extended caps. + /// + public ICapWrapper CapExtendedCaps + { + get + { + return _extendedCaps ?? (_extendedCaps = new CapWrapper(this, CapabilityId.CapExtendedCaps, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + + private CapWrapper _autoFeed; + + /// + /// Gets the property to work with auto feed page flag for the current source. + /// + /// + /// The auto feed flag. + /// + public ICapWrapper CapAutoFeed + { + get + { + return _autoFeed ?? (_autoFeed = new CapWrapper(this, CapabilityId.CapAutoFeed, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Bool + })); + } + } + private CapWrapper _clearPage; /// @@ -2204,6 +2222,27 @@ namespace NTwain } } + private CapWrapper _autoScan; + + /// + /// Gets the property to work with auto scan page flag for the current source. + /// + /// + /// The auto scan flag. + /// + public ICapWrapper CapAutoScan + { + get + { + return _autoScan ?? (_autoScan = new CapWrapper(this, CapabilityId.CapAutoScan, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Bool + })); + } + } + private CapWrapper _thumbsEnabled; /// @@ -2225,6 +2264,43 @@ namespace NTwain } } + private CapWrapper _duplex; + + /// + /// Gets the property to see what's the duplex mode for the current source. + /// + /// + /// The duplex mode. + /// + public IReadOnlyCapWrapper CapDuplex + { + get + { + return _duplex ?? (_duplex = new CapWrapper(this, CapabilityId.CapDuplex, ValueExtensions.ConvertToEnum)); + } + } + + private CapWrapper _duplexEnabled; + + /// + /// Gets the property to work with duplex enabled flag for the current source. + /// + /// + /// The duplex enabled flag. + /// + public ICapWrapper CapDuplexEnabled + { + get + { + return _duplexEnabled ?? (_duplexEnabled = new CapWrapper(this, CapabilityId.CapDuplexEnabled, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Bool + })); + } + } + private CapWrapper _dsUIonly; /// @@ -2257,6 +2333,27 @@ namespace NTwain } } + private CapWrapper _endorser; + + /// + /// Gets the property to work with endorser for the current source. + /// + /// + /// The endorser option. + /// + public ICapWrapper CapEndorser + { + get + { + return _endorser ?? (_endorser = new CapWrapper(this, CapabilityId.CapEndorser, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = value, + ItemType = ItemType.UInt32 + })); + } + } + private CapWrapper _jobControl; /// @@ -2278,6 +2375,27 @@ namespace NTwain } } + private CapWrapper _alarms; + + /// + /// Gets the property to work with alarms for the current source. + /// + /// + /// The alarms. + /// + public ICapWrapper CapAlarms + { + get + { + return _alarms ?? (_alarms = new CapWrapper(this, CapabilityId.CapAlarms, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + private CapWrapper _alarmVolume; /// @@ -2299,27 +2417,202 @@ namespace NTwain } } - //private CapWrapper _autoCapture; + private CapWrapper _autoCapture; - ///// - ///// Gets the property to work with auto capture count for the current source. - ///// - ///// - ///// The auto capture count. - ///// - //public ICapWrapper CapAutomaticCapture - //{ - // get - // { - // return _autoCapture ?? (_autoCapture = new CapWrapper(this, CapabilityId.CapAutomaticCapture, ValueExtensions.ConvertToEnum, - // new TWCapability(CapabilityId.CapAutomaticCapture, new TWOneValue - // { - // Item = (uint)value, - // ItemType = ItemType.Int32 - // })); - // } - //} + /// + /// Gets the property to work with auto capture count for the current source. + /// + /// + /// The auto capture count. + /// + public ICapWrapper CapAutomaticCapture + { + get + { + return _autoCapture ?? (_autoCapture = new CapWrapper(this, CapabilityId.CapAutomaticCapture, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Int32 + })); + } + } + private CapWrapper _timeBeforeCap; + + /// + /// Gets the property to work with the time before first capture (milliseconds) for the current source. + /// + /// + /// The time before first capture. + /// + public ICapWrapper CapTimeBeforeFirstCapture + { + get + { + return _timeBeforeCap ?? (_timeBeforeCap = new CapWrapper(this, CapabilityId.CapTimeBeforeFirstCapture, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Int32 + })); + } + } + + private CapWrapper _timeBetweenCap; + + /// + /// Gets the property to work with the time between captures (milliseconds) for the current source. + /// + /// + /// The time between captures. + /// + public ICapWrapper CapTimeBetweenCaptures + { + get + { + return _timeBetweenCap ?? (_timeBetweenCap = new CapWrapper(this, CapabilityId.CapTimeBetweenCaptures, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.Int32 + })); + } + } + + private CapWrapper _clearBuff; + + /// + /// Gets the property to work with the clear buffers option for the current source. + /// + /// + /// The clear buffers option. + /// + public ICapWrapper CapClearBuffers + { + get + { + return _clearBuff ?? (_clearBuff = new CapWrapper(this, CapabilityId.CapClearBuffers, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + + private CapWrapper _maxBatchBuff; + + /// + /// Gets the property to work with the max buffered pages for the current source. + /// + /// + /// The max batch buffered pages. + /// + public ICapWrapper CapMaxBatchBuffers + { + get + { + return _maxBatchBuff ?? (_maxBatchBuff = new CapWrapper(this, CapabilityId.CapMaxBatchBuffers, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = value, + ItemType = ItemType.UInt32 + })); + } + } + + // TODO: add CAP_DEVICETIMEDATE + + private CapWrapper _powerSup; + + /// + /// Gets the property to see current device's power supply. + /// + /// + /// The power supply indicator. + /// + public IReadOnlyCapWrapper CapPowerSupply + { + get + { + return _powerSup ?? (_powerSup = new CapWrapper(this, CapabilityId.CapPowerSupply, ValueExtensions.ConvertToEnum)); + } + } + + private CapWrapper _camPreviewUI; + + /// + /// Gets the property to see whether device supports camera preview UI flag. + /// + /// + /// The camera preview UI flag. + /// + public IReadOnlyCapWrapper CapCameraPreviewUI + { + get + { + return _camPreviewUI ?? (_camPreviewUI = new CapWrapper(this, CapabilityId.CapCameraPreviewUI, ValueExtensions.ConvertToEnum)); + } + } + + private CapWrapper _devEvent; + + /// + /// Gets the property to work with the reported device events for the current source. + /// + /// + /// The reported device events. + /// + public ICapWrapper CapDeviceEvent + { + get + { + return _devEvent ?? (_devEvent = new CapWrapper(this, CapabilityId.CapDeviceEvent, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } + + private CapWrapper _serialNo; + + /// + /// Gets the property for device serial number. + /// + /// + /// The device serial number. + /// + public IReadOnlyCapWrapper CapSerialNumber + { + get + { + return _serialNo ?? (_serialNo = new CapWrapper(this, CapabilityId.CapSerialNumber, value => { return value.ToString(); })); + } + } + + private CapWrapper _printer; + + /// + /// Gets the property to work printer list for the current source. + /// + /// + /// The printer list. + /// + public ICapWrapper CapPrinter + { + get + { + return _printer ?? (_printer = new CapWrapper(this, CapabilityId.CapPrinter, ValueExtensions.ConvertToEnum, + value => new TWOneValue + { + Item = (uint)value, + ItemType = ItemType.UInt16 + })); + } + } #endregion diff --git a/NTwain/DataSource.cs b/NTwain/DataSource.cs index 2267d21..7309a20 100644 --- a/NTwain/DataSource.cs +++ b/NTwain/DataSource.cs @@ -150,9 +150,9 @@ namespace NTwain static readonly CapabilityId[] _emptyCapList = new CapabilityId[0]; - private IList _supportedCaps; + private IList _supportedCapsList; /// - /// Gets the supported caps for this source. + /// Gets the list of supported caps for this source. /// /// /// The supported caps. @@ -161,15 +161,15 @@ namespace NTwain { get { - if (_supportedCaps == null && _session.State > 3) + if (_supportedCapsList == null && _session.State > 3) { - _supportedCaps = CapGet(CapabilityId.CapSupportedCaps).CastToEnum(false); + _supportedCapsList = CapSupportedCaps.Get();// CapGet(CapabilityId.CapSupportedCaps).CastToEnum(false); } - return _supportedCaps ?? _emptyCapList; + return _supportedCapsList ?? _emptyCapList; } private set { - _supportedCaps = value; + _supportedCapsList = value; //OnPropertyChanged("SupportedCaps"); } } diff --git a/Tests/Tester.WPF/MainWindow.xaml.cs b/Tests/Tester.WPF/MainWindow.xaml.cs index 3db6fc6..cfb3db0 100644 --- a/Tests/Tester.WPF/MainWindow.xaml.cs +++ b/Tests/Tester.WPF/MainWindow.xaml.cs @@ -138,16 +138,16 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.CapAutoFeed: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapAutoFeed.Get(); break; case CapabilityId.CapAutomaticCapture: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapAutomaticCapture.Get(); break; case CapabilityId.CapAutomaticSenseMedium: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.CapAutoScan: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapAutoScan.Get(); break; case CapabilityId.CapBatteryMinutes: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -162,7 +162,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.CapCameraPreviewUI: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapCameraPreviewUI.Get(); break; case CapabilityId.CapCameraSide: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -171,7 +171,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.CapClearBuffers: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapClearBuffers.Get(); break; case CapabilityId.CapClearPage: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapClearPage.Get(); @@ -183,7 +183,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.CapDeviceEvent: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapDeviceEvent.Get(); break; case CapabilityId.CapDeviceOnline: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapDeviceOnline.Get(); @@ -213,10 +213,10 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapEnableDSUIOnly.Get(); break; case CapabilityId.CapEndorser: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapEndorser.Get(); break; case CapabilityId.CapExtendedCaps: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapExtendedCaps.Get(); break; case CapabilityId.CapFeederAlignment: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); @@ -252,7 +252,7 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.CapMaxBatchBuffers: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapMaxBatchBuffers.Get(); break; case CapabilityId.CapMicrEnabled: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -267,10 +267,10 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); break; case CapabilityId.CapPowerSupply: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapPowerSupply.Get(); break; case CapabilityId.CapPrinter: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapPrinter.Get(); break; case CapabilityId.CapPrinterCharRotation: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -324,10 +324,10 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); break; case CapabilityId.CapSerialNumber: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapSerialNumber.Get(); break; case CapabilityId.CapSupportedCaps: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap).CastToEnum(); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapSupportedCaps.Get(); break; case CapabilityId.CapSupportedCapsSegmentUnique: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); @@ -339,10 +339,10 @@ namespace Tester.WPF CapDetailList.ItemsSource = _twainVM.CurrentSource.CapThumbnailsEnabled.Get(); break; case CapabilityId.CapTimeBeforeFirstCapture: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapTimeBeforeFirstCapture.Get(); break; case CapabilityId.CapTimeBetweenCaptures: - CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); + CapDetailList.ItemsSource = _twainVM.CurrentSource.CapTimeBetweenCaptures.Get(); break; case CapabilityId.CapTimeDate: CapDetailList.ItemsSource = _twainVM.CurrentSource.CapGet(cap); diff --git a/Tests/Tester.WPF/Tester.WPF.csproj b/Tests/Tester.WPF/Tester.WPF.csproj index eadff1d..874ee2f 100644 --- a/Tests/Tester.WPF/Tester.WPF.csproj +++ b/Tests/Tester.WPF/Tester.WPF.csproj @@ -45,7 +45,7 @@ False - ..\..\packages\CommonWin32.2.0.5.4\lib\net35-Client\CommonWin32.dll + ..\..\packages\CommonWin32.2.0.5.5\lib\net35-Client\CommonWin32.dll False diff --git a/Tests/Tester.WPF/packages.config b/Tests/Tester.WPF/packages.config index 38c632e..76a130e 100644 --- a/Tests/Tester.WPF/packages.config +++ b/Tests/Tester.WPF/packages.config @@ -1,7 +1,7 @@  - + \ No newline at end of file diff --git a/Tests/Tester.Winform/Tester.Winform.csproj b/Tests/Tester.Winform/Tester.Winform.csproj index e81a038..125cb95 100644 --- a/Tests/Tester.Winform/Tester.Winform.csproj +++ b/Tests/Tester.Winform/Tester.Winform.csproj @@ -40,7 +40,7 @@ False - ..\..\packages\CommonWin32.2.0.5.4\lib\net35-Client\CommonWin32.dll + ..\..\packages\CommonWin32.2.0.5.5\lib\net35-Client\CommonWin32.dll diff --git a/Tests/Tester.Winform/packages.config b/Tests/Tester.Winform/packages.config index e978129..23005ef 100644 --- a/Tests/Tester.Winform/packages.config +++ b/Tests/Tester.Winform/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file