Add method to set filexfer options on xferready event.

This commit is contained in:
Eugene Wang
2025-02-15 18:39:13 -05:00
parent b2fe1c1bcd
commit e3dfa8f4dd
4 changed files with 91 additions and 70 deletions

View File

@@ -2,7 +2,7 @@
<PropertyGroup> <PropertyGroup>
<!--change these in each release--> <!--change these in each release-->
<VersionPrefix>4.0.0.0</VersionPrefix> <VersionPrefix>4.0.0.0</VersionPrefix>
<VersionSuffix>alpha.5</VersionSuffix> <VersionSuffix>alpha.6</VersionSuffix>
<!--keep it the same until major # changes--> <!--keep it the same until major # changes-->
<AssemblyVersion>4.0.0.0</AssemblyVersion> <AssemblyVersion>4.0.0.0</AssemblyVersion>

View File

@@ -8,11 +8,11 @@ namespace NTwain
/// </summary> /// </summary>
public class TransferReadyEventArgs : EventArgs public class TransferReadyEventArgs : EventArgs
{ {
public TransferReadyEventArgs(TWSX imgXferMech, TWSX audXferMech, int pendingCount, TWEJ endOfJobFlag) public TransferReadyEventArgs(TwainAppSession twain, TWSX imgXferMech, TWSX audXferMech, int pendingCount, TWEJ endOfJobFlag)
{ {
_twain = twain;
ImgXferMech = imgXferMech; ImgXferMech = imgXferMech;
AudXferMech = audXferMech; AudXferMech = audXferMech;
//_twain = twain;
PendingCount = pendingCount; PendingCount = pendingCount;
EndOfJobFlag = endOfJobFlag; EndOfJobFlag = endOfJobFlag;
} }
@@ -43,9 +43,20 @@ namespace NTwain
/// </summary> /// </summary>
public int PendingCount { get; private set; } public int PendingCount { get; private set; }
//TW_IMAGEINFO? _imgInfo; private readonly TwainAppSession _twain;
//private readonly TwainAppSession _twain;
/// <summary>
/// If the transfer mech is file-related,
/// setup the file transfer options here.
/// </summary>
/// <param name="fileXfer"></param>
/// <returns></returns>
public STS SetupFileTransfer(ref TW_SETUPFILEXFER fileXfer)
{
return _twain.SetFileXfer(ref fileXfer);
}
//TW_IMAGEINFO? _imgInfo;
///// <summary> ///// <summary>
///// Gets the tentative image information for the current transfer if applicable. ///// Gets the tentative image information for the current transfer if applicable.
///// This may differ from the final image depending on the transfer mode used (mostly when doing mem xfer). ///// This may differ from the final image depending on the transfer mode used (mostly when doing mem xfer).

View File

@@ -3,8 +3,8 @@ using NTwain.Triplets;
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace NTwain namespace NTwain;
{
// this file contains property and event definitions // this file contains property and event definitions
partial class TwainAppSession partial class TwainAppSession
@@ -16,7 +16,7 @@ namespace NTwain
{ {
get => _appIdentity; get => _appIdentity;
} }
TW_IDENTITY_LEGACY _appIdentity; internal TW_IDENTITY_LEGACY _appIdentity;
/// <summary> /// <summary>
/// Gets the current (opened) data source. /// Gets the current (opened) data source.
@@ -34,7 +34,7 @@ namespace NTwain
catch { } catch { }
} }
} }
TW_IDENTITY_LEGACY _currentDS; internal TW_IDENTITY_LEGACY _currentDS;
/// <summary> /// <summary>
/// Gets/sets the default data source. /// Gets/sets the default data source.
@@ -167,4 +167,3 @@ namespace NTwain
/// </summary> /// </summary>
public event TwainEventDelegate<TransferredEventArgs>? Transferred; public event TwainEventDelegate<TransferredEventArgs>? Transferred;
} }
}

View File

@@ -23,6 +23,17 @@ namespace NTwain
return WrapInSTS(DGImage.ExtImageInfo.Get(ref _appIdentity, ref _currentDS, ref container)); return WrapInSTS(DGImage.ExtImageInfo.Get(ref _appIdentity, ref _currentDS, ref container));
} }
/// <summary>
/// Can only be called in state 6, so it's here and only exposed
/// in transfer ready event.
/// </summary>
/// <param name="settings"></param>
/// <returns></returns>
internal STS SetFileXfer(ref TW_SETUPFILEXFER settings)
{
return WrapInSTS(DGControl.SetupFileXfer.Set(ref _appIdentity, ref _currentDS, ref settings));
}
/// <summary> /// <summary>
/// Start the transfer loop. /// Start the transfer loop.
@@ -66,7 +77,7 @@ namespace NTwain
{ {
do do
{ {
var readyArgs = new TransferReadyEventArgs(imgXferMech, audXferMech, pending.Count, (TWEJ)pending.EOJ); var readyArgs = new TransferReadyEventArgs(this, imgXferMech, audXferMech, pending.Count, (TWEJ)pending.EOJ);
try try
{ {
TransferReady?.Invoke(this, readyArgs); TransferReady?.Invoke(this, readyArgs);