Some name-breaking changes so master is now v3. V2 will continue to be the code on nuget for now.

This commit is contained in:
soukoku
2014-09-15 07:24:13 -04:00
parent 0cd02ac16e
commit 92063d2b84
62 changed files with 422 additions and 267 deletions

View File

@@ -48,6 +48,12 @@
<Compile Include="..\NTwain\CapabilityReader.cs"> <Compile Include="..\NTwain\CapabilityReader.cs">
<Link>CapabilityReader.cs</Link> <Link>CapabilityReader.cs</Link>
</Compile> </Compile>
<Compile Include="..\NTwain\DataSource.Caps.cs">
<Link>DataSource.Caps.cs</Link>
</Compile>
<Compile Include="..\NTwain\DataSource.cs">
<Link>DataSource.cs</Link>
</Compile>
<Compile Include="..\NTwain\DataTransferredEventArgs.cs"> <Compile Include="..\NTwain\DataTransferredEventArgs.cs">
<Link>DataTransferredEventArgs.cs</Link> <Link>DataTransferredEventArgs.cs</Link>
</Compile> </Compile>
@@ -69,6 +75,9 @@
<Compile Include="..\NTwain\DeviceEventArgs.cs"> <Compile Include="..\NTwain\DeviceEventArgs.cs">
<Link>DeviceEventArgs.cs</Link> <Link>DeviceEventArgs.cs</Link>
</Compile> </Compile>
<Compile Include="..\NTwain\IDataSource.cs">
<Link>IDataSource.cs</Link>
</Compile>
<Compile Include="..\NTwain\IMemoryManager.cs"> <Compile Include="..\NTwain\IMemoryManager.cs">
<Link>IMemoryManager.cs</Link> <Link>IMemoryManager.cs</Link>
</Compile> </Compile>
@@ -108,14 +117,17 @@
<Compile Include="..\NTwain\Internals\WrappedManualResetEvent.cs"> <Compile Include="..\NTwain\Internals\WrappedManualResetEvent.cs">
<Link>Internals\WrappedManualResetEvent.cs</Link> <Link>Internals\WrappedManualResetEvent.cs</Link>
</Compile> </Compile>
<Compile Include="..\NTwain\IPlatformInfo.cs">
<Link>IPlatformInfo.cs</Link>
</Compile>
<Compile Include="..\NTwain\ITwainSession.cs"> <Compile Include="..\NTwain\ITwainSession.cs">
<Link>ITwainSession.cs</Link> <Link>ITwainSession.cs</Link>
</Compile> </Compile>
<Compile Include="..\NTwain\MessageLoopHooks.cs"> <Compile Include="..\NTwain\MessageLoopHooks.cs">
<Link>MessageLoopHooks.cs</Link> <Link>MessageLoopHooks.cs</Link>
</Compile> </Compile>
<Compile Include="..\NTwain\Platform.cs"> <Compile Include="..\NTwain\PlatformInfo.cs">
<Link>Platform.cs</Link> <Link>PlatformInfo.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>
@@ -270,8 +282,8 @@
<Compile Include="..\NTwain\Triplets\Dsm.WinOld.cs"> <Compile Include="..\NTwain\Triplets\Dsm.WinOld.cs">
<Link>Triplets\Dsm.WinOld.cs</Link> <Link>Triplets\Dsm.WinOld.cs</Link>
</Compile> </Compile>
<Compile Include="..\NTwain\Triplets\OpBase.cs"> <Compile Include="..\NTwain\Triplets\TripletBase.cs">
<Link>Triplets\OpBase.cs</Link> <Link>Triplets\TripletBase.cs</Link>
</Compile> </Compile>
<Compile Include="..\NTwain\TwainException.cs"> <Compile Include="..\NTwain\TwainException.cs">
<Link>TwainException.cs</Link> <Link>TwainException.cs</Link>
@@ -282,12 +294,6 @@
<Compile Include="..\NTwain\TwainSessionInternal.cs"> <Compile Include="..\NTwain\TwainSessionInternal.cs">
<Link>TwainSessionInternal.cs</Link> <Link>TwainSessionInternal.cs</Link>
</Compile> </Compile>
<Compile Include="..\NTwain\TwainSource.Caps.cs">
<Link>TwainSource.Caps.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainSource.cs">
<Link>TwainSource.cs</Link>
</Compile>
<Compile Include="..\NTwain\TwainStateException.cs"> <Compile Include="..\NTwain\TwainStateException.cs">
<Link>TwainStateException.cs</Link> <Link>TwainStateException.cs</Link>
</Compile> </Compile>

View File

@@ -20,20 +20,39 @@ namespace NTwain
/// <param name="capability">The capability.</param> /// <param name="capability">The capability.</param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="System.ArgumentNullException">capability</exception> /// <exception cref="System.ArgumentNullException">capability</exception>
/// <exception cref="System.ArgumentException"> /// <exception cref="System.ArgumentException">Capability contains no data.;capability
/// Capability contains no data.;capability
/// or /// or
/// capability /// capability</exception>
/// </exception>
public static CapabilityReader ReadValue(TWCapability capability) public static CapabilityReader ReadValue(TWCapability capability)
{
return ReadValue(capability, PlatformInfo.Current);
}
/// <summary>
/// Reads the value from a <see cref="TWCapability" /> that was returned
/// from a TWAIN source.
/// </summary>
/// <param name="capability">The capability.</param>
/// <param name="platformInfo">The platform information.</param>
/// <returns></returns>
/// <exception cref="System.ArgumentNullException">
/// capability
/// or
/// platformInfo
/// </exception>
/// <exception cref="System.ArgumentException">Capability contains no data.;capability
/// or
/// capability</exception>
public static CapabilityReader ReadValue(TWCapability capability, IPlatformInfo platformInfo)
{ {
if (capability == null) { throw new ArgumentNullException("capability"); } if (capability == null) { throw new ArgumentNullException("capability"); }
if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); } if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); }
if (platformInfo == null) { throw new ArgumentNullException("platformInfo"); }
IntPtr baseAddr = IntPtr.Zero; IntPtr baseAddr = IntPtr.Zero;
try try
{ {
baseAddr = Platform.MemoryManager.Lock(capability.Container); baseAddr = platformInfo.MemoryManager.Lock(capability.Container);
switch (capability.ContainerType) switch (capability.ContainerType)
{ {
case ContainerType.Array: case ContainerType.Array:
@@ -64,7 +83,7 @@ namespace NTwain
{ {
if (baseAddr != IntPtr.Zero) if (baseAddr != IntPtr.Zero)
{ {
Platform.MemoryManager.Unlock(baseAddr); platformInfo.MemoryManager.Unlock(baseAddr);
} }
} }
} }

View File

@@ -635,7 +635,7 @@ namespace NTwain.Data
public TWCapability(CapabilityId capability) public TWCapability(CapabilityId capability)
{ {
Capability = capability; Capability = capability;
ContainerType = ContainerType.DontCare; ContainerType = ContainerType.DoNotCare;
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TWCapability" /> class. /// Initializes a new instance of the <see cref="TWCapability" /> class.
@@ -699,7 +699,7 @@ namespace NTwain.Data
// 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(CultureInfo.InvariantCulture, Resources.BadValueType, "TWOneValue")); } if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TWOneValue")); }
_hContainer = Platform.MemoryManager.Allocate((uint)Marshal.SizeOf(value)); _hContainer = PlatformInfo.Current.MemoryManager.Allocate((uint)Marshal.SizeOf(value));
if (_hContainer != IntPtr.Zero) if (_hContainer != IntPtr.Zero)
{ {
Marshal.StructureToPtr(value, _hContainer, false); Marshal.StructureToPtr(value, _hContainer, false);
@@ -715,8 +715,8 @@ namespace NTwain.Data
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 = Platform.MemoryManager.Allocate((uint)valueSize); _hContainer = PlatformInfo.Current.MemoryManager.Allocate((uint)valueSize);
IntPtr baseAddr = Platform.MemoryManager.Lock(_hContainer); IntPtr baseAddr = PlatformInfo.Current.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);
@@ -727,7 +727,7 @@ namespace NTwain.Data
{ {
WriteValue(baseAddr, ref offset, value.ItemType, item); WriteValue(baseAddr, ref offset, value.ItemType, item);
} }
Platform.MemoryManager.Unlock(baseAddr); PlatformInfo.Current.MemoryManager.Unlock(baseAddr);
} }
@@ -739,7 +739,7 @@ namespace NTwain.Data
// 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(CultureInfo.InvariantCulture, Resources.BadValueType, "TWRange")); } if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, Resources.BadValueType, "TWRange")); }
_hContainer = Platform.MemoryManager.Allocate((uint)Marshal.SizeOf(value)); _hContainer = PlatformInfo.Current.MemoryManager.Allocate((uint)Marshal.SizeOf(value));
if (_hContainer != IntPtr.Zero) if (_hContainer != IntPtr.Zero)
{ {
Marshal.StructureToPtr(value, _hContainer, false); Marshal.StructureToPtr(value, _hContainer, false);
@@ -903,7 +903,7 @@ namespace NTwain.Data
if (disposing) { } if (disposing) { }
if (_hContainer != IntPtr.Zero) if (_hContainer != IntPtr.Zero)
{ {
Platform.MemoryManager.Free(_hContainer); PlatformInfo.Current.MemoryManager.Free(_hContainer);
_hContainer = IntPtr.Zero; _hContainer = IntPtr.Zero;
} }
} }
@@ -1435,7 +1435,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));
Platform.MemoryManager.Free(ptr); PlatformInfo.Current.MemoryManager.Free(ptr);
} }
} }
it.Item = UIntPtr.Zero; it.Item = UIntPtr.Zero;
@@ -2138,7 +2138,7 @@ namespace NTwain.Data
/// </summary> /// </summary>
public TWPendingXfers() public TWPendingXfers()
{ {
_count = TwainConst.DontCare16; _count = TwainConst.DoNotCare16;
} }
/// <summary> /// <summary>
@@ -2146,7 +2146,7 @@ namespace NTwain.Data
/// connected to. If no more transfers are available, set to zero. If an unknown and /// connected to. If no more transfers are available, set to zero. If an unknown and
/// non-zero number of transfers are available, set to -1. /// non-zero number of transfers are available, set to -1.
/// </summary> /// </summary>
public int Count { get { return _count == TwainConst.DontCare16 ? -1 : (int)_count; } } public int Count { get { return _count == TwainConst.DoNotCare16 ? -1 : (int)_count; } }
/// <summary> /// <summary>
/// The application should check this field if the CapJobControl is set to other /// The application should check this field if the CapJobControl is set to other
/// than None. If this is not 0, the application should expect more data /// than None. If this is not 0, the application should expect more data
@@ -2181,7 +2181,7 @@ namespace NTwain.Data
/// <summary> /// <summary>
/// The devices "power-on" value for the capability. If the application is /// The devices "power-on" value for the capability. If the application is
/// performing a MSG_SET operation and isnt sure what the default /// performing a MSG_SET operation and isnt sure what the default
/// value is, set this field to <see cref="TwainConst.DontCare32"/>. /// value is, set this field to <see cref="TwainConst.DoNotCare32"/>.
/// </summary> /// </summary>
public uint DefaultValue { get { return _defaultValue; } set { _defaultValue = value; } } public uint DefaultValue { get { return _defaultValue; } set { _defaultValue = value; } }
/// <summary> /// <summary>
@@ -2352,7 +2352,7 @@ namespace NTwain.Data
} }
if (_uTF8string != IntPtr.Zero) if (_uTF8string != IntPtr.Zero)
{ {
Platform.MemoryManager.Free(_uTF8string); PlatformInfo.Current.MemoryManager.Free(_uTF8string);
_uTF8string = IntPtr.Zero; _uTF8string = IntPtr.Zero;
} }
} }

