Updated IPlatformInfo to include internally used properties.

This commit is contained in:
soukoku
2015-02-18 19:21:32 -05:00
parent bace6e6323
commit bcb1ec2382
7 changed files with 163 additions and 107 deletions

View File

@@ -38,6 +38,36 @@ namespace NTwain
/// <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>
bool IsSupported { get; } bool IsSupported { get; }
/// <summary>
/// Gets a value indicating whether the lib is expecting to use new DSM.
/// </summary>
/// <value>
/// <c>true</c> if using the new DSM; otherwise, <c>false</c>.
/// </value>
bool UseNewWinDSM { get; }
/// <summary>
/// Gets a value indicating whether the current runtime is mono.
/// </summary>
/// <value>
/// <c>true</c> if the current runtime is on mono; otherwise, <c>false</c>.
/// </value>
bool IsOnMono { get; }
/// <summary>
/// Gets a value indicating whether the current OS is windows.
/// </summary>
/// <value>
/// <c>true</c> if the current OS is windows; otherwise, <c>false</c>.
/// </value>
bool IsWindows { get; }
/// <summary>
/// Gets a value indicating whether the current OS is linux.
/// </summary>
/// <value>
/// <c>true</c> if the current OS is linux; otherwise, <c>false</c>.
/// </value>
bool IsLinux { get; }
/// <summary> /// <summary>
/// Gets the <see cref="IMemoryManager"/> for communicating with data sources. /// Gets the <see cref="IMemoryManager"/> for communicating with data sources.

View File

@@ -6,8 +6,7 @@ using System.Text;
namespace NTwain.Internals namespace NTwain.Internals
{ {
/// <summary> /// <summary>
/// Interface for checking whether messages from WndProc is a TWAIN message and is handled /// Interface for something that can check whether messages from WndProc is a TWAIN message and already handled.
/// internally.
/// </summary> /// </summary>
interface IWinMessageFilter interface IWinMessageFilter
{ {

View File

@@ -36,7 +36,7 @@ namespace NTwain.Internals
{ {
Debug.WriteLine("NTwain message loop is starting."); Debug.WriteLine("NTwain message loop is starting.");
_dispatcher = Dispatcher.CurrentDispatcher; _dispatcher = Dispatcher.CurrentDispatcher;
if (!PlatformInfo.__global.IsOnMono) if (!PlatformInfo.Current.IsOnMono)
{ {
_hook = new WindowsHook(filter); _hook = new WindowsHook(filter);
Handle = _hook.Handle; Handle = _hook.Handle;
@@ -75,7 +75,7 @@ namespace NTwain.Internals
{ {
action(); action();
} }
else if (PlatformInfo.__global.IsOnMono) else if (PlatformInfo.Current.IsOnMono)
{ {
using (var man = new WrappedManualResetEvent()) using (var man = new WrappedManualResetEvent())
{ {

View File

@@ -13,7 +13,8 @@ namespace NTwain
/// </summary> /// </summary>
public class PlatformInfo : IPlatformInfo public class PlatformInfo : IPlatformInfo
{ {
internal static readonly PlatformInfo __global = new PlatformInfo(); static readonly PlatformInfo __global = new PlatformInfo();
internal static PlatformInfo InternalCurrent { get { return __global; } }
/// <summary> /// <summary>
/// Gets the current platform info related to TWAIN. /// Gets the current platform info related to TWAIN.
/// </summary> /// </summary>
@@ -74,10 +75,36 @@ namespace NTwain
_defaultMemManager = new WinMemoryManager(); _defaultMemManager = new WinMemoryManager();
} }
internal readonly bool UseNewWinDSM; /// <summary>
internal readonly bool IsOnMono; /// Gets a value indicating whether the lib is expecting to use new DSM.
internal readonly bool IsWindows; /// </summary>
internal readonly bool IsLinux; /// <value>
/// <c>true</c> if using the new DSM; otherwise, <c>false</c>.
/// </value>
public bool UseNewWinDSM { get; private set; }
/// <summary>
/// Gets a value indicating whether the current runtime is mono.
/// </summary>
/// <value>
/// <c>true</c> if the current runtime is on mono; otherwise, <c>false</c>.
/// </value>
public bool IsOnMono { get; private set; }
/// <summary>
/// Gets a value indicating whether the current OS is windows.
/// </summary>
/// <value>
/// <c>true</c> if the current OS is windows; otherwise, <c>false</c>.
/// </value>
public bool IsWindows { get; private set; }
/// <summary>
/// Gets a value indicating whether the current OS is linux.
/// </summary>
/// <value>
/// <c>true</c> if the current OS is linux; otherwise, <c>false</c>.
/// </value>
public bool IsLinux { get; private set; }
/// <summary> /// <summary>
/// Gets a value indicating whether the application is running in 64-bit. /// Gets a value indicating whether the application is running in 64-bit.

View File

@@ -3,16 +3,16 @@
[assembly: AssemblyCopyright("Copyright \x00a9 Yin-Chun Wang 2012-2015")] [assembly: AssemblyCopyright("Copyright \x00a9 Yin-Chun Wang 2012-2015")]
[assembly: AssemblyCompany("Yin-Chun Wang")] [assembly: AssemblyCompany("Yin-Chun Wang")]
[assembly: AssemblyVersion(NTwain.NTwainVersionInfo.Release)] [assembly: AssemblyVersion(NTwain.VersionInfo.Release)]
[assembly: AssemblyFileVersion(NTwain.NTwainVersionInfo.Build)] [assembly: AssemblyFileVersion(NTwain.VersionInfo.Build)]
[assembly: AssemblyInformationalVersion(NTwain.NTwainVersionInfo.Build)] [assembly: AssemblyInformationalVersion(NTwain.VersionInfo.Build)]
namespace NTwain namespace NTwain
{ {
/// <summary> /// <summary>
/// Contains version info of this assembly. /// Contains version info of NTwain.
/// </summary> /// </summary>
static class NTwainVersionInfo static class VersionInfo
{ {
/// <summary> /// <summary>
/// The major release version number. /// The major release version number.
@@ -23,7 +23,7 @@ namespace NTwain
/// <summary> /// <summary>
/// The build release version number. /// The build release version number.
/// </summary> /// </summary>
public const string Build = "3.2.7"; // change this for each nuget release public const string Build = "3.2.8"; // change this for each nuget release
} }

View File

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

View File

@@ -242,7 +242,7 @@ namespace NTwain
rc = ((ITwainSessionInternal)this).DGControl.EntryPoint.Get(out entry); rc = ((ITwainSessionInternal)this).DGControl.EntryPoint.Get(out entry);
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
PlatformInfo.__global.MemoryManager = entry; PlatformInfo.InternalCurrent.MemoryManager = entry;
Debug.WriteLine("Using TWAIN2 memory functions."); Debug.WriteLine("Using TWAIN2 memory functions.");
} }
else else
@@ -269,7 +269,7 @@ namespace NTwain
rc = ((ITwainSessionInternal)this).DGControl.Parent.CloseDsm(_msgLoopHook.Handle); rc = ((ITwainSessionInternal)this).DGControl.Parent.CloseDsm(_msgLoopHook.Handle);
if (rc == ReturnCode.Success) if (rc == ReturnCode.Success)
{ {
PlatformInfo.__global.MemoryManager = null; PlatformInfo.InternalCurrent.MemoryManager = null;
_msgLoopHook.Stop(); _msgLoopHook.Stop();
} }
}); });