Added twaindirect triplet.

This commit is contained in:
Eugene Wang 2018-11-18 12:36:20 -05:00
parent 1ee5668ff1
commit 5f7fa37459
8 changed files with 107 additions and 0 deletions

View File

@ -0,0 +1,47 @@
using NTwain.Data;
using NTwain.Internals;
using System.Runtime.InteropServices;
namespace NTwain.Triplets.Control
{
/// <summary>
/// Represents <see cref="DataArgumentType.TwainDirect"/>.
/// </summary>
public sealed class TwainDirect : BaseTriplet
{
internal TwainDirect(TwainSession session) : base(session) { }
/// <summary>
/// Sends a TWAIN Direct task from the application to the driver.
/// </summary>
/// <param name="task"></param>
/// <returns></returns>
public ReturnCode SetTask(ref TW_TWAINDIRECT task)
{
if (Is32Bit)
{
if (IsWin)
return NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DataArgumentType.TwainDirect, Message.SetTask, ref task);
if (IsLinux)
return NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DataArgumentType.TwainDirect, Message.SetTask, ref task);
if (IsMac)
return NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DataArgumentType.TwainDirect, Message.SetTask, ref task);
}
if (IsWin)
return NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DataArgumentType.TwainDirect, Message.SetTask, ref task);
if (IsLinux)
return NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DataArgumentType.TwainDirect, Message.SetTask, ref task);
if (IsMac)
return NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32,
DataGroups.Control, DataArgumentType.TwainDirect, Message.SetTask, ref task);
return ReturnCode.Failure;
}
}
}

View File

@ -92,5 +92,11 @@ namespace NTwain.Triplets
/// Gets the operations defined for DAT_METRICS.
/// </summary>
public Metrics Metrics => _metrics ?? (_metrics = new Metrics(Session));
TwainDirect _twDirect;
/// <summary>
/// Gets the operations defined for DAT_TWAINDIRECT.
/// </summary>
public TwainDirect TwainDirect => _twDirect ?? (_twDirect = new TwainDirect(Session));
}
}

View File

@ -288,5 +288,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_METRICS 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_TWAINDIRECT data);
}
}

View File

@ -288,5 +288,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_METRICS 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_TWAINDIRECT data);
}
}

View File

@ -288,5 +288,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_METRICS 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_TWAINDIRECT data);
}
}

View File

@ -288,5 +288,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_METRICS 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_TWAINDIRECT data);
}
}

View File

@ -288,5 +288,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_METRICS 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_TWAINDIRECT data);
}
}

View File

@ -288,5 +288,14 @@ namespace NTwain.Triplets
Message msg,
ref TW_METRICS 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_TWAINDIRECT data);
}
}