mirror of
https://github.com/soukoku/ntwain.git
synced 2025-09-19 01:57:56 +08:00
Fixed some CA violations.
This commit is contained in:
@@ -2351,7 +2351,7 @@ namespace NTwain.Data
|
|||||||
/// uncompressed row in the block to be transferred. An application should
|
/// uncompressed row in the block to be transferred. An application should
|
||||||
/// never allocate a buffer smaller than this.
|
/// never allocate a buffer smaller than this.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int MinBufferSize { get { return (int)_minBufSize; } }
|
public uint MinBufferSize { get { return _minBufSize; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The size of the largest transfer buffer, in bytes, that a Source can fill. If a
|
/// The size of the largest transfer buffer, in bytes, that a Source can fill. If a
|
||||||
/// Source can fill an arbitrarily large buffer, it might set this field to negative 1 to
|
/// Source can fill an arbitrarily large buffer, it might set this field to negative 1 to
|
||||||
@@ -2359,7 +2359,7 @@ namespace NTwain.Data
|
|||||||
/// cord is). Other Sources, such as frame grabbers, cannot fill a buffer larger than
|
/// cord is). Other Sources, such as frame grabbers, cannot fill a buffer larger than
|
||||||
/// a certain size. Allocation of a transfer buffer larger than this value is wasteful.
|
/// a certain size. Allocation of a transfer buffer larger than this value is wasteful.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int MaxBufferSize { get { return (int)_maxBufSize; } }
|
public uint MaxBufferSize { get { return _maxBufSize; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The size of the optimum transfer buffer, in bytes. A smart application will
|
/// The size of the optimum transfer buffer, in bytes. A smart application will
|
||||||
/// allocate transfer buffers of this size, if possible. Buffers of this size will
|
/// allocate transfer buffers of this size, if possible. Buffers of this size will
|
||||||
@@ -2367,7 +2367,7 @@ namespace NTwain.Data
|
|||||||
/// reasonable values in this field. Buffers that are 10’s of kbytes will be easier for
|
/// reasonable values in this field. Buffers that are 10’s of kbytes will be easier for
|
||||||
/// applications to allocate than buffers that are 100’s or 1000’s of kbytes.
|
/// applications to allocate than buffers that are 100’s or 1000’s of kbytes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Preferred { get { return (int)_preferred; } }
|
public uint Preferred { get { return _preferred; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@@ -38,15 +38,23 @@ namespace NTwain
|
|||||||
/// <returns>Handle to the allocated memory.</returns>
|
/// <returns>Handle to the allocated memory.</returns>
|
||||||
public IntPtr Allocate(uint size)
|
public IntPtr Allocate(uint size)
|
||||||
{
|
{
|
||||||
|
IntPtr retVal = IntPtr.Zero;
|
||||||
|
|
||||||
if (_twain2Entry != null && _twain2Entry.AllocateFunction != null)
|
if (_twain2Entry != null && _twain2Entry.AllocateFunction != null)
|
||||||
{
|
{
|
||||||
return _twain2Entry.AllocateFunction(size);
|
retVal = _twain2Entry.AllocateFunction(size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 0x0040 is GPTR
|
// 0x0040 is GPTR
|
||||||
return WinGlobalAlloc(0x0040, new UIntPtr(size));
|
retVal = NativeMethods.WinGlobalAlloc(0x0040, new UIntPtr(size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (retVal == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new OutOfMemoryException("Failed to allocate requested memory.");
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -61,7 +69,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WinGlobalFree(handle);
|
NativeMethods.WinGlobalFree(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +86,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return WinGlobalLock(handle);
|
return NativeMethods.WinGlobalLock(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,26 +102,8 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WinGlobalUnlock(handle);
|
NativeMethods.WinGlobalUnlock(handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region old mem stuff for twain 1.x
|
|
||||||
|
|
||||||
|
|
||||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalAlloc")]
|
|
||||||
static extern IntPtr WinGlobalAlloc(uint uFlags, UIntPtr dwBytes);
|
|
||||||
|
|
||||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalFree")]
|
|
||||||
static extern IntPtr WinGlobalFree(IntPtr hMem);
|
|
||||||
|
|
||||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalLock")]
|
|
||||||
static extern IntPtr WinGlobalLock(IntPtr handle);
|
|
||||||
|
|
||||||
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalUnlock")]
|
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
|
||||||
static extern bool WinGlobalUnlock(IntPtr handle);
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -61,6 +61,7 @@
|
|||||||
<Compile Include="ITwainOperation.cs" />
|
<Compile Include="ITwainOperation.cs" />
|
||||||
<Compile Include="ITwainState.cs" />
|
<Compile Include="ITwainState.cs" />
|
||||||
<Compile Include="MemoryManager.cs" />
|
<Compile Include="MemoryManager.cs" />
|
||||||
|
<Compile Include="NativeMethods.cs" />
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DesignTime>True</DesignTime>
|
<DesignTime>True</DesignTime>
|
||||||
|
30
NTwain/NativeMethods.cs
Normal file
30
NTwain/NativeMethods.cs
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NTwain
|
||||||
|
{
|
||||||
|
static class NativeMethods
|
||||||
|
{
|
||||||
|
// should be unsafe native methods?
|
||||||
|
|
||||||
|
#region mem stuff for twain 1.x
|
||||||
|
|
||||||
|
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalAlloc")]
|
||||||
|
internal static extern IntPtr WinGlobalAlloc(uint uFlags, UIntPtr dwBytes);
|
||||||
|
|
||||||
|
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalFree")]
|
||||||
|
internal static extern IntPtr WinGlobalFree(IntPtr hMem);
|
||||||
|
|
||||||
|
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalLock")]
|
||||||
|
internal static extern IntPtr WinGlobalLock(IntPtr handle);
|
||||||
|
|
||||||
|
[DllImport("kernel32", SetLastError = true, EntryPoint = "GlobalUnlock")]
|
||||||
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
|
internal static extern bool WinGlobalUnlock(IntPtr handle);
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
|||||||
{
|
{
|
||||||
static partial class PInvoke
|
static partial class PInvoke
|
||||||
{
|
{
|
||||||
static partial class WinNativeMethods
|
static partial class NativeMethods
|
||||||
{
|
{
|
||||||
[DllImport("twain_32", EntryPoint = "#1")]
|
[DllImport("twain_32", EntryPoint = "#1")]
|
||||||
public static extern ReturnCode DsmEntry32(
|
public static extern ReturnCode DsmEntry32(
|
||||||
|
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
|||||||
{
|
{
|
||||||
static partial class PInvoke
|
static partial class PInvoke
|
||||||
{
|
{
|
||||||
static partial class WinNativeMethods
|
static partial class NativeMethods
|
||||||
{
|
{
|
||||||
[DllImport("twaindsm", EntryPoint = "#1")]
|
[DllImport("twaindsm", EntryPoint = "#1")]
|
||||||
public static extern ReturnCode DsmEntry64(
|
public static extern ReturnCode DsmEntry64(
|
||||||
|
@@ -43,8 +43,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
ref IntPtr data)
|
ref IntPtr data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReturnCode DsmEntry(
|
public static ReturnCode DsmEntry(
|
||||||
@@ -55,8 +55,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
ref uint data)
|
ref uint data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, dg, dat, msg, ref data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, dg, dat, msg, ref data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReturnCode DsmEntry(
|
public static ReturnCode DsmEntry(
|
||||||
@@ -65,8 +65,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWAudioInfo data)
|
TWAudioInfo data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -76,8 +76,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCapability data)
|
TWCapability data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -87,8 +87,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCustomDSData data)
|
TWCustomDSData data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,8 +98,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWDeviceEvent data)
|
TWDeviceEvent data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -109,8 +109,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCallback data)
|
TWCallback data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -120,8 +120,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCallback2 data)
|
TWCallback2 data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -131,8 +131,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWEntryPoint data)
|
TWEntryPoint data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -142,8 +142,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWEvent data)
|
TWEvent data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -153,8 +153,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWFileSystem data)
|
TWFileSystem data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReturnCode DsmEntry(
|
public static ReturnCode DsmEntry(
|
||||||
@@ -162,8 +162,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWIdentity data)
|
TWIdentity data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -173,8 +173,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWPassThru data)
|
TWPassThru data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -184,8 +184,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWPendingXfers data)
|
TWPendingXfers data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -195,8 +195,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWSetupFileXfer data)
|
TWSetupFileXfer data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -206,8 +206,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWSetupMemXfer data)
|
TWSetupMemXfer data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -217,8 +217,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWStatusUtf8 data)
|
TWStatusUtf8 data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -228,8 +228,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWUserInterface data)
|
TWUserInterface data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -239,8 +239,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCieColor data)
|
TWCieColor data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -250,8 +250,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWExtImageInfo data)
|
TWExtImageInfo data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReturnCode DsmEntry(
|
public static ReturnCode DsmEntry(
|
||||||
@@ -260,8 +260,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWFilter data)
|
TWFilter data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReturnCode DsmEntry(
|
public static ReturnCode DsmEntry(
|
||||||
@@ -270,8 +270,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWGrayResponse data)
|
TWGrayResponse data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -281,8 +281,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWImageInfo data)
|
TWImageInfo data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -292,8 +292,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWImageLayout data)
|
TWImageLayout data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -303,8 +303,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWImageMemXfer data)
|
TWImageMemXfer data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -314,8 +314,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWJpegCompression data)
|
TWJpegCompression data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -325,8 +325,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWPalette8 data)
|
TWPalette8 data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -336,8 +336,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWRgbResponse data)
|
TWRgbResponse data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -347,8 +347,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWStatus data)
|
TWStatus data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -359,8 +359,8 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
ref TWMemory data)
|
ref TWMemory data)
|
||||||
{
|
{
|
||||||
if (CanUseTwainDSM) { return WinNativeMethods.DsmEntry64(origin, destination, DataGroups.Control, dat, msg, ref data); }
|
if (CanUseTwainDSM) { return NativeMethods.DsmEntry64(origin, destination, DataGroups.Control, dat, msg, ref data); }
|
||||||
else { return WinNativeMethods.DsmEntry32(origin, destination, DataGroups.Control, dat, msg, ref data); }
|
else { return NativeMethods.DsmEntry32(origin, destination, DataGroups.Control, dat, msg, ref data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -27,7 +27,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
if (appId == null) { throw new ArgumentNullException("appId"); }
|
if (appId == null) { throw new ArgumentNullException("appId"); }
|
||||||
_appId = appId;
|
_appId = appId;
|
||||||
State = 1;
|
((ITwainStateInternal)this).ChangeState(1, false);
|
||||||
EnforceState = true;
|
EnforceState = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -912,14 +912,49 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DoImageMemoryFileXfer()
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void DoImageMemoryXfer()
|
private void DoImageMemoryXfer()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
TWSetupMemXfer memInfo;
|
||||||
|
if (DGControl.SetupMemXfer.Get(out memInfo) == ReturnCode.Success)
|
||||||
|
{
|
||||||
|
TWImageMemXfer xferInfo = new TWImageMemXfer();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
xferInfo.Memory = new TWMemory
|
||||||
|
{
|
||||||
|
Length = memInfo.Preferred,
|
||||||
|
TheMem = MemoryManager.Instance.Allocate(memInfo.Preferred)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
var xrc = ReturnCode.Success;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
xrc = DGImage.ImageMemXfer.Get(xferInfo);
|
||||||
|
|
||||||
|
if (xrc == ReturnCode.XferDone)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
} while (xrc == ReturnCode.Success);
|
||||||
|
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
if (xferInfo.Memory.TheMem != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
MemoryManager.Instance.Free(xferInfo.Memory.TheMem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DoImageMemoryFileXfer()
|
||||||
|
{
|
||||||
|
// no way to test, not supported by sample source
|
||||||
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -932,13 +967,31 @@ namespace NTwain
|
|||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
protected struct MESSAGE
|
protected struct MESSAGE
|
||||||
{
|
{
|
||||||
public IntPtr hwnd;
|
/// <summary>
|
||||||
public uint message;
|
/// Initializes a new instance of the <see cref="MESSAGE"/> struct.
|
||||||
public IntPtr wParam;
|
/// </summary>
|
||||||
public IntPtr lParam;
|
/// <param name="hwnd">The HWND.</param>
|
||||||
public uint time;
|
/// <param name="message">The message.</param>
|
||||||
public int x;
|
/// <param name="wParam">The w parameter.</param>
|
||||||
public int y;
|
/// <param name="lParam">The l parameter.</param>
|
||||||
|
public MESSAGE(IntPtr hwnd, int message, IntPtr wParam, IntPtr lParam)
|
||||||
|
{
|
||||||
|
_hwnd = hwnd;
|
||||||
|
_message = (uint)message;
|
||||||
|
_wParam = wParam;
|
||||||
|
_lParam = lParam;
|
||||||
|
_time = 0;
|
||||||
|
_x = 0;
|
||||||
|
_y = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
IntPtr _hwnd;
|
||||||
|
uint _message;
|
||||||
|
IntPtr _wParam;
|
||||||
|
IntPtr _lParam;
|
||||||
|
uint _time;
|
||||||
|
int _x;
|
||||||
|
int _y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -209,11 +209,7 @@ namespace NTwain
|
|||||||
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
||||||
bool IMessageFilter.PreFilterMessage(ref System.Windows.Forms.Message m)
|
bool IMessageFilter.PreFilterMessage(ref System.Windows.Forms.Message m)
|
||||||
{
|
{
|
||||||
MESSAGE winmsg = default(MESSAGE);
|
var winmsg = new MESSAGE(m.HWnd, m.Msg, m.WParam, m.LParam);
|
||||||
winmsg.hwnd = m.HWnd;
|
|
||||||
winmsg.lParam = m.LParam;
|
|
||||||
winmsg.message = (uint)m.Msg;
|
|
||||||
winmsg.wParam = m.WParam;
|
|
||||||
|
|
||||||
return HandleWndProcMessage(ref winmsg);
|
return HandleWndProcMessage(ref winmsg);
|
||||||
}
|
}
|
||||||
@@ -230,11 +226,7 @@ namespace NTwain
|
|||||||
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
|
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
|
||||||
public IntPtr PreFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
public IntPtr PreFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
{
|
{
|
||||||
MESSAGE winmsg = default(MESSAGE);
|
var winmsg = new MESSAGE(hwnd, msg, wParam, lParam);
|
||||||
winmsg.hwnd = hwnd;
|
|
||||||
winmsg.lParam = lParam;
|
|
||||||
winmsg.message = (uint)msg;
|
|
||||||
winmsg.wParam = wParam;
|
|
||||||
|
|
||||||
handled = base.HandleWndProcMessage(ref winmsg);
|
handled = base.HandleWndProcMessage(ref winmsg);
|
||||||
|
|
||||||
|
@@ -33,11 +33,7 @@ namespace NTwain
|
|||||||
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
|
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
|
||||||
public IntPtr PreFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
public IntPtr PreFilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
{
|
{
|
||||||
MESSAGE winmsg = default(MESSAGE);
|
var winmsg = new MESSAGE(hwnd, msg, wParam, lParam);
|
||||||
winmsg.hwnd = hwnd;
|
|
||||||
winmsg.lParam = lParam;
|
|
||||||
winmsg.message = (uint)msg;
|
|
||||||
winmsg.wParam = wParam;
|
|
||||||
|
|
||||||
handled = base.HandleWndProcMessage(ref winmsg);
|
handled = base.HandleWndProcMessage(ref winmsg);
|
||||||
|
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Permissions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@@ -22,13 +23,10 @@ namespace NTwain
|
|||||||
|
|
||||||
#region IMessageFilter Members
|
#region IMessageFilter Members
|
||||||
|
|
||||||
bool IMessageFilter.PreFilterMessage(ref Message m)
|
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
||||||
|
public bool PreFilterMessage(ref Message m)
|
||||||
{
|
{
|
||||||
MESSAGE winmsg = default(MESSAGE);
|
var winmsg = new MESSAGE(m.HWnd, m.Msg, m.WParam, m.LParam);
|
||||||
winmsg.hwnd = m.HWnd;
|
|
||||||
winmsg.lParam = m.LParam;
|
|
||||||
winmsg.message = (uint)m.Msg;
|
|
||||||
winmsg.wParam = m.WParam;
|
|
||||||
|
|
||||||
return HandleWndProcMessage(ref winmsg);
|
return HandleWndProcMessage(ref winmsg);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user