diff --git a/NTwain.Net35/NTwain.Net35.csproj b/NTwain.Net35/NTwain.Net35.csproj
index 7591022..50a5517 100644
--- a/NTwain.Net35/NTwain.Net35.csproj
+++ b/NTwain.Net35/NTwain.Net35.csproj
@@ -48,6 +48,12 @@
CapabilityReader.cs
+
+ DataSource.Caps.cs
+
+
+ DataSource.cs
+
DataTransferredEventArgs.cs
@@ -69,6 +75,9 @@
DeviceEventArgs.cs
+
+ IDataSource.cs
+
IMemoryManager.cs
@@ -108,14 +117,17 @@
Internals\WrappedManualResetEvent.cs
+
+ IPlatformInfo.cs
+
ITwainSession.cs
MessageLoopHooks.cs
-
- Platform.cs
+
+ PlatformInfo.cs
Properties\AssemblyInfo.cs
@@ -270,8 +282,8 @@
Triplets\Dsm.WinOld.cs
-
- Triplets\OpBase.cs
+
+ Triplets\TripletBase.cs
TwainException.cs
@@ -282,12 +294,6 @@
TwainSessionInternal.cs
-
- TwainSource.Caps.cs
-
-
- TwainSource.cs
-
TwainStateException.cs
diff --git a/NTwain/CapabilityReader.cs b/NTwain/CapabilityReader.cs
index cfb81ea..4680fb9 100644
--- a/NTwain/CapabilityReader.cs
+++ b/NTwain/CapabilityReader.cs
@@ -14,26 +14,45 @@ namespace NTwain
public class CapabilityReader
{
///
- /// Reads the value from a that was returned
+ /// Reads the value from a that was returned
/// from a TWAIN source.
///
/// The capability.
///
/// capability
- ///
- /// Capability contains no data.;capability
+ /// Capability contains no data.;capability
/// or
- /// capability
- ///
+ /// capability
public static CapabilityReader ReadValue(TWCapability capability)
+ {
+ return ReadValue(capability, PlatformInfo.Current);
+ }
+
+ ///
+ /// Reads the value from a that was returned
+ /// from a TWAIN source.
+ ///
+ /// The capability.
+ /// The platform information.
+ ///
+ ///
+ /// capability
+ /// or
+ /// platformInfo
+ ///
+ /// Capability contains no data.;capability
+ /// or
+ /// capability
+ public static CapabilityReader ReadValue(TWCapability capability, IPlatformInfo platformInfo)
{
if (capability == null) { throw new ArgumentNullException("capability"); }
if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); }
+ if (platformInfo == null) { throw new ArgumentNullException("platformInfo"); }
IntPtr baseAddr = IntPtr.Zero;
try
{
- baseAddr = Platform.MemoryManager.Lock(capability.Container);
+ baseAddr = platformInfo.MemoryManager.Lock(capability.Container);
switch (capability.ContainerType)
{
case ContainerType.Array:
@@ -64,7 +83,7 @@ namespace NTwain
{
if (baseAddr != IntPtr.Zero)
{
- Platform.MemoryManager.Unlock(baseAddr);
+ platformInfo.MemoryManager.Unlock(baseAddr);
}
}
}
diff --git a/NTwain/Data/TwainTypesExtended.cs b/NTwain/Data/TwainTypesExtended.cs
index 1bb56da..f53fc98 100644
--- a/NTwain/Data/TwainTypesExtended.cs
+++ b/NTwain/Data/TwainTypesExtended.cs
@@ -635,7 +635,7 @@ namespace NTwain.Data
public TWCapability(CapabilityId capability)
{
Capability = capability;
- ContainerType = ContainerType.DontCare;
+ ContainerType = ContainerType.DoNotCare;
}
///
/// Initializes a new instance of the class.
@@ -699,7 +699,7 @@ namespace NTwain.Data
// 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")); }
- _hContainer = Platform.MemoryManager.Allocate((uint)Marshal.SizeOf(value));
+ _hContainer = PlatformInfo.Current.MemoryManager.Allocate((uint)Marshal.SizeOf(value));
if (_hContainer != IntPtr.Zero)
{
Marshal.StructureToPtr(value, _hContainer, false);
@@ -715,8 +715,8 @@ namespace NTwain.Data
Int32 valueSize = TWEnumeration.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
int offset = 0;
- _hContainer = Platform.MemoryManager.Allocate((uint)valueSize);
- IntPtr baseAddr = Platform.MemoryManager.Lock(_hContainer);
+ _hContainer = PlatformInfo.Current.MemoryManager.Allocate((uint)valueSize);
+ IntPtr baseAddr = PlatformInfo.Current.MemoryManager.Lock(_hContainer);
// can't safely use StructureToPtr here so write it our own
WriteValue(baseAddr, ref offset, ItemType.UInt16, value.ItemType);
@@ -727,7 +727,7 @@ namespace NTwain.Data
{
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
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)
{
Marshal.StructureToPtr(value, _hContainer, false);
@@ -903,7 +903,7 @@ namespace NTwain.Data
if (disposing) { }
if (_hContainer != IntPtr.Zero)
{
- Platform.MemoryManager.Free(_hContainer);
+ PlatformInfo.Current.MemoryManager.Free(_hContainer);
_hContainer = IntPtr.Zero;
}
}
@@ -1435,7 +1435,7 @@ namespace NTwain.Data
{
// uintptr to intptr could be bad
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;
@@ -2138,7 +2138,7 @@ namespace NTwain.Data
///
public TWPendingXfers()
{
- _count = TwainConst.DontCare16;
+ _count = TwainConst.DoNotCare16;
}
///
@@ -2146,7 +2146,7 @@ namespace NTwain.Data
/// 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.
///
- public int Count { get { return _count == TwainConst.DontCare16 ? -1 : (int)_count; } }
+ public int Count { get { return _count == TwainConst.DoNotCare16 ? -1 : (int)_count; } }
///
/// 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
@@ -2181,7 +2181,7 @@ namespace NTwain.Data
///
/// The device’s "power-on" value for the capability. If the application is
/// performing a MSG_SET operation and isn’t sure what the default
- /// value is, set this field to .
+ /// value is, set this field to .
///
public uint DefaultValue { get { return _defaultValue; } set { _defaultValue = value; } }
///
@@ -2352,7 +2352,7 @@ namespace NTwain.Data
}
if (_uTF8string != IntPtr.Zero)
{
- Platform.MemoryManager.Free(_uTF8string);
+ PlatformInfo.Current.MemoryManager.Free(_uTF8string);
_uTF8string = IntPtr.Zero;
}
}
diff --git a/NTwain/Data/TwainValues.cs b/NTwain/Data/TwainValues.cs
index 11d599d..b43a4db 100644
--- a/NTwain/Data/TwainValues.cs
+++ b/NTwain/Data/TwainValues.cs
@@ -40,7 +40,7 @@ namespace NTwain.Data
///
/// The don't care value.
///
- DontCare = TwainConst.DontCare16,
+ DoNotCare = TwainConst.DoNotCare16,
}
///
@@ -2044,7 +2044,7 @@ namespace NTwain.Data
/// Corresponds to TWQC_*.
///
[Flags]
- public enum QuerySupport
+ public enum QuerySupports
{
None = 0,
Get = 0x1,
@@ -2120,15 +2120,15 @@ namespace NTwain.Data
///
/// Don't care value for 8 bit types.
///
- public const byte DontCare8 = 0xff;
+ public const byte DoNotCare8 = 0xff;
///
/// Don't care value for 16 bit types.
///
- public const ushort DontCare16 = 0xffff;
+ public const ushort DoNotCare16 = 0xffff;
///
/// Don't care value for 32 bit types.
///
- public const uint DontCare32 = 0xffffffff;
+ public const uint DoNotCare32 = 0xffffffff;
///
/// The major version number of TWAIN supported by this library.
diff --git a/NTwain/TwainSource.Caps.cs b/NTwain/DataSource.Caps.cs
similarity index 99%
rename from NTwain/TwainSource.Caps.cs
rename to NTwain/DataSource.Caps.cs
index 2b3f865..8d9282b 100644
--- a/NTwain/TwainSource.Caps.cs
+++ b/NTwain/DataSource.Caps.cs
@@ -9,16 +9,16 @@ namespace NTwain
// this contains all cap-related methods prefixed with Cap
- partial class TwainSource
+ partial class DataSource
{
///
/// Gets the actual supported operations for a capability.
///
/// The cap identifier.
///
- public QuerySupport CapQuerySupport(CapabilityId capId)
+ public QuerySupports CapQuerySupport(CapabilityId capId)
{
- QuerySupport retVal = QuerySupport.None;
+ QuerySupports retVal = QuerySupports.None;
using (TWCapability cap = new TWCapability(capId))
{
var rc = _session.DGControl.Capability.QuerySupport(cap);
@@ -28,7 +28,7 @@ namespace NTwain
if (read.ContainerType == ContainerType.OneValue)
{
- retVal = read.OneValue.ConvertToEnum();
+ retVal = read.OneValue.ConvertToEnum();
}
}
}
@@ -76,7 +76,7 @@ namespace NTwain
///
- /// A general method that tries to get capability values from current .
+ /// A general method that tries to get capability values from current .
///
/// The capability unique identifier.
///
diff --git a/NTwain/TwainSource.cs b/NTwain/DataSource.cs
similarity index 98%
rename from NTwain/TwainSource.cs
rename to NTwain/DataSource.cs
index 60fe3e8..ea912d4 100644
--- a/NTwain/TwainSource.cs
+++ b/NTwain/DataSource.cs
@@ -15,11 +15,11 @@ namespace NTwain
///
/// Represents a TWAIN data source.
///
- public partial class TwainSource
+ public partial class DataSource : IDataSource
{
ITwainSessionInternal _session;
- internal TwainSource(ITwainSessionInternal session, TWIdentity sourceId)
+ internal DataSource(ITwainSessionInternal session, TWIdentity sourceId)
{
_session = session;
Identity = sourceId;
diff --git a/NTwain/IDataSource.cs b/NTwain/IDataSource.cs
new file mode 100644
index 0000000..880a906
--- /dev/null
+++ b/NTwain/IDataSource.cs
@@ -0,0 +1,17 @@
+using System;
+namespace NTwain
+{
+ ///
+ /// Represents a TWAIN data source.
+ ///
+ public interface IDataSource
+ {
+ ///
+ /// Gets the source's product name.
+ ///
+ ///
+ /// The name.
+ ///
+ string Name { get; }
+ }
+}
diff --git a/NTwain/IPlatformInfo.cs b/NTwain/IPlatformInfo.cs
new file mode 100644
index 0000000..0d0daa7
--- /dev/null
+++ b/NTwain/IPlatformInfo.cs
@@ -0,0 +1,51 @@
+using System;
+namespace NTwain
+{
+ ///
+ /// Contains various platform requirements and conditions for TWAIN.
+ ///
+ public interface IPlatformInfo
+ {
+ ///
+ /// Gets a value indicating whether the applicable TWAIN DSM library exists in the operating system.
+ ///
+ ///
+ /// true if the TWAIN DSM; otherwise, false.
+ ///
+ bool DsmExists { get; }
+
+ ///
+ /// Gets the expected TWAIN DSM dll path.
+ ///
+ ///
+ /// The expected DSM path.
+ ///
+ string ExpectedDsmPath { get; }
+
+ ///
+ /// Gets a value indicating whether the application is running in 64-bit.
+ ///
+ ///
+ /// true if the application is 64-bit; otherwise, false.
+ ///
+ bool IsApp64bit { get; }
+
+ ///
+ /// 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.
+ ///
+ ///
+ /// true if this library is supported; otherwise, false.
+ ///
+ bool IsSupported { get; }
+
+ ///
+ /// Gets the for communicating with data sources.
+ /// This should only be used when a is open.
+ ///
+ ///
+ /// The memory manager.
+ ///
+ IMemoryManager MemoryManager { get; }
+ }
+}
diff --git a/NTwain/ITwainSession.cs b/NTwain/ITwainSession.cs
index 5a25bb1..4d922f4 100644
--- a/NTwain/ITwainSession.cs
+++ b/NTwain/ITwainSession.cs
@@ -12,11 +12,11 @@ namespace NTwain
///
/// General interface for a TWAIN session.
///
- public interface ITwainSession : INotifyPropertyChanged
+ public interface ITwainSession : IEnumerable, INotifyPropertyChanged
{
///
- /// [Experimental] Gets or sets the optional synchronization context when not specifying a on .
+ /// [Experimental] Gets or sets the optional synchronization context when not specifying a on .
/// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use.
///
///
@@ -39,7 +39,7 @@ namespace NTwain
///
/// The current source.
///
- TwainSource CurrentSource { get; }
+ DataSource CurrentSource { get; }
///
/// Gets or sets the default source for this application.
@@ -49,7 +49,7 @@ namespace NTwain
///
/// The default source.
///
- TwainSource DefaultSource { get; set; }
+ DataSource DefaultSource { get; set; }
///
/// 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.
///
///
- TwainSource ShowSourceSelector();
+ DataSource ShowSourceSelector();
///
@@ -120,7 +120,7 @@ namespace NTwain
/// Gets list of sources available in the system.
///
///
- IEnumerable GetSources();
+ IEnumerable GetSources();
///
/// Quick shortcut to open a source.
diff --git a/NTwain/Internals/ICommittable.cs b/NTwain/Internals/ICommittable.cs
index e43779d..5d63c2a 100644
--- a/NTwain/Internals/ICommittable.cs
+++ b/NTwain/Internals/ICommittable.cs
@@ -2,8 +2,15 @@
namespace NTwain.Internals
{
+ ///
+ /// 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.
+ ///
interface ICommittable : IDisposable
{
+ ///
+ /// Commits the pending changes.
+ ///
void Commit();
}
}
diff --git a/NTwain/Internals/ITwainSessionInternal.cs b/NTwain/Internals/ITwainSessionInternal.cs
index 038f2e6..81c93b2 100644
--- a/NTwain/Internals/ITwainSessionInternal.cs
+++ b/NTwain/Internals/ITwainSessionInternal.cs
@@ -6,6 +6,9 @@ using System.Threading;
namespace NTwain.Internals
{
+ ///
+ /// Extends with extra stuff for internal use.
+ ///
interface ITwainSessionInternal : ITwainSession
{
///
@@ -31,7 +34,7 @@ namespace NTwain.Internals
///
ICommittable GetPendingStateChanger(int newState);
- void ChangeCurrentSource(TwainSource source);
+ void ChangeCurrentSource(DataSource source);
ReturnCode DisableSource();
@@ -41,8 +44,6 @@ namespace NTwain.Internals
ReturnCode EnableSource(SourceEnableMode mode, bool modal, IntPtr windowHandle);
- SynchronizationContext SynchronizationContext { get; set; }
-
///
/// Gets the triplet operations defined for audio data group.
///
diff --git a/NTwain/Internals/InternalMessageLoopHook.cs b/NTwain/Internals/InternalMessageLoopHook.cs
index 64cdc64..0f22e0a 100644
--- a/NTwain/Internals/InternalMessageLoopHook.cs
+++ b/NTwain/Internals/InternalMessageLoopHook.cs
@@ -9,7 +9,11 @@ using System.Windows.Threading;
namespace NTwain.Internals
{
- sealed class InternalMessageLoopHook : MessageLoopHook
+ ///
+ /// This is the self-hosted message loop for TWAIN communication.
+ /// It utilizes the wpf Dispatcher to do all the hard work.
+ ///
+ sealed class InternalMessageLoopHook : MessageLoopHook
{
Dispatcher _dispatcher;
WindowsHook _hook;
@@ -32,7 +36,7 @@ namespace NTwain.Internals
{
Debug.WriteLine("NTwain message loop is starting.");
_dispatcher = Dispatcher.CurrentDispatcher;
- if (!Platform.IsOnMono)
+ if (!PlatformInfo.__global.IsOnMono)
{
_hook = new WindowsHook(filter);
Handle = _hook.Handle;
@@ -71,7 +75,7 @@ namespace NTwain.Internals
{
action();
}
- else if (Platform.IsOnMono)
+ else if (PlatformInfo.__global.IsOnMono)
{
using (var man = new WrappedManualResetEvent())
{
diff --git a/NTwain/Internals/TransferLogic.cs b/NTwain/Internals/TransferLogic.cs
index 562885c..13071f4 100644
--- a/NTwain/Internals/TransferLogic.cs
+++ b/NTwain/Internals/TransferLogic.cs
@@ -134,7 +134,7 @@ namespace NTwain.Internals
session.ChangeState(7, true);
if (dataPtr != IntPtr.Zero)
{
- lockedPtr = Platform.MemoryManager.Lock(dataPtr);
+ lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr);
}
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
if (lockedPtr != IntPtr.Zero)
{
- Platform.MemoryManager.Unlock(lockedPtr);
+ PlatformInfo.Current.MemoryManager.Unlock(lockedPtr);
lockedPtr = IntPtr.Zero;
}
if (dataPtr != IntPtr.Zero)
{
- Platform.MemoryManager.Free(dataPtr);
+ PlatformInfo.Current.MemoryManager.Free(dataPtr);
dataPtr = IntPtr.Zero;
}
}
@@ -201,7 +201,7 @@ namespace NTwain.Internals
session.ChangeState(7, true);
if (dataPtr != IntPtr.Zero)
{
- lockedPtr = Platform.MemoryManager.Lock(dataPtr);
+ lockedPtr = PlatformInfo.Current.MemoryManager.Lock(dataPtr);
}
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
if (lockedPtr != IntPtr.Zero)
{
- Platform.MemoryManager.Unlock(lockedPtr);
+ PlatformInfo.Current.MemoryManager.Unlock(lockedPtr);
lockedPtr = IntPtr.Zero;
}
if (dataPtr != IntPtr.Zero)
{
- Platform.MemoryManager.Free(dataPtr);
+ PlatformInfo.Current.MemoryManager.Free(dataPtr);
dataPtr = IntPtr.Zero;
}
}
@@ -266,7 +266,7 @@ namespace NTwain.Internals
{
Flags = MemoryFlags.AppOwns | MemoryFlags.Pointer,
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,
@@ -290,7 +290,7 @@ namespace NTwain.Internals
IntPtr lockPtr = IntPtr.Zero;
try
{
- lockPtr = Platform.MemoryManager.Lock(xferInfo.Memory.TheMem);
+ lockPtr = PlatformInfo.Current.MemoryManager.Lock(xferInfo.Memory.TheMem);
Marshal.Copy(lockPtr, buffer, 0, buffer.Length);
xferredData.Write(buffer, 0, buffer.Length);
}
@@ -298,7 +298,7 @@ namespace NTwain.Internals
{
if (lockPtr != IntPtr.Zero)
{
- Platform.MemoryManager.Unlock(lockPtr);
+ PlatformInfo.Current.MemoryManager.Unlock(lockPtr);
}
}
}
@@ -323,7 +323,7 @@ namespace NTwain.Internals
session.ChangeState(6, true);
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,
Length = memInfo.Preferred,
- TheMem = Platform.MemoryManager.Allocate(memInfo.Preferred)
+ TheMem = PlatformInfo.Current.MemoryManager.Allocate(memInfo.Preferred)
};
var xrc = ReturnCode.Success;
@@ -367,14 +367,14 @@ namespace NTwain.Internals
IntPtr lockPtr = IntPtr.Zero;
try
{
- lockPtr = Platform.MemoryManager.Lock(xferInfo.Memory.TheMem);
+ lockPtr = PlatformInfo.Current.MemoryManager.Lock(xferInfo.Memory.TheMem);
Marshal.Copy(lockPtr, buffer, 0, buffer.Length);
}
finally
{
if (lockPtr != IntPtr.Zero)
{
- Platform.MemoryManager.Unlock(lockPtr);
+ PlatformInfo.Current.MemoryManager.Unlock(lockPtr);
}
}
outStream.Write(buffer, 0, buffer.Length);
@@ -401,7 +401,7 @@ namespace NTwain.Internals
session.ChangeState(6, true);
if (xferInfo.Memory.TheMem != IntPtr.Zero)
{
- Platform.MemoryManager.Free(xferInfo.Memory.TheMem);
+ PlatformInfo.Current.MemoryManager.Free(xferInfo.Memory.TheMem);
}
if (File.Exists(tempFile))
{
diff --git a/NTwain/NTwain.csproj b/NTwain/NTwain.csproj
index 204c10c..f6f459b 100644
--- a/NTwain/NTwain.csproj
+++ b/NTwain/NTwain.csproj
@@ -59,6 +59,7 @@
+
@@ -69,12 +70,13 @@
+
-
+
True
True
@@ -88,14 +90,14 @@
-
+
-
+
-
+
diff --git a/NTwain/Platform.cs b/NTwain/PlatformInfo.cs
similarity index 61%
rename from NTwain/Platform.cs
rename to NTwain/PlatformInfo.cs
index b2a9bcd..9fb4bd6 100644
--- a/NTwain/Platform.cs
+++ b/NTwain/PlatformInfo.cs
@@ -8,44 +8,57 @@ using System.Text;
namespace NTwain
{
///
- /// Class for checking various platform requirements and conditions.
+ /// Contains various platform requirements and conditions for TWAIN.
///
- public static class Platform
+ public class PlatformInfo : IPlatformInfo
{
- [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1810:InitializeReferenceTypeStaticFieldsInline")]
- static Platform()
+ internal static readonly PlatformInfo __global = new PlatformInfo();
+ ///
+ /// Gets the current platform info related to TWAIN.
+ ///
+ ///
+ /// The current info.
+ ///
+ public static IPlatformInfo Current { get { return __global; } }
+
+
+ PlatformInfo()
{
IsApp64bit = IntPtr.Size == 8;
IsOnMono = Type.GetType("Mono.Runtime") != null;
- IsWin = Environment.OSVersion.Platform == PlatformID.Win32NT;
+ IsWindows = Environment.OSVersion.Platform == PlatformID.Win32NT;
IsLinux = Environment.OSVersion.Platform == PlatformID.Unix;
- if (IsWin)
+ if (IsWindows)
{
var newDsmPath = Path.Combine(Environment.SystemDirectory, Dsm.WIN_NEW_DSM_NAME);
var oldDsmPath = Path.Combine(Environment.SystemDirectory, Dsm.WIN_OLD_DSM_NAME);
if (IsApp64bit)
{
- IsSupported = DsmExists = File.Exists(newDsmPath);
+ ExpectedDsmPath = newDsmPath;
+ IsSupported = DsmExists = File.Exists(ExpectedDsmPath);
UseNewWinDSM = true;
}
else
{
if (File.Exists(newDsmPath))
{
+ ExpectedDsmPath = newDsmPath;
UseNewWinDSM = IsSupported = DsmExists = true;
}
else
{
- IsSupported = DsmExists = File.Exists(oldDsmPath);
+ ExpectedDsmPath = oldDsmPath;
+ IsSupported = DsmExists = File.Exists(ExpectedDsmPath);
}
}
}
else if (IsLinux)
{
- DsmExists = File.Exists(Dsm.LINUX_DSM_PATH);
+ ExpectedDsmPath = Dsm.LINUX_DSM_PATH;
+ DsmExists = File.Exists(ExpectedDsmPath);
IsSupported = DsmExists && IsOnMono;
}
else
@@ -56,11 +69,10 @@ namespace NTwain
_defaultMemManager = new WinMemoryManager();
}
- // prefer the use of the twain dsm on windows.
- internal static readonly bool UseNewWinDSM;
- internal static readonly bool IsOnMono;
- internal static readonly bool IsWin;
- internal static readonly bool IsLinux;
+ internal readonly bool UseNewWinDSM;
+ internal readonly bool IsOnMono;
+ internal readonly bool IsWindows;
+ internal readonly bool IsLinux;
///
/// Gets a value indicating whether the application is running in 64-bit.
@@ -68,7 +80,7 @@ namespace NTwain
///
/// true if the application is 64-bit; otherwise, false.
///
- public static bool IsApp64bit { get; private set; }
+ public bool IsApp64bit { get; private set; }
///
/// Gets a value indicating whether the applicable TWAIN DSM library exists in the operating system.
@@ -76,7 +88,15 @@ namespace NTwain
///
/// true if the TWAIN DSM; otherwise, false.
///
- public static bool DsmExists { get; private set; }
+ public bool DsmExists { get; private set; }
+
+ ///
+ /// Gets the expected TWAIN DSM dll path.
+ ///
+ ///
+ /// The expected DSM path.
+ ///
+ public string ExpectedDsmPath { get; private set; }
///
/// Gets a value indicating whether this library is supported on current OS.
@@ -85,11 +105,11 @@ namespace NTwain
///
/// true if this library is supported; otherwise, false.
///
- public static bool IsSupported { get; private set; }
+ public bool IsSupported { get; private set; }
- static readonly IMemoryManager _defaultMemManager;
- static IMemoryManager _specifiedMemManager;
+ readonly IMemoryManager _defaultMemManager;
+ IMemoryManager _specifiedMemManager;
///
/// Gets the for communicating with data sources.
@@ -98,7 +118,7 @@ namespace NTwain
///
/// The memory manager.
///
- public static IMemoryManager MemoryManager
+ public IMemoryManager MemoryManager
{
get
{
diff --git a/NTwain/Properties/VersionInfo.cs b/NTwain/Properties/VersionInfo.cs
index 78ae7e1..67de7f4 100644
--- a/NTwain/Properties/VersionInfo.cs
+++ b/NTwain/Properties/VersionInfo.cs
@@ -11,9 +11,9 @@ namespace NTwain
{
class _NTwainVersionInfo
{
- // keep this same in majors releases
- public const string Release = "2.0.0.0";
+ // keep this same in major (breaking) releases
+ public const string Release = "3.0.0.0";
// change this for each nuget release
- public const string Build = "2.0.7";
+ public const string Build = "3.0.0";
}
}
\ No newline at end of file
diff --git a/NTwain/Triplets/DGAudio/DGAudio.AudioFileXfer.cs b/NTwain/Triplets/DGAudio/DGAudio.AudioFileXfer.cs
index 8db82b3..b594cf4 100644
--- a/NTwain/Triplets/DGAudio/DGAudio.AudioFileXfer.cs
+++ b/NTwain/Triplets/DGAudio/DGAudio.AudioFileXfer.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class AudioFileXfer : OpBase
+ sealed class AudioFileXfer : TripletBase
{
internal AudioFileXfer(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGAudio/DGAudio.AudioInfo.cs b/NTwain/Triplets/DGAudio/DGAudio.AudioInfo.cs
index 23cbba8..fcb1c7f 100644
--- a/NTwain/Triplets/DGAudio/DGAudio.AudioInfo.cs
+++ b/NTwain/Triplets/DGAudio/DGAudio.AudioInfo.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class AudioInfo : OpBase
+ sealed class AudioInfo : TripletBase
{
internal AudioInfo(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGAudio/DGAudio.AudioNativeXfer.cs b/NTwain/Triplets/DGAudio/DGAudio.AudioNativeXfer.cs
index 7dc6285..e562343 100644
--- a/NTwain/Triplets/DGAudio/DGAudio.AudioNativeXfer.cs
+++ b/NTwain/Triplets/DGAudio/DGAudio.AudioNativeXfer.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class AudioNativeXfer : OpBase
+ sealed class AudioNativeXfer : TripletBase
{
internal AudioNativeXfer(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.Callback.cs b/NTwain/Triplets/DGControl/DGControl.Callback.cs
index cbd894c..c89d4b1 100644
--- a/NTwain/Triplets/DGControl/DGControl.Callback.cs
+++ b/NTwain/Triplets/DGControl/DGControl.Callback.cs
@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets
{
- sealed class Callback : OpBase
+ sealed class Callback : TripletBase
{
internal Callback(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.Callback2.cs b/NTwain/Triplets/DGControl/DGControl.Callback2.cs
index 88c24f5..8b62f44 100644
--- a/NTwain/Triplets/DGControl/DGControl.Callback2.cs
+++ b/NTwain/Triplets/DGControl/DGControl.Callback2.cs
@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets
{
- sealed class Callback2 : OpBase
+ sealed class Callback2 : TripletBase
{
internal Callback2(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.Capability.cs b/NTwain/Triplets/DGControl/DGControl.Capability.cs
index f0f5efc..555b9fd 100644
--- a/NTwain/Triplets/DGControl/DGControl.Capability.cs
+++ b/NTwain/Triplets/DGControl/DGControl.Capability.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class Capability : OpBase
+ public sealed class Capability : TripletBase
{
internal Capability(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.CapabilityCustom.cs b/NTwain/Triplets/DGControl/DGControl.CapabilityCustom.cs
index 1e5f2f4..a1f33ff 100644
--- a/NTwain/Triplets/DGControl/DGControl.CapabilityCustom.cs
+++ b/NTwain/Triplets/DGControl/DGControl.CapabilityCustom.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// This is to support custom DAT value for custom capability defined by some manufacturers.
///
- public sealed class CapabilityCustom : OpBase
+ public sealed class CapabilityCustom : TripletBase
{
internal CapabilityCustom(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGControl/DGControl.CustomDSData.cs b/NTwain/Triplets/DGControl/DGControl.CustomDSData.cs
index 935b97b..2cd5c4b 100644
--- a/NTwain/Triplets/DGControl/DGControl.CustomDSData.cs
+++ b/NTwain/Triplets/DGControl/DGControl.CustomDSData.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class CustomDSData : OpBase
+ public sealed class CustomDSData : TripletBase
{
internal CustomDSData(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs b/NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs
index d350e5d..1c2c070 100644
--- a/NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs
+++ b/NTwain/Triplets/DGControl/DGControl.DeviceEvent.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class DeviceEvent : OpBase
+ sealed class DeviceEvent : TripletBase
{
internal DeviceEvent(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGControl/DGControl.EntryPoint.cs b/NTwain/Triplets/DGControl/DGControl.EntryPoint.cs
index 191664b..101a8e1 100644
--- a/NTwain/Triplets/DGControl/DGControl.EntryPoint.cs
+++ b/NTwain/Triplets/DGControl/DGControl.EntryPoint.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class EntryPoint : OpBase
+ sealed class EntryPoint : TripletBase
{
internal EntryPoint(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.Event.cs b/NTwain/Triplets/DGControl/DGControl.Event.cs
index af64236..1096c3d 100644
--- a/NTwain/Triplets/DGControl/DGControl.Event.cs
+++ b/NTwain/Triplets/DGControl/DGControl.Event.cs
@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets
{
- sealed class Event : OpBase
+ sealed class Event : TripletBase
{
internal Event(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGControl/DGControl.FileSystem.cs b/NTwain/Triplets/DGControl/DGControl.FileSystem.cs
index 3b518fb..a454e7e 100644
--- a/NTwain/Triplets/DGControl/DGControl.FileSystem.cs
+++ b/NTwain/Triplets/DGControl/DGControl.FileSystem.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class FileSystem : OpBase
+ public sealed class FileSystem : TripletBase
{
internal FileSystem(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.Identity.cs b/NTwain/Triplets/DGControl/DGControl.Identity.cs
index 0310951..5b667ff 100644
--- a/NTwain/Triplets/DGControl/DGControl.Identity.cs
+++ b/NTwain/Triplets/DGControl/DGControl.Identity.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class Identity : OpBase
+ sealed class Identity : TripletBase
{
internal Identity(ITwainSessionInternal session) : base(session) { }
@@ -73,7 +73,7 @@ namespace NTwain.Triplets
///
/// The source.
///
- public ReturnCode OpenDS(TwainSource source)
+ public ReturnCode OpenDS(DataSource source)
{
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Identity, Message.OpenDS);
var rc = Dsm.DsmEntry(Session.AppId, Message.OpenDS, source.Identity);
diff --git a/NTwain/Triplets/DGControl/DGControl.Parent.cs b/NTwain/Triplets/DGControl/DGControl.Parent.cs
index 0612ec9..2944739 100644
--- a/NTwain/Triplets/DGControl/DGControl.Parent.cs
+++ b/NTwain/Triplets/DGControl/DGControl.Parent.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class Parent : OpBase
+ sealed class Parent : TripletBase
{
internal Parent(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGControl/DGControl.PassThru.cs b/NTwain/Triplets/DGControl/DGControl.PassThru.cs
index 708bb9f..5075f34 100644
--- a/NTwain/Triplets/DGControl/DGControl.PassThru.cs
+++ b/NTwain/Triplets/DGControl/DGControl.PassThru.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class PassThru : OpBase
+ public sealed class PassThru : TripletBase
{
internal PassThru(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.PendingXfers.cs b/NTwain/Triplets/DGControl/DGControl.PendingXfers.cs
index 3e81527..2590823 100644
--- a/NTwain/Triplets/DGControl/DGControl.PendingXfers.cs
+++ b/NTwain/Triplets/DGControl/DGControl.PendingXfers.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class PendingXfers : OpBase
+ sealed class PendingXfers : TripletBase
{
internal PendingXfers(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs b/NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs
index 62dac5b..779022b 100644
--- a/NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs
+++ b/NTwain/Triplets/DGControl/DGControl.SetupFileXfer.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents .
///
[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) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs b/NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs
index 900d0a8..3d32abc 100644
--- a/NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs
+++ b/NTwain/Triplets/DGControl/DGControl.SetupMemXfer.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents .
///
[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) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.Status.cs b/NTwain/Triplets/DGControl/DGControl.Status.cs
index 6dacd40..4127b2c 100644
--- a/NTwain/Triplets/DGControl/DGControl.Status.cs
+++ b/NTwain/Triplets/DGControl/DGControl.Status.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class Status : OpBase
+ sealed class Status : TripletBase
{
internal Status(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs b/NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs
index 0b1624c..372327b 100644
--- a/NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs
+++ b/NTwain/Triplets/DGControl/DGControl.StatusUtf8.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class StatusUtf8 : OpBase
+ sealed class StatusUtf8 : TripletBase
{
internal StatusUtf8(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGControl/DGControl.UserInterface.cs b/NTwain/Triplets/DGControl/DGControl.UserInterface.cs
index 5adb2b4..cdf798a 100644
--- a/NTwain/Triplets/DGControl/DGControl.UserInterface.cs
+++ b/NTwain/Triplets/DGControl/DGControl.UserInterface.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class UserInterface : OpBase
+ sealed class UserInterface : TripletBase
{
internal UserInterface(ITwainSessionInternal session) : base(session) { }
///
diff --git a/NTwain/Triplets/DGControl/DGControl.XferGroup.cs b/NTwain/Triplets/DGControl/DGControl.XferGroup.cs
index 25209d8..ffce49f 100644
--- a/NTwain/Triplets/DGControl/DGControl.XferGroup.cs
+++ b/NTwain/Triplets/DGControl/DGControl.XferGroup.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents .
///
[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) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.CieColor.cs b/NTwain/Triplets/DGImage/DGImage.CieColor.cs
index cdd687b..c1e3f22 100644
--- a/NTwain/Triplets/DGImage/DGImage.CieColor.cs
+++ b/NTwain/Triplets/DGImage/DGImage.CieColor.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents .
///
[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) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.ExtImageInfo.cs b/NTwain/Triplets/DGImage/DGImage.ExtImageInfo.cs
index 996be22..fd34e75 100644
--- a/NTwain/Triplets/DGImage/DGImage.ExtImageInfo.cs
+++ b/NTwain/Triplets/DGImage/DGImage.ExtImageInfo.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class ExtImageInfo : OpBase
+ public sealed class ExtImageInfo : TripletBase
{
internal ExtImageInfo(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.Filter.cs b/NTwain/Triplets/DGImage/DGImage.Filter.cs
index 7bce3b4..da11cf9 100644
--- a/NTwain/Triplets/DGImage/DGImage.Filter.cs
+++ b/NTwain/Triplets/DGImage/DGImage.Filter.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class Filter : OpBase
+ public sealed class Filter : TripletBase
{
internal Filter(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.GrayResponse.cs b/NTwain/Triplets/DGImage/DGImage.GrayResponse.cs
index 48da269..caf6861 100644
--- a/NTwain/Triplets/DGImage/DGImage.GrayResponse.cs
+++ b/NTwain/Triplets/DGImage/DGImage.GrayResponse.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class GrayResponse : OpBase
+ public sealed class GrayResponse : TripletBase
{
internal GrayResponse(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.IccProfile.cs b/NTwain/Triplets/DGImage/DGImage.IccProfile.cs
index 87249a8..35d9157 100644
--- a/NTwain/Triplets/DGImage/DGImage.IccProfile.cs
+++ b/NTwain/Triplets/DGImage/DGImage.IccProfile.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents .
///
[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) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.ImageFileXfer.cs b/NTwain/Triplets/DGImage/DGImage.ImageFileXfer.cs
index 1cabe54..2354e4f 100644
--- a/NTwain/Triplets/DGImage/DGImage.ImageFileXfer.cs
+++ b/NTwain/Triplets/DGImage/DGImage.ImageFileXfer.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class ImageFileXfer : OpBase
+ sealed class ImageFileXfer : TripletBase
{
internal ImageFileXfer(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.ImageInfo.cs b/NTwain/Triplets/DGImage/DGImage.ImageInfo.cs
index f4f98e3..33e8856 100644
--- a/NTwain/Triplets/DGImage/DGImage.ImageInfo.cs
+++ b/NTwain/Triplets/DGImage/DGImage.ImageInfo.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- sealed class ImageInfo : OpBase
+ sealed class ImageInfo : TripletBase
{
internal ImageInfo(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.ImageLayout.cs b/NTwain/Triplets/DGImage/DGImage.ImageLayout.cs
index d53e348..28e9eab 100644
--- a/NTwain/Triplets/DGImage/DGImage.ImageLayout.cs
+++ b/NTwain/Triplets/DGImage/DGImage.ImageLayout.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class ImageLayout : OpBase
+ public sealed class ImageLayout : TripletBase
{
internal ImageLayout(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.ImageMemFileXfer.cs b/NTwain/Triplets/DGImage/DGImage.ImageMemFileXfer.cs
index 5cec36a..dffce16 100644
--- a/NTwain/Triplets/DGImage/DGImage.ImageMemFileXfer.cs
+++ b/NTwain/Triplets/DGImage/DGImage.ImageMemFileXfer.cs
@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets
{
- sealed class ImageMemFileXfer : OpBase
+ sealed class ImageMemFileXfer : TripletBase
{
internal ImageMemFileXfer(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.ImageMemXfer.cs b/NTwain/Triplets/DGImage/DGImage.ImageMemXfer.cs
index 5e7d8c7..f3f85bf 100644
--- a/NTwain/Triplets/DGImage/DGImage.ImageMemXfer.cs
+++ b/NTwain/Triplets/DGImage/DGImage.ImageMemXfer.cs
@@ -3,7 +3,7 @@ using NTwain.Internals;
namespace NTwain.Triplets
{
- sealed class ImageMemXfer : OpBase
+ sealed class ImageMemXfer : TripletBase
{
internal ImageMemXfer(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.ImageNativeXfer.cs b/NTwain/Triplets/DGImage/DGImage.ImageNativeXfer.cs
index edb16c6..f0bd7f5 100644
--- a/NTwain/Triplets/DGImage/DGImage.ImageNativeXfer.cs
+++ b/NTwain/Triplets/DGImage/DGImage.ImageNativeXfer.cs
@@ -4,7 +4,7 @@ using System;
namespace NTwain.Triplets
{
- sealed class ImageNativeXfer : OpBase
+ sealed class ImageNativeXfer : TripletBase
{
internal ImageNativeXfer(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.JpegCompression.cs b/NTwain/Triplets/DGImage/DGImage.JpegCompression.cs
index b6ee44d..1d07ad2 100644
--- a/NTwain/Triplets/DGImage/DGImage.JpegCompression.cs
+++ b/NTwain/Triplets/DGImage/DGImage.JpegCompression.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class JpegCompression : OpBase
+ public sealed class JpegCompression : TripletBase
{
internal JpegCompression(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.Palette8.cs b/NTwain/Triplets/DGImage/DGImage.Palette8.cs
index d772e16..b8025ca 100644
--- a/NTwain/Triplets/DGImage/DGImage.Palette8.cs
+++ b/NTwain/Triplets/DGImage/DGImage.Palette8.cs
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
///
/// Represents .
///
- public sealed class Palette8 : OpBase
+ public sealed class Palette8 : TripletBase
{
internal Palette8(ITwainSessionInternal session) : base(session) { }
diff --git a/NTwain/Triplets/DGImage/DGImage.RgbResponse.cs b/NTwain/Triplets/DGImage/DGImage.RgbResponse.cs
index 8a7b8fb..24c5d36 100644
--- a/NTwain/Triplets/DGImage/DGImage.RgbResponse.cs
+++ b/NTwain/Triplets/DGImage/DGImage.RgbResponse.cs
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
/// Represents .
///
[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) { }
diff --git a/NTwain/Triplets/Dsm.cs b/NTwain/Triplets/Dsm.cs
index dc76e1a..bdfef23 100644
--- a/NTwain/Triplets/Dsm.cs
+++ b/NTwain/Triplets/Dsm.cs
@@ -25,12 +25,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data);
}
@@ -45,12 +45,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, ref data);
}
@@ -63,12 +63,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data);
}
@@ -83,12 +83,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, data);
}
@@ -102,12 +102,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data);
}
@@ -121,12 +121,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data);
}
@@ -140,12 +140,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
}
@@ -159,12 +159,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
}
@@ -177,12 +177,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data);
}
@@ -196,12 +196,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data);
}
@@ -215,12 +215,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data);
}
@@ -232,12 +232,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data);
}
@@ -251,12 +251,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data);
}
@@ -270,12 +270,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data);
}
@@ -289,12 +289,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data);
}
@@ -308,12 +308,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data);
}
@@ -327,12 +327,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data);
}
@@ -346,12 +346,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data);
}
@@ -365,12 +365,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data);
}
@@ -384,12 +384,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data);
}
@@ -402,12 +402,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data);
}
@@ -420,12 +420,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data);
}
@@ -439,12 +439,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data);
}
@@ -458,12 +458,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data);
}
@@ -477,12 +477,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data);
}
@@ -496,12 +496,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data);
}
@@ -515,12 +515,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data);
}
@@ -534,12 +534,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data);
}
@@ -553,12 +553,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data);
}
@@ -573,12 +573,12 @@ namespace NTwain.Triplets
Message msg,
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 if (Platform.IsLinux)
+ else if (PlatformInfo.__global.IsLinux)
{
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, dat, msg, ref data);
}
diff --git a/NTwain/Triplets/OpBase.cs b/NTwain/Triplets/TripletBase.cs
similarity index 77%
rename from NTwain/Triplets/OpBase.cs
rename to NTwain/Triplets/TripletBase.cs
index b361941..c5ddcb3 100644
--- a/NTwain/Triplets/OpBase.cs
+++ b/NTwain/Triplets/TripletBase.cs
@@ -6,14 +6,14 @@ namespace NTwain.Triplets
///
/// Base class for grouping triplet operations messages.
///
- public abstract class OpBase
+ public abstract class TripletBase
{
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The session.
///
- internal OpBase(ITwainSessionInternal session)
+ internal TripletBase(ITwainSessionInternal session)
{
if (session == null) { throw new ArgumentNullException("session"); }
Session = session;
diff --git a/NTwain/TwainSession.cs b/NTwain/TwainSession.cs
index 2782993..b66711e 100644
--- a/NTwain/TwainSession.cs
+++ b/NTwain/TwainSession.cs
@@ -40,7 +40,7 @@ namespace NTwain
if (appId == null) { throw new ArgumentNullException("appId"); }
_appId = appId;
- _ownedSources = new Dictionary();
+ _ownedSources = new Dictionary();
((ITwainSessionInternal)this).ChangeState(1, false);
#if DEBUG
// defaults to false on release since it's only useful during dev
@@ -54,11 +54,11 @@ namespace NTwain
TWUserInterface _twui;
// cache generated twain sources so if you get same source from one session it'll return the same object
- readonly Dictionary _ownedSources;
+ readonly Dictionary _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);
var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}|{3}", sourceId.Id, sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName);
if (_ownedSources.ContainsKey(key))
@@ -67,7 +67,7 @@ namespace NTwain
}
else
{
- _ownedSources[key] = source = new TwainSource(session, sourceId);
+ _ownedSources[key] = source = new DataSource(session, sourceId);
}
return source;
}
@@ -84,7 +84,7 @@ namespace NTwain
public bool EnforceState { get; set; }
///
- /// [Experimental] Gets or sets the optional synchronization context when not specifying a on .
+ /// [Experimental] Gets or sets the optional synchronization context when not specifying a on .
/// This allows events to be raised on the thread associated with the context. This is experimental is not recommended for use.
///
///
@@ -99,7 +99,7 @@ namespace NTwain
///
/// The current source.
///
- public TwainSource CurrentSource { get; private set; }
+ public DataSource CurrentSource { get; private set; }
///
/// Gets or sets the default source for this application.
@@ -109,7 +109,7 @@ namespace NTwain
///
/// The default source.
///
- public TwainSource DefaultSource
+ public DataSource DefaultSource
{
get
{
@@ -134,7 +134,7 @@ namespace NTwain
/// This is not recommended and is only included for completeness.
///
///
- public TwainSource ShowSourceSelector()
+ public DataSource ShowSourceSelector()
{
TWIdentity id;
if (((ITwainSessionInternal)this).DGControl.Identity.UserSelect(out id) == ReturnCode.Success)
@@ -187,10 +187,10 @@ namespace NTwain
///
/// Opens the data source manager. This must be the first method used
- /// before using other TWAIN functions. Calls to this must be followed by
+ /// before using other TWAIN functions. Calls to this must be followed by
/// when done with a TWAIN session.
///
- ///
public ReturnCode Open()
{
return Open(new InternalMessageLoopHook());
@@ -225,7 +225,7 @@ namespace NTwain
rc = ((ITwainSessionInternal)this).DGControl.EntryPoint.Get(out entry);
if (rc == ReturnCode.Success)
{
- Platform.MemoryManager = entry;
+ PlatformInfo.__global.MemoryManager = entry;
Debug.WriteLine("Using TWAIN2 memory functions.");
}
else
@@ -252,7 +252,7 @@ namespace NTwain
rc = ((ITwainSessionInternal)this).DGControl.Parent.CloseDsm(_msgLoopHook.Handle);
if (rc == ReturnCode.Success)
{
- Platform.MemoryManager = null;
+ PlatformInfo.__global.MemoryManager = null;
_msgLoopHook.Stop();
}
});
@@ -265,15 +265,9 @@ namespace NTwain
/// Only call this at state 2 or higher.
///
///
- public IEnumerable GetSources()
+ public IEnumerable GetSources()
{
- 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);
- }
+ return this;
}
///
@@ -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)
{
return hit.Open();
@@ -445,6 +439,35 @@ namespace NTwain
#endregion
+
+ #region IEnumerable Members
+
+ ///
+ /// Gets the enumerator.
+ ///
+ ///
+ public IEnumerator 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
///
diff --git a/NTwain/TwainSessionInternal.cs b/NTwain/TwainSessionInternal.cs
index 5e3a4b2..92300a5 100644
--- a/NTwain/TwainSessionInternal.cs
+++ b/NTwain/TwainSessionInternal.cs
@@ -42,7 +42,7 @@ namespace NTwain
return new TentativeStateCommitable(this, newState);
}
- void ITwainSessionInternal.ChangeCurrentSource(TwainSource source)
+ void ITwainSessionInternal.ChangeCurrentSource(DataSource source)
{
CurrentSource = source;
OnPropertyChanged("CurrentSource");
@@ -148,18 +148,23 @@ namespace NTwain
_twui.ModalUI = modal;
_twui.hParent = windowHandle;
- if (mode == SourceEnableMode.ShowUIOnly)
+ try
{
- rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDSUIOnly(_twui);
+ if (mode == SourceEnableMode.ShowUIOnly)
+ {
+ rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDSUIOnly(_twui);
+ }
+ else
+ {
+ rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDS(_twui);
+ }
}
- else
+ finally
{
- rc = ((ITwainSessionInternal)this).DGControl.UserInterface.EnableDS(_twui);
- }
-
- if (rc != ReturnCode.Success)
- {
- _callbackObj = null;
+ if (rc != ReturnCode.Success)
+ {
+ _callbackObj = null;
+ }
}
});
return rc;
@@ -305,6 +310,5 @@ namespace NTwain
}
#endregion
-
}
}
diff --git a/README.md b/README.md
index 63d73dd..cce1f14 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,8 @@ This project has these features/goals:
* Optionally hosts an internal message loop so there's no need to hook into application UI thread
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
--------------------------------------
@@ -60,14 +61,14 @@ and call Open() to start using it.
#!c#
// choose and open the first source found
-IEnumerable sources = session.GetSources();
-var myDS = sources.First();
+// note that TwainSession implements IEnumerable so we can do this
+DataSource myDS = session.FirstOrDefault();
myDS.Open();
```
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.
When you're ready to get into transfer mode, just call Enable() on the source object.
diff --git a/Tests/Tester.Console/Program.cs b/Tests/Tester.Console/Program.cs
index b0f5344..1f18196 100644
--- a/Tests/Tester.Console/Program.cs
+++ b/Tests/Tester.Console/Program.cs
@@ -42,7 +42,7 @@ namespace Tester
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)
{
Console.WriteLine("The sample source \"TWAIN2 FreeImage Software Scanner\" is not installed.");
diff --git a/Tests/Tester.WPF/MainWindow.xaml.cs b/Tests/Tester.WPF/MainWindow.xaml.cs
index 99b61d3..f69014d 100644
--- a/Tests/Tester.WPF/MainWindow.xaml.cs
+++ b/Tests/Tester.WPF/MainWindow.xaml.cs
@@ -78,7 +78,7 @@ namespace Tester.WPF
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)
diff --git a/Tests/Tester.WPF/ViewModels/CapVM.cs b/Tests/Tester.WPF/ViewModels/CapVM.cs
index 922fedc..0fa7910 100644
--- a/Tests/Tester.WPF/ViewModels/CapVM.cs
+++ b/Tests/Tester.WPF/ViewModels/CapVM.cs
@@ -21,7 +21,7 @@ namespace Tester.WPF
}
}
- public QuerySupport Supports { get; set; }
+ public QuerySupports Supports { get; set; }
public override string ToString()
{
diff --git a/Tests/Tester.WPF/ViewModels/DSVM.cs b/Tests/Tester.WPF/ViewModels/DSVM.cs
index 389edd0..65d4b65 100644
--- a/Tests/Tester.WPF/ViewModels/DSVM.cs
+++ b/Tests/Tester.WPF/ViewModels/DSVM.cs
@@ -8,7 +8,7 @@ namespace Tester.WPF
///
class DSVM
{
- public TwainSource DS { get; set; }
+ public DataSource DS { get; set; }
public string Name { get { return DS.Name; } }
public string Version { get { return DS.Version.Info; } }
diff --git a/Tests/Tester.Winform/TestForm.cs b/Tests/Tester.Winform/TestForm.cs
index 5d403bf..61fc519 100644
--- a/Tests/Tester.Winform/TestForm.cs
+++ b/Tests/Tester.Winform/TestForm.cs
@@ -155,7 +155,7 @@ namespace Tester.Winform
}
var curBtn = (sender as ToolStripMenuItem);
- var src = curBtn.Tag as TwainSource;
+ var src = curBtn.Tag as DataSource;
if (src.Open() == ReturnCode.Success)
{
curBtn.Checked = true;
@@ -256,7 +256,7 @@ namespace Tester.Winform
first.Click -= SourceMenuItem_Click;
btnSources.DropDownItems.Remove(first);
}
- foreach (var src in _twain.GetSources())
+ foreach (var src in _twain)
{
var srcBtn = new ToolStripMenuItem(src.Name);
srcBtn.Tag = src;