Minor internal changes.

This commit is contained in:
soukoku 2014-09-02 19:10:35 -04:00
parent 41d821a9d5
commit 88bd745883
11 changed files with 167 additions and 141 deletions

View File

@ -6,9 +6,8 @@ namespace NTwain.Internals
{ {
/// <summary> /// <summary>
/// Abstracts out wnd proc hook on Windows from MessageLoop class. /// Abstracts out wnd proc hook on Windows from InternalMessageLoopHook class.
/// This allows things to not depend on PresentationCore.dll at runtime on mono. /// This allows things to not depend on PresentationCore.dll at runtime on mono.
/// Not that everything works yet in mono but it's something.
/// </summary> /// </summary>
class WindowsHook : IDisposable class WindowsHook : IDisposable
{ {

View File

@ -15,21 +15,57 @@ namespace NTwain
static Platform() static Platform()
{ {
IsApp64bit = IntPtr.Size == 8; IsApp64bit = IntPtr.Size == 8;
NewWinDsmExists = File.Exists(Path.Combine(Environment.SystemDirectory, "twaindsm.dll"));
UseNewDSM = IsApp64bit || NewWinDsmExists;
IsOnMono = Type.GetType("Mono.Runtime") != null; IsOnMono = Type.GetType("Mono.Runtime") != null;
IsWin = Environment.OSVersion.Platform == PlatformID.Win32NT; IsWin = Environment.OSVersion.Platform == PlatformID.Win32NT;
IsLinux = Environment.OSVersion.Platform == PlatformID.Unix; IsLinux = Environment.OSVersion.Platform == PlatformID.Unix;
if (IsWin)
{
var newDsmPath = Path.Combine(Environment.SystemDirectory, "twaindsm.dll");
var oldDsmPath = Path.Combine(Environment.SystemDirectory, "twain_32.dll");
if (IsApp64bit)
{
IsSupported = DsmExists = File.Exists(newDsmPath);
UseNewWinDSM = true;
}
else
{
if (File.Exists(newDsmPath))
{
UseNewWinDSM = IsSupported = DsmExists = true;
}
else
{
IsSupported = DsmExists = File.Exists(oldDsmPath);
}
}
}
else if (IsLinux)
{
DsmExists = File.Exists(Triplets.Dsm.LINUX_DSM_PATH);
IsSupported = DsmExists && IsOnMono;
}
else
{
}
_defaultMemManager = new WinMemoryManager(); _defaultMemManager = new WinMemoryManager();
} }
internal static readonly bool UseNewDSM; // prefer the use of the twain dsm on windows.
internal static readonly bool UseNewWinDSM;
internal static readonly bool IsApp64bit; internal static readonly bool IsApp64bit;
internal static readonly bool NewWinDsmExists;
/// <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>
public static bool DsmExists { get; private set; }
internal static readonly bool IsOnMono; internal static readonly bool IsOnMono;
@ -37,23 +73,12 @@ namespace NTwain
internal static readonly bool IsLinux; internal static readonly bool IsLinux;
/// <summary> /// <summary>
/// Gets a value indicating whether this library is supported. /// Gets a value indicating whether this library is supported on current OS.
/// </summary> /// </summary>
/// <value> /// <value>
/// <c>true</c> if this library is supported; otherwise, <c>false</c>. /// <c>true</c> if this library is supported; otherwise, <c>false</c>.
/// </value> /// </value>
public static bool IsSupported public static bool IsSupported { get; private set; }
{
get
{
if (IsWin)
{
if (IsApp64bit) { return NewWinDsmExists; }
return true;
}
return IsOnMono && IsLinux;
}
}
static readonly IMemoryManager _defaultMemManager; static readonly IMemoryManager _defaultMemManager;

View File

@ -6,9 +6,11 @@ namespace NTwain.Triplets
{ {
static partial class Dsm static partial class Dsm
{ {
internal const string LINUX_DSM_PATH = "/usr/local/lib/libtwaindsm.so";
static partial class NativeMethods static partial class NativeMethods
{ {
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -17,7 +19,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
ref IntPtr data); ref IntPtr data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -26,7 +28,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
ref DataGroups data); ref DataGroups data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -35,7 +37,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWAudioInfo data); [In, Out]TWAudioInfo data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -44,7 +46,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWCapability data); [In, Out]TWCapability data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -53,7 +55,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWCustomDSData data); [In, Out]TWCustomDSData data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -62,7 +64,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWDeviceEvent data); [In, Out]TWDeviceEvent data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -71,7 +73,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWCallback data); [In, Out]TWCallback data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -80,7 +82,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWCallback2 data); [In, Out]TWCallback2 data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -89,7 +91,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWEntryPoint data); [In, Out]TWEntryPoint data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -98,7 +100,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWEvent data); [In, Out]TWEvent data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -107,7 +109,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWFileSystem data); [In, Out]TWFileSystem data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
IntPtr zero, IntPtr zero,
@ -116,7 +118,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWIdentity data); [In, Out]TWIdentity data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -125,7 +127,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWPassThru data); [In, Out]TWPassThru data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -134,7 +136,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWPendingXfers data); [In, Out]TWPendingXfers data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -143,7 +145,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWSetupFileXfer data); [In, Out]TWSetupFileXfer data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -152,7 +154,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWSetupMemXfer data); [In, Out]TWSetupMemXfer data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -161,7 +163,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWStatusUtf8 data); [In, Out]TWStatusUtf8 data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -170,7 +172,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWUserInterface data); [In, Out]TWUserInterface data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -179,7 +181,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWCieColor data); [In, Out]TWCieColor data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -188,7 +190,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWExtImageInfo data); [In, Out]TWExtImageInfo data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -197,7 +199,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWFilter data); [In, Out]TWFilter data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -206,7 +208,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWGrayResponse data); [In, Out]TWGrayResponse data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -215,7 +217,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWImageInfo data); [In, Out]TWImageInfo data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -224,7 +226,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWImageLayout data); [In, Out]TWImageLayout data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -233,7 +235,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWImageMemXfer data); [In, Out]TWImageMemXfer data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -242,7 +244,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWJpegCompression data); [In, Out]TWJpegCompression data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -251,7 +253,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWPalette8 data); [In, Out]TWPalette8 data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -260,7 +262,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWRgbResponse data); [In, Out]TWRgbResponse data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,
@ -269,7 +271,7 @@ namespace NTwain.Triplets
Message msg, Message msg,
[In, Out]TWStatus data); [In, Out]TWStatus data);
[DllImport("/usr/local/lib/libtwaindsm.so", EntryPoint = "DSM_Entry")] [DllImport(LINUX_DSM_PATH, EntryPoint = "DSM_Entry")]
public static extern ReturnCode DsmLinux( public static extern ReturnCode DsmLinux(
[In, Out]TWIdentity origin, [In, Out]TWIdentity origin,
[In, Out]TWIdentity destination, [In, Out]TWIdentity destination,

View File

@ -22,7 +22,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); }
else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); } else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -42,7 +42,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, ref data); }
else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); } else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, ref data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -60,7 +60,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Audio, DataArgumentType.AudioInfo, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -80,7 +80,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -99,7 +99,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.CustomDSData, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -118,7 +118,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.DeviceEvent, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -137,7 +137,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -156,7 +156,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -174,7 +174,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
else { return NativeMethods.DsmWinOld(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); } else { return NativeMethods.DsmWinOld(origin, null, DataGroups.Control, DataArgumentType.EntryPoint, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -193,7 +193,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Event, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -212,7 +212,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.FileSystem, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -229,7 +229,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
else { return NativeMethods.DsmWinOld(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); } else { return NativeMethods.DsmWinOld(origin, IntPtr.Zero, DataGroups.Control, DataArgumentType.Identity, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -248,7 +248,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PassThru, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -267,7 +267,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.PendingXfers, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -286,7 +286,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupFileXfer, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -305,7 +305,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.SetupMemXfer, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -324,7 +324,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.StatusUtf8, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -343,7 +343,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.UserInterface, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -362,7 +362,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.CieColor, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -381,7 +381,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ExtImageInfo, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -399,7 +399,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Filter, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -417,7 +417,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.GrayResponse, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -436,7 +436,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageInfo, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -455,7 +455,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageLayout, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -474,7 +474,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.ImageMemXfer, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -493,7 +493,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.JpegCompression, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -512,7 +512,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.Palette8, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -531,7 +531,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Image, DataArgumentType.RgbResponse, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -550,7 +550,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Status, msg, data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)
@ -570,7 +570,7 @@ namespace NTwain.Triplets
{ {
if (Platform.IsWin) if (Platform.IsWin)
{ {
if (Platform.UseNewDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, ref data); } if (Platform.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, dat, msg, ref data); }
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, ref data); } else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, dat, msg, ref data); }
} }
else if (Platform.IsLinux) else if (Platform.IsLinux)

