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
+1 -1
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;
+6 -6
View File
@@ -570,11 +570,11 @@ 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
// {
/// <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>
@@ -824,7 +824,7 @@ namespace NTwain.Data
// }
// #endregion
// }
}
/// <summary>
/// Embedded in the <see cref="TW_CIECOLOR"/> structure;
@@ -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 Source’s 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 Source’s 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 Source’s Default Value. This is the Source’s 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 Source’s 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);
}
}
}
+6
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.
+8 -8
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 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(
+8 -8
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(
+8 -8
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(
+35 -35
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,
+8 -8
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(
+8 -8
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(