Added capability triplets.

This commit is contained in:
Eugene Wang
2018-11-18 12:15:12 -05:00
parent a8a0f81604
commit 34c156da23
10 changed files with 478 additions and 301 deletions

View File

@@ -105,7 +105,7 @@ namespace NTwain.Data
}
[StructLayout(LayoutKind.Sequential, Pack = 2)]
partial class TW_CAPABILITY
partial struct TW_CAPABILITY
{
TW_UINT16 _cap;
TW_UINT16 _conType;

View File

@@ -570,261 +570,261 @@ namespace NTwain.Data
public string Name { get { return _name; } }
}
// /// <summary>
// /// Used by an application either to get information about, or control the setting of a capability.
// /// </summary>
// public sealed partial class TW_CAPABILITY : IDisposable
// {
// #region ctors
/// <summary>
/// Used by an application either to get information about, or control the setting of a capability.
/// </summary>
public partial struct TW_CAPABILITY
{
// #region ctors
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// public TW_CAPABILITY(CapabilityId capability)
// {
// Capability = capability;
// ContainerType = ContainerType.DontCare;
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_ONEVALUE value)
// {
// Capability = capability;
// SetOneValue(value, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY"/> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// /// <param name="type">The type.</param>
// public TW_CAPABILITY(CapabilityId capability, string value, ItemType type)
// {
// Capability = capability;
// SetOneValue(value, type, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY"/> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_FRAME value)
// {
// Capability = capability;
// SetOneValue(value, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// public TW_CAPABILITY(CapabilityId capability)
// {
// Capability = capability;
// ContainerType = ContainerType.DontCare;
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_ONEVALUE value)
// {
// Capability = capability;
// SetOneValue(value, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY"/> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// /// <param name="type">The type.</param>
// public TW_CAPABILITY(CapabilityId capability, string value, ItemType type)
// {
// Capability = capability;
// SetOneValue(value, type, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY"/> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_FRAME value)
// {
// Capability = capability;
// SetOneValue(value, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_ENUMERATION value)
// {
// Capability = capability;
// SetEnumValue(value, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_ENUMERATION value)
// {
// Capability = capability;
// SetEnumValue(value, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_RANGE value)
// {
// Capability = capability;
// SetRangeValue(value, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_RANGE value)
// {
// Capability = capability;
// SetRangeValue(value, PlatformInfo.Current.MemoryManager);
// }
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_ARRAY value)
// {
// Capability = capability;
// SetArrayValue(value, PlatformInfo.Current.MemoryManager);
// }
// #endregion
// /// <summary>
// /// Initializes a new instance of the <see cref="TW_CAPABILITY" /> class.
// /// </summary>
// /// <param name="capability">The capability.</param>
// /// <param name="value">The value.</param>
// public TW_CAPABILITY(CapabilityId capability, TW_ARRAY value)
// {
// Capability = capability;
// SetArrayValue(value, PlatformInfo.Current.MemoryManager);
// }
// #endregion
// #region properties
// #region properties
// /// <summary>
// /// Id of capability to set or get.
// /// </summary>
// public CapabilityId Capability { get { return (CapabilityId)_cap; } set { _cap = (ushort)value; } }
// /// <summary>
// /// The type of the container structure referenced by the pointer internally. The container
// /// will be one of four types: <see cref="TW_ARRAY"/>, <see cref="TW_ENUMERATION"/>,
// /// <see cref="TW_ONEVALUE"/>, or <see cref="TW_RANGE"/>.
// /// </summary>
// public ContainerType ContainerType { get { return (ContainerType)_conType; } set { _conType = (ushort)value; } }
// /// <summary>
// /// Id of capability to set or get.
// /// </summary>
// public CapabilityId Capability { get { return (CapabilityId)_cap; } set { _cap = (ushort)value; } }
// /// <summary>
// /// The type of the container structure referenced by the pointer internally. The container
// /// will be one of four types: <see cref="TW_ARRAY"/>, <see cref="TW_ENUMERATION"/>,
// /// <see cref="TW_ONEVALUE"/>, or <see cref="TW_RANGE"/>.
// /// </summary>
// public ContainerType ContainerType { get { return (ContainerType)_conType; } set { _conType = (ushort)value; } }
// internal IntPtr Container { get { return _hContainer; } }
// internal IntPtr Container { get { return _hContainer; } }
// #endregion
// #endregion
// #region value functions
// #region value functions
// void SetOneValue(string value, ItemType type, IMemoryManager memoryManager)
// {
// ContainerType = ContainerType.OneValue;
// switch (type)
// {
// case ItemType.String128:
// case ItemType.String255:
// case ItemType.String32:
// case ItemType.String64:
// void SetOneValue(string value, ItemType type, IMemoryManager memoryManager)
// {
// ContainerType = ContainerType.OneValue;
// switch (type)
// {
// case ItemType.String128:
// case ItemType.String255:
// case ItemType.String32:
// case ItemType.String64:
// _hContainer = memoryManager.Allocate((uint)(Marshal.SizeOf(typeof(TW_FRAME)) + 2));
// if (_hContainer != IntPtr.Zero)
// {
// IntPtr baseAddr = memoryManager.Lock(_hContainer);
// int offset = 0;
// baseAddr.WriteValue(ref offset, ItemType.UInt16, type);
// baseAddr.WriteValue(ref offset, type, value);
// memoryManager.Unlock(_hContainer);
// }
// break;
// default:
// throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Type {0} is not valid for string.", type));
// }
// }
// void SetOneValue(TW_FRAME value, IMemoryManager memoryManager)
// {
// ContainerType = ContainerType.OneValue;
// _hContainer = memoryManager.Allocate((uint)(Marshal.SizeOf(typeof(TW_FRAME)) + 2));
// if (_hContainer != IntPtr.Zero)
// {
// IntPtr baseAddr = memoryManager.Lock(_hContainer);
// int offset = 0;
// baseAddr.WriteValue(ref offset, ItemType.UInt16, type);
// baseAddr.WriteValue(ref offset, type, value);
// memoryManager.Unlock(_hContainer);
// }
// break;
// default:
// throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Type {0} is not valid for string.", type));
// }
// }
// void SetOneValue(TW_FRAME value, IMemoryManager memoryManager)
// {
// ContainerType = ContainerType.OneValue;
// _hContainer = memoryManager.Allocate((uint)(Marshal.SizeOf(typeof(TW_FRAME)) + 2));
// if (_hContainer != IntPtr.Zero)
// {
// IntPtr baseAddr = memoryManager.Lock(_hContainer);
// int offset = 0;
// baseAddr.WriteValue(ref offset, ItemType.UInt16, ItemType.Frame);
// baseAddr.WriteValue(ref offset, ItemType.Frame, value);
// memoryManager.Unlock(_hContainer);
// }
// }
// _hContainer = memoryManager.Allocate((uint)(Marshal.SizeOf(typeof(TW_FRAME)) + 2));
// if (_hContainer != IntPtr.Zero)
// {
// IntPtr baseAddr = memoryManager.Lock(_hContainer);
// int offset = 0;
// baseAddr.WriteValue(ref offset, ItemType.UInt16, ItemType.Frame);
// baseAddr.WriteValue(ref offset, ItemType.Frame, value);
// memoryManager.Unlock(_hContainer);
// }
// }
// void SetOneValue(TW_ONEVALUE value, IMemoryManager memoryManager)
// {
// if (value == null) { throw new ArgumentNullException("value"); }
// ContainerType = ContainerType.OneValue;
// void SetOneValue(TW_ONEVALUE value, IMemoryManager memoryManager)
// {
// if (value == null) { throw new ArgumentNullException("value"); }
// ContainerType = ContainerType.OneValue;
// // since one value can only house UInt32 we will not allow type size > 4
// if (TypeExtensions.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TW_ONEVALUE")); }
// // since one value can only house UInt32 we will not allow type size > 4
// if (TypeExtensions.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TW_ONEVALUE")); }
// _hContainer = memoryManager.Allocate((uint)Marshal.SizeOf(value));
// if (_hContainer != IntPtr.Zero)
// {
// Marshal.StructureToPtr(value, _hContainer, false);
// }
// }
// _hContainer = memoryManager.Allocate((uint)Marshal.SizeOf(value));
// if (_hContainer != IntPtr.Zero)
// {
// Marshal.StructureToPtr(value, _hContainer, false);
// }
// }
// void SetEnumValue(TW_ENUMERATION value, IMemoryManager memoryManager)
// {
// if (value == null) { throw new ArgumentNullException("value"); }
// ContainerType = ContainerType.Enum;
// void SetEnumValue(TW_ENUMERATION value, IMemoryManager memoryManager)
// {
// if (value == null) { throw new ArgumentNullException("value"); }
// ContainerType = ContainerType.Enum;
// Int32 valueSize = TW_ENUMERATION.ItemOffset + value.ItemList.Length * TypeExtensions.GetItemTypeSize(value.ItemType);
// Int32 valueSize = TW_ENUMERATION.ItemOffset + value.ItemList.Length * TypeExtensions.GetItemTypeSize(value.ItemType);
// int offset = 0;
// _hContainer = memoryManager.Allocate((uint)valueSize);
// if (_hContainer != IntPtr.Zero)
// {
// IntPtr baseAddr = memoryManager.Lock(_hContainer);
// int offset = 0;
// _hContainer = memoryManager.Allocate((uint)valueSize);
// if (_hContainer != IntPtr.Zero)
// {
// IntPtr baseAddr = memoryManager.Lock(_hContainer);
// // can't safely use StructureToPtr here so write it our own
// baseAddr.WriteValue(ref offset, ItemType.UInt16, value.ItemType);
// baseAddr.WriteValue(ref offset, ItemType.UInt32, (uint)value.ItemList.Length);
// baseAddr.WriteValue(ref offset, ItemType.UInt32, value.CurrentIndex);
// baseAddr.WriteValue(ref offset, ItemType.UInt32, value.DefaultIndex);
// foreach (var item in value.ItemList)
// {
// baseAddr.WriteValue(ref offset, value.ItemType, item);
// }
// memoryManager.Unlock(_hContainer);
// }
// }
// // can't safely use StructureToPtr here so write it our own
// baseAddr.WriteValue(ref offset, ItemType.UInt16, value.ItemType);
// baseAddr.WriteValue(ref offset, ItemType.UInt32, (uint)value.ItemList.Length);
// baseAddr.WriteValue(ref offset, ItemType.UInt32, value.CurrentIndex);
// baseAddr.WriteValue(ref offset, ItemType.UInt32, value.DefaultIndex);
// foreach (var item in value.ItemList)
// {
// baseAddr.WriteValue(ref offset, value.ItemType, item);
// }
// memoryManager.Unlock(_hContainer);
// }
// }
// void SetRangeValue(TW_RANGE value, IMemoryManager memoryManager)
// {
// if (value == null) { throw new ArgumentNullException("value"); }
// ContainerType = ContainerType.Range;
// void SetRangeValue(TW_RANGE value, IMemoryManager memoryManager)
// {
// if (value == null) { throw new ArgumentNullException("value"); }
// ContainerType = ContainerType.Range;
// // since range value can only house UInt32 we will not allow type size > 4
// if (TypeExtensions.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TW_RANGE")); }
// // since range value can only house UInt32 we will not allow type size > 4
// if (TypeExtensions.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TW_RANGE")); }
// _hContainer = memoryManager.Allocate((uint)Marshal.SizeOf(value));
// if (_hContainer != IntPtr.Zero)
// {
// Marshal.StructureToPtr(value, _hContainer, false);
// }
// }
// _hContainer = memoryManager.Allocate((uint)Marshal.SizeOf(value));
// if (_hContainer != IntPtr.Zero)
// {
// Marshal.StructureToPtr(value, _hContainer, false);
// }
// }
// void SetArrayValue(TW_ARRAY value, IMemoryManager memoryManager)
// {
// if (value == null) { throw new ArgumentNullException("value"); }
// ContainerType = ContainerType.Array;
// void SetArrayValue(TW_ARRAY value, IMemoryManager memoryManager)
// {
// if (value == null) { throw new ArgumentNullException("value"); }
// ContainerType = ContainerType.Array;
// Int32 valueSize = 6 + value.ItemList.Length * TypeExtensions.GetItemTypeSize(value.ItemType);
// Int32 valueSize = 6 + value.ItemList.Length * TypeExtensions.GetItemTypeSize(value.ItemType);
// int offset = 0;
// _hContainer = memoryManager.Allocate((uint)valueSize);
// if (_hContainer != IntPtr.Zero)
// {
// IntPtr baseAddr = memoryManager.Lock(_hContainer);
// int offset = 0;
// _hContainer = memoryManager.Allocate((uint)valueSize);
// if (_hContainer != IntPtr.Zero)
// {
// IntPtr baseAddr = memoryManager.Lock(_hContainer);
// // can't safely use StructureToPtr here so write it our own
// baseAddr.WriteValue(ref offset, ItemType.UInt16, value.ItemType);
// baseAddr.WriteValue(ref offset, ItemType.UInt32, (uint)value.ItemList.Length);
// foreach (var item in value.ItemList)
// {
// baseAddr.WriteValue(ref offset, value.ItemType, item);
// }
// memoryManager.Unlock(_hContainer);
// }
// }
// // can't safely use StructureToPtr here so write it our own
// baseAddr.WriteValue(ref offset, ItemType.UInt16, value.ItemType);
// baseAddr.WriteValue(ref offset, ItemType.UInt32, (uint)value.ItemList.Length);
// foreach (var item in value.ItemList)
// {
// baseAddr.WriteValue(ref offset, value.ItemType, item);
// }
// memoryManager.Unlock(_hContainer);
// }
// }
// #endregion
// #endregion
// #region IDisposable Members
// #region IDisposable Members
// /// <summary>
// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
// /// </summary>
// public void Dispose()
// {
// Dispose(true);
// GC.SuppressFinalize(this);
// }
// /// <summary>
// /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
// /// </summary>
// public void Dispose()
// {
// Dispose(true);
// GC.SuppressFinalize(this);
// }
// void Dispose(bool disposing)
// {
// if (disposing) { }
// if (_hContainer != IntPtr.Zero)
// {
// PlatformInfo.Current.MemoryManager.Free(_hContainer);
// _hContainer = IntPtr.Zero;
// }
// }
// void Dispose(bool disposing)
// {
// if (disposing) { }
// if (_hContainer != IntPtr.Zero)
// {
// PlatformInfo.Current.MemoryManager.Free(_hContainer);
// _hContainer = IntPtr.Zero;
// }
// }
// /// <summary>
// /// Finalizes an instance of the <see cref="TW_CAPABILITY"/> class.
// /// </summary>
// ~TW_CAPABILITY()
// {
// Dispose(false);
// }
// #endregion
// /// <summary>
// /// Finalizes an instance of the <see cref="TW_CAPABILITY"/> class.
// /// </summary>
// ~TW_CAPABILITY()
// {
// Dispose(false);
// }
// #endregion
// }
}
/// <summary>
/// Embedded in the <see cref="TW_CIECOLOR"/> structure;
@@ -976,7 +976,7 @@ namespace NTwain.Data
// public TW_FIX32[] Samples { get { return _samples; } }
// }
/// <summary>
/// Provides information about the Event that was raised by the Source. The Source should only fill
/// in those fields applicable to the Event. The Application must only read those fields applicable to
@@ -1164,7 +1164,7 @@ namespace NTwain.Data
// /// </summary>
// internal const int ItemOffset = 14;
// }
// /// <summary>
// /// This structure is used to pass specific information between the data source and the application
@@ -2229,7 +2229,7 @@ namespace NTwain.Data
/// </summary>
public uint ReceiveSize { get => _ReceiveSize; }
}
/// <summary>
/// Provides entry points required by TWAIN 2.0 Applications and Sources.
/// </summary>

