mirror of
https://github.com/soukoku/ntwain.git
synced 2025-09-19 18:27:56 +08:00
Playing with more interfaces.
This commit is contained in:
@@ -45,12 +45,12 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\NTwain\CapabilityControl.cs">
|
|
||||||
<Link>CapabilityControl.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\CapabilityReader.cs">
|
<Compile Include="..\NTwain\CapabilityReader.cs">
|
||||||
<Link>CapabilityReader.cs</Link>
|
<Link>CapabilityReader.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\CapWrapper.cs">
|
||||||
|
<Link>CapWrapper.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\NTwain\DataSource.Caps.cs">
|
<Compile Include="..\NTwain\DataSource.Caps.cs">
|
||||||
<Link>DataSource.Caps.cs</Link>
|
<Link>DataSource.Caps.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -78,8 +78,8 @@
|
|||||||
<Compile Include="..\NTwain\DeviceEventArgs.cs">
|
<Compile Include="..\NTwain\DeviceEventArgs.cs">
|
||||||
<Link>DeviceEventArgs.cs</Link>
|
<Link>DeviceEventArgs.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\ICapController.cs">
|
<Compile Include="..\NTwain\ICapControl.cs">
|
||||||
<Link>ICapController.cs</Link>
|
<Link>ICapControl.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\IDataSource.cs">
|
<Compile Include="..\NTwain\IDataSource.cs">
|
||||||
<Link>IDataSource.cs</Link>
|
<Link>IDataSource.cs</Link>
|
||||||
@@ -126,6 +126,9 @@
|
|||||||
<Compile Include="..\NTwain\IPlatformInfo.cs">
|
<Compile Include="..\NTwain\IPlatformInfo.cs">
|
||||||
<Link>IPlatformInfo.cs</Link>
|
<Link>IPlatformInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\ITripletControl.cs">
|
||||||
|
<Link>ITripletControl.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\NTwain\ITwainSession.cs">
|
<Compile Include="..\NTwain\ITwainSession.cs">
|
||||||
<Link>ITwainSession.cs</Link>
|
<Link>ITwainSession.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@@ -10,15 +10,23 @@ namespace NTwain
|
|||||||
/// Wrapped class for reading/writing a TWAIN capability associated with a <see cref="DataSource"/>.
|
/// Wrapped class for reading/writing a TWAIN capability associated with a <see cref="DataSource"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <typeparam name="TValue">The TWAIN type of the value.</typeparam>
|
/// <typeparam name="TValue">The TWAIN type of the value.</typeparam>
|
||||||
public class CapabilityControl<TValue>
|
public class CapWrapper<TValue>
|
||||||
{
|
{
|
||||||
DataSource _source;
|
/// <summary>
|
||||||
|
/// Routine that does nothing.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static ReturnCode NoSetRoutine(TValue value) { return ReturnCode.Failure; }
|
||||||
|
|
||||||
|
|
||||||
|
ICapControl _source;
|
||||||
Func<object, TValue> _convertRoutine;
|
Func<object, TValue> _convertRoutine;
|
||||||
Func<TValue, ReturnCode> _setCustomRoutine;
|
Func<TValue, ReturnCode> _setCustomRoutine;
|
||||||
Func<TValue, TWCapability> _setProvider; // an simplified way to set() that only needs on cap value
|
Func<TValue, TWCapability> _setProvider; // an simplified way to set() that only needs on cap value
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="CapabilityControl{TValue}" /> class.
|
/// Initializes a new instance of the <see cref="CapWrapper{TValue}" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The source.</param>
|
/// <param name="source">The source.</param>
|
||||||
/// <param name="capability">The capability.</param>
|
/// <param name="capability">The capability.</param>
|
||||||
@@ -31,7 +39,7 @@ namespace NTwain
|
|||||||
/// or
|
/// or
|
||||||
/// setValueProvider
|
/// setValueProvider
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public CapabilityControl(DataSource source, CapabilityId capability,
|
public CapWrapper(ICapControl source, CapabilityId capability,
|
||||||
Func<object, TValue> getConversionRoutine,
|
Func<object, TValue> getConversionRoutine,
|
||||||
Func<TValue, TWCapability> setValueProvider)
|
Func<TValue, TWCapability> setValueProvider)
|
||||||
{
|
{
|
||||||
@@ -47,12 +55,12 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="CapabilityControl{TValue}" /> class.
|
/// Initializes a new instance of the <see cref="CapWrapper{TValue}" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="source">The source.</param>
|
/// <param name="source">The source.</param>
|
||||||
/// <param name="capability">The capability.</param>
|
/// <param name="capability">The capability.</param>
|
||||||
/// <param name="getConversionRoutine">The value conversion routine in Get methods.</param>
|
/// <param name="getConversionRoutine">The value conversion routine in Get methods.</param>
|
||||||
/// <param name="setValueRoutine">Callback to perform set value.</param>
|
/// <param name="setValueRoutine">Callback to perform set value. Pass <see cref="NoSetRoutine"/> to not do sets.</param>
|
||||||
/// <exception cref="System.ArgumentNullException">
|
/// <exception cref="System.ArgumentNullException">
|
||||||
/// source
|
/// source
|
||||||
/// or
|
/// or
|
||||||
@@ -60,7 +68,7 @@ namespace NTwain
|
|||||||
/// or
|
/// or
|
||||||
/// setValueRoutine
|
/// setValueRoutine
|
||||||
/// </exception>
|
/// </exception>
|
||||||
public CapabilityControl(DataSource source, CapabilityId capability,
|
public CapWrapper(ICapControl source, CapabilityId capability,
|
||||||
Func<object, TValue> getConversionRoutine,
|
Func<object, TValue> getConversionRoutine,
|
||||||
Func<TValue, ReturnCode> setValueRoutine)
|
Func<TValue, ReturnCode> setValueRoutine)
|
||||||
{
|
{
|
||||||
@@ -306,7 +314,7 @@ namespace NTwain
|
|||||||
#region set methods
|
#region set methods
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets all values and constraint to power-on defaults.
|
/// Resets all values and constraints to power-on defaults.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public ReturnCode ResetAll()
|
public ReturnCode ResetAll()
|
@@ -25,7 +25,7 @@ namespace NTwain
|
|||||||
/// capability</exception>
|
/// capability</exception>
|
||||||
public static CapabilityReader ReadValue(TWCapability capability)
|
public static CapabilityReader ReadValue(TWCapability capability)
|
||||||
{
|
{
|
||||||
return ReadValue(capability, PlatformInfo.Current);
|
return ReadValue(capability, PlatformInfo.Current.MemoryManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -33,26 +33,24 @@ namespace NTwain
|
|||||||
/// from a TWAIN source.
|
/// from a TWAIN source.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capability">The capability.</param>
|
/// <param name="capability">The capability.</param>
|
||||||
/// <param name="platformInfo">The platform information.</param>
|
/// <param name="memoryManager">The memory manager.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
/// <exception cref="System.ArgumentNullException">
|
/// <exception cref="System.ArgumentNullException">capability
|
||||||
/// capability
|
|
||||||
/// or
|
/// or
|
||||||
/// platformInfo
|
/// platformInfo</exception>
|
||||||
/// </exception>
|
|
||||||
/// <exception cref="System.ArgumentException">Capability contains no data.;capability
|
/// <exception cref="System.ArgumentException">Capability contains no data.;capability
|
||||||
/// or
|
/// or
|
||||||
/// capability</exception>
|
/// capability</exception>
|
||||||
public static CapabilityReader ReadValue(TWCapability capability, IPlatformInfo platformInfo)
|
public static CapabilityReader ReadValue(TWCapability capability, IMemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
if (capability == null) { throw new ArgumentNullException("capability"); }
|
if (capability == null) { throw new ArgumentNullException("capability"); }
|
||||||
if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); }
|
if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); }
|
||||||
if (platformInfo == null) { throw new ArgumentNullException("platformInfo"); }
|
if (memoryManager == null) { throw new ArgumentNullException("memoryManager"); }
|
||||||
|
|
||||||
IntPtr baseAddr = IntPtr.Zero;
|
IntPtr baseAddr = IntPtr.Zero;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
baseAddr = platformInfo.MemoryManager.Lock(capability.Container);
|
baseAddr = memoryManager.Lock(capability.Container);
|
||||||
switch (capability.ContainerType)
|
switch (capability.ContainerType)
|
||||||
{
|
{
|
||||||
case ContainerType.Array:
|
case ContainerType.Array:
|
||||||
@@ -83,7 +81,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
if (baseAddr != IntPtr.Zero)
|
if (baseAddr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
platformInfo.MemoryManager.Unlock(baseAddr);
|
memoryManager.Unlock(baseAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -643,32 +643,61 @@ namespace NTwain.Data
|
|||||||
/// <param name="capability">The capability.</param>
|
/// <param name="capability">The capability.</param>
|
||||||
/// <param name="value">The value.</param>
|
/// <param name="value">The value.</param>
|
||||||
public TWCapability(CapabilityId capability, TWOneValue value)
|
public TWCapability(CapabilityId capability, TWOneValue value)
|
||||||
|
: this(capability, value, PlatformInfo.Current.MemoryManager) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="capability">The capability.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="memoryManager">The memory manager.</param>
|
||||||
|
public TWCapability(CapabilityId capability, TWOneValue value, IMemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
Capability = capability;
|
Capability = capability;
|
||||||
ContainerType = ContainerType.OneValue;
|
ContainerType = ContainerType.OneValue;
|
||||||
SetOneValue(value);
|
SetOneValue(value, memoryManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capability">The capability.</param>
|
/// <param name="capability">The capability.</param>
|
||||||
/// <param name="value">The value.</param>
|
/// <param name="value">The value.</param>
|
||||||
public TWCapability(CapabilityId capability, TWEnumeration value)
|
public TWCapability(CapabilityId capability, TWEnumeration value)
|
||||||
|
: this(capability, value, PlatformInfo.Current.MemoryManager) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="capability">The capability.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="memoryManager">The memory manager.</param>
|
||||||
|
public TWCapability(CapabilityId capability, TWEnumeration value, IMemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
Capability = capability;
|
Capability = capability;
|
||||||
ContainerType = ContainerType.Enum;
|
ContainerType = ContainerType.Enum;
|
||||||
SetEnumValue(value);
|
SetEnumValue(value, memoryManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capability">The capability.</param>
|
/// <param name="capability">The capability.</param>
|
||||||
/// <param name="value">The value.</param>
|
/// <param name="value">The value.</param>
|
||||||
public TWCapability(CapabilityId capability, TWRange value)
|
public TWCapability(CapabilityId capability, TWRange value)
|
||||||
|
: this(capability, value, PlatformInfo.Current.MemoryManager) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="capability">The capability.</param>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="memoryManager">The memory manager.</param>
|
||||||
|
public TWCapability(CapabilityId capability, TWRange value, IMemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
Capability = capability;
|
Capability = capability;
|
||||||
ContainerType = ContainerType.Range;
|
ContainerType = ContainerType.Range;
|
||||||
SetRangeValue(value);
|
SetRangeValue(value, memoryManager);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -691,7 +720,7 @@ namespace NTwain.Data
|
|||||||
|
|
||||||
#region value functions
|
#region value functions
|
||||||
|
|
||||||
void SetOneValue(TWOneValue value)
|
void SetOneValue(TWOneValue value, IMemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
ContainerType = ContainerType.OneValue;
|
ContainerType = ContainerType.OneValue;
|
||||||
@@ -699,14 +728,14 @@ namespace NTwain.Data
|
|||||||
// since one value can only house UInt32 we will not allow type size > 4
|
// since one value can only house UInt32 we will not allow type size > 4
|
||||||
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TWOneValue")); }
|
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TWOneValue")); }
|
||||||
|
|
||||||
_hContainer = PlatformInfo.Current.MemoryManager.Allocate((uint)Marshal.SizeOf(value));
|
_hContainer = memoryManager.Allocate((uint)Marshal.SizeOf(value));
|
||||||
if (_hContainer != IntPtr.Zero)
|
if (_hContainer != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Marshal.StructureToPtr(value, _hContainer, false);
|
Marshal.StructureToPtr(value, _hContainer, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetEnumValue(TWEnumeration value)
|
void SetEnumValue(TWEnumeration value, IMemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
ContainerType = ContainerType.Enum;
|
ContainerType = ContainerType.Enum;
|
||||||
@@ -715,8 +744,8 @@ namespace NTwain.Data
|
|||||||
Int32 valueSize = TWEnumeration.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
|
Int32 valueSize = TWEnumeration.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
_hContainer = PlatformInfo.Current.MemoryManager.Allocate((uint)valueSize);
|
_hContainer = memoryManager.Allocate((uint)valueSize);
|
||||||
IntPtr baseAddr = PlatformInfo.Current.MemoryManager.Lock(_hContainer);
|
IntPtr baseAddr = memoryManager.Lock(_hContainer);
|
||||||
|
|
||||||
// can't safely use StructureToPtr here so write it our own
|
// can't safely use StructureToPtr here so write it our own
|
||||||
WriteValue(baseAddr, ref offset, ItemType.UInt16, value.ItemType);
|
WriteValue(baseAddr, ref offset, ItemType.UInt16, value.ItemType);
|
||||||
@@ -727,11 +756,11 @@ namespace NTwain.Data
|
|||||||
{
|
{
|
||||||
WriteValue(baseAddr, ref offset, value.ItemType, item);
|
WriteValue(baseAddr, ref offset, value.ItemType, item);
|
||||||
}
|
}
|
||||||
PlatformInfo.Current.MemoryManager.Unlock(baseAddr);
|
memoryManager.Unlock(baseAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SetRangeValue(TWRange value)
|
void SetRangeValue(TWRange value, IMemoryManager memoryManager)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
ContainerType = ContainerType.Range;
|
ContainerType = ContainerType.Range;
|
||||||
@@ -739,7 +768,7 @@ namespace NTwain.Data
|
|||||||
// since range value can only house UInt32 we will not allow type size > 4
|
// since range value can only house UInt32 we will not allow type size > 4
|
||||||
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TWRange")); }
|
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TWRange")); }
|
||||||
|
|
||||||
_hContainer = PlatformInfo.Current.MemoryManager.Allocate((uint)Marshal.SizeOf(value));
|
_hContainer = memoryManager.Allocate((uint)Marshal.SizeOf(value));
|
||||||
if (_hContainer != IntPtr.Zero)
|
if (_hContainer != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Marshal.StructureToPtr(value, _hContainer, false);
|
Marshal.StructureToPtr(value, _hContainer, false);
|
||||||
|
@@ -9,7 +9,7 @@ namespace NTwain
|
|||||||
// this contains all cap-related methods prefixed with Cap
|
// this contains all cap-related methods prefixed with Cap
|
||||||
|
|
||||||
|
|
||||||
partial class DataSource : ICapController
|
partial class DataSource : ICapControl
|
||||||
{
|
{
|
||||||
#region low-level cap stuff
|
#region low-level cap stuff
|
||||||
|
|
||||||
@@ -170,11 +170,11 @@ namespace NTwain
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region frequently used high-level caps stuff
|
#region high-level caps stuff
|
||||||
|
|
||||||
#region audio caps
|
#region audio caps
|
||||||
|
|
||||||
private CapabilityControl<XferMech> _audXferMech;
|
private CapWrapper<XferMech> _audXferMech;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with audio <see cref="XferMech"/> for the current source.
|
/// Gets the property to work with audio <see cref="XferMech"/> for the current source.
|
||||||
@@ -182,20 +182,16 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The audio xfer mech.
|
/// The audio xfer mech.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<XferMech> CapAudioXferMech
|
public CapWrapper<XferMech> CapAudioXferMech
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_audXferMech == null)
|
return _audXferMech ?? (_audXferMech = new CapWrapper<XferMech>(this, CapabilityId.ACapXferMech, ValueExtensions.ConvertToEnum<XferMech>,
|
||||||
{
|
|
||||||
_audXferMech = new CapabilityControl<XferMech>(this, CapabilityId.ACapXferMech, ValueExtensions.ConvertToEnum<XferMech>,
|
|
||||||
value => new TWCapability(CapabilityId.ACapXferMech, new TWOneValue
|
value => new TWCapability(CapabilityId.ACapXferMech, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.UInt16
|
ItemType = ItemType.UInt16
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _audXferMech;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,7 +199,7 @@ namespace NTwain
|
|||||||
|
|
||||||
#region img caps
|
#region img caps
|
||||||
|
|
||||||
private CapabilityControl<XferMech> _imgXferMech;
|
private CapWrapper<XferMech> _imgXferMech;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image <see cref="XferMech"/> for the current source.
|
/// Gets the property to work with image <see cref="XferMech"/> for the current source.
|
||||||
@@ -211,25 +207,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image xfer mech.
|
/// The image xfer mech.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<XferMech> CapImageXferMech
|
public CapWrapper<XferMech> CapImageXferMech
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_imgXferMech == null)
|
return _imgXferMech ?? (_imgXferMech = new CapWrapper<XferMech>(this, CapabilityId.ICapXferMech, ValueExtensions.ConvertToEnum<XferMech>,
|
||||||
{
|
|
||||||
_imgXferMech = new CapabilityControl<XferMech>(this, CapabilityId.ICapXferMech, ValueExtensions.ConvertToEnum<XferMech>,
|
|
||||||
value => new TWCapability(CapabilityId.ICapXferMech, new TWOneValue
|
value => new TWCapability(CapabilityId.ICapXferMech, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.UInt16
|
ItemType = ItemType.UInt16
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _imgXferMech;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<CompressionType> _compression;
|
private CapWrapper<CompressionType> _compression;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image <see cref="CompressionType"/> for the current source.
|
/// Gets the property to work with image <see cref="CompressionType"/> for the current source.
|
||||||
@@ -237,25 +229,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image compression.
|
/// The image compression.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<CompressionType> CapImageCompression
|
public CapWrapper<CompressionType> CapImageCompression
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_compression == null)
|
return _compression ?? (_compression = new CapWrapper<CompressionType>(this, CapabilityId.ICapCompression, ValueExtensions.ConvertToEnum<CompressionType>,
|
||||||
{
|
|
||||||
_compression = new CapabilityControl<CompressionType>(this, CapabilityId.ICapCompression, ValueExtensions.ConvertToEnum<CompressionType>,
|
|
||||||
value => new TWCapability(CapabilityId.ICapCompression, new TWOneValue
|
value => new TWCapability(CapabilityId.ICapCompression, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.UInt16
|
ItemType = ItemType.UInt16
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _compression;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<FileFormat> _fileFormat;
|
private CapWrapper<FileFormat> _fileFormat;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image <see cref="FileFormat"/> for the current source.
|
/// Gets the property to work with image <see cref="FileFormat"/> for the current source.
|
||||||
@@ -263,25 +251,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image file format.
|
/// The image file format.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<FileFormat> CapImageFileFormat
|
public CapWrapper<FileFormat> CapImageFileFormat
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_fileFormat == null)
|
return _fileFormat ?? (_fileFormat = new CapWrapper<FileFormat>(this, CapabilityId.ICapImageFileFormat, ValueExtensions.ConvertToEnum<FileFormat>,
|
||||||
{
|
|
||||||
_fileFormat = new CapabilityControl<FileFormat>(this, CapabilityId.ICapImageFileFormat, ValueExtensions.ConvertToEnum<FileFormat>,
|
|
||||||
value => new TWCapability(CapabilityId.ICapImageFileFormat, new TWOneValue
|
value => new TWCapability(CapabilityId.ICapImageFileFormat, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.UInt16
|
ItemType = ItemType.UInt16
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _fileFormat;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<PixelType> _pixelType;
|
private CapWrapper<PixelType> _pixelType;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image <see cref="PixelType"/> for the current source.
|
/// Gets the property to work with image <see cref="PixelType"/> for the current source.
|
||||||
@@ -289,25 +273,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image pixel type.
|
/// The image pixel type.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<PixelType> CapImagePixelType
|
public CapWrapper<PixelType> CapImagePixelType
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_pixelType == null)
|
return _pixelType ?? (_pixelType = new CapWrapper<PixelType>(this, CapabilityId.ICapPixelType, ValueExtensions.ConvertToEnum<PixelType>,
|
||||||
{
|
|
||||||
_pixelType = new CapabilityControl<PixelType>(this, CapabilityId.ICapPixelType, ValueExtensions.ConvertToEnum<PixelType>,
|
|
||||||
value => new TWCapability(CapabilityId.ICapPixelType, new TWOneValue
|
value => new TWCapability(CapabilityId.ICapPixelType, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.UInt16
|
ItemType = ItemType.UInt16
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _pixelType;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<SupportedSize> _supportSize;
|
private CapWrapper<SupportedSize> _supportSize;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image <see cref="SupportedSize"/> for the current source.
|
/// Gets the property to work with image <see cref="SupportedSize"/> for the current source.
|
||||||
@@ -315,25 +295,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image supported size.
|
/// The image supported size.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<SupportedSize> CapImageSupportedSize
|
public CapWrapper<SupportedSize> CapImageSupportedSize
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_supportSize == null)
|
return _supportSize ?? (_supportSize = new CapWrapper<SupportedSize>(this, CapabilityId.ICapSupportedSizes, ValueExtensions.ConvertToEnum<SupportedSize>,
|
||||||
{
|
|
||||||
_supportSize = new CapabilityControl<SupportedSize>(this, CapabilityId.ICapSupportedSizes, ValueExtensions.ConvertToEnum<SupportedSize>,
|
|
||||||
value => new TWCapability(CapabilityId.ICapSupportedSizes, new TWOneValue
|
value => new TWCapability(CapabilityId.ICapSupportedSizes, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.UInt16
|
ItemType = ItemType.UInt16
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _supportSize;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<BoolType> _autoDeskew;
|
private CapWrapper<BoolType> _autoDeskew;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image auto deskew flag for the current source.
|
/// Gets the property to work with image auto deskew flag for the current source.
|
||||||
@@ -341,25 +317,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image auto deskew flag.
|
/// The image auto deskew flag.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<BoolType> CapImageAutoDeskew
|
public CapWrapper<BoolType> CapImageAutoDeskew
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_autoDeskew == null)
|
return _autoDeskew ?? (_autoDeskew = new CapWrapper<BoolType>(this, CapabilityId.ICapAutomaticDeskew, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
||||||
{
|
|
||||||
_autoDeskew = new CapabilityControl<BoolType>(this, CapabilityId.ICapAutomaticDeskew, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
|
||||||
new TWCapability(CapabilityId.ICapAutomaticRotate, new TWOneValue
|
new TWCapability(CapabilityId.ICapAutomaticRotate, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.Bool
|
ItemType = ItemType.Bool
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _autoDeskew;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<BoolType> _autoRotate;
|
private CapWrapper<BoolType> _autoRotate;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image auto rotate flag for the current source.
|
/// Gets the property to work with image auto rotate flag for the current source.
|
||||||
@@ -367,25 +339,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image auto rotate flag.
|
/// The image auto rotate flag.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<BoolType> CapImageAutoRotate
|
public CapWrapper<BoolType> CapImageAutoRotate
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_autoRotate == null)
|
return _autoRotate ?? (_autoRotate = new CapWrapper<BoolType>(this, CapabilityId.ICapAutomaticRotate, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
||||||
{
|
|
||||||
_autoRotate = new CapabilityControl<BoolType>(this, CapabilityId.ICapAutomaticRotate, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
|
||||||
new TWCapability(CapabilityId.ICapAutomaticRotate, new TWOneValue
|
new TWCapability(CapabilityId.ICapAutomaticRotate, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.Bool
|
ItemType = ItemType.Bool
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _autoRotate;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<TWFix32> _xResolution;
|
private CapWrapper<TWFix32> _xResolution;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image horizontal resolution for the current source.
|
/// Gets the property to work with image horizontal resolution for the current source.
|
||||||
@@ -393,25 +361,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image horizontal resolution.
|
/// The image horizontal resolution.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<TWFix32> CapImageXResolution
|
public CapWrapper<TWFix32> CapImageXResolution
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_xResolution == null)
|
return _xResolution ?? (_xResolution = new CapWrapper<TWFix32>(this, CapabilityId.ICapXResolution, ValueExtensions.ConvertToFix32,
|
||||||
{
|
|
||||||
_xResolution = new CapabilityControl<TWFix32>(this, CapabilityId.ICapXResolution, ValueExtensions.ConvertToFix32,
|
|
||||||
value => new TWCapability(CapabilityId.ICapXResolution, new TWOneValue
|
value => new TWCapability(CapabilityId.ICapXResolution, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,// ((uint)dpi) << 16;
|
Item = (uint)value,// ((uint)dpi) << 16;
|
||||||
ItemType = ItemType.Fix32
|
ItemType = ItemType.Fix32
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _xResolution;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<TWFix32> _yResolution;
|
private CapWrapper<TWFix32> _yResolution;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with image vertical resolution for the current source.
|
/// Gets the property to work with image vertical resolution for the current source.
|
||||||
@@ -419,25 +383,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The image vertical resolution.
|
/// The image vertical resolution.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<TWFix32> CapImageYResolution
|
public CapWrapper<TWFix32> CapImageYResolution
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_yResolution == null)
|
return _yResolution ?? (_yResolution = new CapWrapper<TWFix32>(this, CapabilityId.ICapYResolution, ValueExtensions.ConvertToFix32,
|
||||||
{
|
|
||||||
_yResolution = new CapabilityControl<TWFix32>(this, CapabilityId.ICapYResolution, ValueExtensions.ConvertToFix32,
|
|
||||||
value => new TWCapability(CapabilityId.ICapYResolution, new TWOneValue
|
value => new TWCapability(CapabilityId.ICapYResolution, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,// ((uint)dpi) << 16;
|
Item = (uint)value,// ((uint)dpi) << 16;
|
||||||
ItemType = ItemType.Fix32
|
ItemType = ItemType.Fix32
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _yResolution;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<BoolType> _borderDetect;
|
private CapWrapper<BoolType> _borderDetect;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with auto border detection flag for the current source.
|
/// Gets the property to work with auto border detection flag for the current source.
|
||||||
@@ -445,13 +405,11 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The auto border detection flag.
|
/// The auto border detection flag.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<BoolType> CapImageAutomaticBorderDetection
|
public CapWrapper<BoolType> CapImageAutomaticBorderDetection
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_borderDetect == null)
|
return _borderDetect ?? ( _borderDetect = new CapWrapper<BoolType>(this, CapabilityId.ICapAutomaticBorderDetection, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
||||||
{
|
|
||||||
_borderDetect = new CapabilityControl<BoolType>(this, CapabilityId.ICapAutomaticBorderDetection, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
|
||||||
{
|
{
|
||||||
var rc = ReturnCode.Failure;
|
var rc = ReturnCode.Failure;
|
||||||
|
|
||||||
@@ -471,9 +429,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
});
|
}));
|
||||||
}
|
|
||||||
return _borderDetect;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,7 +437,7 @@ namespace NTwain
|
|||||||
|
|
||||||
#region other caps
|
#region other caps
|
||||||
|
|
||||||
private CapabilityControl<BoolType> _duplexEnabled;
|
private CapWrapper<BoolType> _duplexEnabled;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with duplex enabled flag for the current source.
|
/// Gets the property to work with duplex enabled flag for the current source.
|
||||||
@@ -489,25 +445,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The duplex enabled flag.
|
/// The duplex enabled flag.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<BoolType> CapDuplexEnabled
|
public CapWrapper<BoolType> CapDuplexEnabled
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_duplexEnabled == null)
|
return _duplexEnabled ?? (_duplexEnabled = new CapWrapper<BoolType>(this, CapabilityId.CapDuplexEnabled, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
||||||
{
|
|
||||||
_duplexEnabled = new CapabilityControl<BoolType>(this, CapabilityId.CapDuplexEnabled, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
|
||||||
new TWCapability(CapabilityId.CapDuplexEnabled, new TWOneValue
|
new TWCapability(CapabilityId.CapDuplexEnabled, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = (uint)value,
|
Item = (uint)value,
|
||||||
ItemType = ItemType.Bool
|
ItemType = ItemType.Bool
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _duplexEnabled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<int> _xferCount;
|
private CapWrapper<int> _xferCount;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with xfer count for the current source.
|
/// Gets the property to work with xfer count for the current source.
|
||||||
@@ -515,25 +467,21 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The xfer count.
|
/// The xfer count.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<int> CapXferCount
|
public CapWrapper<int> CapXferCount
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_xferCount == null)
|
return _xferCount ?? (_xferCount = new CapWrapper<int>(this, CapabilityId.CapXferCount, ValueExtensions.ConvertToEnum<int>, value =>
|
||||||
{
|
|
||||||
_xferCount = new CapabilityControl<int>(this, CapabilityId.CapXferCount, ValueExtensions.ConvertToEnum<int>, value =>
|
|
||||||
new TWCapability(CapabilityId.CapXferCount, new TWOneValue
|
new TWCapability(CapabilityId.CapXferCount, new TWOneValue
|
||||||
{
|
{
|
||||||
Item = value > 0 ? (uint)value : uint.MaxValue,
|
Item = value > 0 ? (uint)value : uint.MaxValue,
|
||||||
ItemType = ItemType.UInt16
|
ItemType = ItemType.UInt16
|
||||||
}));
|
})));
|
||||||
}
|
|
||||||
return _xferCount;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CapabilityControl<BoolType> _feederEnabled;
|
private CapWrapper<BoolType> _feederEnabled;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the property to work with feeder enabled flag for the current source.
|
/// Gets the property to work with feeder enabled flag for the current source.
|
||||||
@@ -541,13 +489,11 @@ namespace NTwain
|
|||||||
/// <value>
|
/// <value>
|
||||||
/// The feeder enabled flag.
|
/// The feeder enabled flag.
|
||||||
/// </value>
|
/// </value>
|
||||||
public CapabilityControl<BoolType> CapFeederEnabled
|
public CapWrapper<BoolType> CapFeederEnabled
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_feederEnabled == null)
|
return _feederEnabled ?? (_feederEnabled = new CapWrapper<BoolType>(this, CapabilityId.CapFeederEnabled, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
||||||
{
|
|
||||||
_feederEnabled = new CapabilityControl<BoolType>(this, CapabilityId.CapFeederEnabled, ValueExtensions.ConvertToEnum<BoolType>, value =>
|
|
||||||
{
|
{
|
||||||
var rc = ReturnCode.Failure;
|
var rc = ReturnCode.Failure;
|
||||||
|
|
||||||
@@ -584,9 +530,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
});
|
}));
|
||||||
}
|
|
||||||
return _feederEnabled;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -4,38 +4,38 @@ using System.Collections.Generic;
|
|||||||
namespace NTwain
|
namespace NTwain
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interface for controlling caps.
|
/// Interface for providing basic functions at controlling caps.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface ICapController
|
public interface ICapControl : ITripletControl
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A general method that tries to get capability values from current <see cref="DataSource" />.
|
/// Gets all the possible values for a capability.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capabilityId">The capability unique identifier.</param>
|
/// <param name="capabilityId">The capability identifier.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
IList<object> CapGet(CapabilityId capabilityId);
|
IList<object> CapGet(CapabilityId capabilityId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current value for a capability.
|
/// Gets the current value for a capability.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capId">The cap id.</param>
|
/// <param name="capabilityId">The capability identifier.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
object CapGetCurrent(CapabilityId capId);
|
object CapGetCurrent(CapabilityId capabilityId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the default value for a capability.
|
/// Gets the default value for a capability.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capId">The cap id.</param>
|
/// <param name="capabilityId">The capability identifier.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
object CapGetDefault(CapabilityId capId);
|
object CapGetDefault(CapabilityId capabilityId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the actual supported operations for a capability.
|
/// Gets the supported operations for a capability.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capId">The cap identifier.</param>
|
/// <param name="capabilityId">The capability identifier.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
QuerySupports CapQuerySupport(CapabilityId capId);
|
QuerySupports CapQuerySupport(CapabilityId capabilityId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets the current value to power-on default.
|
/// Resets the current value to power-on default.
|
||||||
@@ -45,7 +45,7 @@ namespace NTwain
|
|||||||
ReturnCode CapReset(CapabilityId capabilityId);
|
ReturnCode CapReset(CapabilityId capabilityId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resets all values and constraint to power-on defaults.
|
/// Resets all values and constraints to power-on defaults.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="capabilityId">The capability identifier.</param>
|
/// <param name="capabilityId">The capability identifier.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
29
NTwain/ITripletControl.cs
Normal file
29
NTwain/ITripletControl.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using NTwain.Triplets;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NTwain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for providing TWAIN triplet access.
|
||||||
|
/// </summary>
|
||||||
|
public interface ITripletControl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the triplet operations defined for control data group.
|
||||||
|
/// </summary>
|
||||||
|
DGControl DGControl { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the triplet operations defined for image data group.
|
||||||
|
/// </summary>
|
||||||
|
DGImage DGImage { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the direct triplet operation entry for custom values.
|
||||||
|
/// </summary>
|
||||||
|
DGCustom DGCustom { get; }
|
||||||
|
}
|
||||||
|
}
|
@@ -9,7 +9,7 @@ namespace NTwain.Internals
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Extends <see cref="ITwainSession"/> with extra stuff for internal use.
|
/// Extends <see cref="ITwainSession"/> with extra stuff for internal use.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
interface ITwainSessionInternal : ITwainSession
|
interface ITwainSessionInternal : ITwainSession, ITripletControl
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the app id used for the session.
|
/// Gets the app id used for the session.
|
||||||
@@ -48,20 +48,5 @@ namespace NTwain.Internals
|
|||||||
/// Gets the triplet operations defined for audio data group.
|
/// Gets the triplet operations defined for audio data group.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
DGAudio DGAudio { get; }
|
DGAudio DGAudio { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the triplet operations defined for control data group.
|
|
||||||
/// </summary>
|
|
||||||
DGControl DGControl { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the triplet operations defined for image data group.
|
|
||||||
/// </summary>
|
|
||||||
DGImage DGImage { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the direct triplet operation entry for custom values.
|
|
||||||
/// </summary>
|
|
||||||
DGCustom DGCustom { get; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -55,13 +55,13 @@
|
|||||||
<Reference Include="WindowsBase" />
|
<Reference Include="WindowsBase" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="CapabilityControl.cs" />
|
<Compile Include="CapWrapper.cs" />
|
||||||
<Compile Include="CapabilityReader.cs" />
|
<Compile Include="CapabilityReader.cs" />
|
||||||
<Compile Include="Data\TypeReader.cs" />
|
<Compile Include="Data\TypeReader.cs" />
|
||||||
<Compile Include="Data\TwainTypesExtended.cs" />
|
<Compile Include="Data\TwainTypesExtended.cs" />
|
||||||
<Compile Include="DeviceEventArgs.cs" />
|
<Compile Include="DeviceEventArgs.cs" />
|
||||||
<Compile Include="IDataSource.cs" />
|
<Compile Include="IDataSource.cs" />
|
||||||
<Compile Include="ICapController.cs" />
|
<Compile Include="ICapControl.cs" />
|
||||||
<Compile Include="Internals\Extensions.cs" />
|
<Compile Include="Internals\Extensions.cs" />
|
||||||
<Compile Include="DataTransferredEventArgs.cs" />
|
<Compile Include="DataTransferredEventArgs.cs" />
|
||||||
<Compile Include="IMemoryManager.cs" />
|
<Compile Include="IMemoryManager.cs" />
|
||||||
@@ -73,6 +73,7 @@
|
|||||||
<Compile Include="Internals\WindowsHook.cs" />
|
<Compile Include="Internals\WindowsHook.cs" />
|
||||||
<Compile Include="Internals\WrappedManualResetEvent.cs" />
|
<Compile Include="Internals\WrappedManualResetEvent.cs" />
|
||||||
<Compile Include="IPlatformInfo.cs" />
|
<Compile Include="IPlatformInfo.cs" />
|
||||||
|
<Compile Include="ITripletControl.cs" />
|
||||||
<Compile Include="ITwainSession.cs" />
|
<Compile Include="ITwainSession.cs" />
|
||||||
<Compile Include="Internals\WinMemoryManager.cs" />
|
<Compile Include="Internals\WinMemoryManager.cs" />
|
||||||
<Compile Include="Internals\UnsafeNativeMethods.cs" />
|
<Compile Include="Internals\UnsafeNativeMethods.cs" />
|
||||||
|
@@ -73,7 +73,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
DGControl _dgControl;
|
DGControl _dgControl;
|
||||||
DGControl ITwainSessionInternal.DGControl
|
DGControl ITripletControl.DGControl
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -83,7 +83,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
DGImage _dgImage;
|
DGImage _dgImage;
|
||||||
DGImage ITwainSessionInternal.DGImage
|
DGImage ITripletControl.DGImage
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
@@ -93,7 +93,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
|
|
||||||
DGCustom _dgCustom;
|
DGCustom _dgCustom;
|
||||||
DGCustom ITwainSessionInternal.DGCustom
|
DGCustom ITripletControl.DGCustom
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@@ -297,7 +297,7 @@ namespace Tester.Winform
|
|||||||
_loadingCaps = false;
|
_loadingCaps = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadPaperSize(CapabilityControl<SupportedSize> cap)
|
private void LoadPaperSize(CapWrapper<SupportedSize> cap)
|
||||||
{
|
{
|
||||||
var list = cap.Get();
|
var list = cap.Get();
|
||||||
comboSize.DataSource = list;
|
comboSize.DataSource = list;
|
||||||
@@ -314,13 +314,13 @@ namespace Tester.Winform
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void LoadDuplex(CapabilityControl<BoolType> cap)
|
private void LoadDuplex(CapWrapper<BoolType> cap)
|
||||||
{
|
{
|
||||||
ckDuplex.Checked = cap.GetCurrent() == BoolType.True;
|
ckDuplex.Checked = cap.GetCurrent() == BoolType.True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void LoadDPI(CapabilityControl<TWFix32> cap)
|
private void LoadDPI(CapWrapper<TWFix32> cap)
|
||||||
{
|
{
|
||||||
// only allow dpi of certain values for those source that lists everything
|
// only allow dpi of certain values for those source that lists everything
|
||||||
var list = cap.Get().Where(dpi => (dpi % 50) == 0).ToList();
|
var list = cap.Get().Where(dpi => (dpi % 50) == 0).ToList();
|
||||||
@@ -332,7 +332,7 @@ namespace Tester.Winform
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadDepth(CapabilityControl<PixelType> cap)
|
private void LoadDepth(CapWrapper<PixelType> cap)
|
||||||
{
|
{
|
||||||
var list = cap.Get();
|
var list = cap.Get();
|
||||||
comboDepth.DataSource = list;
|
comboDepth.DataSource = list;
|
||||||
|
Reference in New Issue
Block a user