mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-24 08:47:06 +08:00
Added device event.
This commit is contained in:
@@ -12,19 +12,20 @@ namespace NTwain.Triplets
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads and opens the specified data source.
|
||||
/// Loads the custom DS data.
|
||||
/// </summary>
|
||||
/// <param name="ds"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS Get(ref TW_CUSTOMDSDATA data)
|
||||
public STS Get(out TW_CUSTOMDSDATA data)
|
||||
{
|
||||
data = default;
|
||||
return DoIt(MSG.GET, ref data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the customs data.
|
||||
/// Sets the custom DS data.
|
||||
/// </summary>
|
||||
/// <param name="ds"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS Set(ref TW_CUSTOMDSDATA data)
|
||||
{
|
||||
|
||||
57
src/NTwain/Triplets/DATDeviceEvent.cs
Normal file
57
src/NTwain/Triplets/DATDeviceEvent.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains calls used with <see cref="DG.CONTROL"/> and <see cref="DAT.DEVICEEVENT"/>.
|
||||
/// </summary>
|
||||
public class DATDeviceEvent : TripletBase
|
||||
{
|
||||
public DATDeviceEvent(TwainSession session) : base(session)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the device event detail.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS Get(out TW_DEVICEEVENT data)
|
||||
{
|
||||
data = default;
|
||||
return DoIt(MSG.GET, ref data);
|
||||
}
|
||||
|
||||
STS DoIt(MSG msg, ref TW_DEVICEEVENT data)
|
||||
{
|
||||
var rc = STS.FAILURE;
|
||||
if (TwainPlatform.IsWindows)
|
||||
{
|
||||
var app = Session.AppIdentity;
|
||||
var ds = Session.CurrentSource;
|
||||
if (TwainPlatform.Is32bit && TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)NativeMethods.WindowsTwain32DsmEntryDeviceevent(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)NativeMethods.WindowsTwaindsmDsmEntryDeviceevent(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
}
|
||||
else if (TwainPlatform.IsMacOSX)
|
||||
{
|
||||
TW_IDENTITY_MACOSX app = Session.AppIdentity;
|
||||
TW_IDENTITY_MACOSX ds = Session.CurrentSource;
|
||||
if (TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)NativeMethods.MacosxTwainDsmEntryDeviceevent(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)NativeMethods.MacosxTwaindsmDsmEntryDeviceevent(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,8 +18,9 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="entry"></param>
|
||||
/// <returns></returns>
|
||||
public STS Get(ref TW_ENTRYPOINT_DELEGATES entry)
|
||||
public STS Get(out TW_ENTRYPOINT_DELEGATES entry)
|
||||
{
|
||||
entry = default;
|
||||
TW_ENTRYPOINT rawentry = default;
|
||||
var rc = DoIt(MSG.GET, ref rawentry);
|
||||
if (rc == STS.SUCCESS)
|
||||
|
||||
@@ -34,8 +34,7 @@ namespace NTwain.Triplets
|
||||
// determine memory mgmt routines used
|
||||
if ((((DG)Session.AppIdentity.SupportedGroups) & DG.DSM2) == DG.DSM2)
|
||||
{
|
||||
TW_ENTRYPOINT_DELEGATES entry = default;
|
||||
if (Session.DGControl.EntryPoint.Get(ref entry) == STS.SUCCESS)
|
||||
if (Session.DGControl.EntryPoint.Get(out TW_ENTRYPOINT_DELEGATES entry) == STS.SUCCESS)
|
||||
{
|
||||
Session._entryPoint = entry;
|
||||
}
|
||||
|
||||
@@ -27,5 +27,8 @@
|
||||
private DATCustomDsData? _customDsData;
|
||||
public DATCustomDsData CustomDsData => _customDsData ??= new DATCustomDsData(Session);
|
||||
|
||||
private DATDeviceEvent? _deviceEvent;
|
||||
public DATDeviceEvent DeviceEvent => _deviceEvent ??= new DATDeviceEvent(Session);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -77,8 +77,7 @@ namespace NTwain
|
||||
{
|
||||
get
|
||||
{
|
||||
TW_CUSTOMDSDATA data = default;
|
||||
var sts = DGControl.CustomDsData.Get(ref data);
|
||||
var sts = DGControl.CustomDsData.Get(out TW_CUSTOMDSDATA data);
|
||||
if (sts == STS.SUCCESS)
|
||||
{
|
||||
if (data.hData != IntPtr.Zero && data.InfoLength > 0)
|
||||
|
||||
Reference in New Issue
Block a user