View File

@@ -0,0 +1,171 @@
using NTwain.Data;
using NTwain.Internals;
namespace NTwain.Triplets
{
/// <summary>
/// Represents <see cref="DataArgumentType.Capability"/>.
/// </summary>
public sealed class Capability : BaseTriplet
{
internal Capability(TwainSession session) : base(session) { }
/// <summary>
/// Capability triplet call with custom DAT and message.
/// </summary>
/// <param name="DAT"></param>
/// <param name="message"></param>
/// <param name="capability"></param>
/// <returns></returns>
public ReturnCode Custom(DataArgumentType DAT, Message message, ref TW_CAPABILITY capability)
{
if (Is32Bit)
{
if (IsWin)
return NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DAT, message, ref capability);
if (IsLinux)
return NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DAT, message, ref capability);
if (IsMac)
return NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DAT, message, ref capability);
}
if (IsWin)
return NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DAT, message, ref capability);
if (IsLinux)
return NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DAT, message, ref capability);
if (IsMac)
return NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DAT, message, ref capability);
return ReturnCode.Failure;
}
/// <summary>
/// Returns the Sources Current, Default and Available Values for a specified capability.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode Get(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.Get, ref capability);
}
/// <summary>
/// Returns the Sources Current Value for the specified capability.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetCurrent(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.GetCurrent, ref capability);
}
/// <summary>
/// Returns the Sources Default Value. This is the Sources preferred default value.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetDefault(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.GetDefault, ref capability);
}
/// <summary>
/// Returns help text suitable for use in a GUI; for instance: "Specify the amount of detail in an
/// image. Higher values result in more detail." for ICapXRESOLUTION.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetHelp(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.GetHelp, ref capability);
}
/// <summary>
/// Returns a label suitable for use in a GUI, for instance "Resolution:"
/// for ICapXRESOLUTION.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetLabel(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.GetLabel, ref capability);
}
/// <summary>
/// Return all of the labels for a capability of type <see cref="TW_ARRAY"/> or <see cref="TW_ENUMERATION"/>, for example
/// "US Letter" for ICapSupportedSizes TWSS_USLETTER.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode GetLabelEnum(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.GetLabelEnum, ref capability);
}
/// <summary>
/// Returns the Sources support status of this capability.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode QuerySupport(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.QuerySupport, ref capability);
}
/// <summary>
/// Change the Current Value of the specified capability back to its power-on value and return the
/// new Current Value.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode Reset(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.Reset, ref capability);
}
/// <summary>
/// This command resets all of the current values and constraints to their defaults for all of the
/// negotiable capabilities supported by the driver.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode ResetAll(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.ResetAll, ref capability);
}
/// <summary>
/// Changes the Current Value(s) and Available Values of the specified capability to those specified
/// by the application. As of TWAIN 2.2 this only modifies the Current Value of the specified capability, constraints cannot be
/// changed with this.
/// Current Values are set when the container is a <see cref="TW_ONEVALUE"/> or <see cref="TW_ARRAY"/>. Available and
/// Current Values are set when the container is a <see cref="TW_ENUMERATION"/> or <see cref="TW_RANGE"/>.
/// </summary>
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode Set(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.Set, ref capability);
}
/// <summary>
/// Changes the Current Value(s) and Available Value(s) of the specified capability to those specified
/// by the application.
/// </summary>
/// Current Values are set when the container is a <see cref="TW_ONEVALUE"/> or <see cref="TW_ARRAY"/>. Available and
/// Current Values are set when the container is a <see cref="TW_ENUMERATION"/> or <see cref="TW_RANGE"/>.
/// <param name="capability">The capability.</param>
/// <returns></returns>
public ReturnCode SetConstraint(ref TW_CAPABILITY capability)
{
return Custom(DataArgumentType.Capability, Message.SetConstraint, ref capability);
}
}
}

