mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-08 02:24:46 +08:00
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:
@@ -14,26 +14,45 @@ namespace NTwain
|
||||
public class CapabilityReader
|
||||
{
|
||||
/// <summary>
|
||||
/// Reads the value from a <see cref="TWCapability"/> that was returned
|
||||
/// Reads the value from a <see cref="TWCapability" /> that was returned
|
||||
/// from a TWAIN source.
|
||||
/// </summary>
|
||||
/// <param name="capability">The capability.</param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="System.ArgumentNullException">capability</exception>
|
||||
/// <exception cref="System.ArgumentException">
|
||||
/// Capability contains no data.;capability
|
||||
/// <exception cref="System.ArgumentException">Capability contains no data.;capability
|
||||
/// or
|
||||
/// capability
|
||||
/// </exception>
|
||||
/// capability</exception>
|
||||
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.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -635,7 +635,7 @@ namespace NTwain.Data
|
||||
public TWCapability(CapabilityId capability)
|
||||
{
|
||||
Capability = capability;
|
||||
ContainerType = ContainerType.DontCare;
|
||||
ContainerType = ContainerType.DoNotCare;
|
||||
}
|
||||
/// <summary>
|
||||
/// 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
|
||||
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
|
||||
/// </summary>
|
||||
public TWPendingXfers()
|
||||
{
|
||||
_count = TwainConst.DontCare16;
|
||||
_count = TwainConst.DoNotCare16;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -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.
|
||||
/// </summary>
|
||||
public int Count { get { return _count == TwainConst.DontCare16 ? -1 : (int)_count; } }
|
||||
public int Count { get { return _count == TwainConst.DoNotCare16 ? -1 : (int)_count; } }
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// <summary>
|
||||
/// 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 <see cref="TwainConst.DontCare32"/>.
|
||||
/// value is, set this field to <see cref="TwainConst.DoNotCare32"/>.
|
||||
/// </summary>
|
||||
public uint DefaultValue { get { return _defaultValue; } set { _defaultValue = value; } }
|
||||
/// <summary>
|
||||
@@ -2352,7 +2352,7 @@ namespace NTwain.Data
|
||||
}
|
||||
if (_uTF8string != IntPtr.Zero)
|
||||
{
|
||||
Platform.MemoryManager.Free(_uTF8string);
|
||||
PlatformInfo.Current.MemoryManager.Free(_uTF8string);
|
||||
_uTF8string = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace NTwain.Data
|
||||
/// <summary>
|
||||
/// The don't care value.
|
||||
/// </summary>
|
||||
DontCare = TwainConst.DontCare16,
|
||||
DoNotCare = TwainConst.DoNotCare16,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2044,7 +2044,7 @@ namespace NTwain.Data
|
||||
/// Corresponds to TWQC_*.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum QuerySupport
|
||||
public enum QuerySupports
|
||||
{
|
||||
None = 0,
|
||||
Get = 0x1,
|
||||
@@ -2120,15 +2120,15 @@ namespace NTwain.Data
|
||||
/// <summary>
|
||||
/// Don't care value for 8 bit types.
|
||||
/// </summary>
|
||||
public const byte DontCare8 = 0xff;
|
||||
public const byte DoNotCare8 = 0xff;
|
||||
/// <summary>
|
||||
/// Don't care value for 16 bit types.
|
||||
/// </summary>
|
||||
public const ushort DontCare16 = 0xffff;
|
||||
public const ushort DoNotCare16 = 0xffff;
|
||||
/// <summary>
|
||||
/// Don't care value for 32 bit types.
|
||||
/// </summary>
|
||||
public const uint DontCare32 = 0xffffffff;
|
||||
public const uint DoNotCare32 = 0xffffffff;
|
||||
|
||||
/// <summary>
|
||||
/// The major version number of TWAIN supported by this library.
|
||||
|
||||
@@ -9,16 +9,16 @@ namespace NTwain
|
||||
// this contains all cap-related methods prefixed with Cap
|
||||
|
||||
|
||||
partial class TwainSource
|
||||
partial class DataSource
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the actual supported operations for a capability.
|
||||
/// </summary>
|
||||
/// <param name="capId">The cap identifier.</param>
|
||||
/// <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))
|
||||
{
|
||||
var rc = _session.DGControl.Capability.QuerySupport(cap);
|
||||
@@ -28,7 +28,7 @@ namespace NTwain
|
||||
|
||||
if (read.ContainerType == ContainerType.OneValue)
|
||||
{
|
||||
retVal = read.OneValue.ConvertToEnum<QuerySupport>();
|
||||
retVal = read.OneValue.ConvertToEnum<QuerySupports>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ namespace NTwain
|
||||
|
||||
|
||||
/// <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>
|
||||
/// <param name="capabilityId">The capability unique identifier.</param>
|
||||
/// <returns></returns>
|
||||
@@ -15,11 +15,11 @@ namespace NTwain
|
||||
/// <summary>
|
||||
/// Represents a TWAIN data source.
|
||||
/// </summary>
|
||||
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;
|
||||
17
NTwain/IDataSource.cs
Normal file
17
NTwain/IDataSource.cs
Normal 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
51
NTwain/IPlatformInfo.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -12,11 +12,11 @@ namespace NTwain
|
||||
/// <summary>
|
||||
/// General interface for a TWAIN session.
|
||||
/// </summary>
|
||||
public interface ITwainSession : INotifyPropertyChanged
|
||||
public interface ITwainSession : IEnumerable<DataSource>, INotifyPropertyChanged
|
||||
{
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
@@ -39,7 +39,7 @@ namespace NTwain
|
||||
/// <value>
|
||||
/// The current source.
|
||||
/// </value>
|
||||
TwainSource CurrentSource { get; }
|
||||
DataSource CurrentSource { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default source for this application.
|
||||
@@ -49,7 +49,7 @@ namespace NTwain
|
||||
/// <value>
|
||||
/// The default source.
|
||||
/// </value>
|
||||
TwainSource DefaultSource { get; set; }
|
||||
DataSource DefaultSource { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TwainSource ShowSourceSelector();
|
||||
DataSource ShowSourceSelector();
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -120,7 +120,7 @@ namespace NTwain
|
||||
/// Gets list of sources available in the system.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
IEnumerable<TwainSource> GetSources();
|
||||
IEnumerable<DataSource> GetSources();
|
||||
|
||||
/// <summary>
|
||||
/// Quick shortcut to open a source.
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Commits the pending changes.
|
||||
/// </summary>
|
||||
void Commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ using System.Threading;
|
||||
|
||||
namespace NTwain.Internals
|
||||
{
|
||||
/// <summary>
|
||||
/// Extends <see cref="ITwainSession"/> with extra stuff for internal use.
|
||||
/// </summary>
|
||||
interface ITwainSessionInternal : ITwainSession
|
||||
{
|
||||
/// <summary>
|
||||
@@ -31,7 +34,7 @@ namespace NTwain.Internals
|
||||
/// <returns></returns>
|
||||
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; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the triplet operations defined for audio data group.
|
||||
/// </summary>
|
||||
|
||||
@@ -9,7 +9,11 @@ using System.Windows.Threading;
|
||||
|
||||
namespace NTwain.Internals
|
||||
{
|
||||
sealed class InternalMessageLoopHook : MessageLoopHook
|
||||
/// <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
|
||||
{
|
||||
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())
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
<Compile Include="Data\TypeReader.cs" />
|
||||
<Compile Include="Data\TwainTypesExtended.cs" />
|
||||
<Compile Include="DeviceEventArgs.cs" />
|
||||
<Compile Include="IDataSource.cs" />
|
||||
<Compile Include="Internals\Extensions.cs" />
|
||||
<Compile Include="DataTransferredEventArgs.cs" />
|
||||
<Compile Include="IMemoryManager.cs" />
|
||||
@@ -69,12 +70,13 @@
|
||||
<Compile Include="Internals\TransferLogic.cs" />
|
||||
<Compile Include="Internals\WindowsHook.cs" />
|
||||
<Compile Include="Internals\WrappedManualResetEvent.cs" />
|
||||
<Compile Include="IPlatformInfo.cs" />
|
||||
<Compile Include="ITwainSession.cs" />
|
||||
<Compile Include="Internals\WinMemoryManager.cs" />
|
||||
<Compile Include="Internals\UnsafeNativeMethods.cs" />
|
||||
<Compile Include="Internals\IWinMessageFilter.cs" />
|
||||
<Compile Include="MessageLoopHooks.cs" />
|
||||
<Compile Include="Platform.cs" />
|
||||
<Compile Include="PlatformInfo.cs" />
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
@@ -88,14 +90,14 @@
|
||||
<Compile Include="Triplets\DGControl\DGControl.CapabilityCustom.cs" />
|
||||
<Compile Include="Triplets\DGImage\DGImage.Filter.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.WinOld.cs" />
|
||||
<Compile Include="Triplets\Dsm.WinNew.cs" />
|
||||
<Compile Include="TwainSessionInternal.cs" />
|
||||
<Compile Include="TwainSource.Caps.cs" />
|
||||
<Compile Include="DataSource.Caps.cs" />
|
||||
<Compile Include="TwainSession.cs" />
|
||||
<Compile Include="TwainSource.cs" />
|
||||
<Compile Include="DataSource.cs" />
|
||||
<Compile Include="TwainStateException.cs" />
|
||||
<Compile Include="Data\TwainTypes.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
|
||||
@@ -8,44 +8,57 @@ using System.Text;
|
||||
namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for checking various platform requirements and conditions.
|
||||
/// Contains various platform requirements and conditions for TWAIN.
|
||||
/// </summary>
|
||||
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();
|
||||
/// <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;
|
||||
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the application is running in 64-bit.
|
||||
@@ -68,7 +80,7 @@ namespace NTwain
|
||||
/// <value>
|
||||
/// <c>true</c> if the application is 64-bit; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
public static bool IsApp64bit { get; private set; }
|
||||
public bool IsApp64bit { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the applicable TWAIN DSM library exists in the operating system.
|
||||
@@ -76,7 +88,15 @@ namespace NTwain
|
||||
/// <value>
|
||||
/// <c>true</c> if the TWAIN DSM; otherwise, <c>false</c>.
|
||||
/// </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>
|
||||
/// Gets a value indicating whether this library is supported on current OS.
|
||||
@@ -85,11 +105,11 @@ namespace NTwain
|
||||
/// <value>
|
||||
/// <c>true</c> if this library is supported; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IMemoryManager"/> for communicating with data sources.
|
||||
@@ -98,7 +118,7 @@ namespace NTwain
|
||||
/// <value>
|
||||
/// The memory manager.
|
||||
/// </value>
|
||||
public static IMemoryManager MemoryManager
|
||||
public IMemoryManager MemoryManager
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.AudioFileXfer"/>.
|
||||
/// </summary>
|
||||
sealed class AudioFileXfer : OpBase
|
||||
sealed class AudioFileXfer : TripletBase
|
||||
{
|
||||
internal AudioFileXfer(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.AudioInfo"/>.
|
||||
/// </summary>
|
||||
sealed class AudioInfo : OpBase
|
||||
sealed class AudioInfo : TripletBase
|
||||
{
|
||||
internal AudioInfo(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.AudioNativeXfer"/>.
|
||||
/// </summary>
|
||||
sealed class AudioNativeXfer : OpBase
|
||||
sealed class AudioNativeXfer : TripletBase
|
||||
{
|
||||
internal AudioNativeXfer(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,7 @@ using NTwain.Internals;
|
||||
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
sealed class Callback : OpBase
|
||||
sealed class Callback : TripletBase
|
||||
{
|
||||
internal Callback(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,7 @@ using NTwain.Internals;
|
||||
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
sealed class Callback2 : OpBase
|
||||
sealed class Callback2 : TripletBase
|
||||
{
|
||||
internal Callback2(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Capability"/>.
|
||||
/// </summary>
|
||||
public sealed class Capability : OpBase
|
||||
public sealed class Capability : TripletBase
|
||||
{
|
||||
internal Capability(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// This is to support custom DAT value for custom capability defined by some manufacturers.
|
||||
/// </summary>
|
||||
public sealed class CapabilityCustom : OpBase
|
||||
public sealed class CapabilityCustom : TripletBase
|
||||
{
|
||||
internal CapabilityCustom(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.CustomDSData"/>.
|
||||
/// </summary>
|
||||
public sealed class CustomDSData : OpBase
|
||||
public sealed class CustomDSData : TripletBase
|
||||
{
|
||||
internal CustomDSData(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.DeviceEvent"/>.
|
||||
/// </summary>
|
||||
sealed class DeviceEvent : OpBase
|
||||
sealed class DeviceEvent : TripletBase
|
||||
{
|
||||
internal DeviceEvent(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.EntryPoint"/>.
|
||||
/// </summary>
|
||||
sealed class EntryPoint : OpBase
|
||||
sealed class EntryPoint : TripletBase
|
||||
{
|
||||
internal EntryPoint(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -3,7 +3,7 @@ using NTwain.Internals;
|
||||
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
sealed class Event : OpBase
|
||||
sealed class Event : TripletBase
|
||||
{
|
||||
internal Event(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.FileSystem"/>.
|
||||
/// </summary>
|
||||
public sealed class FileSystem : OpBase
|
||||
public sealed class FileSystem : TripletBase
|
||||
{
|
||||
internal FileSystem(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Identity"/>.
|
||||
/// </summary>
|
||||
sealed class Identity : OpBase
|
||||
sealed class Identity : TripletBase
|
||||
{
|
||||
internal Identity(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="source">The source.</param>
|
||||
/// <returns></returns>
|
||||
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);
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Parent"/>.
|
||||
/// </summary>
|
||||
sealed class Parent : OpBase
|
||||
sealed class Parent : TripletBase
|
||||
{
|
||||
internal Parent(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.PassThru"/>.
|
||||
/// </summary>
|
||||
public sealed class PassThru : OpBase
|
||||
public sealed class PassThru : TripletBase
|
||||
{
|
||||
internal PassThru(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.PendingXfers"/>.
|
||||
/// </summary>
|
||||
sealed class PendingXfers : OpBase
|
||||
sealed class PendingXfers : TripletBase
|
||||
{
|
||||
internal PendingXfers(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// Represents <see cref="DataArgumentType.SetupFileXfer"/>.
|
||||
/// </summary>
|
||||
[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) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// Represents <see cref="DataArgumentType.SetupMemXfer"/>.
|
||||
/// </summary>
|
||||
[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) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Status"/>.
|
||||
/// </summary>
|
||||
sealed class Status : OpBase
|
||||
sealed class Status : TripletBase
|
||||
{
|
||||
internal Status(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.StatusUtf8"/>.
|
||||
/// </summary>
|
||||
sealed class StatusUtf8 : OpBase
|
||||
sealed class StatusUtf8 : TripletBase
|
||||
{
|
||||
internal StatusUtf8(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.UserInterface"/>.
|
||||
/// </summary>
|
||||
sealed class UserInterface : OpBase
|
||||
sealed class UserInterface : TripletBase
|
||||
{
|
||||
internal UserInterface(ITwainSessionInternal session) : base(session) { }
|
||||
/// <summary>
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// Represents <see cref="DataArgumentType.XferGroup"/>.
|
||||
/// </summary>
|
||||
[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) { }
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// Represents <see cref="DataArgumentType.CieColor"/>.
|
||||
/// </summary>
|
||||
[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) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.ExtImageInfo"/>.
|
||||
/// </summary>
|
||||
public sealed class ExtImageInfo : OpBase
|
||||
public sealed class ExtImageInfo : TripletBase
|
||||
{
|
||||
internal ExtImageInfo(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Filter"/>.
|
||||
/// </summary>
|
||||
public sealed class Filter : OpBase
|
||||
public sealed class Filter : TripletBase
|
||||
{
|
||||
internal Filter(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.GrayResponse"/>.
|
||||
/// </summary>
|
||||
public sealed class GrayResponse : OpBase
|
||||
public sealed class GrayResponse : TripletBase
|
||||
{
|
||||
internal GrayResponse(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// Represents <see cref="DataArgumentType.IccProfile"/>.
|
||||
/// </summary>
|
||||
[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) { }
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.ImageFileXfer"/>.
|
||||
/// </summary>
|
||||
sealed class ImageFileXfer : OpBase
|
||||
sealed class ImageFileXfer : TripletBase
|
||||
{
|
||||
internal ImageFileXfer(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.ImageInfo"/>.
|
||||
/// </summary>
|
||||
sealed class ImageInfo : OpBase
|
||||
sealed class ImageInfo : TripletBase
|
||||
{
|
||||
internal ImageInfo(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.ImageLayout"/>.
|
||||
/// </summary>
|
||||
public sealed class ImageLayout : OpBase
|
||||
public sealed class ImageLayout : TripletBase
|
||||
{
|
||||
internal ImageLayout(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ using NTwain.Internals;
|
||||
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
sealed class ImageMemFileXfer : OpBase
|
||||
sealed class ImageMemFileXfer : TripletBase
|
||||
{
|
||||
internal ImageMemFileXfer(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ using NTwain.Internals;
|
||||
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
sealed class ImageMemXfer : OpBase
|
||||
sealed class ImageMemXfer : TripletBase
|
||||
{
|
||||
internal ImageMemXfer(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using System;
|
||||
|
||||
namespace NTwain.Triplets
|
||||
{
|
||||
sealed class ImageNativeXfer : OpBase
|
||||
sealed class ImageNativeXfer : TripletBase
|
||||
{
|
||||
internal ImageNativeXfer(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.JpegCompression"/>.
|
||||
/// </summary>
|
||||
public sealed class JpegCompression : OpBase
|
||||
public sealed class JpegCompression : TripletBase
|
||||
{
|
||||
internal JpegCompression(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Represents <see cref="DataArgumentType.Palette8"/>.
|
||||
/// </summary>
|
||||
public sealed class Palette8 : OpBase
|
||||
public sealed class Palette8 : TripletBase
|
||||
{
|
||||
internal Palette8(ITwainSessionInternal session) : base(session) { }
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace NTwain.Triplets
|
||||
/// Represents <see cref="DataArgumentType.RgbResponse"/>.
|
||||
/// </summary>
|
||||
[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) { }
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace NTwain.Triplets
|
||||
/// <summary>
|
||||
/// Base class for grouping triplet operations messages.
|
||||
/// </summary>
|
||||
public abstract class OpBase
|
||||
public abstract class TripletBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="OpBase" /> class.
|
||||
/// Initializes a new instance of the <see cref="TripletBase" /> class.
|
||||
/// </summary>
|
||||
/// <param name="session">The session.</param>
|
||||
/// <exception cref="System.ArgumentNullException"></exception>
|
||||
internal OpBase(ITwainSessionInternal session)
|
||||
internal TripletBase(ITwainSessionInternal session)
|
||||
{
|
||||
if (session == null) { throw new ArgumentNullException("session"); }
|
||||
Session = session;
|
||||
@@ -40,7 +40,7 @@ namespace NTwain
|
||||
if (appId == null) { throw new ArgumentNullException("appId"); }
|
||||
|
||||
_appId = appId;
|
||||
_ownedSources = new Dictionary<string, TwainSource>();
|
||||
_ownedSources = new Dictionary<string, DataSource>();
|
||||
((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<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);
|
||||
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; }
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
@@ -99,7 +99,7 @@ namespace NTwain
|
||||
/// <value>
|
||||
/// The current source.
|
||||
/// </value>
|
||||
public TwainSource CurrentSource { get; private set; }
|
||||
public DataSource CurrentSource { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the default source for this application.
|
||||
@@ -109,7 +109,7 @@ namespace NTwain
|
||||
/// <value>
|
||||
/// The default source.
|
||||
/// </value>
|
||||
public TwainSource DefaultSource
|
||||
public DataSource DefaultSource
|
||||
{
|
||||
get
|
||||
{
|
||||
@@ -134,7 +134,7 @@ namespace NTwain
|
||||
/// This is not recommended and is only included for completeness.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public TwainSource ShowSourceSelector()
|
||||
public DataSource ShowSourceSelector()
|
||||
{
|
||||
TWIdentity id;
|
||||
if (((ITwainSessionInternal)this).DGControl.Identity.UserSelect(out id) == ReturnCode.Success)
|
||||
@@ -187,10 +187,10 @@ namespace NTwain
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// <see cref="Close" /> when done with a TWAIN session.
|
||||
/// </summary>
|
||||
/// <returns></returns
|
||||
/// <returns></returns>
|
||||
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.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IEnumerable<TwainSource> GetSources()
|
||||
public IEnumerable<DataSource> 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;
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
return hit.Open();
|
||||
@@ -445,6 +439,35 @@ namespace NTwain
|
||||
|
||||
#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
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -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
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user