View File

@@ -40,7 +40,7 @@ namespace NTwain.Data
/// <summary> /// <summary>
/// The don't care value. /// The don't care value.
/// </summary> /// </summary>
DontCare = TwainConst.DontCare16, DoNotCare = TwainConst.DoNotCare16,
} }
/// <summary> /// <summary>
@@ -2044,7 +2044,7 @@ namespace NTwain.Data
/// Corresponds to TWQC_*. /// Corresponds to TWQC_*.
/// </summary> /// </summary>
[Flags] [Flags]
public enum QuerySupport public enum QuerySupports
{ {
None = 0, None = 0,
Get = 0x1, Get = 0x1,
@@ -2120,15 +2120,15 @@ namespace NTwain.Data
/// <summary> /// <summary>
/// Don't care value for 8 bit types. /// Don't care value for 8 bit types.
/// </summary> /// </summary>
public const byte DontCare8 = 0xff; public const byte DoNotCare8 = 0xff;
/// <summary> /// <summary>
/// Don't care value for 16 bit types. /// Don't care value for 16 bit types.
/// </summary> /// </summary>
public const ushort DontCare16 = 0xffff; public const ushort DoNotCare16 = 0xffff;
/// <summary> /// <summary>
/// Don't care value for 32 bit types. /// Don't care value for 32 bit types.
/// </summary> /// </summary>
public const uint DontCare32 = 0xffffffff; public const uint DoNotCare32 = 0xffffffff;
/// <summary> /// <summary>
/// The major version number of TWAIN supported by this library. /// The major version number of TWAIN supported by this library.

View File

@@ -9,16 +9,16 @@ namespace NTwain
// this contains all cap-related methods prefixed with Cap // this contains all cap-related methods prefixed with Cap
partial class TwainSource partial class DataSource
{ {
/// <summary> /// <summary>
/// Gets the actual supported operations for a capability. /// Gets the actual supported operations for a capability.
/// </summary> /// </summary>
/// <param name="capId">The cap identifier.</param> /// <param name="capId">The cap identifier.</param>
/// <returns></returns> /// <returns></returns>
public QuerySupport CapQuerySupport(CapabilityId capId) public QuerySupports CapQuerySupport(CapabilityId capId)
{ {
QuerySupport retVal = QuerySupport.None; QuerySupports retVal = QuerySupports.None;
using (TWCapability cap = new TWCapability(capId)) using (TWCapability cap = new TWCapability(capId))
{ {
var rc = _session.DGControl.Capability.QuerySupport(cap); var rc = _session.DGControl.Capability.QuerySupport(cap);
@@ -28,7 +28,7 @@ namespace NTwain
if (read.ContainerType == ContainerType.OneValue) if (read.ContainerType == ContainerType.OneValue)
{ {
retVal = read.OneValue.ConvertToEnum<QuerySupport>(); retVal = read.OneValue.ConvertToEnum<QuerySupports>();
} }
} }
} }
@@ -76,7 +76,7 @@ namespace NTwain
/// <summary> /// <summary>
/// A general method that tries to get capability values from current <see cref="TwainSource" />. /// A general method that tries to get capability values from current <see cref="DataSource" />.
/// </summary> /// </summary>
/// <param name="capabilityId">The capability unique identifier.</param> /// <param name="capabilityId">The capability unique identifier.</param>
/// <returns></returns> /// <returns></returns>

View File

@@ -15,11 +15,11 @@ namespace NTwain
/// <summary> /// <summary>
/// Represents a TWAIN data source. /// Represents a TWAIN data source.
/// </summary> /// </summary>
public partial class TwainSource public partial class DataSource : IDataSource
{ {
ITwainSessionInternal _session; ITwainSessionInternal _session;
internal TwainSource(ITwainSessionInternal session, TWIdentity sourceId) internal DataSource(ITwainSessionInternal session, TWIdentity sourceId)
{ {
_session = session; _session = session;
Identity = sourceId; Identity = sourceId;

17
NTwain/IDataSource.cs Normal file
View File

@@ -0,0 +1,17 @@
using System;
namespace NTwain
{
/// <summary>
/// Represents a TWAIN data source.
/// </summary>
public interface IDataSource
{
/// <summary>
/// Gets the source's product name.
/// </summary>
/// <value>
/// The name.
/// </value>
string Name { get; }
}
}

51
NTwain/IPlatformInfo.cs Normal file
View File

@@ -0,0 +1,51 @@
using System;
namespace NTwain
{
/// <summary>
/// Contains various platform requirements and conditions for TWAIN.
/// </summary>
public interface IPlatformInfo
{
/// <summary>
/// Gets a value indicating whether the applicable TWAIN DSM library exists in the operating system.
/// </summary>
/// <value>
/// <c>true</c> if the TWAIN DSM; otherwise, <c>false</c>.
/// </value>
bool DsmExists { get; }
/// <summary>
/// Gets the expected TWAIN DSM dll path.
/// </summary>
/// <value>
/// The expected DSM path.
/// </value>
string ExpectedDsmPath { get; }
/// <summary>
/// Gets a value indicating whether the application is running in 64-bit.
/// </summary>
/// <value>
/// <c>true</c> if the application is 64-bit; otherwise, <c>false</c>.
/// </value>
bool IsApp64bit { get; }
/// <summary>
/// Gets a value indicating whether this library is supported on current OS.
/// Check the other platform properties to determine the reason if this is false.
/// </summary>
/// <value>
/// <c>true</c> if this library is supported; otherwise, <c>false</c>.
/// </value>
bool IsSupported { get; }
/// <summary>
/// Gets the <see cref="IMemoryManager"/> for communicating with data sources.
/// This should only be used when a <see cref="TwainSession"/> is open.
/// </summary>
/// <value>
/// The memory manager.
/// </value>
IMemoryManager MemoryManager { get; }
}
}

View File

@@ -12,11 +12,11 @@ namespace NTwain
/// <summary> /// <summary>
/// General interface for a TWAIN session. /// General interface for a TWAIN session.
/// </summary> /// </summary>
public interface ITwainSession : INotifyPropertyChanged public interface ITwainSession : IEnumerable<DataSource>, INotifyPropertyChanged
{ {
/// <summary> /// <summary>
/// [Experimental] Gets or sets the optional synchronization context when not specifying a <see cref="MessageLoopHook"/> on <see cref="Open"/>. /// [Experimental] Gets or sets the optional synchronization context when not specifying a <see cref="MessageLoopHook"/> on <see cref="Open()"/>.
/// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use. /// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use.
/// </summary> /// </summary>
/// <value> /// <value>
@@ -39,7 +39,7 @@ namespace NTwain
/// <value> /// <value>
/// The current source. /// The current source.
/// </value> /// </value>
TwainSource CurrentSource { get; } DataSource CurrentSource { get; }
/// <summary> /// <summary>
/// Gets or sets the default source for this application. /// Gets or sets the default source for this application.
@@ -49,7 +49,7 @@ namespace NTwain
/// <value> /// <value>
/// The default source. /// The default source.
/// </value> /// </value>
TwainSource DefaultSource { get; set; } DataSource DefaultSource { get; set; }
/// <summary> /// <summary>
/// Gets the current state number as defined by the TWAIN spec. /// Gets the current state number as defined by the TWAIN spec.
@@ -83,7 +83,7 @@ namespace NTwain
/// This is not recommended and is only included for completeness. /// This is not recommended and is only included for completeness.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
TwainSource ShowSourceSelector(); DataSource ShowSourceSelector();
/// <summary> /// <summary>
@@ -120,7 +120,7 @@ namespace NTwain
/// Gets list of sources available in the system. /// Gets list of sources available in the system.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
IEnumerable<TwainSource> GetSources(); IEnumerable<DataSource> GetSources();
/// <summary> /// <summary>
/// Quick shortcut to open a source. /// Quick shortcut to open a source.

View File

@@ -2,8 +2,15 @@
namespace NTwain.Internals namespace NTwain.Internals
{ {
/// <summary>
/// For something that is in a pending state until finalized with a Commit() call.
/// The changes are rolled back if it is disposed without being committed.
/// </summary>
interface ICommittable : IDisposable interface ICommittable : IDisposable
{ {
/// <summary>
/// Commits the pending changes.
/// </summary>
void Commit(); void Commit();
} }
} }

View File

@@ -6,6 +6,9 @@ using System.Threading;
namespace NTwain.Internals namespace NTwain.Internals
{ {
/// <summary>
/// Extends <see cref="ITwainSession"/> with extra stuff for internal use.
/// </summary>
interface ITwainSessionInternal : ITwainSession interface ITwainSessionInternal : ITwainSession
{ {
/// <summary> /// <summary>
@@ -31,7 +34,7 @@ namespace NTwain.Internals
/// <returns></returns> /// <returns></returns>
ICommittable GetPendingStateChanger(int newState); ICommittable GetPendingStateChanger(int newState);
void ChangeCurrentSource(TwainSource source); void ChangeCurrentSource(DataSource source);
ReturnCode DisableSource(); ReturnCode DisableSource();
@@ -41,8 +44,6 @@ namespace NTwain.Internals
ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle); ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle);
SynchronizationContext SynchronizationContext { get; set; }
/// <summary> /// <summary>
/// Gets the triplet operations defined for audio data group. /// Gets the triplet operations defined for audio data group.
/// </summary> /// </summary>

View File

@@ -9,6 +9,10 @@ using System.Windows.Threading;
namespace NTwain.Internals namespace NTwain.Internals
{ {
/// <summary>
/// This is the self-hosted message loop for TWAIN communication.
/// It utilizes the wpf Dispatcher to do all the hard work.
/// </summary>
sealed class InternalMessageLoopHook : MessageLoopHook sealed class InternalMessageLoopHook : MessageLoopHook
{ {
Dispatcher _dispatcher; Dispatcher _dispatcher;
@@ -32,7 +36,7 @@ namespace NTwain.Internals
{ {
Debug.WriteLine("NTwain message loop is starting."); Debug.WriteLine("NTwain message loop is starting.");
_dispatcher = Dispatcher.CurrentDispatcher; _dispatcher = Dispatcher.CurrentDispatcher;
if (!Platform.IsOnMono) if (!PlatformInfo.__global.IsOnMono)
{ {
_hook = new WindowsHook(filter); _hook = new WindowsHook(filter);
Handle = _hook.Handle; Handle = _hook.Handle;
@@ -71,7 +75,7 @@ namespace NTwain.Internals
{ {
action(); action();
} }
else if (Platform.IsOnMono) else if (PlatformInfo.__global.IsOnMono)
{ {
using (var man = new WrappedManualResetEvent()) using (var man = new WrappedManualResetEvent())
{ {

View File

@@ -134,7 +134,7 @@ namespace NTwain.Internals
session.ChangeState(7, true); session.ChangeState(7, true);
if (dataPtr != IntPtr.Zero) if (dataPtr != IntPtr.Zero)
{ {
lockedPtr = Platform.MemoryManager.Lock(dataPtr); lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr);
} }
session.SafeSyncableRaiseEvent(new DataTransferredEventArgs(lockedPtr, null)); session.SafeSyncableRaiseEvent(new DataTransferredEventArgs(lockedPtr, null));
@@ -154,12 +154,12 @@ namespace NTwain.Internals
// 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)
{ {
Platform.MemoryManager.Unlock(lockedPtr); PlatformInfo.Current.MemoryManager.Unlock(lockedPtr);
lockedPtr = IntPtr.Zero; lockedPtr = IntPtr.Zero;
} }
if (dataPtr != IntPtr.Zero) if (dataPtr != IntPtr.Zero)
{ {
Platform.MemoryManager.Free(dataPtr); PlatformInfo.Current.MemoryManager.Free(dataPtr);
dataPtr = IntPtr.Zero; dataPtr = IntPtr.Zero;
} }
} }
@@ -201,7 +201,7 @@ namespace NTwain.Internals
session.ChangeState(7, true); session.ChangeState(7, true);
if (dataPtr != IntPtr.Zero) if (dataPtr != IntPtr.Zero)
{ {
lockedPtr = Platform.MemoryManager.Lock(dataPtr); lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr);
} }
DoImageXferredEventRoutine(session, lockedPtr, null, null); DoImageXferredEventRoutine(session, lockedPtr, null, null);
} }
@@ -220,12 +220,12 @@ namespace NTwain.Internals
// 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)
{ {
Platform.MemoryManager.Unlock(lockedPtr); PlatformInfo.Current.MemoryManager.Unlock(lockedPtr);
lockedPtr = IntPtr.Zero; lockedPtr = IntPtr.Zero;
} }
if (dataPtr != IntPtr.Zero) if (dataPtr != IntPtr.Zero)
{ {
Platform.MemoryManager.Free(dataPtr); PlatformInfo.Current.MemoryManager.Free(dataPtr);
dataPtr = IntPtr.Zero; dataPtr = IntPtr.Zero;
} }
} }
@@ -266,7 +266,7 @@ namespace NTwain.Internals
{ {
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer, Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
Length = memInfo.Preferred, Length = memInfo.Preferred,
TheMem = Platform.MemoryManager.Allocate(memInfo.Preferred) TheMem = PlatformInfo.Current.MemoryManager.Allocate(memInfo.Preferred)
}; };
// do the unthinkable and keep all xferred batches in memory, // do the unthinkable and keep all xferred batches in memory,
@@ -290,7 +290,7 @@ namespace NTwain.Internals
IntPtr lockPtr = IntPtr.Zero; IntPtr lockPtr = IntPtr.Zero;
try try
{ {
lockPtr = Platform.MemoryManager.Lock(xferInfo.Memory.TheMem); lockPtr = PlatformInfo.Current.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);
} }
@@ -298,7 +298,7 @@ namespace NTwain.Internals
{ {
if (lockPtr != IntPtr.Zero) if (lockPtr != IntPtr.Zero)
{ {
Platform.MemoryManager.Unlock(lockPtr); PlatformInfo.Current.MemoryManager.Unlock(lockPtr);
} }
} }
} }
@@ -323,7 +323,7 @@ namespace NTwain.Internals
session.ChangeState(6, true); session.ChangeState(6, true);
if (xferInfo.Memory.TheMem != IntPtr.Zero) if (xferInfo.Memory.TheMem != IntPtr.Zero)
{ {
Platform.MemoryManager.Free(xferInfo.Memory.TheMem); PlatformInfo.Current.MemoryManager.Free(xferInfo.Memory.TheMem);
} }
} }
@@ -348,7 +348,7 @@ namespace NTwain.Internals
{ {
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer, Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
Length = memInfo.Preferred, Length = memInfo.Preferred,
TheMem = Platform.MemoryManager.Allocate(memInfo.Preferred) TheMem = PlatformInfo.Current.MemoryManager.Allocate(memInfo.Preferred)
}; };
var xrc = ReturnCode.Success; var xrc = ReturnCode.Success;
@@ -367,14 +367,14 @@ namespace NTwain.Internals
IntPtr lockPtr = IntPtr.Zero; IntPtr lockPtr = IntPtr.Zero;
try try
{ {
lockPtr = Platform.MemoryManager.Lock(xferInfo.Memory.TheMem); lockPtr = PlatformInfo.Current.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)
{ {
Platform.MemoryManager.Unlock(lockPtr); PlatformInfo.Current.MemoryManager.Unlock(lockPtr);
} }
} }
outStream.Write(buffer, 0, buffer.Length); outStream.Write(buffer, 0, buffer.Length);
@@ -401,7 +401,7 @@ namespace NTwain.Internals
session.ChangeState(6, true); session.ChangeState(6, true);
if (xferInfo.Memory.TheMem != IntPtr.Zero) if (xferInfo.Memory.TheMem != IntPtr.Zero)
{ {
Platform.MemoryManager.Free(xferInfo.Memory.TheMem); PlatformInfo.Current.MemoryManager.Free(xferInfo.Memory.TheMem);
} }
if (File.Exists(tempFile)) if (File.Exists(tempFile))
{ {

View File

@@ -59,6 +59,7 @@
<Compile Include="Data\TypeReader.cs" /> <Compile Include="Data\TypeReader.cs" />
<Compile Include="Data\TwainTypesExtended.cs" /> <Compile Include="Data\TwainTypesExtended.cs" />
<Compile Include="DeviceEventArgs.cs" /> <Compile Include="DeviceEventArgs.cs" />
<Compile Include="IDataSource.cs" />
<Compile Include="Internals\Extensions.cs" /> <Compile Include="Internals\Extensions.cs" />
<Compile Include="DataTransferredEventArgs.cs" /> <Compile Include="DataTransferredEventArgs.cs" />
<Compile Include="IMemoryManager.cs" /> <Compile Include="IMemoryManager.cs" />
@@ -69,12 +70,13 @@
<Compile Include="Internals\TransferLogic.cs" /> <Compile Include="Internals\TransferLogic.cs" />
<Compile Include="Internals\WindowsHook.cs" /> <Compile Include="Internals\WindowsHook.cs" />
<Compile Include="Internals\WrappedManualResetEvent.cs" /> <Compile Include="Internals\WrappedManualResetEvent.cs" />
<Compile Include="IPlatformInfo.cs" />
<Compile Include="ITwainSession.cs" /> <Compile Include="ITwainSession.cs" />
<Compile Include="Internals\WinMemoryManager.cs" /> <Compile Include="Internals\WinMemoryManager.cs" />
<Compile Include="Internals\UnsafeNativeMethods.cs" /> <Compile Include="Internals\UnsafeNativeMethods.cs" />
<Compile Include="Internals\IWinMessageFilter.cs" /> <Compile Include="Internals\IWinMessageFilter.cs" />
<Compile Include="MessageLoopHooks.cs" /> <Compile Include="MessageLoopHooks.cs" />
<Compile Include="Platform.cs" /> <Compile Include="PlatformInfo.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>
@@ -88,14 +90,14 @@
<Compile Include="Triplets\DGControl\DGControl.CapabilityCustom.cs" /> <Compile Include="Triplets\DGControl\DGControl.CapabilityCustom.cs" />
<Compile Include="Triplets\DGImage\DGImage.Filter.cs" /> <Compile Include="Triplets\DGImage\DGImage.Filter.cs" />
<Compile Include="Triplets\DGCustom.cs" /> <Compile Include="Triplets\DGCustom.cs" />
<Compile Include="Triplets\OpBase.cs" /> <Compile Include="Triplets\TripletBase.cs" />
<Compile Include="Triplets\Dsm.Linux.cs" /> <Compile Include="Triplets\Dsm.Linux.cs" />
<Compile Include="Triplets\Dsm.WinOld.cs" /> <Compile Include="Triplets\Dsm.WinOld.cs" />
<Compile Include="Triplets\Dsm.WinNew.cs" /> <Compile Include="Triplets\Dsm.WinNew.cs" />
<Compile Include="TwainSessionInternal.cs" /> <Compile Include="TwainSessionInternal.cs" />
<Compile Include="TwainSource.Caps.cs" /> <Compile Include="DataSource.Caps.cs" />
<Compile Include="TwainSession.cs" /> <Compile Include="TwainSession.cs" />
<Compile Include="TwainSource.cs" /> <Compile Include="DataSource.cs" />
<Compile Include="TwainStateException.cs" /> <Compile Include="TwainStateException.cs" />
<Compile Include="Data\TwainTypes.cs" /> <Compile Include="Data\TwainTypes.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />

View File

@@ -8,44 +8,57 @@ using System.Text;
namespace NTwain namespace NTwain
{ {
/// <summary> /// <summary>
/// Class for checking various platform requirements and conditions. /// Contains various platform requirements and conditions for TWAIN.
/// </summary> /// </summary>
public static class Platform public class PlatformInfo : IPlatformInfo
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")] internal static readonly PlatformInfo __global = new PlatformInfo();
static Platform() /// <summary>
/// Gets the current platform info related to TWAIN.
/// </summary>
/// <value>
/// The current info.
/// </value>
public static IPlatformInfo Current { get { return __global; } }
PlatformInfo()
{ {
IsApp64bit = IntPtr.Size == 8; IsApp64bit = IntPtr.Size == 8;
IsOnMono = Type.GetType("Mono.Runtime") != null; IsOnMono = Type.GetType("Mono.Runtime") != null;
IsWin = Environment.OSVersion.Platform == PlatformID.Win32NT; IsWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;
IsLinux = Environment.OSVersion.Platform == PlatformID.Unix; IsLinux = Environment.OSVersion.Platform == PlatformID.Unix;
if (IsWin) if (IsWindows)
{ {
var newDsmPath = Path.Combine(Environment.SystemDirectory, Dsm.WIN_NEW_DSM_NAME); var newDsmPath = Path.Combine(Environment.SystemDirectory, Dsm.WIN_NEW_DSM_NAME);
var oldDsmPath = Path.Combine(Environment.SystemDirectory, Dsm.WIN_OLD_DSM_NAME); var oldDsmPath = Path.Combine(Environment.SystemDirectory, Dsm.WIN_OLD_DSM_NAME);
if (IsApp64bit) if (IsApp64bit)
{ {
IsSupported = DsmExists = File.Exists(newDsmPath); ExpectedDsmPath = newDsmPath;
IsSupported = DsmExists = File.Exists(ExpectedDsmPath);
UseNewWinDSM = true; UseNewWinDSM = true;
} }
else else
{ {
if (File.Exists(newDsmPath)) if (File.Exists(newDsmPath))
{ {
ExpectedDsmPath = newDsmPath;
UseNewWinDSM = IsSupported = DsmExists = true; UseNewWinDSM = IsSupported = DsmExists = true;
} }
else else
{ {
IsSupported = DsmExists = File.Exists(oldDsmPath); ExpectedDsmPath = oldDsmPath;
IsSupported = DsmExists = File.Exists(ExpectedDsmPath);
} }
} }
} }
else if (IsLinux) else if (IsLinux)
{ {
DsmExists = File.Exists(Dsm.LINUX_DSM_PATH); ExpectedDsmPath = Dsm.LINUX_DSM_PATH;
DsmExists = File.Exists(ExpectedDsmPath);
IsSupported = DsmExists && IsOnMono; IsSupported = DsmExists && IsOnMono;
} }
else else
@@ -56,11 +69,10 @@ namespace NTwain
_defaultMemManager = new WinMemoryManager(); _defaultMemManager = new WinMemoryManager();
} }
// prefer the use of the twain dsm on windows. internal readonly bool UseNewWinDSM;
internal static readonly bool UseNewWinDSM; internal readonly bool IsOnMono;
internal static readonly bool IsOnMono; internal readonly bool IsWindows;
internal static readonly bool IsWin; internal readonly bool IsLinux;
internal static readonly bool IsLinux;
/// <summary> /// <summary>
/// Gets a value indicating whether the application is running in 64-bit. /// Gets a value indicating whether the application is running in 64-bit.
@@ -68,7 +80,7 @@ namespace NTwain
/// <value> /// <value>
/// <c>true</c> if the application is 64-bit; otherwise, <c>false</c>. /// <c>true</c> if the application is 64-bit; otherwise, <c>false</c>.
/// </value> /// </value>
public static bool IsApp64bit { get; private set; } public bool IsApp64bit { get; private set; }
/// <summary> /// <summary>
/// Gets a value indicating whether the applicable TWAIN DSM library exists in the operating system. /// Gets a value indicating whether the applicable TWAIN DSM library exists in the operating system.
@@ -76,7 +88,15 @@ namespace NTwain
/// <value> /// <value>
/// <c>true</c> if the TWAIN DSM; otherwise, <c>false</c>. /// <c>true</c> if the TWAIN DSM; otherwise, <c>false</c>.
/// </value> /// </value>
public static bool DsmExists { get; private set; } public bool DsmExists { get; private set; }
/// <summary>
/// Gets the expected TWAIN DSM dll path.
/// </summary>
/// <value>
/// The expected DSM path.
/// </value>
public string ExpectedDsmPath { get; private set; }
/// <summary> /// <summary>
/// Gets a value indicating whether this library is supported on current OS. /// Gets a value indicating whether this library is supported on current OS.
@@ -85,11 +105,11 @@ namespace NTwain
/// <value> /// <value>
/// <c>true</c> if this library is supported; otherwise, <c>false</c>. /// <c>true</c> if this library is supported; otherwise, <c>false</c>.
/// </value> /// </value>
public static bool IsSupported { get; private set; } public bool IsSupported { get; private set; }
static readonly IMemoryManager _defaultMemManager; readonly IMemoryManager _defaultMemManager;
static IMemoryManager _specifiedMemManager; IMemoryManager _specifiedMemManager;
/// <summary> /// <summary>
/// Gets the <see cref="IMemoryManager"/> for communicating with data sources. /// Gets the <see cref="IMemoryManager"/> for communicating with data sources.
@@ -98,7 +118,7 @@ namespace NTwain
/// <value> /// <value>
/// The memory manager. /// The memory manager.
/// </value> /// </value>
public static IMemoryManager MemoryManager public IMemoryManager MemoryManager
{ {
get get
{ {

View File

@@ -11,9 +11,9 @@ namespace NTwain
{ {
class _NTwainVersionInfo class _NTwainVersionInfo
{ {
// keep this same in majors releases // keep this same in major (breaking) releases
public const string Release = "2.0.0.0"; public const string Release = "3.0.0.0";
// change this for each nuget release // change this for each nuget release
public const string Build = "2.0.7"; public const string Build = "3.0.0";
} }
} }

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.AudioFileXfer"/>. /// Represents <see cref="DataArgumentType.AudioFileXfer"/>.
/// </summary> /// </summary>
sealed class AudioFileXfer : OpBase sealed class AudioFileXfer : TripletBase
{ {
internal AudioFileXfer(ITwainSessionInternal session) : base(session) { } internal AudioFileXfer(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.AudioInfo"/>. /// Represents <see cref="DataArgumentType.AudioInfo"/>.
/// </summary> /// </summary>
sealed class AudioInfo : OpBase sealed class AudioInfo : TripletBase
{ {
internal AudioInfo(ITwainSessionInternal session) : base(session) { } internal AudioInfo(ITwainSessionInternal session) : base(session) { }

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.AudioNativeXfer"/>. /// Represents <see cref="DataArgumentType.AudioNativeXfer"/>.
/// </summary> /// </summary>
sealed class AudioNativeXfer : OpBase sealed class AudioNativeXfer : TripletBase
{ {
internal AudioNativeXfer(ITwainSessionInternal session) : base(session) { } internal AudioNativeXfer(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets namespace NTwain.Triplets
{ {
sealed class Callback : OpBase sealed class Callback : TripletBase
{ {
internal Callback(ITwainSessionInternal session) : base(session) { } internal Callback(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets namespace NTwain.Triplets
{ {
sealed class Callback2 : OpBase sealed class Callback2 : TripletBase
{ {
internal Callback2(ITwainSessionInternal session) : base(session) { } internal Callback2(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.Capability"/>. /// Represents <see cref="DataArgumentType.Capability"/>.
/// </summary> /// </summary>
public sealed class Capability : OpBase public sealed class Capability : TripletBase
{ {
internal Capability(ITwainSessionInternal session) : base(session) { } internal Capability(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// This is to support custom DAT value for custom capability defined by some manufacturers. /// This is to support custom DAT value for custom capability defined by some manufacturers.
/// </summary> /// </summary>
public sealed class CapabilityCustom : OpBase public sealed class CapabilityCustom : TripletBase
{ {
internal CapabilityCustom(ITwainSessionInternal session) : base(session) { } internal CapabilityCustom(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.CustomDSData"/>. /// Represents <see cref="DataArgumentType.CustomDSData"/>.
/// </summary> /// </summary>
public sealed class CustomDSData : OpBase public sealed class CustomDSData : TripletBase
{ {
internal CustomDSData(ITwainSessionInternal session) : base(session) { } internal CustomDSData(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.DeviceEvent"/>. /// Represents <see cref="DataArgumentType.DeviceEvent"/>.
/// </summary> /// </summary>
sealed class DeviceEvent : OpBase sealed class DeviceEvent : TripletBase
{ {
internal DeviceEvent(ITwainSessionInternal session) : base(session) { } internal DeviceEvent(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.EntryPoint"/>. /// Represents <see cref="DataArgumentType.EntryPoint"/>.
/// </summary> /// </summary>
sealed class EntryPoint : OpBase sealed class EntryPoint : TripletBase
{ {
internal EntryPoint(ITwainSessionInternal session) : base(session) { } internal EntryPoint(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets namespace NTwain.Triplets
{ {
sealed class Event : OpBase sealed class Event : TripletBase
{ {
internal Event(ITwainSessionInternal session) : base(session) { } internal Event(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.FileSystem"/>. /// Represents <see cref="DataArgumentType.FileSystem"/>.
/// </summary> /// </summary>
public sealed class FileSystem : OpBase public sealed class FileSystem : TripletBase
{ {
internal FileSystem(ITwainSessionInternal session) : base(session) { } internal FileSystem(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.Identity"/>. /// Represents <see cref="DataArgumentType.Identity"/>.
/// </summary> /// </summary>
sealed class Identity : OpBase sealed class Identity : TripletBase
{ {
internal Identity(ITwainSessionInternal session) : base(session) { } internal Identity(ITwainSessionInternal session) : base(session) { }
@@ -73,7 +73,7 @@ namespace NTwain.Triplets
/// </summary> /// </summary>
/// <param name="source">The source.</param> /// <param name="source">The source.</param>
/// <returns></returns> /// <returns></returns>
public ReturnCode OpenDS(TwainSource source) public ReturnCode OpenDS(DataSource source)
{ {
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.OpenDS); Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.OpenDS);
var rc = Dsm.DsmEntry(Session.AppId, Message.OpenDS, source.Identity); var rc = Dsm.DsmEntry(Session.AppId, Message.OpenDS, source.Identity);

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.Parent"/>. /// Represents <see cref="DataArgumentType.Parent"/>.
/// </summary> /// </summary>
sealed class Parent : OpBase sealed class Parent : TripletBase
{ {
internal Parent(ITwainSessionInternal session) : base(session) { } internal Parent(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.PassThru"/>. /// Represents <see cref="DataArgumentType.PassThru"/>.
/// </summary> /// </summary>
public sealed class PassThru : OpBase public sealed class PassThru : TripletBase
{ {
internal PassThru(ITwainSessionInternal session) : base(session) { } internal PassThru(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.PendingXfers"/>. /// Represents <see cref="DataArgumentType.PendingXfers"/>.
/// </summary> /// </summary>
sealed class PendingXfers : OpBase sealed class PendingXfers : TripletBase
{ {
internal PendingXfers(ITwainSessionInternal session) : base(session) { } internal PendingXfers(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents <see cref="DataArgumentType.SetupFileXfer"/>. /// Represents <see cref="DataArgumentType.SetupFileXfer"/>.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")]
public sealed class SetupFileXfer : OpBase public sealed class SetupFileXfer : TripletBase
{ {
internal SetupFileXfer(ITwainSessionInternal session) : base(session) { } internal SetupFileXfer(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents <see cref="DataArgumentType.SetupMemXfer"/>. /// Represents <see cref="DataArgumentType.SetupMemXfer"/>.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mem")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mem")]
public sealed class SetupMemXfer : OpBase public sealed class SetupMemXfer : TripletBase
{ {
internal SetupMemXfer(ITwainSessionInternal session) : base(session) { } internal SetupMemXfer(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.Status"/>. /// Represents <see cref="DataArgumentType.Status"/>.
/// </summary> /// </summary>
sealed class Status : OpBase sealed class Status : TripletBase
{ {
internal Status(ITwainSessionInternal session) : base(session) { } internal Status(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.StatusUtf8"/>. /// Represents <see cref="DataArgumentType.StatusUtf8"/>.
/// </summary> /// </summary>
sealed class StatusUtf8 : OpBase sealed class StatusUtf8 : TripletBase
{ {
internal StatusUtf8(ITwainSessionInternal session) : base(session) { } internal StatusUtf8(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.UserInterface"/>. /// Represents <see cref="DataArgumentType.UserInterface"/>.
/// </summary> /// </summary>
sealed class UserInterface : OpBase sealed class UserInterface : TripletBase
{ {
internal UserInterface(ITwainSessionInternal session) : base(session) { } internal UserInterface(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents <see cref="DataArgumentType.XferGroup"/>. /// Represents <see cref="DataArgumentType.XferGroup"/>.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")]
public sealed class XferGroup : OpBase public sealed class XferGroup : TripletBase
{ {
internal XferGroup(ITwainSessionInternal session) : base(session) { } internal XferGroup(ITwainSessionInternal session) : base(session) { }

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents <see cref="DataArgumentType.CieColor"/>. /// Represents <see cref="DataArgumentType.CieColor"/>.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cie")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Cie")]
public sealed class CieColor : OpBase public sealed class CieColor : TripletBase
{ {
internal CieColor(ITwainSessionInternal session) : base(session) { } internal CieColor(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.ExtImageInfo"/>. /// Represents <see cref="DataArgumentType.ExtImageInfo"/>.
/// </summary> /// </summary>
public sealed class ExtImageInfo : OpBase public sealed class ExtImageInfo : TripletBase
{ {
internal ExtImageInfo(ITwainSessionInternal session) : base(session) { } internal ExtImageInfo(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.Filter"/>. /// Represents <see cref="DataArgumentType.Filter"/>.
/// </summary> /// </summary>
public sealed class Filter : OpBase public sealed class Filter : TripletBase
{ {
internal Filter(ITwainSessionInternal session) : base(session) { } internal Filter(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.GrayResponse"/>. /// Represents <see cref="DataArgumentType.GrayResponse"/>.
/// </summary> /// </summary>
public sealed class GrayResponse : OpBase public sealed class GrayResponse : TripletBase
{ {
internal GrayResponse(ITwainSessionInternal session) : base(session) { } internal GrayResponse(ITwainSessionInternal session) : base(session) { }

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents <see cref="DataArgumentType.IccProfile"/>. /// Represents <see cref="DataArgumentType.IccProfile"/>.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Icc")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Icc")]
public sealed class IccProfile : OpBase public sealed class IccProfile : TripletBase
{ {
internal IccProfile(ITwainSessionInternal session) : base(session) { } internal IccProfile(ITwainSessionInternal session) : base(session) { }

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.ImageFileXfer"/>. /// Represents <see cref="DataArgumentType.ImageFileXfer"/>.
/// </summary> /// </summary>
sealed class ImageFileXfer : OpBase sealed class ImageFileXfer : TripletBase
{ {
internal ImageFileXfer(ITwainSessionInternal session) : base(session) { } internal ImageFileXfer(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.ImageInfo"/>. /// Represents <see cref="DataArgumentType.ImageInfo"/>.
/// </summary> /// </summary>
sealed class ImageInfo : OpBase sealed class ImageInfo : TripletBase
{ {
internal ImageInfo(ITwainSessionInternal session) : base(session) { } internal ImageInfo(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.ImageLayout"/>. /// Represents <see cref="DataArgumentType.ImageLayout"/>.
/// </summary> /// </summary>
public sealed class ImageLayout : OpBase public sealed class ImageLayout : TripletBase
{ {
internal ImageLayout(ITwainSessionInternal session) : base(session) { } internal ImageLayout(ITwainSessionInternal session) : base(session) { }

View File

@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets namespace NTwain.Triplets
{ {
sealed class ImageMemFileXfer : OpBase sealed class ImageMemFileXfer : TripletBase
{ {
internal ImageMemFileXfer(ITwainSessionInternal session) : base(session) { } internal ImageMemFileXfer(ITwainSessionInternal session) : base(session) { }

View File

@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets namespace NTwain.Triplets
{ {
sealed class ImageMemXfer : OpBase sealed class ImageMemXfer : TripletBase
{ {
internal ImageMemXfer(ITwainSessionInternal session) : base(session) { } internal ImageMemXfer(ITwainSessionInternal session) : base(session) { }

View File

@@ -4,7 +4,7 @@ using System;
namespace NTwain.Triplets namespace NTwain.Triplets
{ {
sealed class ImageNativeXfer : OpBase sealed class ImageNativeXfer : TripletBase
{ {
internal ImageNativeXfer(ITwainSessionInternal session) : base(session) { } internal ImageNativeXfer(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.JpegCompression"/>. /// Represents <see cref="DataArgumentType.JpegCompression"/>.
/// </summary> /// </summary>
public sealed class JpegCompression : OpBase public sealed class JpegCompression : TripletBase
{ {
internal JpegCompression(ITwainSessionInternal session) : base(session) { } internal JpegCompression(ITwainSessionInternal session) : base(session) { }

View File

@@ -6,7 +6,7 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.Palette8"/>. /// Represents <see cref="DataArgumentType.Palette8"/>.
/// </summary> /// </summary>
public sealed class Palette8 : OpBase public sealed class Palette8 : TripletBase
{ {
internal Palette8(ITwainSessionInternal session) : base(session) { } internal Palette8(ITwainSessionInternal session) : base(session) { }

View File

@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents <see cref="DataArgumentType.RgbResponse"/>. /// Represents <see cref="DataArgumentType.RgbResponse"/>.
/// </summary> /// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rgb")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rgb")]
public sealed class RgbResponse : OpBase public sealed class RgbResponse : TripletBase
{ {
internal RgbResponse(ITwainSessionInternal session) : base(session) { } internal RgbResponse(ITwainSessionInternal session) : base(session) { }

View File

@@ -25,12 +25,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
ref IntPtr data) ref IntPtr data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data); return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data);
} }
@@ -45,12 +45,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
ref DataGroups data) ref DataGroups data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data); return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data);
} }
@@ -63,12 +63,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWAudioInfo data) TWAudioInfo data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data);
} }
@@ -83,12 +83,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWCapability data) TWCapability data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, data); }
} }
else if (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, data);
} }
@@ -102,12 +102,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWCustomDSData data) TWCustomDSData data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data);
} }
@@ -121,12 +121,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWDeviceEvent data) TWDeviceEvent data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data);
} }
@@ -140,12 +140,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWCallback data) TWCallback data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
} }
@@ -159,12 +159,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWCallback2 data) TWCallback2 data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
} }
@@ -177,12 +177,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWEntryPoint data) TWEntryPoint data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
else { return NativeMethods.DsmWinOld(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } else { return NativeMethods.DsmWinOld(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
} }
else if (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); return NativeMethods.DsmLinux(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data);
} }
@@ -196,12 +196,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWEvent data) TWEvent data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data);
} }
@@ -215,12 +215,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWFileSystem data) TWFileSystem data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data);
} }
@@ -232,12 +232,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWIdentity data) TWIdentity data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.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);
} }
@@ -251,12 +251,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWPassThru data) TWPassThru data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data);
} }
@@ -270,12 +270,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWPendingXfers data) TWPendingXfers data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data);
} }
@@ -289,12 +289,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWSetupFileXfer data) TWSetupFileXfer data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data);
} }
@@ -308,12 +308,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWSetupMemXfer data) TWSetupMemXfer data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data);
} }
@@ -327,12 +327,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWStatusUtf8 data) TWStatusUtf8 data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data);
} }
@@ -346,12 +346,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWUserInterface data) TWUserInterface data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data);
} }
@@ -365,12 +365,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWCieColor data) TWCieColor data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data);
} }
@@ -384,12 +384,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWExtImageInfo data) TWExtImageInfo data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data);
} }
@@ -402,12 +402,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWFilter data) TWFilter data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data);
} }
@@ -420,12 +420,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWGrayResponse data) TWGrayResponse data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data);
} }
@@ -439,12 +439,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWImageInfo data) TWImageInfo data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data);
} }
@@ -458,12 +458,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWImageLayout data) TWImageLayout data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data);
} }
@@ -477,12 +477,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWImageMemXfer data) TWImageMemXfer data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data);
} }
@@ -496,12 +496,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWJpegCompression data) TWJpegCompression data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data);
} }
@@ -515,12 +515,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWPalette8 data) TWPalette8 data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data);
} }
@@ -534,12 +534,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWRgbResponse data) TWRgbResponse data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data);
} }
@@ -553,12 +553,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
TWStatus data) TWStatus data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data);
} }
@@ -573,12 +573,12 @@ namespace NTwain.Triplets
Message msg, Message msg,
ref TWMemory data) ref TWMemory data)
{ {
if (Platform.IsWin) if (PlatformInfo.__global.IsWindows)
{ {
if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, ref data); } if (PlatformInfo.__global.UseNewWinDSM) { 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 (Platform.IsLinux) else if (PlatformInfo.__global.IsLinux)
{ {
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, ref data); return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, ref data);
} }

View File

@@ -6,14 +6,14 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Base class for grouping triplet operations messages. /// Base class for grouping triplet operations messages.
/// </summary> /// </summary>
public abstract class OpBase public abstract class TripletBase
{ {
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="OpBase" /> class. /// Initializes a new instance of the <see cref="TripletBase" /> class.
/// </summary> /// </summary>
/// <param name="session">The session.</param> /// <param name="session">The session.</param>
/// <exception cref="System.ArgumentNullException"></exception> /// <exception cref="System.ArgumentNullException"></exception>
internal OpBase(ITwainSessionInternal session) internal TripletBase(ITwainSessionInternal session)
{ {
if (session == null) { throw new ArgumentNullException("session"); } if (session == null) { throw new ArgumentNullException("session"); }
Session = session; Session = session;

View File

@@ -40,7 +40,7 @@ namespace NTwain
if (appId == null) { throw new ArgumentNullException("appId"); } if (appId == null) { throw new ArgumentNullException("appId"); }
_appId = appId; _appId = appId;
_ownedSources = new Dictionary<string, TwainSource>(); _ownedSources = new Dictionary<string, DataSource>();
((ITwainSessionInternal)this).ChangeState(1, false); ((ITwainSessionInternal)this).ChangeState(1, false);
#if DEBUG #if DEBUG
// defaults to false on release since it's only useful during dev // defaults to false on release since it's only useful during dev
@@ -54,11 +54,11 @@ namespace NTwain
TWUserInterface _twui; TWUserInterface _twui;
// cache generated twain sources so if you get same source from one session it'll return the same object // cache generated twain sources so if you get same source from one session it'll return the same object
readonly Dictionary<string, TwainSource> _ownedSources; readonly Dictionary<string, DataSource> _ownedSources;
TwainSource GetSourceInstance(ITwainSessionInternal session, TWIdentity sourceId) DataSource GetSourceInstance(ITwainSessionInternal session, TWIdentity sourceId)
{ {
TwainSource source = null; DataSource source = null;
Debug.WriteLine("Source id = " + sourceId.Id); Debug.WriteLine("Source id = " + sourceId.Id);
var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}|{3}", sourceId.Id, sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName); var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}|{3}", sourceId.Id, sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName);
if (_ownedSources.ContainsKey(key)) if (_ownedSources.ContainsKey(key))
@@ -67,7 +67,7 @@ namespace NTwain
} }
else else
{ {
_ownedSources[key] = source = new TwainSource(session, sourceId); _ownedSources[key] = source = new DataSource(session, sourceId);
} }
return source; return source;
} }
@@ -84,7 +84,7 @@ namespace NTwain
public bool EnforceState { get; set; } public bool EnforceState { get; set; }
/// <summary> /// <summary>
/// [Experimental] Gets or sets the optional synchronization context when not specifying a <see cref="MessageLoopHook"/> on <see cref="Open"/>. /// [Experimental] Gets or sets the optional synchronization context when not specifying a <see cref="MessageLoopHook"/> on <see cref="Open()"/>.
/// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use. /// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use.
/// </summary> /// </summary>
/// <value> /// <value>
@@ -99,7 +99,7 @@ namespace NTwain
/// <value> /// <value>
/// The current source. /// The current source.
/// </value> /// </value>
public TwainSource CurrentSource { get; private set; } public DataSource CurrentSource { get; private set; }
/// <summary> /// <summary>
/// Gets or sets the default source for this application. /// Gets or sets the default source for this application.
@@ -109,7 +109,7 @@ namespace NTwain
/// <value> /// <value>
/// The default source. /// The default source.
/// </value> /// </value>
public TwainSource DefaultSource public DataSource DefaultSource
{ {
get get
{ {
@@ -134,7 +134,7 @@ namespace NTwain
/// This is not recommended and is only included for completeness. /// This is not recommended and is only included for completeness.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public TwainSource ShowSourceSelector() public DataSource ShowSourceSelector()
{ {
TWIdentity id; TWIdentity id;
if (((ITwainSessionInternal)this).DGControl.Identity.UserSelect(out id) == ReturnCode.Success) if (((ITwainSessionInternal)this).DGControl.Identity.UserSelect(out id) == ReturnCode.Success)
@@ -190,7 +190,7 @@ namespace NTwain
/// before using other TWAIN functions. Calls to this must be followed by /// before using other TWAIN functions. Calls to this must be followed by
/// <see cref="Close" /> when done with a TWAIN session. /// <see cref="Close" /> when done with a TWAIN session.
/// </summary> /// </summary>
/// <returns></returns /// <returns></returns>
public ReturnCode Open() public ReturnCode Open()
{ {
return Open(new InternalMessageLoopHook()); return Open(new InternalMessageLoopHook());
@@ -225,7 +225,7 @@ namespace NTwain
rc = ((ITwainSessionInternal)this).DGControl.EntryPoint.Get(out entry); rc = ((ITwainSessionInternal)this).DGControl.EntryPoint.Get(out entry);
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
Platform.MemoryManager = entry; PlatformInfo.__global.MemoryManager = entry;
Debug.WriteLine("Using TWAIN2 memory functions."); Debug.WriteLine("Using TWAIN2 memory functions.");
} }
else else
@@ -252,7 +252,7 @@ namespace NTwain
rc = ((ITwainSessionInternal)this).DGControl.Parent.CloseDsm(_msgLoopHook.Handle); rc = ((ITwainSessionInternal)this).DGControl.Parent.CloseDsm(_msgLoopHook.Handle);
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
Platform.MemoryManager = null; PlatformInfo.__global.MemoryManager = null;
_msgLoopHook.Stop(); _msgLoopHook.Stop();
} }
}); });
@@ -265,15 +265,9 @@ namespace NTwain
/// Only call this at state 2 or higher. /// Only call this at state 2 or higher.
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public IEnumerable<TwainSource> GetSources() public IEnumerable<DataSource> GetSources()
{ {
TWIdentity srcId; return this;
var rc = ((ITwainSessionInternal)this).DGControl.Identity.GetFirst(out srcId);
while (rc == ReturnCode.Success)
{
yield return GetSourceInstance(this, srcId);
rc = ((ITwainSessionInternal)this).DGControl.Identity.GetNext(out srcId);
}
} }
/// <summary> /// <summary>
@@ -290,7 +284,7 @@ namespace NTwain
} }
var hit = GetSources().Where(s => string.Equals(s.Name, sourceName)).FirstOrDefault(); var hit = this.Where(s => string.Equals(s.Name, sourceName)).FirstOrDefault();
if (hit != null) if (hit != null)
{ {
return hit.Open(); return hit.Open();
@@ -445,6 +439,35 @@ namespace NTwain
#endregion #endregion
#region IEnumerable<DataSource> Members
/// <summary>
/// Gets the enumerator.
/// </summary>
/// <returns></returns>
public IEnumerator<DataSource> GetEnumerator()
{
TWIdentity srcId;
var rc = ((ITwainSessionInternal)this).DGControl.Identity.GetFirst(out srcId);
while (rc == ReturnCode.Success)
{
yield return GetSourceInstance(this, srcId);
rc = ((ITwainSessionInternal)this).DGControl.Identity.GetNext(out srcId);
}
}
#endregion
#region IEnumerable Members
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return GetEnumerator();
}
#endregion
#region events overridables #region events overridables
/// <summary> /// <summary>

View File

@@ -42,7 +42,7 @@ namespace NTwain
return new TentativeStateCommitable(this, newState); return new TentativeStateCommitable(this, newState);
} }
void ITwainSessionInternal.ChangeCurrentSource(TwainSource source) void ITwainSessionInternal.ChangeCurrentSource(DataSource source)
{ {
CurrentSource = source; CurrentSource = source;
OnPropertyChanged("CurrentSource"); OnPropertyChanged("CurrentSource");
@@ -148,6 +148,8 @@ namespace NTwain
_twui.ModalUI = modal; _twui.ModalUI = modal;
_twui.hParent = windowHandle; _twui.hParent = windowHandle;
try
{
if (mode == SourceEnableMode.ShowUIOnly) if (mode == SourceEnableMode.ShowUIOnly)
{ {
rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDSUIOnly(_twui); rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDSUIOnly(_twui);
@@ -156,11 +158,14 @@ namespace NTwain
{ {
rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDS(_twui); rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDS(_twui);
} }
}
finally
{
if (rc != ReturnCode.Success) if (rc != ReturnCode.Success)
{ {
_callbackObj = null; _callbackObj = null;
} }
}
}); });
return rc; return rc;
} }
@@ -305,6 +310,5 @@ namespace NTwain
} }
#endregion #endregion
} }
} }