View File

@@ -51,6 +51,12 @@ namespace NTwain.Triplets
CustomDSData _custDSData;
internal CustomDSData CustomDSData => _custDSData ?? (_custDSData = new CustomDSData(Session));
Capability _caps;
/// <summary>
/// Gets the operations defined for DAT_CAPABILITY.
/// </summary>
public Capability Capability => _caps ?? (_caps = new Capability(Session));
PassThru _passThru;
/// <summary>
/// Gets the operations defined for DAT_PASSTHRU.

View File

@@ -36,15 +36,15 @@ namespace NTwain.Triplets
Message msg,
ref TW_AUDIOINFO data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmLinux32(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
// DataArgumentType dat,
// Message msg,
// ref TWCapability data);
[DllImport(LinuxDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmLinux32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref TW_CAPABILITY data);
[DllImport(LinuxDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmLinux32(
[In, Out]TW_IDENTITY origin,

View File

@@ -36,14 +36,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_AUDIOINFO data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmLinux64(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
// DataArgumentType dat,
// Message msg,
// ref TWCapability data);
[DllImport(LinuxDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmLinux64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref TW_CAPABILITY data);
[DllImport(LinuxDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmLinux64(

View File

@@ -36,14 +36,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_AUDIOINFO data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmMac32(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
// DataArgumentType dat,
// Message msg,
// ref TWCapability data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref TW_CAPABILITY data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac32(

View File

@@ -9,7 +9,7 @@ namespace NTwain.Triplets
{
static partial class NativeMethods
{
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -18,7 +18,7 @@ namespace NTwain.Triplets
Message msg,
ref IntPtr data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -27,7 +27,7 @@ namespace NTwain.Triplets
Message msg,
ref DataGroups data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -36,16 +36,16 @@ namespace NTwain.Triplets
Message msg,
ref TW_AUDIOINFO data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmMac64(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
// DataArgumentType dat,
// Message msg,
// ref TWCapability data);
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref TW_CAPABILITY data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -54,7 +54,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_CUSTOMDSDATA data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -63,7 +63,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_DEVICEEVENT data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -72,7 +72,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_CALLBACK data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -81,7 +81,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_CALLBACK2 data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
IntPtr zero,
@@ -90,7 +90,7 @@ namespace NTwain.Triplets
Message msg,
[In, Out]TW_ENTRYPOINT data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -99,7 +99,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_EVENT data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -108,7 +108,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_FILESYSTEM data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
IntPtr zero,
@@ -117,7 +117,7 @@ namespace NTwain.Triplets
Message msg,
[In, Out]TW_IDENTITY data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -126,7 +126,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_PASSTHRU data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -135,7 +135,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_PENDINGXFERS data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -144,7 +144,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_SETUPFILEXFER data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -153,7 +153,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_SETUPMEMXFER data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -162,7 +162,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_STATUSUTF8 data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -171,7 +171,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_USERINTERFACE data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -180,7 +180,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_CIECOLOR data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -189,7 +189,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_EXTIMAGEINFO data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -207,7 +207,7 @@ namespace NTwain.Triplets
// Message msg,
// ref TWGrayResponse data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -216,7 +216,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_IMAGEINFO data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -225,7 +225,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_IMAGELAYOUT data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -234,7 +234,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_IMAGEMEMXFER data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -243,7 +243,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_JPEGCOMPRESSION data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -261,7 +261,7 @@ namespace NTwain.Triplets
// Message msg,
// ref TWRgbResponse data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
@@ -270,7 +270,7 @@ namespace NTwain.Triplets
Message msg,
ref TW_STATUS data);
[DllImport(Mac32Dll, EntryPoint = EntryName)]
[DllImport(Mac64Dll, EntryPoint = EntryName)]
public static extern ReturnCode DsmMac64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,

View File

@@ -36,14 +36,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_AUDIOINFO data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmWin32(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
// DataArgumentType dat,
// Message msg,
// ref TWCapability data);
[DllImport(WinDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref TW_CAPABILITY data);
[DllImport(WinDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin32(

View File

@@ -36,14 +36,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_AUDIOINFO data);
//[DllImport(DSM.WinDsmDll, EntryPoint = DSM.EntryName)]
//public static extern ReturnCode DsmWin64(
// [In, Out]TW_IDENTITY origin,
// [In, Out]TW_IDENTITY destination,
// DataGroups dg,
// DataArgumentType dat,
// Message msg,
// ref TWCapability data);
[DllImport(WinDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin64(
[In, Out]TW_IDENTITY origin,
[In, Out]TW_IDENTITY destination,
DataGroups dg,
DataArgumentType dat,
Message msg,
ref TW_CAPABILITY data);
[DllImport(WinDll, EntryPoint = EntryName)]
public static extern ReturnCode DsmWin64(