mirror of
https://github.com/soukoku/ntwain.git
synced 2025-07-15 19:10:32 +08:00
I just love reorganizing.
This commit is contained in:
parent
306a67f7a2
commit
890e5680be
@ -1,8 +1,8 @@
|
||||
using NTwain;
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace SampleConsole
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using NTwain;
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace WinForm32
|
||||
{
|
||||
|
@ -1,92 +1,123 @@
|
||||
using System;
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
static class OSXLegacyDSM
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods for /System/Library/Frameworks/framework/TWAIN.
|
||||
/// </summary>
|
||||
public static class OSXLegacyDSM
|
||||
{
|
||||
const string DsmName = "/System/Library/Frameworks/framework/TWAIN";
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref IntPtr hwnd
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_IDENTITY_MACOSX twidentity
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUS twstatus
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUS twstatus
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUSUTF8 twstatusutf8
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_ENTRYPOINT twentrypoint
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_DEVICEEVENT twdeviceevent
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CUSTOMDSDATA twcustomedsdata
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CALLBACK twcallback
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CALLBACK2 twcallback
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref DG xfergroup
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_USERINTERFACE userinterface
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_EVENT evt
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_PENDINGXFERS pendingxfers
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_SETUPMEMXFER memxfer
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_SETUPFILEXFER filexfer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,92 +1,123 @@
|
||||
using System;
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
static class OSXNewDSM
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods for /Library/Frameworks/TWAINDSM.framework/TWAINDSM.
|
||||
/// </summary>
|
||||
public static class OSXNewDSM
|
||||
{
|
||||
const string DsmName = "/Library/Frameworks/TWAINDSM.framework/TWAINDSM";
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref IntPtr hwnd
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_IDENTITY_MACOSX twidentity
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUS twstatus
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUS twstatus
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUSUTF8 twstatusutf8
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_ENTRYPOINT twentrypoint
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_DEVICEEVENT twdeviceevent
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CUSTOMDSDATA twcustomedsdata
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CALLBACK twcallback
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CALLBACK2 twcallback
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref DG xfergroup
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_USERINTERFACE userinterface
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_EVENT evt
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_PENDINGXFERS pendingxfers
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_SETUPMEMXFER memxfer
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_MACOSX origin, ref TW_IDENTITY_MACOSX dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_SETUPFILEXFER filexfer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
7
src/NTwain/DSM/Readme.md
Normal file
7
src/NTwain/DSM/Readme.md
Normal file
@ -0,0 +1,7 @@
|
||||
This contains the pinvoke methods for the DSM entry.
|
||||
This is the lowest API level of the lib and should not
|
||||
be used directly unless you know what you're doing.
|
||||
|
||||
A higher level abstraction such as the ones in the
|
||||
Triplets namespace or the TwainSession object
|
||||
would be easier to use.
|
@ -1,92 +1,123 @@
|
||||
using System;
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
static class WinLegacyDSM
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods for twain_32.dll.
|
||||
/// </summary>
|
||||
public static class WinLegacyDSM
|
||||
{
|
||||
const string DsmName = "twain_32.dll";
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref IntPtr hwnd
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_IDENTITY_LEGACY twidentity
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUS twstatus
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUS twstatus
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUSUTF8 twstatusutf8
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_ENTRYPOINT twentrypoint
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_DEVICEEVENT twdeviceevent
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CUSTOMDSDATA twcustomedsdata
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CALLBACK twcallback
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CALLBACK2 twcallback
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref DG xfergroup
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_USERINTERFACE userinterface
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_EVENT evt
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_PENDINGXFERS pendingxfers
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_SETUPMEMXFER memxfer
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_SETUPFILEXFER filexfer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,92 +1,123 @@
|
||||
using System;
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.DSM
|
||||
{
|
||||
static class WinNewDSM
|
||||
/// <summary>
|
||||
/// Low-level pinvoke methods for twaindsm.dll.
|
||||
/// </summary>
|
||||
public static class WinNewDSM
|
||||
{
|
||||
const string DsmName = "twaindsm.dll";
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref IntPtr hwnd
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_IDENTITY_LEGACY twidentity
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUS twstatus
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUS twstatus
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_STATUSUTF8 twstatusutf8
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, IntPtr dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_ENTRYPOINT twentrypoint
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_DEVICEEVENT twdeviceevent
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CUSTOMDSDATA twcustomedsdata
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CALLBACK twcallback
|
||||
);
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_CALLBACK2 twcallback
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref DG xfergroup
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
internal static extern ushort DSM_Entry
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_USERINTERFACE userinterface
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_EVENT evt
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_PENDINGXFERS pendingxfers
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_SETUPMEMXFER memxfer
|
||||
);
|
||||
|
||||
[DllImport(DsmName, CharSet = CharSet.Ansi)]
|
||||
public static extern ushort DSM_Entry
|
||||
(
|
||||
ref TW_IDENTITY_LEGACY origin, ref TW_IDENTITY_LEGACY dest,
|
||||
DG dg, DAT dat, MSG msg, ref TW_SETUPFILEXFER filexfer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
11
src/NTwain/Data/README.md
Normal file
11
src/NTwain/Data/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
This namespace contains types and utilities that were modified
|
||||
from the [twaincs project](https://github.com/twain/twain-cs).
|
||||
|
||||
Version initially used is 2.5.0.0.
|
||||
|
||||
I just couldn't trust myself with making correct struct definitions
|
||||
so used those instead.
|
||||
|
||||
The TWAINH.cs file are minimally modified so they could be updated
|
||||
easily should I need to. Most modifications are added in
|
||||
TWAINH_EXTRAS.cs.
|
@ -46,7 +46,7 @@ using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace TWAINWorkingGroup
|
||||
namespace NTwain.Data
|
||||
{
|
||||
///// <summary>
|
||||
///// This file contains content gleaned from version 2.4 of the C/C++ H
|
@ -4,9 +4,9 @@ using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace TWAINWorkingGroup
|
||||
namespace NTwain.Data
|
||||
{
|
||||
// this contains my additions under the TWAINWorkingGroup namespace
|
||||
// this contains my additions
|
||||
// that makes some twain types easier to work with.
|
||||
|
||||
/// <summary>
|
@ -1,15 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<PackageId>NTwain</PackageId>
|
||||
<Description>Library containing the TWAIN API for dotnet.</Description>
|
||||
<TargetFrameworks>net6.0;net462;</TargetFrameworks>
|
||||
<PropertyGroup>
|
||||
<PackageId>NTwain</PackageId>
|
||||
<Description>Library containing the TWAIN API for dotnet.</Description>
|
||||
<TargetFrameworks>net6.0;net6.0-windows;net462;</TargetFrameworks>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'net462' OR '$(TargetFramework)' == 'net6.0-windows'">
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -41,6 +41,7 @@
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
///////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
@ -1,4 +0,0 @@
|
||||
This namespace contains types and utilities that were modified
|
||||
from the [twaincs project](https://github.com/twain/twain-cs).
|
||||
|
||||
Version initially used is 2.5.0.0.
|
@ -1,5 +1,5 @@
|
||||
using NTwain.DSM;
|
||||
using TWAINWorkingGroup;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
@ -8,11 +8,6 @@ namespace NTwain.Triplets.ControlDATs
|
||||
/// </summary>
|
||||
public class Callback
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the callback function.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS RegisterCallback(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_CALLBACK data)
|
||||
{
|
||||
var rc = STS.FAILURE;
|
||||
|
@ -1,5 +1,5 @@
|
||||
using NTwain.DSM;
|
||||
using TWAINWorkingGroup;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
@ -8,11 +8,6 @@ namespace NTwain.Triplets.ControlDATs
|
||||
/// </summary>
|
||||
public class Callback2
|
||||
{
|
||||
/// <summary>
|
||||
/// Registers the callback function.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS RegisterCallback(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_CALLBACK2 data)
|
||||
{
|
||||
var rc = STS.FAILURE;
|
||||
|
@ -1,5 +1,5 @@
|
||||
using NTwain.DSM;
|
||||
using TWAINWorkingGroup;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
@ -8,22 +8,12 @@ namespace NTwain.Triplets.ControlDATs
|
||||
/// </summary>
|
||||
public class CustomDsData
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads the custom DS data.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS Get(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, out TW_CUSTOMDSDATA data)
|
||||
{
|
||||
data = default;
|
||||
return DoIt(ref app, ref ds, MSG.GET, ref data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the custom DS data.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS Set(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_CUSTOMDSDATA data)
|
||||
=> DoIt(ref app, ref ds, MSG.SET, ref data);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
using NTwain.DSM;
|
||||
using TWAINWorkingGroup;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
@ -16,21 +16,16 @@ namespace NTwain.Triplets.ControlDATs
|
||||
public STS Get(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, out TW_DEVICEEVENT data)
|
||||
{
|
||||
data = default;
|
||||
return DoIt(ref app, ref ds, MSG.GET, ref data);
|
||||
}
|
||||
|
||||
static STS DoIt(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, MSG msg, ref TW_DEVICEEVENT data)
|
||||
{
|
||||
var rc = STS.FAILURE;
|
||||
if (TwainPlatform.IsWindows)
|
||||
{
|
||||
if (TwainPlatform.Is32bit && TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)WinLegacyDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
rc = (STS)WinLegacyDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, MSG.GET, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)WinNewDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
rc = (STS)WinNewDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, MSG.GET, ref data);
|
||||
}
|
||||
}
|
||||
else if (TwainPlatform.IsMacOSX)
|
||||
@ -39,11 +34,11 @@ namespace NTwain.Triplets.ControlDATs
|
||||
TW_IDENTITY_MACOSX ds2 = ds;
|
||||
if (TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)OSXLegacyDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
rc = (STS)OSXLegacyDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, MSG.GET, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)OSXNewDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
rc = (STS)OSXNewDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, MSG.GET, ref data);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using NTwain.DSM;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
@ -10,11 +10,6 @@ namespace NTwain.Triplets.ControlDATs
|
||||
/// </summary>
|
||||
public class EntryPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads and opens the DSM.
|
||||
/// </summary>
|
||||
/// <param name="entry"></param>
|
||||
/// <returns></returns>
|
||||
public STS Get(ref TW_IDENTITY_LEGACY app, out TW_ENTRYPOINT_DELEGATES entry)
|
||||
{
|
||||
entry = default;
|
||||
|
41
src/NTwain/Triplets/ControlDATs/Event.cs
Normal file
41
src/NTwain/Triplets/ControlDATs/Event.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains calls used with <see cref="DG.CONTROL"/> and <see cref="DAT.EVENT"/>.
|
||||
/// </summary>
|
||||
public class Event
|
||||
{
|
||||
public STS ProcessEvent(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_EVENT data)
|
||||
{
|
||||
var rc = STS.FAILURE;
|
||||
if (TwainPlatform.IsWindows)
|
||||
{
|
||||
if (TwainPlatform.Is32bit && TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)WinLegacyDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, MSG.PROCESSEVENT, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)WinNewDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, MSG.PROCESSEVENT, ref data);
|
||||
}
|
||||
}
|
||||
else if (TwainPlatform.IsMacOSX)
|
||||
{
|
||||
TW_IDENTITY_MACOSX app2 = app;
|
||||
TW_IDENTITY_MACOSX ds2 = ds;
|
||||
if (TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)OSXLegacyDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, MSG.PROCESSEVENT, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)OSXNewDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, MSG.PROCESSEVENT, ref data);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using NTwain.DSM;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
using System;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
@ -9,18 +9,9 @@ namespace NTwain.Triplets.ControlDATs
|
||||
/// </summary>
|
||||
public class Identity
|
||||
{
|
||||
/// <summary>
|
||||
/// Loads and opens the specified data source.
|
||||
/// </summary>
|
||||
/// <param name="ds"></param>
|
||||
/// <returns></returns>
|
||||
public STS OpenDS(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds)
|
||||
=> DoIt(ref app, MSG.OPENDS, ref ds);
|
||||
|
||||
/// <summary>
|
||||
/// Closes the currently open data source.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public STS CloseDS(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds)
|
||||
=> DoIt(ref app, MSG.CLOSEDS, ref ds);
|
||||
|
||||
@ -35,11 +26,6 @@ namespace NTwain.Triplets.ControlDATs
|
||||
return DoIt(ref app, MSG.USERSELECT, ref ds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default data source.
|
||||
/// </summary>
|
||||
/// <param name="ds"></param>
|
||||
/// <returns></returns>
|
||||
public STS GetDefault(ref TW_IDENTITY_LEGACY app, out TW_IDENTITY_LEGACY ds)
|
||||
{
|
||||
ds = default;
|
||||
|
@ -1,6 +1,6 @@
|
||||
using NTwain.DSM;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
using System;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
|
51
src/NTwain/Triplets/ControlDATs/PendingXfers.cs
Normal file
51
src/NTwain/Triplets/ControlDATs/PendingXfers.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains calls used with <see cref="DG.CONTROL"/> and <see cref="DAT.PENDINGXFERS"/>.
|
||||
/// </summary>
|
||||
public class PendingXfers
|
||||
{
|
||||
public STS EndXfer(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_PENDINGXFERS data)
|
||||
=> DoIt(ref app, ref ds, MSG.ENDXFER, ref data);
|
||||
public STS Get(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_PENDINGXFERS data)
|
||||
=> DoIt(ref app, ref ds, MSG.GET, ref data);
|
||||
public STS Reset(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_PENDINGXFERS data)
|
||||
=> DoIt(ref app, ref ds, MSG.RESET, ref data);
|
||||
public STS StopFeeder(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_PENDINGXFERS data)
|
||||
=> DoIt(ref app, ref ds, MSG.STOPFEEDER, ref data);
|
||||
|
||||
|
||||
static STS DoIt(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, MSG msg, ref TW_PENDINGXFERS data)
|
||||
{
|
||||
var rc = STS.FAILURE;
|
||||
if (TwainPlatform.IsWindows)
|
||||
{
|
||||
if (TwainPlatform.Is32bit && TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)WinLegacyDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)WinNewDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
}
|
||||
else if (TwainPlatform.IsMacOSX)
|
||||
{
|
||||
TW_IDENTITY_MACOSX app2 = app;
|
||||
TW_IDENTITY_MACOSX ds2 = ds;
|
||||
if (TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)OSXLegacyDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)OSXNewDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
51
src/NTwain/Triplets/ControlDATs/SetupFileXfer.cs
Normal file
51
src/NTwain/Triplets/ControlDATs/SetupFileXfer.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains calls used with <see cref="DG.SetupMemXfer"/> and <see cref="DAT.SETUPFILEXFER"/>.
|
||||
/// </summary>
|
||||
public class SetupFileXfer
|
||||
{
|
||||
public STS Get(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_SETUPFILEXFER data)
|
||||
=> DoIt(ref app, ref ds, MSG.GET, ref data);
|
||||
public STS Set(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_SETUPFILEXFER data)
|
||||
=> DoIt(ref app, ref ds, MSG.SET, ref data);
|
||||
public STS GetDefault(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_SETUPFILEXFER data)
|
||||
=> DoIt(ref app, ref ds, MSG.GETDEFAULT, ref data);
|
||||
public STS Reset(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_SETUPFILEXFER data)
|
||||
=> DoIt(ref app, ref ds, MSG.RESET, ref data);
|
||||
|
||||
|
||||
static STS DoIt(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, MSG msg, ref TW_SETUPFILEXFER data)
|
||||
{
|
||||
var rc = STS.FAILURE;
|
||||
if (TwainPlatform.IsWindows)
|
||||
{
|
||||
if (TwainPlatform.Is32bit && TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)WinLegacyDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)WinNewDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
}
|
||||
else if (TwainPlatform.IsMacOSX)
|
||||
{
|
||||
TW_IDENTITY_MACOSX app2 = app;
|
||||
TW_IDENTITY_MACOSX ds2 = ds;
|
||||
if (TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)OSXLegacyDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)OSXNewDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, msg, ref data);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
41
src/NTwain/Triplets/ControlDATs/SetupMemXfer.cs
Normal file
41
src/NTwain/Triplets/ControlDATs/SetupMemXfer.cs
Normal file
@ -0,0 +1,41 @@
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains calls used with <see cref="DG.SetupMemXfer"/> and <see cref="DAT.SETUPMEMXFER"/>.
|
||||
/// </summary>
|
||||
public class SetupMemXfer
|
||||
{
|
||||
public STS Get(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_SETUPMEMXFER data)
|
||||
{
|
||||
var rc = STS.FAILURE;
|
||||
if (TwainPlatform.IsWindows)
|
||||
{
|
||||
if (TwainPlatform.Is32bit && TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)WinLegacyDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, MSG.GET, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)WinNewDSM.DSM_Entry(ref app, ref ds, DG.CONTROL, DAT.DEVICEEVENT, MSG.GET, ref data);
|
||||
}
|
||||
}
|
||||
else if (TwainPlatform.IsMacOSX)
|
||||
{
|
||||
TW_IDENTITY_MACOSX app2 = app;
|
||||
TW_IDENTITY_MACOSX ds2 = ds;
|
||||
if (TwainPlatform.PreferLegacyDSM)
|
||||
{
|
||||
rc = (STS)OSXLegacyDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, MSG.GET, ref data);
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = (STS)OSXNewDSM.DSM_Entry(ref app2, ref ds2, DG.CONTROL, DAT.DEVICEEVENT, MSG.GET, ref data);
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
using NTwain.DSM;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
using System;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using NTwain.DSM;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
using System;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
|
@ -1,5 +1,5 @@
|
||||
using NTwain.DSM;
|
||||
using TWAINWorkingGroup;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
@ -8,27 +8,12 @@ namespace NTwain.Triplets.ControlDATs
|
||||
/// </summary>
|
||||
public class UserInterface
|
||||
{
|
||||
/// <summary>
|
||||
/// Disables source to bring state down to <see cref="STATE.S4"/>.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS DisableDS(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_USERINTERFACE data)
|
||||
=> DoIt(ref app, ref ds, MSG.DISABLEDS, ref data);
|
||||
|
||||
/// <summary>
|
||||
/// Enables source to bring state up to <see cref="STATE.S5"/>.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS EnableDS(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_USERINTERFACE data)
|
||||
=> DoIt(ref app, ref ds, MSG.ENABLEDS, ref data);
|
||||
|
||||
/// <summary>
|
||||
/// Enables source to bring state up to <see cref="STATE.S5"/>.
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public STS EnableDSUIOnly(ref TW_IDENTITY_LEGACY app, ref TW_IDENTITY_LEGACY ds, ref TW_USERINTERFACE data)
|
||||
=> DoIt(ref app, ref ds, MSG.ENABLEDSUIONLY, ref data);
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
using NTwain.DSM;
|
||||
using TWAINWorkingGroup;
|
||||
using NTwain.Data;
|
||||
using NTwain.DSM;
|
||||
|
||||
namespace NTwain.Triplets.ControlDATs
|
||||
{
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains calls used with <see cref="DG.AUDIO"/>.
|
||||
/// Contains triplet calls starting with <see cref="DG.AUDIO"/>.
|
||||
/// </summary>
|
||||
public class DGAudio
|
||||
public static class DGAudio
|
||||
{
|
||||
}
|
||||
}
|
@ -3,42 +3,35 @@
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains calls used with <see cref="DG.CONTROL"/>.
|
||||
/// Contains triplet calls starting with <see cref="DG.CONTROL"/>.
|
||||
/// </summary>
|
||||
public class DGControl
|
||||
public static class DGControl
|
||||
{
|
||||
private Parent? _parent;
|
||||
public Parent Parent => _parent ??= new Parent();
|
||||
public static readonly Parent Parent = new();
|
||||
|
||||
private EntryPoint? _entryPoint;
|
||||
public EntryPoint EntryPoint => _entryPoint ??= new EntryPoint();
|
||||
public static readonly EntryPoint EntryPoint = new();
|
||||
|
||||
private Identity? _identity;
|
||||
public Identity Identity => _identity ??= new Identity();
|
||||
public static readonly Identity Identity = new();
|
||||
|
||||
private Status? _status;
|
||||
public Status Status => _status ??= new Status();
|
||||
public static readonly Status Status = new();
|
||||
|
||||
private StatusUtf8? _statusUtf8;
|
||||
public StatusUtf8 StatusUtf8 => _statusUtf8 ??= new StatusUtf8();
|
||||
public static readonly StatusUtf8 StatusUtf8 = new();
|
||||
|
||||
private CustomDsData? _customDsData;
|
||||
public CustomDsData CustomDsData => _customDsData ??= new CustomDsData();
|
||||
public static readonly CustomDsData CustomDsData = new();
|
||||
|
||||
private DeviceEvent? _deviceEvent;
|
||||
public DeviceEvent DeviceEvent => _deviceEvent ??= new DeviceEvent();
|
||||
public static readonly DeviceEvent DeviceEvent = new();
|
||||
|
||||
private Callback? _callback;
|
||||
public Callback Callback => _callback ??= new Callback();
|
||||
public static readonly Callback Callback = new();
|
||||
|
||||
private Callback2? _callback2;
|
||||
public Callback2 Callback2 => _callback2 ??= new Callback2();
|
||||
public static readonly Callback2 Callback2 = new();
|
||||
|
||||
private XferGroup? _xferGroup;
|
||||
public XferGroup XferGroup => _xferGroup ??= new XferGroup();
|
||||
public static readonly XferGroup XferGroup = new();
|
||||
|
||||
private UserInterface? _userInterface;
|
||||
public UserInterface UserInterface => _userInterface ??= new UserInterface();
|
||||
public static readonly UserInterface UserInterface = new();
|
||||
|
||||
public static readonly Event Event = new();
|
||||
|
||||
public static readonly PendingXfers PendingXfers = new();
|
||||
|
||||
}
|
||||
}
|
@ -3,9 +3,9 @@
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains calls used with <see cref="DG.IMAGE"/>.
|
||||
/// Contains triplet calls starting with <see cref="DG.IMAGE"/>.
|
||||
/// </summary>
|
||||
public class DGImage
|
||||
public static class DGImage
|
||||
{
|
||||
}
|
||||
}
|
@ -1,9 +1,8 @@
|
||||
All TWAIN operations are done through the a combination of
|
||||
Data Group (DG), Data Argument Type (DAT), and Message (MSG)
|
||||
triplets. Rather than letting consumers of this lib deal
|
||||
with all the combinations themselves and risk passing the
|
||||
wrong thing, all valid triplet combinations are simply
|
||||
made available under this namespace.
|
||||
triplets. Rather than dealing with all the combinations
|
||||
directly and risk passing the wrong thing, all valid triplet
|
||||
combinations are simply made available under this namespace.
|
||||
|
||||
Example:
|
||||
To get the status of the DS, just use the
|
||||
@ -18,5 +17,5 @@ DGControl.Status.Get(...)
|
||||
Only triplets usable by the
|
||||
application-side are defined here.
|
||||
|
||||
Due to the number of things involved, the properties are
|
||||
lazy-loaded until used.
|
||||
These are still low-level calls and TwainSession is the higher
|
||||
level abstraction with some state keeping and other checks for ease of use.
|
||||
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using NTwain.Data;
|
||||
using NTwain.Triplets;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using TWAINWorkingGroup;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
using NTwain.Triplets;
|
||||
using NTwain.Data;
|
||||
using NTwain.Triplets;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
@ -116,22 +116,6 @@ namespace NTwain
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// TWAIN triplet API calls with <see cref="DG.CONTROL"/>.
|
||||
/// </summary>
|
||||
public DGControl DGControl { get; }
|
||||
/// <summary>
|
||||
/// TWAIN triplet API calls with <see cref="DG.IMAGE"/>.
|
||||
/// </summary>
|
||||
public DGImage DGImage { get; }
|
||||
/// <summary>
|
||||
/// TWAIN triplet API calls with <see cref="DG.AUDIO"/>.
|
||||
/// </summary>
|
||||
public DGAudio DGAudio { get; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Fires when <see cref="State"/> changes.
|
||||
/// </summary>
|
||||
|
@ -1,6 +1,6 @@
|
||||
using NTwain.Triplets;
|
||||
using NTwain.Data;
|
||||
using NTwain.Triplets;
|
||||
using System.Collections.Generic;
|
||||
using TWAINWorkingGroup;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
@ -34,6 +34,10 @@ namespace NTwain
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads and opens the specified data source.
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
public void OpenSource(TW_IDENTITY_LEGACY source)
|
||||
{
|
||||
if (DGControl.Identity.OpenDS(ref _appIdentity, ref source) == STS.SUCCESS)
|
||||
@ -44,6 +48,9 @@ namespace NTwain
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Closes the currently open data source.
|
||||
/// </summary>
|
||||
public void CloseSource()
|
||||
{
|
||||
if (DGControl.Identity.CloseDS(ref _appIdentity, ref _currentDS) == STS.SUCCESS)
|
||||
@ -53,8 +60,15 @@ namespace NTwain
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the default data source.
|
||||
/// </summary>
|
||||
/// <param name="source"></param>
|
||||
/// <returns></returns>
|
||||
public STS SetDefaultSource(TW_IDENTITY_LEGACY source)
|
||||
{
|
||||
// TODO: this doesn't work???
|
||||
|
||||
var rc = DGControl.Identity.Set(ref _appIdentity, ref source);
|
||||
if (rc == STS.SUCCESS)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
using NTwain.Triplets;
|
||||
using NTwain.Data;
|
||||
using NTwain.Triplets;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Text;
|
||||
@ -77,10 +78,6 @@ namespace NTwain
|
||||
}
|
||||
};
|
||||
|
||||
DGControl = new DGControl();
|
||||
DGImage = new DGImage();
|
||||
DGAudio = new DGAudio();
|
||||
|
||||
_legacyCallbackDelegate = LegacyCallbackHandler;
|
||||
_osxCallbackDelegate = OSXCallbackHandler;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user