View File

@@ -12,6 +12,7 @@ This project has these features/goals:
The solution contains tester projects in winform, wpf, and even (gasp!) console. The solution contains tester projects in winform, wpf, and even (gasp!) console.
A nuget package is also [available here](https://www.nuget.org/packages/ntwain) A nuget package is also [available here](https://www.nuget.org/packages/ntwain)
(NOTE: this doc describes v3. For older version go to Source and choose v2 branch.)
Using the lib Using the lib
-------------------------------------- --------------------------------------
@@ -60,14 +61,14 @@ and call Open() to start using it.
#!c# #!c#
// choose and open the first source found // choose and open the first source found
IEnumerable<TwainSources> sources = session.GetSources(); // note that TwainSession implements IEnumerable<DataSource> so we can do this
var myDS = sources.First(); DataSource myDS = session.FirstOrDefault();
myDS.Open(); myDS.Open();
``` ```
At this point you can negotiate with the source using all the typical TWAIN triplet API. At this point you can negotiate with the source using all the typical TWAIN triplet API.
The TwainSource class itself has some handy pre-defined methods for common capability negotiation The DataSource class itself has some handy pre-defined methods for common capability negotiation
such as DPI, bitdepth, or paper size to get you started. such as DPI, bitdepth, or paper size to get you started.
When you're ready to get into transfer mode, just call Enable() on the source object. When you're ready to get into transfer mode, just call Enable() on the source object.

View File

@@ -42,7 +42,7 @@ namespace Tester
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
var hit = twain.GetSources().Where(s => string.Equals(s.Name, "TWAIN2 FreeImage Software Scanner")).FirstOrDefault(); var hit = twain.Where(s => string.Equals(s.Name, "TWAIN2 FreeImage Software Scanner")).FirstOrDefault();
if (hit == null) if (hit == null)
{ {
Console.WriteLine("The sample source \"TWAIN2 FreeImage Software Scanner\" is not installed."); Console.WriteLine("The sample source \"TWAIN2 FreeImage Software Scanner\" is not installed.");

View File

@@ -78,7 +78,7 @@ namespace Tester.WPF
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
SrcList.ItemsSource = _twainVM.GetSources().Select(s => new DSVM { DS = s }); SrcList.ItemsSource = _twainVM.Select(s => new DSVM { DS = s });
} }
} }
private void Button_Click_1(object sender, RoutedEventArgs e) private void Button_Click_1(object sender, RoutedEventArgs e)

