diff --git a/src/NTwain/Data/TwainTypes.cs b/src/NTwain/Data/TwainTypes.cs
index c6a0a06..bdfd05b 100644
--- a/src/NTwain/Data/TwainTypes.cs
+++ b/src/NTwain/Data/TwainTypes.cs
@@ -97,19 +97,19 @@ namespace NTwain.Data
[StructLayout(LayoutKind.Sequential, Pack = 2)]
- partial class TW_CALLBACK
+ partial struct TW_CALLBACK
{
[MarshalAs(UnmanagedType.FunctionPtr)]
- CallbackDelegate _callBackProc;
+ public CallbackDelegate _callBackProc;
TW_UINT32 _refCon;
TW_INT16 _message;
}
[StructLayout(LayoutKind.Sequential, Pack = 2)]
- partial class TW_CALLBACK2
+ partial struct TW_CALLBACK2
{
[MarshalAs(UnmanagedType.FunctionPtr)]
- CallbackDelegate _callBackProc;
+ public CallbackDelegate _callBackProc;
TW_UINTPTR _refCon;
TW_INT16 _message;
}
@@ -131,7 +131,7 @@ namespace NTwain.Data
}
[StructLayout(LayoutKind.Sequential, Pack = 2)]
- partial class TW_CIECOLOR
+ partial struct TW_CIECOLOR
{
TW_UINT16 _colorSpace;
TW_INT16 _lowEndian;
@@ -227,7 +227,7 @@ namespace NTwain.Data
[StructLayout(LayoutKind.Explicit, Pack = 2),
BestFitMapping(false, ThrowOnUnmappableChar = true)]
- partial class TW_FILESYSTEM
+ partial struct TW_FILESYSTEM
{
[FieldOffset(0)]
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = TwainConst.String255)]
diff --git a/src/NTwain/Data/TwainTypesExtended.cs b/src/NTwain/Data/TwainTypesExtended.cs
index a68a58d..a2d6b8c 100644
--- a/src/NTwain/Data/TwainTypesExtended.cs
+++ b/src/NTwain/Data/TwainTypesExtended.cs
@@ -570,68 +570,7 @@ namespace NTwain.Data
public string Name { get { return _name; } }
}
- ///
- /// Used in Callback mechanism for sending messages from the Source to the Application.
- /// Applications version 2.2 or higher must use .
- ///
- partial class TW_CALLBACK
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The callback function’s entry point.
- public TW_CALLBACK(CallbackDelegate callback)
- {
- _callBackProc = callback;
- }
- /////
- ///// An application defined reference constant.
- /////
- /////
- ///// The reference constant.
- /////
- //public uint RefCon { get { return _refCon; } set { _refCon = value; } }
-
- /////
- ///// Initialized to any valid DG_CONTROL / DAT_NULL message.
- /////
- /////
- ///// The message.
- /////
- //public short Message { get { return _message; } set { _message = value; } }
- }
- ///
- /// Used in the Callback mechanism for sending messages from the Source to the Application.
- ///
- partial class TW_CALLBACK2
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The callback function’s entry point.
- public TW_CALLBACK2(CallbackDelegate callback)
- {
- _callBackProc = callback;
- }
-
- /////
- ///// An application defined reference constant. It has a different size on different
- ///// platforms.
- /////
- /////
- ///// The reference constant.
- /////
- //public UIntPtr RefCon { get { return _refCon; } set { _refCon = value; } }
-
- /////
- ///// Initialized to any valid DG_CONTROL / DAT_NULL message.
- /////
- /////
- ///// The message.
- /////
- //public short Message { get { return _message; } set { _message = value; } }
- }
// ///
// /// Used by an application either to get information about, or control the setting of a capability.
@@ -978,7 +917,7 @@ namespace NTwain.Data
// ///
// /// Defines the mapping from an RGB color space device into CIE 1931 (XYZ) color space.
// ///
- // public partial class TW_CIECOLOR
+ // public partial struct TW_CIECOLOR
// {
// internal TW_CIECOLOR() { }
@@ -1442,89 +1381,137 @@ namespace NTwain.Data
public TW_INFO[] Info { get { return _info; } }
}
- // ///
- // /// Provides information about the currently selected device.
- // ///
- // public partial class TW_FILESYSTEM
- // {
- // ///
- // /// The name of the input or source file.
- // ///
- // public string InputName { get { return _inputName; } set { _inputName = value; } }
- // ///
- // /// The result of an operation or the name of a destination file.
- // ///
- // public string OutputName { get { return _outputName; } set { _outputName = value; } }
- // ///
- // /// A pointer to Source specific data used to remember state
- // /// information, such as the current directory.
- // ///
- // public IntPtr Context { get { return _context; } set { _context = value; } }
+ ///
+ /// Provides information about the currently selected device.
+ ///
+ public partial struct TW_FILESYSTEM
+ {
+ ///
+ /// The name of the input or source file.
+ ///
+ public string InputName
+ {
+ get { return _inputName; }
+ set { _inputName = value; }
+ }
+ ///
+ /// The result of an operation or the name of a destination file.
+ ///
+ public string OutputName
+ {
+ get { return _outputName; }
+ set { _outputName = value; }
+ }
+ ///
+ /// A pointer to Source specific data used to remember state
+ /// information, such as the current directory.
+ ///
+ public IntPtr Context
+ {
+ get { return _context; }
+ set { _context = value; }
+ }
- // ///
- // /// When set to TRUE recursively apply the operation. (ex: deletes
- // /// all subdirectories in the directory being deleted; or copies all
- // /// sub-directories in the directory being copied.
- // ///
- // public bool Recursive { get { return _subdirectories == TwainConst.True; } set { _subdirectories = value ? TwainConst.True : TwainConst.False; } }
+ ///
+ /// When set to TRUE recursively apply the operation. (ex: deletes
+ /// all subdirectories in the directory being deleted; or copies all
+ /// sub-directories in the directory being copied.
+ ///
+ public bool Recursive
+ {
+ get { return _subdirectories == TwainConst.True; }
+ set { _subdirectories = value ? TwainConst.True : TwainConst.False; }
+ }
- // ///
- // /// Gets the type of the file.
- // ///
- // ///
- // /// The type of the file.
- // ///
- // public FileType FileType { get { return (FileType)_fileType; } set { _fileType = (int)value; } }
+ ///
+ /// Gets the type of the file.
+ ///
+ ///
+ /// The type of the file.
+ ///
+ public FileType FileType
+ {
+ get { return (FileType)_fileType; }
+ set { _fileType = (int)value; }
+ }
- // ///
- // /// If , total size of media in bytes.
- // /// If , size of image in bytes.
- // ///
- // ///
- // /// The size.
- // ///
- // public uint Size { get { return _size; } set { _size = value; } }
- // ///
- // /// The create date of the file, in the form "YYYY/MM/DD
- // /// HH:mm:SS:sss" where YYYY is the year, MM is the numerical
- // /// month, DD is the numerical day, HH is the hour, mm is the
- // /// minute, SS is the second, and sss is the millisecond.
- // ///
- // public string CreateTimeDate { get { return _createTimeDate; } set { _createTimeDate = value; } }
- // ///
- // /// Last date the file was modified. Same format as .
- // ///
- // public string ModifiedTimeDate { get { return _modifiedTimeDate; } set { _modifiedTimeDate = value; } }
- // ///
- // /// The bytes of free space left on the current device.
- // ///
- // public uint FreeSpace { get { return _freeSpace; } set { _freeSpace = value; } }
- // ///
- // /// An estimate of the amount of space a new image would take
- // /// up, based on image layout, resolution and compression.
- // /// Dividing this value into the FreeSpace will yield the
- // /// approximate number of images that the Device has room for.
- // ///
- // public int NewImageSize { get { return _newImageSize; } set { _newImageSize = value; } }
- // ///
- // /// If applicable, return the number of files on the file system including those in all sub-directories.
- // ///
- // ///
- // /// The number of files.
- // ///
- // public uint NumberOfFiles { get { return _numberOfFiles; } set { _numberOfFiles = value; } }
- // ///
- // /// The number of audio snippets associated with a file of type .
- // ///
- // ///
- // /// The number of snippets.
- // ///
- // public uint NumberOfSnippets { get { return _numberOfSnippets; } set { _numberOfSnippets = value; } }
- // ///
- // /// Used to group cameras (ex: front/rear bitonal, front/rear grayscale...).
- // ///
- // public uint DeviceGroupMask { get { return _deviceGroupMask; } set { _deviceGroupMask = value; } }
- // }
+ ///
+ /// If , total size of media in bytes.
+ /// If , size of image in bytes.
+ ///
+ ///
+ /// The size.
+ ///
+ public uint Size { get { return _size; } set { _size = value; } }
+ ///
+ /// The create date of the file, in the form "YYYY/MM/DD
+ /// HH:mm:SS:sss" where YYYY is the year, MM is the numerical
+ /// month, DD is the numerical day, HH is the hour, mm is the
+ /// minute, SS is the second, and sss is the millisecond.
+ ///
+ public string CreateTimeDate
+ {
+ get { return _createTimeDate; }
+ set { _createTimeDate = value; }
+ }
+ ///
+ /// Last date the file was modified. Same format as .
+ ///
+ public string ModifiedTimeDate
+ {
+ get { return _modifiedTimeDate; }
+ set { _modifiedTimeDate = value; }
+ }
+ ///
+ /// The bytes of free space left on the current device.
+ ///
+ public uint FreeSpace
+ {
+ get { return _freeSpace; }
+ set { _freeSpace = value; }
+ }
+ ///
+ /// An estimate of the amount of space a new image would take
+ /// up, based on image layout, resolution and compression.
+ /// Dividing this value into the FreeSpace will yield the
+ /// approximate number of images that the Device has room for.
+ ///
+ public int NewImageSize
+ {
+ get { return _newImageSize; }
+ set { _newImageSize = value; }
+ }
+ ///
+ /// If applicable, return the number of files on the file system including those in all sub-directories.
+ ///
+ ///
+ /// The number of files.
+ ///
+ public uint NumberOfFiles
+ {
+ get { return _numberOfFiles; }
+ set { _numberOfFiles = value; }
+ }
+ ///
+ /// The number of audio snippets associated with a file of type .
+ ///
+ ///
+ /// The number of snippets.
+ ///
+ public uint NumberOfSnippets
+ {
+ get { return _numberOfSnippets; }
+ set { _numberOfSnippets = value; }
+ }
+ ///
+ /// Used to group cameras (ex: front/rear bitonal, front/rear grayscale...).
+ ///
+ public uint DeviceGroupMask
+ {
+ get { return _deviceGroupMask; }
+ set { _deviceGroupMask = value; }
+ }
+ }
// /////
// ///// This structure is used by the application to specify a set of mapping values to be applied to
@@ -2216,7 +2203,7 @@ namespace NTwain.Data
// /// Translates the contents of Status into a localized UTF8string, with the total number of bytes
// /// in the string.
// ///
- // public sealed partial class TW_STATUSUTF8 : IDisposable
+ // public sealed partial struct TW_STATUSUTF8 : IDisposable
// {
// ///
// /// data received from a previous call.
@@ -2295,18 +2282,49 @@ namespace NTwain.Data
// #endregion
// }
-
+ ///
+ /// Provides identification information about a TWAIN entity. Used to maintain consistent
+ /// communication between entities.
+ ///
public partial struct TW_TWAINDIRECT
{
- //public TW_TWAINDIRECT()
- //{
- // _SizeOf = (uint)Marshal.SizeOf(this);
- //}
+ public TW_TWAINDIRECT(ushort manager, IntPtr send, uint sendSize)
+ {
+ _SizeOf = (uint)Marshal.SizeOf(typeof(TW_TWAINDIRECT));
+ _CommunicationManager = manager;
+ _Send = send;
+ _SendSize = sendSize;
+ _Receive = IntPtr.Zero;
+ _ReceiveSize = 0;
+ }
+ ///
+ /// The interpretation of the Send data may be influenced by the communication
+ /// manager that is helping the application connect to the scanner.
+ /// For instance, a task action to “scan” may need to be ignored under some
+ /// circumstances.
+ ///
public ushort CommunicationManager { get => _CommunicationManager; }
+ ///
+ /// A handle to data to be sent from the application to the driver. The application
+ /// owns this handle.If there is no data, this field is set to NULL.
+ ///
public IntPtr Send { get => _Send; set => _Send = value; }
+ ///
+ /// The number of bytes in the Send buffer.
+ /// If there is no data this field is set to 0.
+ ///
public uint SendSize { get => _SendSize; set => _SendSize = value; }
+ ///
+ /// A handle to data sent from the driver to the application.
+ /// The driver creates this handle, the application must free it.
+ /// If there is no data this field is set to NULL.
+ ///
public IntPtr Receive { get => _Receive; }
+ ///
+ /// The number of bytes in the Receive buffer, set by the driver.
+ /// If there is no data this field is set to 0.
+ ///
public uint ReceiveSize { get => _ReceiveSize; }
}