mirror of
https://github.com/soukoku/ntwain.git
synced 2026-02-25 13:04:07 +08:00
Road to v1 begins!
This commit is contained in:
@@ -49,38 +49,65 @@
|
|||||||
<Compile Include="..\NTwain\Data\CapReadOut.cs">
|
<Compile Include="..\NTwain\Data\CapReadOut.cs">
|
||||||
<Link>Data\CapReadOut.cs</Link>
|
<Link>Data\CapReadOut.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Data\SourceEnableMode.cs">
|
||||||
|
<Link>Data\SourceEnableMode.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Data\TwainTypes.cs">
|
||||||
|
<Link>Data\TwainTypes.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Data\TwainTypesExtended.cs">
|
||||||
|
<Link>Data\TwainTypesExtended.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Data\TwainValues.cs">
|
||||||
|
<Link>Data\TwainValues.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\NTwain\Data\TypeReader.cs">
|
<Compile Include="..\NTwain\Data\TypeReader.cs">
|
||||||
<Link>Data\TypeReader.cs</Link>
|
<Link>Data\TypeReader.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\Data\Types.cs">
|
<Compile Include="..\NTwain\Data\ValueConverter.cs">
|
||||||
<Link>Data\Types.cs</Link>
|
<Link>Data\ValueConverter.cs</Link>
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\Data\TypesExtended.cs">
|
|
||||||
<Link>Data\TypesExtended.cs</Link>
|
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\DeviceEventArgs.cs">
|
<Compile Include="..\NTwain\DeviceEventArgs.cs">
|
||||||
<Link>DeviceEventArgs.cs</Link>
|
<Link>DeviceEventArgs.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\Extensions.cs">
|
|
||||||
<Link>Extensions.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\IMemoryManager.cs">
|
<Compile Include="..\NTwain\IMemoryManager.cs">
|
||||||
<Link>IMemoryManager.cs</Link>
|
<Link>IMemoryManager.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\Extensions.cs">
|
||||||
|
<Link>Internals\Extensions.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\ICommittable.cs">
|
||||||
|
<Link>Internals\ICommittable.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\ITwainStateInternal.cs">
|
||||||
|
<Link>Internals\ITwainStateInternal.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\MessageLoop.cs">
|
||||||
|
<Link>Internals\MessageLoop.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\NativeMethods.cs">
|
||||||
|
<Link>Internals\NativeMethods.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\TentativeStateCommitable.cs">
|
||||||
|
<Link>Internals\TentativeStateCommitable.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\WindowsHook.cs">
|
||||||
|
<Link>Internals\WindowsHook.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\WinMemoryManager.cs">
|
||||||
|
<Link>Internals\WinMemoryManager.cs</Link>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="..\NTwain\Internals\WrappedManualResetEvent.cs">
|
||||||
|
<Link>Internals\WrappedManualResetEvent.cs</Link>
|
||||||
|
</Compile>
|
||||||
<Compile Include="..\NTwain\ITwainOperation.cs">
|
<Compile Include="..\NTwain\ITwainOperation.cs">
|
||||||
<Link>ITwainOperation.cs</Link>
|
<Link>ITwainOperation.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\ITwainState.cs">
|
<Compile Include="..\NTwain\ITwainState.cs">
|
||||||
<Link>ITwainState.cs</Link>
|
<Link>ITwainState.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\MemoryManager.cs">
|
<Compile Include="..\NTwain\Platform.cs">
|
||||||
<Link>MemoryManager.cs</Link>
|
<Link>Platform.cs</Link>
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\MessageLoop.cs">
|
|
||||||
<Link>MessageLoop.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\NativeMethods.cs">
|
|
||||||
<Link>NativeMethods.cs</Link>
|
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\Properties\AssemblyInfo.cs">
|
<Compile Include="..\NTwain\Properties\AssemblyInfo.cs">
|
||||||
<Link>Properties\AssemblyInfo.cs</Link>
|
<Link>Properties\AssemblyInfo.cs</Link>
|
||||||
@@ -94,9 +121,6 @@
|
|||||||
<Compile Include="..\NTwain\Properties\VersionInfo.cs">
|
<Compile Include="..\NTwain\Properties\VersionInfo.cs">
|
||||||
<Link>Properties\VersionInfo.cs</Link>
|
<Link>Properties\VersionInfo.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\TentativeStateCommitable.cs">
|
|
||||||
<Link>TentativeStateCommitable.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\TransferErrorEventArgs.cs">
|
<Compile Include="..\NTwain\TransferErrorEventArgs.cs">
|
||||||
<Link>TransferErrorEventArgs.cs</Link>
|
<Link>TransferErrorEventArgs.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -244,18 +268,6 @@
|
|||||||
<Compile Include="..\NTwain\TwainStateException.cs">
|
<Compile Include="..\NTwain\TwainStateException.cs">
|
||||||
<Link>TwainStateException.cs</Link>
|
<Link>TwainStateException.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\NTwain\Values\DataValues.cs">
|
|
||||||
<Link>Values\DataValues.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\Values\SourceEnableMode.cs">
|
|
||||||
<Link>Values\SourceEnableMode.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\Values\TwainConst.cs">
|
|
||||||
<Link>Values\TwainConst.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="..\NTwain\Values\ValueConverter.cs">
|
|
||||||
<Link>Values\ValueConverter.cs</Link>
|
|
||||||
</Compile>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="..\NTwain\Properties\Resources.resx">
|
<EmbeddedResource Include="..\NTwain\Properties\Resources.resx">
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using NTwain.Properties;
|
using NTwain.Properties;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@@ -32,7 +31,7 @@ namespace NTwain.Data
|
|||||||
IntPtr baseAddr = IntPtr.Zero;
|
IntPtr baseAddr = IntPtr.Zero;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
baseAddr = MemoryManager.Instance.Lock(capability.Container);
|
baseAddr = Platform.MemoryManager.Lock(capability.Container);
|
||||||
switch (capability.ContainerType)
|
switch (capability.ContainerType)
|
||||||
{
|
{
|
||||||
case ContainerType.Array:
|
case ContainerType.Array:
|
||||||
@@ -63,7 +62,7 @@ namespace NTwain.Data
|
|||||||
{
|
{
|
||||||
if (baseAddr != IntPtr.Zero)
|
if (baseAddr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Unlock(baseAddr);
|
Platform.MemoryManager.Unlock(baseAddr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,7 +86,7 @@ namespace NTwain.Data
|
|||||||
public ItemType ItemType { get; private set; }
|
public ItemType ItemType { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the one value if container is <see cref="NTwain.Values.ContainerType.Array"/>.
|
/// Gets the one value if container is <see cref="NTwain.ContainerType.Array"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The one value.
|
/// The one value.
|
||||||
@@ -95,7 +94,7 @@ namespace NTwain.Data
|
|||||||
public object OneValue { get; private set; }
|
public object OneValue { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the collection values if container is <see cref="NTwain.Values.ContainerType.Enum"/> or <see cref="NTwain.Values.ContainerType.Range"/> .
|
/// Gets the collection values if container is <see cref="NTwain.ContainerType.Enum"/> or <see cref="NTwain.ContainerType.Range"/> .
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The collection values.
|
/// The collection values.
|
||||||
@@ -107,11 +106,11 @@ namespace NTwain.Data
|
|||||||
#region enum prop
|
#region enum prop
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current value index if container is <see cref="NTwain.Values.ContainerType.Enum"/>.
|
/// Gets the current value index if container is <see cref="NTwain.ContainerType.Enum"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int EnumCurrentIndex { get; private set; }
|
public int EnumCurrentIndex { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the default value index if container is <see cref="NTwain.Values.ContainerType.Enum" />.
|
/// Gets the default value index if container is <see cref="NTwain.ContainerType.Enum" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int EnumDefaultIndex { get; private set; }
|
public int EnumDefaultIndex { get; private set; }
|
||||||
|
|
||||||
@@ -120,14 +119,14 @@ namespace NTwain.Data
|
|||||||
#region range prop
|
#region range prop
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current value if container is <see cref="NTwain.Values.ContainerType.Range" />.
|
/// Gets the current value if container is <see cref="NTwain.ContainerType.Range" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The range current value.
|
/// The range current value.
|
||||||
/// </value>
|
/// </value>
|
||||||
public object RangeCurrentValue { get; private set; }
|
public object RangeCurrentValue { get; private set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the default value if container is <see cref="NTwain.Values.ContainerType.Range" />.
|
/// Gets the default value if container is <see cref="NTwain.ContainerType.Range" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The range default value.
|
/// The range default value.
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace NTwain.Values
|
namespace NTwain.Data
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates how the source should be enabled in a TWAIN session.
|
/// Indicates how the source should be enabled in a TWAIN session.
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
// This file contains all the structs defined in the twain.h file.
|
// This file contains all the structs defined in the twain.h file.
|
||||||
|
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using TW_BOOL = System.UInt16; // unsigned short
|
using TW_BOOL = System.UInt16; // unsigned short
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Properties;
|
using NTwain.Internals;
|
||||||
using NTwain.Values;
|
using NTwain.Properties;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
@@ -625,7 +625,7 @@ namespace NTwain.Data
|
|||||||
public TWCapability(CapabilityId capability)
|
public TWCapability(CapabilityId capability)
|
||||||
{
|
{
|
||||||
Capability = capability;
|
Capability = capability;
|
||||||
ContainerType = Values.ContainerType.DontCare;
|
ContainerType = ContainerType.DontCare;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
/// Initializes a new instance of the <see cref="TWCapability" /> class.
|
||||||
@@ -636,7 +636,7 @@ namespace NTwain.Data
|
|||||||
public TWCapability(CapabilityId capability, TWOneValue value)
|
public TWCapability(CapabilityId capability, TWOneValue value)
|
||||||
{
|
{
|
||||||
Capability = capability;
|
Capability = capability;
|
||||||
ContainerType = Values.ContainerType.OneValue;
|
ContainerType = ContainerType.OneValue;
|
||||||
SetOneValue(value);
|
SetOneValue(value);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -648,7 +648,7 @@ namespace NTwain.Data
|
|||||||
public TWCapability(CapabilityId capability, TWEnumeration value)
|
public TWCapability(CapabilityId capability, TWEnumeration value)
|
||||||
{
|
{
|
||||||
Capability = capability;
|
Capability = capability;
|
||||||
ContainerType = Values.ContainerType.Enum;
|
ContainerType = ContainerType.Enum;
|
||||||
SetEnumValue(value);
|
SetEnumValue(value);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -660,7 +660,7 @@ namespace NTwain.Data
|
|||||||
public TWCapability(CapabilityId capability, TWRange value)
|
public TWCapability(CapabilityId capability, TWRange value)
|
||||||
{
|
{
|
||||||
Capability = capability;
|
Capability = capability;
|
||||||
ContainerType = Values.ContainerType.Range;
|
ContainerType = ContainerType.Range;
|
||||||
SetRangeValue(value);
|
SetRangeValue(value);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@@ -676,7 +676,7 @@ namespace NTwain.Data
|
|||||||
/// will be one of four types: <see cref="TWArray"/>, <see cref="TWEnumeration"/>,
|
/// will be one of four types: <see cref="TWArray"/>, <see cref="TWEnumeration"/>,
|
||||||
/// <see cref="TWOneValue"/>, or <see cref="TWRange"/>.
|
/// <see cref="TWOneValue"/>, or <see cref="TWRange"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ContainerType ContainerType { get { return (Values.ContainerType)_conType; } set { _conType = (ushort)value; } }
|
public ContainerType ContainerType { get { return (ContainerType)_conType; } set { _conType = (ushort)value; } }
|
||||||
|
|
||||||
internal IntPtr Container { get { return _hContainer; } }
|
internal IntPtr Container { get { return _hContainer; } }
|
||||||
|
|
||||||
@@ -688,12 +688,12 @@ namespace NTwain.Data
|
|||||||
void SetOneValue(TWOneValue value)
|
void SetOneValue(TWOneValue value)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
ContainerType = Values.ContainerType.OneValue;
|
ContainerType = ContainerType.OneValue;
|
||||||
|
|
||||||
// since one value can only house UInt32 we will not allow type size > 4
|
// since one value can only house UInt32 we will not allow type size > 4
|
||||||
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(Resources.BadValueType, "TWOneValue")); }
|
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(Resources.BadValueType, "TWOneValue")); }
|
||||||
|
|
||||||
_hContainer = MemoryManager.Instance.Allocate((uint)Marshal.SizeOf(value));
|
_hContainer = Platform.MemoryManager.Allocate((uint)Marshal.SizeOf(value));
|
||||||
if (_hContainer != IntPtr.Zero)
|
if (_hContainer != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Marshal.StructureToPtr(value, _hContainer, false);
|
Marshal.StructureToPtr(value, _hContainer, false);
|
||||||
@@ -704,14 +704,14 @@ namespace NTwain.Data
|
|||||||
void SetEnumValue(TWEnumeration value)
|
void SetEnumValue(TWEnumeration value)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
ContainerType = Values.ContainerType.Enum;
|
ContainerType = ContainerType.Enum;
|
||||||
|
|
||||||
|
|
||||||
Int32 valueSize = TWEnumeration.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
|
Int32 valueSize = TWEnumeration.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
|
||||||
|
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
_hContainer = MemoryManager.Instance.Allocate((uint)valueSize);
|
_hContainer = Platform.MemoryManager.Allocate((uint)valueSize);
|
||||||
IntPtr baseAddr = MemoryManager.Instance.Lock(_hContainer);
|
IntPtr baseAddr = Platform.MemoryManager.Lock(_hContainer);
|
||||||
|
|
||||||
// can't safely use StructureToPtr here so write it our own
|
// can't safely use StructureToPtr here so write it our own
|
||||||
WriteValue(baseAddr, ref offset, ItemType.UInt16, value.ItemType);
|
WriteValue(baseAddr, ref offset, ItemType.UInt16, value.ItemType);
|
||||||
@@ -722,7 +722,7 @@ namespace NTwain.Data
|
|||||||
{
|
{
|
||||||
WriteValue(baseAddr, ref offset, value.ItemType, item);
|
WriteValue(baseAddr, ref offset, value.ItemType, item);
|
||||||
}
|
}
|
||||||
MemoryManager.Instance.Unlock(baseAddr);
|
Platform.MemoryManager.Unlock(baseAddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -730,12 +730,12 @@ namespace NTwain.Data
|
|||||||
void SetRangeValue(TWRange value)
|
void SetRangeValue(TWRange value)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
ContainerType = Values.ContainerType.Range;
|
ContainerType = ContainerType.Range;
|
||||||
|
|
||||||
// since range value can only house UInt32 we will not allow type size > 4
|
// since range value can only house UInt32 we will not allow type size > 4
|
||||||
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(Resources.BadValueType, "TWRange")); }
|
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(Resources.BadValueType, "TWRange")); }
|
||||||
|
|
||||||
_hContainer = MemoryManager.Instance.Allocate((uint)Marshal.SizeOf(value));
|
_hContainer = Platform.MemoryManager.Allocate((uint)Marshal.SizeOf(value));
|
||||||
if (_hContainer != IntPtr.Zero)
|
if (_hContainer != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Marshal.StructureToPtr(value, _hContainer, false);
|
Marshal.StructureToPtr(value, _hContainer, false);
|
||||||
@@ -899,7 +899,7 @@ namespace NTwain.Data
|
|||||||
if (disposing) { }
|
if (disposing) { }
|
||||||
if (_hContainer != IntPtr.Zero)
|
if (_hContainer != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Free(_hContainer);
|
Platform.MemoryManager.Free(_hContainer);
|
||||||
_hContainer = IntPtr.Zero;
|
_hContainer = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1376,7 +1376,7 @@ namespace NTwain.Data
|
|||||||
{
|
{
|
||||||
// uintptr to intptr could be bad
|
// uintptr to intptr could be bad
|
||||||
var ptr = new IntPtr(BitConverter.ToInt64(BitConverter.GetBytes(it.Item.ToUInt64()), 0));
|
var ptr = new IntPtr(BitConverter.ToInt64(BitConverter.GetBytes(it.Item.ToUInt64()), 0));
|
||||||
MemoryManager.Instance.Free(ptr);
|
Platform.MemoryManager.Free(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
it.Item = UIntPtr.Zero;
|
it.Item = UIntPtr.Zero;
|
||||||
@@ -1794,12 +1794,12 @@ namespace NTwain.Data
|
|||||||
/// color is called Rgb, for R-G-B color. There is no
|
/// color is called Rgb, for R-G-B color. There is no
|
||||||
/// default for this value.
|
/// default for this value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public PixelType PixelType { get { return (Values.PixelType)_pixelType; } }
|
public PixelType PixelType { get { return (PixelType)_pixelType; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The compression method used to process the data being transferred.
|
/// The compression method used to process the data being transferred.
|
||||||
/// Default is no compression.
|
/// Default is no compression.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CompressionType Compression { get { return (Values.CompressionType)_compression; } }
|
public CompressionType Compression { get { return (CompressionType)_compression; } }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -2266,7 +2266,7 @@ namespace NTwain.Data
|
|||||||
}
|
}
|
||||||
if (_uTF8string != IntPtr.Zero)
|
if (_uTF8string != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Free(_uTF8string);
|
Platform.MemoryManager.Free(_uTF8string);
|
||||||
_uTF8string = IntPtr.Zero;
|
_uTF8string = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2312,34 +2312,39 @@ namespace NTwain.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides entry points required by TWAIN 2.0 Applications and Sources.
|
/// Provides entry points required by TWAIN 2.0 Applications and Sources.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
partial class TWEntryPoint
|
partial class TWEntryPoint : IMemoryManager
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TWEntryPoint"/> class.
|
/// Initializes a new instance of the <see cref="TWEntryPoint"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
|
|
||||||
public TWEntryPoint()
|
public TWEntryPoint()
|
||||||
{
|
{
|
||||||
_size = (uint)Marshal.SizeOf(this);
|
_size = (uint)Marshal.SizeOf(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#region IMemoryManager Members
|
||||||
/// The memory allocation function.
|
|
||||||
/// </summary>
|
|
||||||
public MemAllocateDelegate AllocateFunction { get { return _dSM_MemAllocate; } }
|
|
||||||
/// <summary>
|
|
||||||
/// The memory free function.
|
|
||||||
/// </summary>
|
|
||||||
public MemFreeDelegate FreeFunction { get { return _dSM_MemFree; } }
|
|
||||||
/// <summary>
|
|
||||||
/// The memory lock function.
|
|
||||||
/// </summary>
|
|
||||||
public MemLockDelegate LockFunction { get { return _dSM_MemLock; } }
|
|
||||||
/// <summary>
|
|
||||||
/// The memory unlock function.
|
|
||||||
/// </summary>
|
|
||||||
public MemUnlockDelegate UnlockFunction { get { return _dSM_MemUnlock; } }
|
|
||||||
|
|
||||||
|
public IntPtr Allocate(uint size)
|
||||||
|
{
|
||||||
|
return _dSM_MemAllocate(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Free(IntPtr handle)
|
||||||
|
{
|
||||||
|
_dSM_MemFree(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr Lock(IntPtr handle)
|
||||||
|
{
|
||||||
|
return _dSM_MemLock(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unlock(IntPtr handle)
|
||||||
|
{
|
||||||
|
_dSM_MemUnlock(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using NTwain.Data;
|
using System;
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace NTwain.Values
|
namespace NTwain.Data
|
||||||
{
|
{
|
||||||
// these are from the corresponding twain.h sections
|
// these are from the corresponding twain.h sections
|
||||||
|
|
||||||
@@ -734,7 +733,7 @@ namespace NTwain.Values
|
|||||||
/// ICapOrientation values.
|
/// ICapOrientation values.
|
||||||
/// Corresponds to TWOR_* values.
|
/// Corresponds to TWOR_* values.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum Orientation : ushort
|
public enum OrientationType : ushort
|
||||||
{
|
{
|
||||||
Rot0 = 0,
|
Rot0 = 0,
|
||||||
Rot90 = 1,
|
Rot90 = 1,
|
||||||
@@ -1990,4 +1989,65 @@ namespace NTwain.Values
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
True = 1
|
True = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Contains direct magic values for some TWAIN stuff.
|
||||||
|
/// </summary>
|
||||||
|
public static class TwainConst
|
||||||
|
{
|
||||||
|
// these are specified here since the actual
|
||||||
|
// array length doesn't reflect the name :(
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Length of an array that holds TW_STR32.
|
||||||
|
/// </summary>
|
||||||
|
public const int String32 = 34;
|
||||||
|
/// <summary>
|
||||||
|
/// Length of an array that holds TW_STR64.
|
||||||
|
/// </summary>
|
||||||
|
public const int String64 = 66;
|
||||||
|
/// <summary>
|
||||||
|
/// Length of an array that holds TW_STR128.
|
||||||
|
/// </summary>
|
||||||
|
public const int String128 = 130;
|
||||||
|
/// <summary>
|
||||||
|
/// Length of an array that holds TW_STR255.
|
||||||
|
/// </summary>
|
||||||
|
public const int String255 = 256;
|
||||||
|
|
||||||
|
// deprecated
|
||||||
|
//public const int String1024 = 1026;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Don't care value for 8 bit types.
|
||||||
|
/// </summary>
|
||||||
|
public const byte DontCare8 = 0xff;
|
||||||
|
/// <summary>
|
||||||
|
/// Don't care value for 16 bit types.
|
||||||
|
/// </summary>
|
||||||
|
public const ushort DontCare16 = 0xffff;
|
||||||
|
/// <summary>
|
||||||
|
/// Don't care value for 32 bit types.
|
||||||
|
/// </summary>
|
||||||
|
public const uint DontCare32 = 0xffffffff;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The major version number of TWAIN supported by this library.
|
||||||
|
/// </summary>
|
||||||
|
public const short ProtocolMajor = 2;
|
||||||
|
/// <summary>
|
||||||
|
/// The minor version number of TWAIN supported by this library.
|
||||||
|
/// </summary>
|
||||||
|
public const short ProtocolMinor = 3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Value for false where applicable.
|
||||||
|
/// </summary>
|
||||||
|
public const ushort True = 1;
|
||||||
|
/// <summary>
|
||||||
|
/// Value for true where applicable.
|
||||||
|
/// </summary>
|
||||||
|
public const ushort False = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using NTwain.Values;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace NTwain.Data
|
namespace NTwain.Data
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
using NTwain.Data;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace NTwain.Values
|
namespace NTwain.Data
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Utility on converting (possibly bad) integer values to enum values.
|
/// Utility on converting (possibly bad) integer values to enum values.
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
using NTwain.Properties;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace NTwain
|
|
||||||
{
|
|
||||||
static class Extensions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Verifies the string length is under the maximum length
|
|
||||||
/// and throws <see cref="ArgumentException"/> if violated.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="value">The value.</param>
|
|
||||||
/// <param name="maxLength">The maximum length.</param>
|
|
||||||
internal static void VerifyLengthUnder(this string value, int maxLength)
|
|
||||||
{
|
|
||||||
if (value != null && value.Length > maxLength)
|
|
||||||
throw new ArgumentException(Resources.MaxStringLengthExceeded);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using System;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
namespace NTwain
|
namespace NTwain
|
||||||
{
|
{
|
||||||
@@ -20,47 +19,4 @@ namespace NTwain
|
|||||||
/// <value>The state.</value>
|
/// <value>The state.</value>
|
||||||
int State { get; }
|
int State { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Internal interface for state management.
|
|
||||||
/// </summary>
|
|
||||||
interface ITwainStateInternal : ITwainState
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the app id used for the session.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
TWIdentity AppId { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets a value indicating whether calls to triplets will verify the current twain session state.
|
|
||||||
/// </summary>
|
|
||||||
/// <value>
|
|
||||||
/// <c>true</c> if state value is enforced; otherwise, <c>false</c>.
|
|
||||||
/// </value>
|
|
||||||
bool EnforceState { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Changes the state right away.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="newState">The new state.</param>
|
|
||||||
/// <param name="notifyChange">if set to <c>true</c> to notify change.</param>
|
|
||||||
void ChangeState(int newState, bool notifyChange);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the pending state changer and tentatively changes the session state to the specified value.
|
|
||||||
/// Value will only stick if committed.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="newState">The new state.</param>
|
|
||||||
/// <returns></returns>
|
|
||||||
ICommitable GetPendingStateChanger(int newState);
|
|
||||||
|
|
||||||
void ChangeSourceId(TWIdentity sourceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ICommitable : IDisposable
|
|
||||||
{
|
|
||||||
void Commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
43
NTwain/Internals/Extensions.cs
Normal file
43
NTwain/Internals/Extensions.cs
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
using NTwain.Data;
|
||||||
|
using NTwain.Properties;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NTwain.Internals
|
||||||
|
{
|
||||||
|
static class Extensions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Verifies the string length is under the maximum length
|
||||||
|
/// and throws <see cref="ArgumentException"/> if violated.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="value">The value.</param>
|
||||||
|
/// <param name="maxLength">The maximum length.</param>
|
||||||
|
public static void VerifyLengthUnder(this string value, int maxLength)
|
||||||
|
{
|
||||||
|
if (value != null && value.Length > maxLength)
|
||||||
|
throw new ArgumentException(Resources.MaxStringLengthExceeded);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Verifies the session is within the specified state range (inclusive). Throws
|
||||||
|
/// <see cref="TwainStateException" /> if violated.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="session">The session.</param>
|
||||||
|
/// <param name="allowedMinimum">The allowed minimum.</param>
|
||||||
|
/// <param name="allowedMaximum">The allowed maximum.</param>
|
||||||
|
/// <param name="group">The triplet data group.</param>
|
||||||
|
/// <param name="dataArgumentType">The triplet data argument type.</param>
|
||||||
|
/// <param name="message">The triplet message.</param>
|
||||||
|
/// <exception cref="TwainStateException"></exception>
|
||||||
|
public static void VerifyState(this ITwainStateInternal session, int allowedMinimum, int allowedMaximum, DataGroups group, DataArgumentType dataArgumentType, Message message)
|
||||||
|
{
|
||||||
|
if (session.EnforceState && (session.State < allowedMinimum || session.State > allowedMaximum))
|
||||||
|
{
|
||||||
|
throw new TwainStateException(session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message,
|
||||||
|
string.Format("TWAIN state {0} does not match required range {1}-{2} for operation {3}-{4}-{5}.",
|
||||||
|
session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
NTwain/Internals/ICommittable.cs
Normal file
9
NTwain/Internals/ICommittable.cs
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NTwain.Internals
|
||||||
|
{
|
||||||
|
interface ICommittable : IDisposable
|
||||||
|
{
|
||||||
|
void Commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
41
NTwain/Internals/ITwainStateInternal.cs
Normal file
41
NTwain/Internals/ITwainStateInternal.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using NTwain.Data;
|
||||||
|
|
||||||
|
namespace NTwain.Internals
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Internal interface for state management.
|
||||||
|
/// </summary>
|
||||||
|
interface ITwainStateInternal : ITwainState
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the app id used for the session.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
TWIdentity AppId { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether calls to triplets will verify the current twain session state.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// <c>true</c> if state value is enforced; otherwise, <c>false</c>.
|
||||||
|
/// </value>
|
||||||
|
bool EnforceState { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the state right away.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newState">The new state.</param>
|
||||||
|
/// <param name="notifyChange">if set to <c>true</c> to notify change.</param>
|
||||||
|
void ChangeState(int newState, bool notifyChange);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the pending state changer and tentatively changes the session state to the specified value.
|
||||||
|
/// Value will only stick if committed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newState">The new state.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
ICommittable GetPendingStateChanger(int newState);
|
||||||
|
|
||||||
|
void ChangeSourceId(TWIdentity sourceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
102
NTwain/Internals/MessageLoop.cs
Normal file
102
NTwain/Internals/MessageLoop.cs
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
using NTwain.Properties;
|
||||||
|
using NTwain.Triplets;
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
|
namespace NTwain.Internals
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides a message loop for old TWAIN to post or new TWAIN to synchronize callbacks.
|
||||||
|
/// </summary>
|
||||||
|
class MessageLoop
|
||||||
|
{
|
||||||
|
static MessageLoop _instance = new MessageLoop();
|
||||||
|
public static MessageLoop Instance { get { return _instance; } }
|
||||||
|
|
||||||
|
Dispatcher _dispatcher;
|
||||||
|
WindowsHook _hook;
|
||||||
|
private MessageLoop() { }
|
||||||
|
|
||||||
|
public void EnsureStarted(WindowsHook.WndProcHook hook)
|
||||||
|
{
|
||||||
|
if (_dispatcher == null)
|
||||||
|
{
|
||||||
|
// using this terrible hack so the new thread will start running before this function returns
|
||||||
|
using (var hack = new WrappedManualResetEvent())
|
||||||
|
{
|
||||||
|
var loopThread = new Thread(new ThreadStart(() =>
|
||||||
|
{
|
||||||
|
Debug.WriteLine("NTwain message loop is starting.");
|
||||||
|
_dispatcher = Dispatcher.CurrentDispatcher;
|
||||||
|
if (!Platform.IsOnMono)
|
||||||
|
{
|
||||||
|
_hook = new WindowsHook(hook);
|
||||||
|
}
|
||||||
|
hack.Set();
|
||||||
|
Dispatcher.Run();
|
||||||
|
// if for whatever reason it ever gets here make everything uninitialized
|
||||||
|
_dispatcher = null;
|
||||||
|
if (_hook != null)
|
||||||
|
{
|
||||||
|
_hook.Dispose();
|
||||||
|
_hook = null;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
loopThread.IsBackground = true;
|
||||||
|
loopThread.SetApartmentState(ApartmentState.STA);
|
||||||
|
loopThread.Start();
|
||||||
|
hack.Wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr LoopHandle
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _hook == null ? IntPtr.Zero : _hook.Handle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void BeginInvoke(Action action)
|
||||||
|
{
|
||||||
|
if (_dispatcher == null) { throw new InvalidOperationException(Resources.MsgLoopUnavailble); }
|
||||||
|
|
||||||
|
_dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Invoke(Action action)
|
||||||
|
{
|
||||||
|
if (_dispatcher == null) { throw new InvalidOperationException(Resources.MsgLoopUnavailble); }
|
||||||
|
|
||||||
|
if (_dispatcher.CheckAccess())
|
||||||
|
{
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
else if (Platform.IsOnMono)
|
||||||
|
{
|
||||||
|
using (var man = new WrappedManualResetEvent())
|
||||||
|
{
|
||||||
|
_dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
man.Set();
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
man.Wait();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_dispatcher.Invoke(DispatcherPriority.Normal, action);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace NTwain
|
namespace NTwain.Internals
|
||||||
{
|
{
|
||||||
static class NativeMethods
|
static class NativeMethods
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace NTwain
|
namespace NTwain.Internals
|
||||||
{
|
{
|
||||||
class TentativeStateCommitable : ICommitable
|
class TentativeStateCommitable : ICommittable
|
||||||
{
|
{
|
||||||
bool _commit;
|
bool _commit;
|
||||||
ITwainStateInternal _session;
|
ITwainStateInternal _session;
|
||||||
39
NTwain/Internals/WinMemoryManager.cs
Normal file
39
NTwain/Internals/WinMemoryManager.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NTwain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides methods for managing memory on data exchanged with twain sources using old win32 methods.
|
||||||
|
/// This should only be used after the DSM has been opened.
|
||||||
|
/// </summary>
|
||||||
|
class WinMemoryManager : IMemoryManager
|
||||||
|
{
|
||||||
|
public IntPtr Allocate(uint size)
|
||||||
|
{
|
||||||
|
IntPtr retVal = NativeMethods.WinGlobalAlloc(0x0040, new UIntPtr(size));
|
||||||
|
|
||||||
|
if (retVal == IntPtr.Zero)
|
||||||
|
{
|
||||||
|
throw new OutOfMemoryException();
|
||||||
|
}
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Free(IntPtr handle)
|
||||||
|
{
|
||||||
|
NativeMethods.WinGlobalFree(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr Lock(IntPtr handle)
|
||||||
|
{
|
||||||
|
return NativeMethods.WinGlobalLock(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unlock(IntPtr handle)
|
||||||
|
{
|
||||||
|
NativeMethods.WinGlobalUnlock(handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
94
NTwain/Internals/WindowsHook.cs
Normal file
94
NTwain/Internals/WindowsHook.cs
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
|
||||||
|
namespace NTwain.Internals
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Abstracts out wnd proc hook on Windows from MessageLoop class.
|
||||||
|
/// This allows things to not depend on PresentationCore.dll at runtime on mono.
|
||||||
|
/// Not that everything works yet in mono but it's something.
|
||||||
|
/// </summary>
|
||||||
|
class WindowsHook : IDisposable
|
||||||
|
{
|
||||||
|
IDisposable _win;
|
||||||
|
WndProcHook _hook;
|
||||||
|
|
||||||
|
public WindowsHook(WndProcHook hook)
|
||||||
|
{
|
||||||
|
// hook into windows msg loop for old twain to post msgs.
|
||||||
|
// the style values are purely guesses here with
|
||||||
|
// CS_NOCLOSE, WS_DISABLED, and WS_EX_NOACTIVATE
|
||||||
|
HwndSource win = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
win = new HwndSource(0x0200, 0x8000000, 0x8000000, 0, 0, "NTWAIN_LOOPER", IntPtr.Zero);
|
||||||
|
Handle = win.Handle;
|
||||||
|
win.AddHook(WndProc);
|
||||||
|
_win = win;
|
||||||
|
_hook = hook;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
if (win != null) { win.Dispose(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public delegate void WndProcHook(ref MESSAGE winMsg, ref bool handled);
|
||||||
|
|
||||||
|
|
||||||
|
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
||||||
|
{
|
||||||
|
if (_hook != null)
|
||||||
|
{
|
||||||
|
var winmsg = new MESSAGE(hwnd, msg, wParam, lParam);
|
||||||
|
_hook(ref winmsg, ref handled);
|
||||||
|
}
|
||||||
|
return IntPtr.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr Handle { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The MSG structure in Windows for TWAIN use.
|
||||||
|
/// </summary>
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct MESSAGE
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
if (_win != null)
|
||||||
|
{
|
||||||
|
((HwndSource)_win).RemoveHook(WndProc);
|
||||||
|
_win.Dispose();
|
||||||
|
_win = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
57
NTwain/Internals/WrappedManualResetEvent.cs
Normal file
57
NTwain/Internals/WrappedManualResetEvent.cs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
namespace NTwain.Internals
|
||||||
|
{
|
||||||
|
|
||||||
|
// just a test
|
||||||
|
|
||||||
|
class WrappedManualResetEvent : IDisposable
|
||||||
|
{
|
||||||
|
#if NET4
|
||||||
|
ManualResetEventSlim _slim;
|
||||||
|
#else
|
||||||
|
ManualResetEvent _mre;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public WrappedManualResetEvent()
|
||||||
|
{
|
||||||
|
#if NET4
|
||||||
|
_slim = new ManualResetEventSlim();
|
||||||
|
#else
|
||||||
|
_mre = new ManualResetEvent(false);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Wait()
|
||||||
|
{
|
||||||
|
#if NET4
|
||||||
|
_slim.Wait();
|
||||||
|
#else
|
||||||
|
_mre.WaitOne();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Set()
|
||||||
|
{
|
||||||
|
#if NET4
|
||||||
|
_slim.Set();
|
||||||
|
#else
|
||||||
|
_mre.Set();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
#if NET4
|
||||||
|
_slim.Dispose();
|
||||||
|
#else
|
||||||
|
_mre.Close();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,107 +0,0 @@
|
|||||||
using NTwain.Data;
|
|
||||||
using NTwain.Properties;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace NTwain
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Provides methods for managing memory on data exchanged with twain sources.
|
|
||||||
/// This should only be used after the DSM has been opened.
|
|
||||||
/// </summary>
|
|
||||||
public class MemoryManager : IMemoryManager
|
|
||||||
{
|
|
||||||
static readonly MemoryManager _instance = new MemoryManager();
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the singleton <see cref="MemoryManager"/> instance.
|
|
||||||
/// </summary>
|
|
||||||
public static MemoryManager Instance { get { return _instance; } }
|
|
||||||
|
|
||||||
private MemoryManager() { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Updates the entry point used by TWAIN.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="entryPoint">The entry point.</param>
|
|
||||||
internal void UpdateEntryPoint(TWEntryPoint entryPoint)
|
|
||||||
{
|
|
||||||
_twain2Entry = entryPoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
TWEntryPoint _twain2Entry;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Function to allocate memory. Calls to this must be coupled with <see cref="Free"/> later.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="size">The size in bytes.</param>
|
|
||||||
/// <returns>Handle to the allocated memory.</returns>
|
|
||||||
public IntPtr Allocate(uint size)
|
|
||||||
{
|
|
||||||
IntPtr retVal = IntPtr.Zero;
|
|
||||||
|
|
||||||
if (_twain2Entry != null && _twain2Entry.AllocateFunction != null)
|
|
||||||
{
|
|
||||||
retVal = _twain2Entry.AllocateFunction(size);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// 0x0040 is GPTR
|
|
||||||
retVal = NativeMethods.WinGlobalAlloc(0x0040, new UIntPtr(size));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (retVal == IntPtr.Zero)
|
|
||||||
{
|
|
||||||
throw new OutOfMemoryException();
|
|
||||||
}
|
|
||||||
return retVal;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Function to free memory.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">The handle from <see cref="Allocate"/>.</param>
|
|
||||||
public void Free(IntPtr handle)
|
|
||||||
{
|
|
||||||
if (_twain2Entry != null && _twain2Entry.FreeFunction != null)
|
|
||||||
{
|
|
||||||
_twain2Entry.FreeFunction(handle);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NativeMethods.WinGlobalFree(handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Function to lock some memory. Calls to this must be coupled with <see cref="Unlock"/> later.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">The handle to allocated memory.</param>
|
|
||||||
/// <returns>Handle to the lock.</returns>
|
|
||||||
public IntPtr Lock(IntPtr handle)
|
|
||||||
{
|
|
||||||
if (_twain2Entry != null && _twain2Entry.LockFunction != null)
|
|
||||||
{
|
|
||||||
return _twain2Entry.LockFunction(handle);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return NativeMethods.WinGlobalLock(handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Function to unlock a previously locked memory region.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="handle">The handle from <see cref="Lock"/>.</param>
|
|
||||||
public void Unlock(IntPtr handle)
|
|
||||||
{
|
|
||||||
if (_twain2Entry != null && _twain2Entry.UnlockFunction != null)
|
|
||||||
{
|
|
||||||
_twain2Entry.UnlockFunction(handle);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
NativeMethods.WinGlobalUnlock(handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,242 +0,0 @@
|
|||||||
using NTwain.Properties;
|
|
||||||
using NTwain.Triplets;
|
|
||||||
using System;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Windows.Interop;
|
|
||||||
using System.Windows.Threading;
|
|
||||||
|
|
||||||
namespace NTwain
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Provides a message loop for old TWAIN to post or new TWAIN to synchronize callbacks.
|
|
||||||
/// </summary>
|
|
||||||
class MessageLoop
|
|
||||||
{
|
|
||||||
static MessageLoop _instance = new MessageLoop();
|
|
||||||
public static MessageLoop Instance { get { return _instance; } }
|
|
||||||
|
|
||||||
Dispatcher _dispatcher;
|
|
||||||
WindowsHook _hook;
|
|
||||||
private MessageLoop() { }
|
|
||||||
|
|
||||||
public void EnsureStarted(WindowsHook.WndProcHook hook)
|
|
||||||
{
|
|
||||||
if (_dispatcher == null)
|
|
||||||
{
|
|
||||||
// using this terrible hack so the new thread will start running before this function returns
|
|
||||||
using (var hack = new WrappedManualResetEvent())
|
|
||||||
{
|
|
||||||
var loopThread = new Thread(new ThreadStart(() =>
|
|
||||||
{
|
|
||||||
Debug.WriteLine("NTwain message loop is starting.");
|
|
||||||
_dispatcher = Dispatcher.CurrentDispatcher;
|
|
||||||
if (!Dsm.IsOnMono)
|
|
||||||
{
|
|
||||||
_hook = new WindowsHook(hook);
|
|
||||||
}
|
|
||||||
hack.Set();
|
|
||||||
Dispatcher.Run();
|
|
||||||
// if for whatever reason it ever gets here make everything uninitialized
|
|
||||||
_dispatcher = null;
|
|
||||||
if (_hook != null)
|
|
||||||
{
|
|
||||||
_hook.Dispose();
|
|
||||||
_hook = null;
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
loopThread.IsBackground = true;
|
|
||||||
loopThread.SetApartmentState(ApartmentState.STA);
|
|
||||||
loopThread.Start();
|
|
||||||
hack.Wait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr LoopHandle
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _hook == null ? IntPtr.Zero : _hook.Handle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void BeginInvoke(Action action)
|
|
||||||
{
|
|
||||||
if (_dispatcher == null) { throw new InvalidOperationException(Resources.MsgLoopUnavailble); }
|
|
||||||
|
|
||||||
_dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Invoke(Action action)
|
|
||||||
{
|
|
||||||
if (_dispatcher == null) { throw new InvalidOperationException(Resources.MsgLoopUnavailble); }
|
|
||||||
|
|
||||||
if (_dispatcher.CheckAccess())
|
|
||||||
{
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
else if (Dsm.IsOnMono)
|
|
||||||
{
|
|
||||||
using (var man = new WrappedManualResetEvent())
|
|
||||||
{
|
|
||||||
_dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
man.Set();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
man.Wait();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_dispatcher.Invoke(DispatcherPriority.Normal, action);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Abstracts out wnd proc hook on Windows from MessageLoop class.
|
|
||||||
/// This allows things to not depend on PresentationCore.dll at runtime on mono.
|
|
||||||
/// Not that everything works yet in mono but it's something.
|
|
||||||
/// </summary>
|
|
||||||
class WindowsHook : IDisposable
|
|
||||||
{
|
|
||||||
IDisposable _win;
|
|
||||||
WndProcHook _hook;
|
|
||||||
|
|
||||||
public WindowsHook(WndProcHook hook)
|
|
||||||
{
|
|
||||||
// hook into windows msg loop for old twain to post msgs.
|
|
||||||
// the style values are purely guesses here with
|
|
||||||
// CS_NOCLOSE, WS_DISABLED, and WS_EX_NOACTIVATE
|
|
||||||
HwndSource win = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
win = new HwndSource(0x0200, 0x8000000, 0x8000000, 0, 0, "NTWAIN_LOOPER", IntPtr.Zero);
|
|
||||||
Handle = win.Handle;
|
|
||||||
win.AddHook(WndProc);
|
|
||||||
_win = win;
|
|
||||||
_hook = hook;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
if (win != null) { win.Dispose(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public delegate void WndProcHook(ref MESSAGE winMsg, ref bool handled);
|
|
||||||
|
|
||||||
|
|
||||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
|
||||||
{
|
|
||||||
if (_hook != null)
|
|
||||||
{
|
|
||||||
var winmsg = new MESSAGE(hwnd, msg, wParam, lParam);
|
|
||||||
_hook(ref winmsg, ref handled);
|
|
||||||
}
|
|
||||||
return IntPtr.Zero;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr Handle { get; private set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The MSG structure in Windows for TWAIN use.
|
|
||||||
/// </summary>
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
public struct MESSAGE
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Members
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
if (_win != null)
|
|
||||||
{
|
|
||||||
((HwndSource)_win).RemoveHook(WndProc);
|
|
||||||
_win.Dispose();
|
|
||||||
_win = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
// just a test
|
|
||||||
|
|
||||||
class WrappedManualResetEvent : IDisposable
|
|
||||||
{
|
|
||||||
#if NET4
|
|
||||||
ManualResetEventSlim _slim;
|
|
||||||
#else
|
|
||||||
ManualResetEvent _mre;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public WrappedManualResetEvent()
|
|
||||||
{
|
|
||||||
#if NET4
|
|
||||||
_slim = new ManualResetEventSlim();
|
|
||||||
#else
|
|
||||||
_mre = new ManualResetEvent(false);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Wait()
|
|
||||||
{
|
|
||||||
#if NET4
|
|
||||||
_slim.Wait();
|
|
||||||
#else
|
|
||||||
_mre.WaitOne();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Set()
|
|
||||||
{
|
|
||||||
#if NET4
|
|
||||||
_slim.Set();
|
|
||||||
#else
|
|
||||||
_mre.Set();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#region IDisposable Members
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
#if NET4
|
|
||||||
_slim.Dispose();
|
|
||||||
#else
|
|
||||||
_mre.Close();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<DebugType>full</DebugType>
|
<DebugType>full</DebugType>
|
||||||
<Optimize>false</Optimize>
|
<Optimize>false</Optimize>
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
<DefineConstants>TRACE;DEBUG;WIN32</DefineConstants>
|
<DefineConstants>TRACE;DEBUG;NET4</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<RunCodeAnalysis>false</RunCodeAnalysis>
|
<RunCodeAnalysis>false</RunCodeAnalysis>
|
||||||
@@ -54,23 +54,28 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Data\CapReadOut.cs" />
|
<Compile Include="Data\CapReadOut.cs" />
|
||||||
<Compile Include="Data\TypeReader.cs" />
|
<Compile Include="Data\TypeReader.cs" />
|
||||||
<Compile Include="Data\TypesExtended.cs" />
|
<Compile Include="Data\TwainTypesExtended.cs" />
|
||||||
<Compile Include="DeviceEventArgs.cs" />
|
<Compile Include="DeviceEventArgs.cs" />
|
||||||
<Compile Include="Extensions.cs" />
|
<Compile Include="Internals\Extensions.cs" />
|
||||||
<Compile Include="DataTransferredEventArgs.cs" />
|
<Compile Include="DataTransferredEventArgs.cs" />
|
||||||
<Compile Include="IMemoryManager.cs" />
|
<Compile Include="IMemoryManager.cs" />
|
||||||
|
<Compile Include="Internals\ICommittable.cs" />
|
||||||
|
<Compile Include="Internals\ITwainStateInternal.cs" />
|
||||||
|
<Compile Include="Internals\WindowsHook.cs" />
|
||||||
|
<Compile Include="Internals\WrappedManualResetEvent.cs" />
|
||||||
<Compile Include="ITwainOperation.cs" />
|
<Compile Include="ITwainOperation.cs" />
|
||||||
<Compile Include="ITwainState.cs" />
|
<Compile Include="ITwainState.cs" />
|
||||||
<Compile Include="MemoryManager.cs" />
|
<Compile Include="Internals\WinMemoryManager.cs" />
|
||||||
<Compile Include="MessageLoop.cs" />
|
<Compile Include="Internals\MessageLoop.cs" />
|
||||||
<Compile Include="NativeMethods.cs" />
|
<Compile Include="Internals\NativeMethods.cs" />
|
||||||
|
<Compile Include="Platform.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>
|
||||||
<DependentUpon>Resources.resx</DependentUpon>
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Properties\VersionInfo.cs" />
|
<Compile Include="Properties\VersionInfo.cs" />
|
||||||
<Compile Include="TentativeStateCommitable.cs" />
|
<Compile Include="Internals\TentativeStateCommitable.cs" />
|
||||||
<Compile Include="TransferErrorEventArgs.cs" />
|
<Compile Include="TransferErrorEventArgs.cs" />
|
||||||
<Compile Include="TransferReadyEventArgs.cs" />
|
<Compile Include="TransferReadyEventArgs.cs" />
|
||||||
<Compile Include="Triplets\DGControl\DGControl.Callback2.cs" />
|
<Compile Include="Triplets\DGControl\DGControl.Callback2.cs" />
|
||||||
@@ -82,7 +87,7 @@
|
|||||||
<Compile Include="TwainSessionExtensions.cs" />
|
<Compile Include="TwainSessionExtensions.cs" />
|
||||||
<Compile Include="TwainSession.cs" />
|
<Compile Include="TwainSession.cs" />
|
||||||
<Compile Include="TwainStateException.cs" />
|
<Compile Include="TwainStateException.cs" />
|
||||||
<Compile Include="Data\Types.cs" />
|
<Compile Include="Data\TwainTypes.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Triplets\DGAudio\DGAudio.AudioFileXfer.cs" />
|
<Compile Include="Triplets\DGAudio\DGAudio.AudioFileXfer.cs" />
|
||||||
<Compile Include="Triplets\DGAudio\DGAudio.AudioInfo.cs" />
|
<Compile Include="Triplets\DGAudio\DGAudio.AudioInfo.cs" />
|
||||||
@@ -122,10 +127,9 @@
|
|||||||
<Compile Include="Triplets\DGImage\DGImage.RgbResponse.cs" />
|
<Compile Include="Triplets\DGImage\DGImage.RgbResponse.cs" />
|
||||||
<Compile Include="Triplets\Dsm.cs" />
|
<Compile Include="Triplets\Dsm.cs" />
|
||||||
<Compile Include="TwainException.cs" />
|
<Compile Include="TwainException.cs" />
|
||||||
<Compile Include="Values\DataValues.cs" />
|
<Compile Include="Data\TwainValues.cs" />
|
||||||
<Compile Include="Values\SourceEnableMode.cs" />
|
<Compile Include="Data\SourceEnableMode.cs" />
|
||||||
<Compile Include="Values\TwainConst.cs" />
|
<Compile Include="Data\ValueConverter.cs" />
|
||||||
<Compile Include="Values\ValueConverter.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="NTwain.nuspec" />
|
<None Include="NTwain.nuspec" />
|
||||||
@@ -140,6 +144,7 @@
|
|||||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
86
NTwain/Platform.cs
Normal file
86
NTwain/Platform.cs
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace NTwain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class for checking various platform requirements and conditions.
|
||||||
|
/// </summary>
|
||||||
|
public static class Platform
|
||||||
|
{
|
||||||
|
// Change pinvoke base on where running in 64bit mode.
|
||||||
|
// Theoretically [DllImport("twaindsm", EntryPoint = "#1")]
|
||||||
|
// works on both 32 and 64 bit
|
||||||
|
// but it's not installed on either system by default.
|
||||||
|
// A proper 64 bit twain driver would've installed it so
|
||||||
|
// in essence it only exists in 64 bit systems and thus
|
||||||
|
// the 2 sets of identical pinvokes for windows :(
|
||||||
|
|
||||||
|
static Platform()
|
||||||
|
{
|
||||||
|
IsApp64bit = IntPtr.Size == 8;
|
||||||
|
NewWinDsmExists = File.Exists(Path.Combine(Environment.SystemDirectory, "twaindsm.dll"));
|
||||||
|
|
||||||
|
UseNewDSM = IsApp64bit || NewWinDsmExists;
|
||||||
|
|
||||||
|
IsOnMono = Type.GetType("Mono.Runtime") != null;
|
||||||
|
IsWin = Environment.OSVersion.Platform == PlatformID.Win32NT;
|
||||||
|
IsLinux = Environment.OSVersion.Platform == PlatformID.Unix;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static readonly bool UseNewDSM;
|
||||||
|
|
||||||
|
internal static readonly bool IsApp64bit;
|
||||||
|
internal static readonly bool NewWinDsmExists;
|
||||||
|
|
||||||
|
internal static readonly bool IsOnMono;
|
||||||
|
|
||||||
|
internal static readonly bool IsWin;
|
||||||
|
internal static readonly bool IsLinux;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether this library is supported.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// <c>true</c> if this library is supported; otherwise, <c>false</c>.
|
||||||
|
/// </value>
|
||||||
|
public static bool IsSupported
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (IsWin)
|
||||||
|
{
|
||||||
|
if (IsApp64bit) { return NewWinDsmExists; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return IsOnMono && IsLinux;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static readonly WinMemoryManager _defaultMemManager = new WinMemoryManager();
|
||||||
|
static IMemoryManager _specifiedMemManager = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the <see cref="IMemoryManager"/> for communicating with data sources.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The memory manager.
|
||||||
|
/// </value>
|
||||||
|
public static IMemoryManager MemoryManager
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_specifiedMemManager == null) { return _defaultMemManager; }
|
||||||
|
return _specifiedMemManager;
|
||||||
|
}
|
||||||
|
internal set
|
||||||
|
{
|
||||||
|
_specifiedMemManager = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
4
NTwain/Properties/Resources.Designer.cs
generated
4
NTwain/Properties/Resources.Designer.cs
generated
@@ -8,8 +8,8 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace NTwain.Properties {
|
namespace NTwain.Properties
|
||||||
using System;
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ namespace NTwain
|
|||||||
class _NTwainVersionInfo
|
class _NTwainVersionInfo
|
||||||
{
|
{
|
||||||
// keep this same in majors releases
|
// keep this same in majors releases
|
||||||
public const string Release = "0.11.0.0";
|
public const string Release = "1.0.0.0";
|
||||||
// change this for each nuget release
|
// change this for each nuget release
|
||||||
public const string Build = "0.11.3";
|
public const string Build = "1.0.0";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NTwain
|
namespace NTwain
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using System;
|
using System;
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using System;
|
using System;
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using System;
|
using System;
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
@@ -12,33 +10,6 @@ namespace NTwain.Triplets
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
static partial class Dsm
|
static partial class Dsm
|
||||||
{
|
{
|
||||||
// Change pinvoke base on where running in 64bit mode.
|
|
||||||
// Theoretically [DllImport("twaindsm", EntryPoint = "#1")]
|
|
||||||
// works on both 32 and 64 bit
|
|
||||||
// but it's not installed on either system by default.
|
|
||||||
// A proper 64 bit twain driver would've installed it so
|
|
||||||
// in essence it only exists in 64 bit systems and thus
|
|
||||||
// the 2 sets of identical pinvokes for windows :(
|
|
||||||
|
|
||||||
internal static readonly bool UseNewDSM = CheckIfCanUseNewDSM();
|
|
||||||
|
|
||||||
private static bool CheckIfCanUseNewDSM()
|
|
||||||
{
|
|
||||||
#if DEBUG
|
|
||||||
return IntPtr.Size == 8;
|
|
||||||
#else
|
|
||||||
var path = Path.Combine(Environment.SystemDirectory, "twaindsm.dll");
|
|
||||||
// if 64bit or the new dll exists use it
|
|
||||||
return IntPtr.Size == 8 || File.Exists(path);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
internal static readonly bool IsOnMono = Type.GetType("Mono.Runtime") != null;
|
|
||||||
|
|
||||||
internal static readonly bool IsWin = Environment.OSVersion.Platform == PlatformID.Win32NT;
|
|
||||||
static readonly bool IsLinux = Environment.OSVersion.Platform == PlatformID.Unix;
|
|
||||||
|
|
||||||
// define sig for each different data type since "object" doesn't work
|
|
||||||
|
|
||||||
#region wrapped calls
|
#region wrapped calls
|
||||||
|
|
||||||
public static ReturnCode DsmEntry(
|
public static ReturnCode DsmEntry(
|
||||||
@@ -49,12 +20,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
ref IntPtr data)
|
ref IntPtr data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data);
|
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data);
|
||||||
}
|
}
|
||||||
@@ -69,12 +40,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
ref DataGroups data)
|
ref DataGroups data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data);
|
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data);
|
||||||
}
|
}
|
||||||
@@ -87,12 +58,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWAudioInfo data)
|
TWAudioInfo data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data);
|
||||||
}
|
}
|
||||||
@@ -106,12 +77,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCapability data)
|
TWCapability data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Capability, msg, data);
|
||||||
}
|
}
|
||||||
@@ -125,12 +96,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCustomDSData data)
|
TWCustomDSData data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data);
|
||||||
}
|
}
|
||||||
@@ -144,12 +115,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWDeviceEvent data)
|
TWDeviceEvent data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data);
|
||||||
}
|
}
|
||||||
@@ -163,12 +134,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCallback data)
|
TWCallback data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
|
||||||
}
|
}
|
||||||
@@ -182,12 +153,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCallback2 data)
|
TWCallback2 data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
|
||||||
}
|
}
|
||||||
@@ -201,12 +172,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWEntryPoint data)
|
TWEntryPoint data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.EntryPoint, msg, data);
|
||||||
}
|
}
|
||||||
@@ -220,12 +191,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWEvent data)
|
TWEvent data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data);
|
||||||
}
|
}
|
||||||
@@ -239,12 +210,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWFileSystem data)
|
TWFileSystem data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data);
|
||||||
}
|
}
|
||||||
@@ -256,12 +227,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWIdentity data)
|
TWIdentity data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data);
|
return NativeMethods.DsmLinux(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data);
|
||||||
}
|
}
|
||||||
@@ -275,12 +246,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWPassThru data)
|
TWPassThru data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data);
|
||||||
}
|
}
|
||||||
@@ -294,12 +265,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWPendingXfers data)
|
TWPendingXfers data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data);
|
||||||
}
|
}
|
||||||
@@ -313,12 +284,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWSetupFileXfer data)
|
TWSetupFileXfer data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data);
|
||||||
}
|
}
|
||||||
@@ -332,12 +303,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWSetupMemXfer data)
|
TWSetupMemXfer data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data);
|
||||||
}
|
}
|
||||||
@@ -351,12 +322,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWStatusUtf8 data)
|
TWStatusUtf8 data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data);
|
||||||
}
|
}
|
||||||
@@ -370,12 +341,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWUserInterface data)
|
TWUserInterface data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data);
|
||||||
}
|
}
|
||||||
@@ -389,12 +360,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWCieColor data)
|
TWCieColor data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data);
|
||||||
}
|
}
|
||||||
@@ -408,12 +379,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWExtImageInfo data)
|
TWExtImageInfo data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data);
|
||||||
}
|
}
|
||||||
@@ -426,12 +397,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWFilter data)
|
TWFilter data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data);
|
||||||
}
|
}
|
||||||
@@ -444,12 +415,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWGrayResponse data)
|
TWGrayResponse data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data);
|
||||||
}
|
}
|
||||||
@@ -463,12 +434,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWImageInfo data)
|
TWImageInfo data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data);
|
||||||
}
|
}
|
||||||
@@ -482,12 +453,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWImageLayout data)
|
TWImageLayout data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data);
|
||||||
}
|
}
|
||||||
@@ -501,12 +472,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWImageMemXfer data)
|
TWImageMemXfer data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data);
|
||||||
}
|
}
|
||||||
@@ -520,12 +491,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWJpegCompression data)
|
TWJpegCompression data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data);
|
||||||
}
|
}
|
||||||
@@ -539,12 +510,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWPalette8 data)
|
TWPalette8 data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data);
|
||||||
}
|
}
|
||||||
@@ -558,12 +529,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWRgbResponse data)
|
TWRgbResponse data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data);
|
||||||
}
|
}
|
||||||
@@ -577,12 +548,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
TWStatus data)
|
TWStatus data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data);
|
||||||
}
|
}
|
||||||
@@ -597,12 +568,12 @@ namespace NTwain.Triplets
|
|||||||
Message msg,
|
Message msg,
|
||||||
ref TWMemory data)
|
ref TWMemory data)
|
||||||
{
|
{
|
||||||
if (IsWin)
|
if (Platform.IsWin)
|
||||||
{
|
{
|
||||||
if (UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, ref data); }
|
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, ref data); }
|
||||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, ref data); }
|
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, ref data); }
|
||||||
}
|
}
|
||||||
else if (IsLinux)
|
else if (Platform.IsLinux)
|
||||||
{
|
{
|
||||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, ref data);
|
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, ref data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using NTwain.Internals;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace NTwain.Triplets
|
namespace NTwain.Triplets
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Security.Permissions;
|
using System.Security.Permissions;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
|
using NTwain.Internals;
|
||||||
using NTwain.Properties;
|
using NTwain.Properties;
|
||||||
using NTwain.Triplets;
|
using NTwain.Triplets;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
@@ -25,6 +25,7 @@ namespace NTwain
|
|||||||
public TwainSession(TWIdentity appId)
|
public TwainSession(TWIdentity appId)
|
||||||
{
|
{
|
||||||
if (appId == null) { throw new ArgumentNullException("appId"); }
|
if (appId == null) { throw new ArgumentNullException("appId"); }
|
||||||
|
|
||||||
_appId = appId;
|
_appId = appId;
|
||||||
((ITwainStateInternal)this).ChangeState(1, false);
|
((ITwainStateInternal)this).ChangeState(1, false);
|
||||||
EnforceState = true;
|
EnforceState = true;
|
||||||
@@ -99,7 +100,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ICommitable ITwainStateInternal.GetPendingStateChanger(int newState)
|
ICommittable ITwainStateInternal.GetPendingStateChanger(int newState)
|
||||||
{
|
{
|
||||||
return new TentativeStateCommitable(this, newState);
|
return new TentativeStateCommitable(this, newState);
|
||||||
}
|
}
|
||||||
@@ -251,7 +252,7 @@ namespace NTwain
|
|||||||
rc = DGControl.EntryPoint.Get(out entry);
|
rc = DGControl.EntryPoint.Get(out entry);
|
||||||
if (rc == ReturnCode.Success)
|
if (rc == ReturnCode.Success)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.UpdateEntryPoint(entry);
|
Platform.MemoryManager = entry;
|
||||||
Debug.WriteLine("Using TWAIN2 memory functions.");
|
Debug.WriteLine("Using TWAIN2 memory functions.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -603,7 +604,7 @@ namespace NTwain
|
|||||||
#region TWAIN logic during xfer work
|
#region TWAIN logic during xfer work
|
||||||
|
|
||||||
//[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
|
//[EnvironmentPermissionAttribute(SecurityAction.LinkDemand)]
|
||||||
void HandleWndProcMessage(ref NTwain.WindowsHook.MESSAGE winMsg, ref bool handled)
|
void HandleWndProcMessage(ref WindowsHook.MESSAGE winMsg, ref bool handled)
|
||||||
{
|
{
|
||||||
// this handles the message from a typical WndProc message loop and check if it's from the TWAIN source.
|
// this handles the message from a typical WndProc message loop and check if it's from the TWAIN source.
|
||||||
if (State >= 5)
|
if (State >= 5)
|
||||||
@@ -798,7 +799,7 @@ namespace NTwain
|
|||||||
State = 7;
|
State = 7;
|
||||||
if (dataPtr != IntPtr.Zero)
|
if (dataPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
lockedPtr = MemoryManager.Instance.Lock(dataPtr);
|
lockedPtr = Platform.MemoryManager.Lock(dataPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs { NativeData = lockedPtr });
|
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs { NativeData = lockedPtr });
|
||||||
@@ -818,12 +819,12 @@ namespace NTwain
|
|||||||
// data here is allocated by source so needs to use shared mem calls
|
// data here is allocated by source so needs to use shared mem calls
|
||||||
if (lockedPtr != IntPtr.Zero)
|
if (lockedPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Unlock(lockedPtr);
|
Platform.MemoryManager.Unlock(lockedPtr);
|
||||||
lockedPtr = IntPtr.Zero;
|
lockedPtr = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
if (dataPtr != IntPtr.Zero)
|
if (dataPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Free(dataPtr);
|
Platform.MemoryManager.Free(dataPtr);
|
||||||
dataPtr = IntPtr.Zero;
|
dataPtr = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -878,7 +879,7 @@ namespace NTwain
|
|||||||
}
|
}
|
||||||
if (dataPtr != IntPtr.Zero)
|
if (dataPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
lockedPtr = MemoryManager.Instance.Lock(dataPtr);
|
lockedPtr = Platform.MemoryManager.Lock(dataPtr);
|
||||||
}
|
}
|
||||||
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs
|
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs
|
||||||
{
|
{
|
||||||
@@ -903,12 +904,12 @@ namespace NTwain
|
|||||||
// data here is allocated by source so needs to use shared mem calls
|
// data here is allocated by source so needs to use shared mem calls
|
||||||
if (lockedPtr != IntPtr.Zero)
|
if (lockedPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Unlock(lockedPtr);
|
Platform.MemoryManager.Unlock(lockedPtr);
|
||||||
lockedPtr = IntPtr.Zero;
|
lockedPtr = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
if (dataPtr != IntPtr.Zero)
|
if (dataPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Free(dataPtr);
|
Platform.MemoryManager.Free(dataPtr);
|
||||||
dataPtr = IntPtr.Zero;
|
dataPtr = IntPtr.Zero;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -968,7 +969,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
|
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
|
||||||
Length = memInfo.Preferred,
|
Length = memInfo.Preferred,
|
||||||
TheMem = MemoryManager.Instance.Allocate(memInfo.Preferred)
|
TheMem = Platform.MemoryManager.Allocate(memInfo.Preferred)
|
||||||
};
|
};
|
||||||
|
|
||||||
// do the unthinkable and keep all xferred batches in memory,
|
// do the unthinkable and keep all xferred batches in memory,
|
||||||
@@ -992,7 +993,7 @@ namespace NTwain
|
|||||||
IntPtr lockPtr = IntPtr.Zero;
|
IntPtr lockPtr = IntPtr.Zero;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lockPtr = MemoryManager.Instance.Lock(xferInfo.Memory.TheMem);
|
lockPtr = Platform.MemoryManager.Lock(xferInfo.Memory.TheMem);
|
||||||
Marshal.Copy(lockPtr, buffer, 0, buffer.Length);
|
Marshal.Copy(lockPtr, buffer, 0, buffer.Length);
|
||||||
xferredData.Write(buffer, 0, buffer.Length);
|
xferredData.Write(buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
@@ -1000,7 +1001,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
if (lockPtr != IntPtr.Zero)
|
if (lockPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Unlock(lockPtr);
|
Platform.MemoryManager.Unlock(lockPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1045,7 +1046,7 @@ namespace NTwain
|
|||||||
State = 6;
|
State = 6;
|
||||||
if (xferInfo.Memory.TheMem != IntPtr.Zero)
|
if (xferInfo.Memory.TheMem != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Free(xferInfo.Memory.TheMem);
|
Platform.MemoryManager.Free(xferInfo.Memory.TheMem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1070,7 +1071,7 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
|
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
|
||||||
Length = memInfo.Preferred,
|
Length = memInfo.Preferred,
|
||||||
TheMem = MemoryManager.Instance.Allocate(memInfo.Preferred)
|
TheMem = Platform.MemoryManager.Allocate(memInfo.Preferred)
|
||||||
};
|
};
|
||||||
|
|
||||||
var xrc = ReturnCode.Success;
|
var xrc = ReturnCode.Success;
|
||||||
@@ -1089,14 +1090,14 @@ namespace NTwain
|
|||||||
IntPtr lockPtr = IntPtr.Zero;
|
IntPtr lockPtr = IntPtr.Zero;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lockPtr = MemoryManager.Instance.Lock(xferInfo.Memory.TheMem);
|
lockPtr = Platform.MemoryManager.Lock(xferInfo.Memory.TheMem);
|
||||||
Marshal.Copy(lockPtr, buffer, 0, buffer.Length);
|
Marshal.Copy(lockPtr, buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
if (lockPtr != IntPtr.Zero)
|
if (lockPtr != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Unlock(lockPtr);
|
Platform.MemoryManager.Unlock(lockPtr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
outStream.Write(buffer, 0, buffer.Length);
|
outStream.Write(buffer, 0, buffer.Length);
|
||||||
@@ -1170,7 +1171,7 @@ namespace NTwain
|
|||||||
State = 6;
|
State = 6;
|
||||||
if (xferInfo.Memory.TheMem != IntPtr.Zero)
|
if (xferInfo.Memory.TheMem != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
MemoryManager.Instance.Free(xferInfo.Memory.TheMem);
|
Platform.MemoryManager.Free(xferInfo.Memory.TheMem);
|
||||||
}
|
}
|
||||||
if (File.Exists(tempFile))
|
if (File.Exists(tempFile))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
@@ -60,29 +59,7 @@ namespace NTwain
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
#region caps routines
|
||||||
/// Verifies the session is within the specified state range (inclusive). Throws
|
|
||||||
/// <see cref="TwainStateException" /> if violated.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="session">The session.</param>
|
|
||||||
/// <param name="allowedMinimum">The allowed minimum.</param>
|
|
||||||
/// <param name="allowedMaximum">The allowed maximum.</param>
|
|
||||||
/// <param name="group">The triplet data group.</param>
|
|
||||||
/// <param name="dataArgumentType">The triplet data argument type.</param>
|
|
||||||
/// <param name="message">The triplet message.</param>
|
|
||||||
/// <exception cref="TwainStateException"></exception>
|
|
||||||
internal static void VerifyState(this ITwainStateInternal session, int allowedMinimum, int allowedMaximum, DataGroups group, DataArgumentType dataArgumentType, NTwain.Values.Message message)
|
|
||||||
{
|
|
||||||
if (session.EnforceState && (session.State < allowedMinimum || session.State > allowedMaximum))
|
|
||||||
{
|
|
||||||
throw new TwainStateException(session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message,
|
|
||||||
string.Format("TWAIN state {0} does not match required range {1}-{2} for operation {3}-{4}-{5}.",
|
|
||||||
session.State, allowedMinimum, allowedMaximum, group, dataArgumentType, message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#region common caps
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the current value for a capability.
|
/// Gets the current value for a capability.
|
||||||
@@ -231,7 +208,7 @@ namespace NTwain
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static ReturnCode CapSetImageCompression(this TwainSession session, CompressionType compression)
|
public static ReturnCode CapSetImageCompression(this TwainSession session, CompressionType compression)
|
||||||
{
|
{
|
||||||
using (TWCapability compressCap = new TWCapability(CapabilityId.ICapCompression, new TWOneValue { Item = (uint)compression, ItemType = Values.ItemType.UInt16 }))
|
using (TWCapability compressCap = new TWCapability(CapabilityId.ICapCompression, new TWOneValue { Item = (uint)compression, ItemType = ItemType.UInt16 }))
|
||||||
{
|
{
|
||||||
return session.DGControl.Capability.Set(compressCap);
|
return session.DGControl.Capability.Set(compressCap);
|
||||||
}
|
}
|
||||||
@@ -260,7 +237,7 @@ namespace NTwain
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static ReturnCode CapSetImageFormat(this TwainSession session, FileFormat format)
|
public static ReturnCode CapSetImageFormat(this TwainSession session, FileFormat format)
|
||||||
{
|
{
|
||||||
using (TWCapability formatCap = new TWCapability(CapabilityId.ICapImageFileFormat, new TWOneValue { Item = (uint)format, ItemType = Values.ItemType.UInt16 }))
|
using (TWCapability formatCap = new TWCapability(CapabilityId.ICapImageFileFormat, new TWOneValue { Item = (uint)format, ItemType = ItemType.UInt16 }))
|
||||||
{
|
{
|
||||||
return session.DGControl.Capability.Set(formatCap);
|
return session.DGControl.Capability.Set(formatCap);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
using System.Security.Permissions;
|
using System.Security.Permissions;
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
namespace NTwain.Values
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Contains direct magic values for some TWAIN stuff.
|
|
||||||
/// </summary>
|
|
||||||
public static class TwainConst
|
|
||||||
{
|
|
||||||
// these are specified here since the actual
|
|
||||||
// array length doesn't reflect the name :(
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Length of an array that holds TW_STR32.
|
|
||||||
/// </summary>
|
|
||||||
public const int String32 = 34;
|
|
||||||
/// <summary>
|
|
||||||
/// Length of an array that holds TW_STR64.
|
|
||||||
/// </summary>
|
|
||||||
public const int String64 = 66;
|
|
||||||
/// <summary>
|
|
||||||
/// Length of an array that holds TW_STR128.
|
|
||||||
/// </summary>
|
|
||||||
public const int String128 = 130;
|
|
||||||
/// <summary>
|
|
||||||
/// Length of an array that holds TW_STR255.
|
|
||||||
/// </summary>
|
|
||||||
public const int String255 = 256;
|
|
||||||
|
|
||||||
// deprecated
|
|
||||||
//public const int String1024 = 1026;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Don't care value for 8 bit types.
|
|
||||||
/// </summary>
|
|
||||||
public const byte DontCare8 = 0xff;
|
|
||||||
/// <summary>
|
|
||||||
/// Don't care value for 16 bit types.
|
|
||||||
/// </summary>
|
|
||||||
public const ushort DontCare16 = 0xffff;
|
|
||||||
/// <summary>
|
|
||||||
/// Don't care value for 32 bit types.
|
|
||||||
/// </summary>
|
|
||||||
public const uint DontCare32 = 0xffffffff;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The major version number of TWAIN supported by this library.
|
|
||||||
/// </summary>
|
|
||||||
public const short ProtocolMajor = 2;
|
|
||||||
/// <summary>
|
|
||||||
/// The minor version number of TWAIN supported by this library.
|
|
||||||
/// </summary>
|
|
||||||
public const short ProtocolMinor = 3;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Value for false where applicable.
|
|
||||||
/// </summary>
|
|
||||||
public const ushort True = 1;
|
|
||||||
/// <summary>
|
|
||||||
/// Value for true where applicable.
|
|
||||||
/// </summary>
|
|
||||||
public const ushort False = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
using NTwain.Data;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NTwain.Data;
|
||||||
using System;
|
using System;
|
||||||
using NTwain.Values;
|
|
||||||
|
|
||||||
namespace NTwain.Tests.Data
|
namespace NTwain.Tests.Data
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using NTwain;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using System;
|
|
||||||
using NTwain.Values;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
|
|
||||||
namespace NTwain.Tests
|
namespace NTwain.Tests
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|||||||
@@ -1,10 +1,4 @@
|
|||||||
using NTwain;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using System;
|
|
||||||
using NTwain.Values;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
using NTwain.Data;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace NTwain.Tests
|
namespace NTwain.Tests
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
using System;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using NTwain.Internals;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace NTwain.Tests
|
namespace NTwain.Tests
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
using NTwain;
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
using NTwain.Data;
|
||||||
using System;
|
|
||||||
using NTwain.Values;
|
|
||||||
using System.Runtime.Serialization;
|
|
||||||
|
|
||||||
namespace NTwain.Tests
|
namespace NTwain.Tests
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
using NTwain;
|
using NTwain;
|
||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Threading;
|
|
||||||
|
|
||||||
namespace Tester
|
namespace Tester
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
// General Information about an assembly is controlled through the following
|
// General Information about an assembly is controlled through the following
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
using ModernWPF;
|
using ModernWPF;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Configuration;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Tester.WPF
|
namespace Tester.WPF
|
||||||
|
|||||||
@@ -1,27 +1,14 @@
|
|||||||
using System;
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
using System.Collections.Generic;
|
using ModernWPF.Controls;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Controls;
|
|
||||||
using System.Windows.Data;
|
|
||||||
using System.Windows.Documents;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Media.Imaging;
|
|
||||||
using System.Windows.Navigation;
|
|
||||||
using System.Windows.Shapes;
|
|
||||||
using NTwain;
|
using NTwain;
|
||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
using System;
|
||||||
using System.Windows.Interop;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using CommonWin32;
|
|
||||||
using System.Threading;
|
|
||||||
using ModernWPF.Controls;
|
|
||||||
using System.Reflection;
|
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using GalaSoft.MvvmLight.Messaging;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Interop;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
namespace Tester.WPF
|
namespace Tester.WPF
|
||||||
{
|
{
|
||||||
@@ -522,7 +509,7 @@ namespace Tester.WPF
|
|||||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<NoiseFilter>();
|
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<NoiseFilter>();
|
||||||
break;
|
break;
|
||||||
case CapabilityId.ICapOrientation:
|
case CapabilityId.ICapOrientation:
|
||||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<NTwain.Values.Orientation>();
|
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<OrientationType>();
|
||||||
break;
|
break;
|
||||||
case CapabilityId.ICapOverScan:
|
case CapabilityId.ICapOverScan:
|
||||||
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<OverScan>();
|
CapDetailList.ItemsSource = _twainVM.GetCapabilityValues(cap).CastToEnum<OverScan>();
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Resources;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Tester.WPF.Properties {
|
namespace Tester.WPF.Properties
|
||||||
using System;
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
<Compile Include="TwainVM.cs" />
|
<Compile Include="ViewModels\TwainVM.cs" />
|
||||||
<Page Include="MainWindow.xaml">
|
<Page Include="MainWindow.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="CapVM.cs" />
|
<Compile Include="ViewModels\CapVM.cs" />
|
||||||
<Compile Include="DSVM.cs" />
|
<Compile Include="ViewModels\DSVM.cs" />
|
||||||
<Compile Include="MainWindow.xaml.cs">
|
<Compile Include="MainWindow.xaml.cs">
|
||||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Data;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Tester.WPF
|
namespace Tester.WPF
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Tester.WPF
|
namespace Tester.WPF
|
||||||
{
|
{
|
||||||
@@ -1,17 +1,12 @@
|
|||||||
using NTwain;
|
using CommonWin32;
|
||||||
|
using GalaSoft.MvvmLight.Messaging;
|
||||||
|
using NTwain;
|
||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
using NTwain.Values;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Threading;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using CommonWin32;
|
|
||||||
using System.Threading;
|
|
||||||
using GalaSoft.MvvmLight.Messaging;
|
|
||||||
using System.Diagnostics;
|
|
||||||
|
|
||||||
namespace Tester.WPF
|
namespace Tester.WPF
|
||||||
{
|
{
|
||||||
@@ -86,8 +81,6 @@ namespace Tester.WPF
|
|||||||
|
|
||||||
protected override void OnDataTransferred(DataTransferredEventArgs e)
|
protected override void OnDataTransferred(DataTransferredEventArgs e)
|
||||||
{
|
{
|
||||||
//App.Current.Dispatcher.Invoke(new Action(() =>
|
|
||||||
//{
|
|
||||||
if (e.NativeData != IntPtr.Zero)
|
if (e.NativeData != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
Image = e.NativeData.GetWPFBitmap();
|
Image = e.NativeData.GetWPFBitmap();
|
||||||
@@ -97,7 +90,6 @@ namespace Tester.WPF
|
|||||||
var img = new BitmapImage(new Uri(e.FileDataPath));
|
var img = new BitmapImage(new Uri(e.FileDataPath));
|
||||||
Image = img;
|
Image = img;
|
||||||
}
|
}
|
||||||
//}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void TestCapture(IntPtr hwnd)
|
public void TestCapture(IntPtr hwnd)
|
||||||
@@ -8,8 +8,8 @@
|
|||||||
// </auto-generated>
|
// </auto-generated>
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
namespace Tester.Winform.Properties {
|
namespace Tester.Winform.Properties
|
||||||
using System;
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,19 +1,14 @@
|
|||||||
using System;
|
using CommonWin32;
|
||||||
using System.Windows.Forms;
|
|
||||||
using System.Linq;
|
|
||||||
using NTwain.Data;
|
|
||||||
using NTwain.Values;
|
|
||||||
using NTwain.Triplets;
|
|
||||||
using NTwain;
|
using NTwain;
|
||||||
|
using NTwain.Data;
|
||||||
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Runtime.InteropServices;
|
using System.Drawing.Imaging;
|
||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using CommonWin32;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace Tester.Winform
|
namespace Tester.Winform
|
||||||
{
|
{
|
||||||
@@ -62,7 +57,7 @@ namespace Tester.Winform
|
|||||||
var appId = TWIdentity.CreateFromAssembly(DataGroups.Image, Assembly.GetEntryAssembly());
|
var appId = TWIdentity.CreateFromAssembly(DataGroups.Image, Assembly.GetEntryAssembly());
|
||||||
_twain = new TwainSession(appId);
|
_twain = new TwainSession(appId);
|
||||||
// either set this and don't worry about threads during events,
|
// either set this and don't worry about threads during events,
|
||||||
// or don't and invoke during the events yourselv
|
// or don't and invoke during the events yourself
|
||||||
_twain.SynchronizationContext = SynchronizationContext.Current;
|
_twain.SynchronizationContext = SynchronizationContext.Current;
|
||||||
_twain.StateChanged += (s, e) =>
|
_twain.StateChanged += (s, e) =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user