View File

@@ -21,7 +21,7 @@ namespace Tester.WPF
} }
} }
public QuerySupport Supports { get; set; } public QuerySupports Supports { get; set; }
public override string ToString() public override string ToString()
{ {

View File

@@ -8,7 +8,7 @@ namespace Tester.WPF
/// </summary> /// </summary>
class DSVM class DSVM
{ {
public TwainSource DS { get; set; } public DataSource DS { get; set; }
public string Name { get { return DS.Name; } } public string Name { get { return DS.Name; } }
public string Version { get { return DS.Version.Info; } } public string Version { get { return DS.Version.Info; } }

View File

@@ -155,7 +155,7 @@ namespace Tester.Winform
} }
var curBtn = (sender as ToolStripMenuItem); var curBtn = (sender as ToolStripMenuItem);
var src = curBtn.Tag as TwainSource; var src = curBtn.Tag as DataSource;
if (src.Open() == ReturnCode.Success) if (src.Open() == ReturnCode.Success)
{ {
curBtn.Checked = true; curBtn.Checked = true;
@@ -256,7 +256,7 @@ namespace Tester.Winform
first.Click -= SourceMenuItem_Click; first.Click -= SourceMenuItem_Click;
btnSources.DropDownItems.Remove(first); btnSources.DropDownItems.Remove(first);
} }
foreach (var src in _twain.GetSources()) foreach (var src in _twain)
{ {
var srcBtn = new ToolStripMenuItem(src.Name); var srcBtn = new ToolStripMenuItem(src.Name);
srcBtn.Tag = src; srcBtn.Tag = src;