View File

@ -53,20 +53,19 @@ namespace NTwain
TWUserInterface _twui; TWUserInterface _twui;
static readonly Dictionary<string, TwainSource> __ownedSources = new Dictionary<string, TwainSource>(); readonly Dictionary<string, TwainSource> _ownedSources = new Dictionary<string, TwainSource>();
internal static TwainSource GetSourceInstance(ITwainSessionInternal session, TWIdentity sourceId) TwainSource GetSourceInstance(ITwainSessionInternal session, TWIdentity sourceId)
{ {
TwainSource source = null; TwainSource source = null;
var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}", sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName); var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}", sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName);
if (__ownedSources.ContainsKey(key)) if (_ownedSources.ContainsKey(key))
{ {
source = __ownedSources[key]; source = _ownedSources[key];
source.Session = session;
} }
else else
{ {
__ownedSources[key] = source = new TwainSource(session, sourceId); _ownedSources[key] = source = new TwainSource(session, sourceId);
} }
return source; return source;
} }

View File

@ -18,7 +18,7 @@ namespace NTwain
QuerySupport retVal = QuerySupport.None; QuerySupport retVal = QuerySupport.None;
using (TWCapability cap = new TWCapability(capId)) using (TWCapability cap = new TWCapability(capId))
{ {
var rc = Session.DGControl.Capability.QuerySupport(cap); var rc = _session.DGControl.Capability.QuerySupport(cap);
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
var read = CapabilityReader.ReadValue(cap); var read = CapabilityReader.ReadValue(cap);
@ -41,7 +41,7 @@ namespace NTwain
{ {
using (TWCapability cap = new TWCapability(capId)) using (TWCapability cap = new TWCapability(capId))
{ {
var rc = Session.DGControl.Capability.GetCurrent(cap); var rc = _session.DGControl.Capability.GetCurrent(cap);
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
var read = CapabilityReader.ReadValue(cap); var read = CapabilityReader.ReadValue(cap);
@ -82,7 +82,7 @@ namespace NTwain
var list = new List<object>(); var list = new List<object>();
using (TWCapability cap = new TWCapability(capabilityId)) using (TWCapability cap = new TWCapability(capabilityId))
{ {
var rc = Session.DGControl.Capability.Get(cap); var rc = _session.DGControl.Capability.Get(cap);
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
cap.ReadMultiCapValues(list); cap.ReadMultiCapValues(list);
@ -126,7 +126,7 @@ namespace NTwain
{ {
using (TWCapability compressCap = new TWCapability(CapabilityId.ICapCompression, new TWOneValue { Item = (uint)compression, ItemType = ItemType.UInt16 })) using (TWCapability compressCap = new TWCapability(CapabilityId.ICapCompression, new TWOneValue { Item = (uint)compression, ItemType = ItemType.UInt16 }))
{ {
return Session.DGControl.Capability.Set(compressCap); return _session.DGControl.Capability.Set(compressCap);
} }
} }
@ -153,7 +153,7 @@ namespace NTwain
{ {
using (TWCapability formatCap = new TWCapability(CapabilityId.ICapImageFileFormat, new TWOneValue { Item = (uint)format, ItemType = ItemType.UInt16 })) using (TWCapability formatCap = new TWCapability(CapabilityId.ICapImageFileFormat, new TWOneValue { Item = (uint)format, ItemType = ItemType.UInt16 }))
{ {
return Session.DGControl.Capability.Set(formatCap); return _session.DGControl.Capability.Set(formatCap);
} }
} }
@ -183,7 +183,7 @@ namespace NTwain
one.ItemType = ItemType.UInt16; one.ItemType = ItemType.UInt16;
using (TWCapability dx = new TWCapability(CapabilityId.ICapPixelType, one)) using (TWCapability dx = new TWCapability(CapabilityId.ICapPixelType, one))
{ {
return Session.DGControl.Capability.Set(dx); return _session.DGControl.Capability.Set(dx);
} }
} }
@ -223,7 +223,7 @@ namespace NTwain
one.ItemType = ItemType.UInt16; one.ItemType = ItemType.UInt16;
using (TWCapability dx = new TWCapability(CapabilityId.ICapXferMech, one)) using (TWCapability dx = new TWCapability(CapabilityId.ICapXferMech, one))
{ {
return Session.DGControl.Capability.Set(dx); return _session.DGControl.Capability.Set(dx);
} }
} }
@ -239,7 +239,7 @@ namespace NTwain
one.ItemType = ItemType.UInt16; one.ItemType = ItemType.UInt16;
using (TWCapability dx = new TWCapability(CapabilityId.ACapXferMech, one)) using (TWCapability dx = new TWCapability(CapabilityId.ACapXferMech, one))
{ {
return Session.DGControl.Capability.Set(dx); return _session.DGControl.Capability.Set(dx);
} }
} }
@ -282,13 +282,13 @@ namespace NTwain
using (TWCapability xres = new TWCapability(CapabilityId.ICapXResolution, one)) using (TWCapability xres = new TWCapability(CapabilityId.ICapXResolution, one))
{ {
var rc = Session.DGControl.Capability.Set(xres); var rc = _session.DGControl.Capability.Set(xres);
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
one.Item = (uint)yDPI; one.Item = (uint)yDPI;
using (TWCapability yres = new TWCapability(CapabilityId.ICapYResolution, one)) using (TWCapability yres = new TWCapability(CapabilityId.ICapYResolution, one))
{ {
rc = Session.DGControl.Capability.Set(yres); rc = _session.DGControl.Capability.Set(yres);
} }
} }
return rc; return rc;
@ -322,7 +322,7 @@ namespace NTwain
using (TWCapability xres = new TWCapability(CapabilityId.ICapSupportedSizes, one)) using (TWCapability xres = new TWCapability(CapabilityId.ICapSupportedSizes, one))
{ {
var rc = Session.DGControl.Capability.Set(xres); var rc = _session.DGControl.Capability.Set(xres);
return rc; return rc;
} }
} }
@ -351,7 +351,7 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticDeskew, en)) using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticDeskew, en))
{ {
rc = Session.DGControl.Capability.Set(dx); rc = _session.DGControl.Capability.Set(dx);
} }
} }
else else
@ -362,7 +362,7 @@ namespace NTwain
using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticDeskew, one)) using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticDeskew, one))
{ {
rc = Session.DGControl.Capability.Set(capValue); rc = _session.DGControl.Capability.Set(capValue);
} }
} }
} }
@ -389,7 +389,7 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticRotate, en)) using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticRotate, en))
{ {
rc = Session.DGControl.Capability.Set(dx); rc = _session.DGControl.Capability.Set(dx);
} }
} }
else else
@ -400,7 +400,7 @@ namespace NTwain
using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticRotate, one)) using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticRotate, one))
{ {
rc = Session.DGControl.Capability.Set(capValue); rc = _session.DGControl.Capability.Set(capValue);
} }
} }
} }
@ -428,11 +428,11 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.ICapUndefinedImageSize, en)) using (TWCapability dx = new TWCapability(CapabilityId.ICapUndefinedImageSize, en))
{ {
rc = Session.DGControl.Capability.Set(dx); rc = _session.DGControl.Capability.Set(dx);
} }
using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, en)) using (TWCapability dx = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, en))
{ {
rc = Session.DGControl.Capability.Set(dx); rc = _session.DGControl.Capability.Set(dx);
} }
} }
else else
@ -443,11 +443,11 @@ namespace NTwain
using (TWCapability capValue = new TWCapability(CapabilityId.ICapUndefinedImageSize, one)) using (TWCapability capValue = new TWCapability(CapabilityId.ICapUndefinedImageSize, one))
{ {
rc = Session.DGControl.Capability.Set(capValue); rc = _session.DGControl.Capability.Set(capValue);
} }
using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, one)) using (TWCapability capValue = new TWCapability(CapabilityId.ICapAutomaticBorderDetection, one))
{ {
rc = Session.DGControl.Capability.Set(capValue); rc = _session.DGControl.Capability.Set(capValue);
} }
} }
} }
@ -471,7 +471,7 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.CapDuplexEnabled, en)) using (TWCapability dx = new TWCapability(CapabilityId.CapDuplexEnabled, en))
{ {
return Session.DGControl.Capability.Set(dx); return _session.DGControl.Capability.Set(dx);
} }
} }
else else
@ -482,7 +482,7 @@ namespace NTwain
using (TWCapability dx = new TWCapability(CapabilityId.CapDuplexEnabled, one)) using (TWCapability dx = new TWCapability(CapabilityId.CapDuplexEnabled, one))
{ {
return Session.DGControl.Capability.Set(dx); return _session.DGControl.Capability.Set(dx);
} }
} }
} }
@ -512,7 +512,7 @@ namespace NTwain
{ {
using (TWCapability dx = new TWCapability(CapabilityId.CapFeederEnabled, en)) using (TWCapability dx = new TWCapability(CapabilityId.CapFeederEnabled, en))
{ {
rc = Session.DGControl.Capability.Set(dx); rc = _session.DGControl.Capability.Set(dx);
} }
} }
@ -522,14 +522,14 @@ namespace NTwain
{ {
using (TWCapability dx = new TWCapability(CapabilityId.CapAutoScan, en)) using (TWCapability dx = new TWCapability(CapabilityId.CapAutoScan, en))
{ {
rc = Session.DGControl.Capability.Set(dx); rc = _session.DGControl.Capability.Set(dx);
} }
} }
else if (SupportedCaps.Contains(CapabilityId.CapAutoFeed)) else if (SupportedCaps.Contains(CapabilityId.CapAutoFeed))
{ {
using (TWCapability dx = new TWCapability(CapabilityId.CapAutoFeed, en)) using (TWCapability dx = new TWCapability(CapabilityId.CapAutoFeed, en))
{ {
rc = Session.DGControl.Capability.Set(dx); rc = _session.DGControl.Capability.Set(dx);
} }
} }
} }
@ -543,7 +543,7 @@ namespace NTwain
{ {
using (TWCapability enabled = new TWCapability(CapabilityId.CapFeederEnabled, one)) using (TWCapability enabled = new TWCapability(CapabilityId.CapFeederEnabled, one))
{ {
rc = Session.DGControl.Capability.Set(enabled); rc = _session.DGControl.Capability.Set(enabled);
} }
} }
// to really use feeder we must also set autofeed or autoscan, but only // to really use feeder we must also set autofeed or autoscan, but only
@ -552,14 +552,14 @@ namespace NTwain
{ {
using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoScan, one)) using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoScan, one))
{ {
rc = Session.DGControl.Capability.Set(autoScan); rc = _session.DGControl.Capability.Set(autoScan);
} }
} }
else if (SupportedCaps.Contains(CapabilityId.CapAutoFeed)) else if (SupportedCaps.Contains(CapabilityId.CapAutoFeed))
{ {
using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoFeed, one)) using (TWCapability autoScan = new TWCapability(CapabilityId.CapAutoFeed, one))
{ {
rc = Session.DGControl.Capability.Set(autoScan); rc = _session.DGControl.Capability.Set(autoScan);
} }
} }
} }

