mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Added SetupFileXfer triplets.
This commit is contained in:
88
src/NTwain/Triplets/Control/SetupFileXfer.cs
Normal file
88
src/NTwain/Triplets/Control/SetupFileXfer.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.Internals;
|
||||
|
||||
namespace NTwain.Triplets.Control
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.SetupFileXfer"/>.
|
||||
/// </summary>
|
||||
public sealed class SetupFileXfer : BaseTriplet
|
||||
{
|
||||
internal SetupFileXfer(TwainSession session) : base(session) { }
|
||||
|
||||
ReturnCode DoIt(Message msg, ref TW_SETUPFILEXFER xfer)
|
||||
{
|
||||
if (Is32Bit)
|
||||
{
|
||||
if (IsWin)
|
||||
return NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.SetupFileXfer, msg, ref xfer);
|
||||
if (IsLinux)
|
||||
return NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.SetupFileXfer, msg, ref xfer);
|
||||
if (IsMac)
|
||||
return NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.SetupFileXfer, msg, ref xfer);
|
||||
}
|
||||
|
||||
if (IsWin)
|
||||
return NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.SetupFileXfer, msg, ref xfer);
|
||||
if (IsLinux)
|
||||
return NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.SetupFileXfer, msg, ref xfer);
|
||||
if (IsMac)
|
||||
return NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.SetupFileXfer, msg, ref xfer);
|
||||
|
||||
return ReturnCode.Failure;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns information about the file into which the Source has or will put the acquired image
|
||||
/// or audio data.
|
||||
/// </summary>
|
||||
/// <param name="setupFileXfer">The setup file xfer.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Get(ref TW_SETUPFILEXFER setupFileXfer)
|
||||
{
|
||||
return DoIt(Message.Get, ref setupFileXfer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns information for the default image or audio file.
|
||||
/// </summary>
|
||||
/// <param name="setupFileXfer">The setup file xfer.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode GetDefault(ref TW_SETUPFILEXFER setupFileXfer)
|
||||
{
|
||||
return DoIt(Message.GetDefault, ref setupFileXfer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the current file information to the image or audio default file information and
|
||||
/// returns that default information.
|
||||
/// </summary>
|
||||
/// <param name="setupFileXfer">The setup file xfer.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Reset(ref TW_SETUPFILEXFER setupFileXfer)
|
||||
{
|
||||
return DoIt(Message.Reset, ref setupFileXfer);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the file transfer information for the next file transfer. The application is responsible for
|
||||
/// verifying that the specified file name is valid and that the file either does not currently exist (in
|
||||
/// which case, the Source is to create the file), or that the existing file is available for opening and
|
||||
/// read/write operations. The application should also assure that the file format it is requesting
|
||||
/// can be provided by the Source
|
||||
/// </summary>
|
||||
/// <param name="setupFileXfer">The setup file xfer.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode Set(ref TW_SETUPFILEXFER setupFileXfer)
|
||||
{
|
||||
return DoIt(Message.Set, ref setupFileXfer);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,12 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
public SetupMemXfer SetupMemXfer => _memXfer ?? (_memXfer = new SetupMemXfer(Session));
|
||||
|
||||
SetupFileXfer _fileXfer;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_SETUPFILEXFER.
|
||||
/// </summary>
|
||||
public SetupFileXfer SetupFileXfer => _fileXfer ?? (_fileXfer = new SetupFileXfer(Session));
|
||||
|
||||
FileSystem _fs;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_FILESYSTEM.
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace NTwain
|
||||
var xMech = GetTransferMechs();
|
||||
|
||||
TW_PENDINGXFERS pending = default;
|
||||
var rc = DGControl.PendingXfers.Get(pending);
|
||||
var rc = DGControl.PendingXfers.Get(ref pending);
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
do
|
||||
@@ -122,7 +122,7 @@ namespace NTwain
|
||||
|
||||
if (readyArgs.CancelAll || _disableDSNow)
|
||||
{
|
||||
rc = DGControl.PendingXfers.Reset(pending);
|
||||
rc = DGControl.PendingXfers.Reset(ref pending);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -165,11 +165,11 @@ namespace NTwain
|
||||
if (rc != ReturnCode.Success)// && StopOnTransferError)
|
||||
{
|
||||
// end xfer without setting rc to exit (good/bad?)
|
||||
DGControl.PendingXfers.Reset(pending);
|
||||
DGControl.PendingXfers.Reset(ref pending);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = DGControl.PendingXfers.EndXfer(pending);
|
||||
rc = DGControl.PendingXfers.EndXfer(ref pending);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user