View File

@ -17,11 +17,11 @@ namespace NTwain
/// </summary> /// </summary>
public partial class TwainSource public partial class TwainSource
{ {
internal ITwainSessionInternal Session { get; set; } ITwainSessionInternal _session;
internal TwainSource(ITwainSessionInternal session, TWIdentity sourceId) internal TwainSource(ITwainSessionInternal session, TWIdentity sourceId)
{ {
Session = session; _session = session;
Identity = sourceId; Identity = sourceId;
} }
@ -32,11 +32,11 @@ namespace NTwain
public ReturnCode Open() public ReturnCode Open()
{ {
var rc = ReturnCode.Failure; var rc = ReturnCode.Failure;
Session.MessageLoopHook.Invoke(() => _session.MessageLoopHook.Invoke(() =>
{ {
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: OpenSource.", Thread.CurrentThread.ManagedThreadId)); Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: OpenSource.", Thread.CurrentThread.ManagedThreadId));
rc = Session.DGControl.Identity.OpenDS(this); rc = _session.DGControl.Identity.OpenDS(this);
}); });
return rc; return rc;
} }
@ -48,11 +48,11 @@ namespace NTwain
public ReturnCode Close() public ReturnCode Close()
{ {
var rc = ReturnCode.Failure; var rc = ReturnCode.Failure;
Session.MessageLoopHook.Invoke(() => _session.MessageLoopHook.Invoke(() =>
{ {
Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseSource.", Thread.CurrentThread.ManagedThreadId)); Debug.WriteLine(string.Format(CultureInfo.InvariantCulture, "Thread {0}: CloseSource.", Thread.CurrentThread.ManagedThreadId));
rc = Session.DGControl.Identity.CloseDS(); rc = _session.DGControl.Identity.CloseDS();
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
SupportedCaps = null; SupportedCaps = null;
@ -71,7 +71,7 @@ namespace NTwain
/// <returns></returns> /// <returns></returns>
public ReturnCode StartTransfer(SourceEnableMode mode, bool modal, IntPtr windowHandle) public ReturnCode StartTransfer(SourceEnableMode mode, bool modal, IntPtr windowHandle)
{ {
return Session.EnableSource(mode, modal, windowHandle); return _session.EnableSource(mode, modal, windowHandle);
} }
/// <summary> /// <summary>
@ -81,7 +81,7 @@ namespace NTwain
public TWStatus GetStatus() public TWStatus GetStatus()
{ {
TWStatus stat; TWStatus stat;
Session.DGControl.Status.GetSource(out stat); _session.DGControl.Status.GetSource(out stat);
return stat; return stat;
} }
/// <summary> /// <summary>
@ -91,7 +91,7 @@ namespace NTwain
public TWStatusUtf8 GetStatusUtf8() public TWStatusUtf8 GetStatusUtf8()
{ {
TWStatusUtf8 stat; TWStatusUtf8 stat;
Session.DGControl.StatusUtf8.GetSource(out stat); _session.DGControl.StatusUtf8.GetSource(out stat);
return stat; return stat;
} }
@ -170,7 +170,7 @@ namespace NTwain
{ {
get get
{ {
if (_supportedCaps == null && Session.State > 3) if (_supportedCaps == null && _session.State > 3)
{ {
_supportedCaps = CapGetValues(CapabilityId.CapSupportedCaps).CastToEnum<CapabilityId>(false); _supportedCaps = CapGetValues(CapabilityId.CapSupportedCaps).CastToEnum<CapabilityId>(false);
} }
@ -191,7 +191,7 @@ namespace NTwain
{ {
get get
{ {
return Session.DGControl; return _session.DGControl;
} }
} }
@ -202,7 +202,7 @@ namespace NTwain
{ {
get get
{ {
return Session.DGImage; return _session.DGImage;
} }
} }
@ -213,7 +213,7 @@ namespace NTwain
{ {
get get
{ {
return Session.DGCustom; return _session.DGCustom;
} }
} }

View File

@ -42,26 +42,27 @@
<ItemGroup> <ItemGroup>
<Reference Include="CommonWin32, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a0a4edcfe233918d, processorArchitecture=MSIL"> <Reference Include="CommonWin32, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a0a4edcfe233918d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\CommonWin32.2.0.5.2\lib\net35-Client\CommonWin32.dll</HintPath> <HintPath>..\..\packages\CommonWin32.2.0.5.4\lib\net35-Client\CommonWin32.dll</HintPath>
</Reference> </Reference>
<Reference Include="GalaSoft.MvvmLight.Extras.WPF4"> <Reference Include="GalaSoft.MvvmLight">
<HintPath>..\..\packages\MvvmLightLibs.4.3.31.1\lib\net40\GalaSoft.MvvmLight.Extras.WPF4.dll</HintPath> <HintPath>..\..\packages\MvvmLightLibs.4.4.32.1\lib\net40\GalaSoft.MvvmLight.dll</HintPath>
</Reference> </Reference>
<Reference Include="GalaSoft.MvvmLight.WPF4"> <Reference Include="GalaSoft.MvvmLight.Extras">
<HintPath>..\..\packages\MvvmLightLibs.4.3.31.1\lib\net40\GalaSoft.MvvmLight.WPF4.dll</HintPath> <HintPath>..\..\packages\MvvmLightLibs.4.4.32.1\lib\net40\GalaSoft.MvvmLight.Extras.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Practices.ServiceLocation"> <Reference Include="Microsoft.Practices.ServiceLocation, Version=1.3.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\CommonServiceLocator.1.2\lib\portable-windows8+net40+sl5+windowsphone8\Microsoft.Practices.ServiceLocation.dll</HintPath> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll</HintPath>
</Reference> </Reference>
<Reference Include="ModernWPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c99d0cfbea7491ef, processorArchitecture=MSIL"> <Reference Include="ModernWPF, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c99d0cfbea7491ef, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\ModernWPF.1.1.43\lib\net40-Client\ModernWPF.dll</HintPath> <HintPath>..\..\packages\ModernWPF.1.1.45.2\lib\net40-Client\ModernWPF.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL"> <Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\MvvmLightLibs.4.3.31.1\lib\net40\System.Windows.Interactivity.dll</HintPath> <HintPath>..\..\packages\MvvmLightLibs.4.4.32.1\lib\net40\System.Windows.Interactivity.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommonServiceLocator" version="1.2" targetFramework="net40-Client" /> <package id="CommonServiceLocator" version="1.3" targetFramework="net40-Client" />
<package id="CommonWin32" version="2.0.5.2" targetFramework="net40-Client" /> <package id="CommonWin32" version="2.0.5.4" targetFramework="net40-Client" />
<package id="ModernWPF" version="1.1.43" targetFramework="net40-Client" /> <package id="ModernWPF" version="1.1.45.2" targetFramework="net40-Client" />
<package id="MvvmLightLibs" version="4.3.31.1" targetFramework="net40-Client" /> <package id="MvvmLightLibs" version="4.4.32.1" targetFramework="net40-Client" />
</packages> </packages>

View File

@ -37,7 +37,7 @@
<ItemGroup> <ItemGroup>
<Reference Include="CommonWin32, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a0a4edcfe233918d, processorArchitecture=MSIL"> <Reference Include="CommonWin32, Version=2.0.0.0, Culture=neutral, PublicKeyToken=a0a4edcfe233918d, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\CommonWin32.2.0.5.2\lib\net35-Client\CommonWin32.dll</HintPath> <HintPath>..\..\packages\CommonWin32.2.0.5.4\lib\net35-Client\CommonWin32.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommonWin32" version="2.0.5.2" targetFramework="net35-Client" /> <package id="CommonWin32" version="2.0.5.4" targetFramework="net35-Client" />
</packages> </packages>