mirror of
https://github.com/soukoku/ntwain.git
synced 2025-04-05 20:59:23 +08:00
New 3.6 build done in github with fixes for mistakes discovered in v4 dev.
This commit is contained in:
parent
15155084ad
commit
bbc81da779
@ -1,5 +1,7 @@
|
||||
# TWAIN Application-Side Library
|
||||
|
||||
Note: This was migrated from [https://bitbucket.org/soukoku/ntwain/](https://bitbucket.org/soukoku/ntwain/) for v4 dev.
|
||||
|
||||
## Info
|
||||
This is a library created to make working with [TWAIN](http://twain.org/) interface possible in dotnet.
|
||||
This project has these features/goals:
|
||||
|
@ -443,8 +443,8 @@ namespace NTwain.Data
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
||||
partial class TWStatus
|
||||
{
|
||||
TW_UINT16 _conditionCode;
|
||||
TW_UINT16 _data;
|
||||
internal TW_UINT16 _conditionCode;
|
||||
internal TW_UINT16 _data;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 2)]
|
||||
|
@ -2301,6 +2301,11 @@ namespace NTwain.Data
|
||||
public TWStatus Status
|
||||
{
|
||||
get { return new TWStatus(_conditionCode, _data); }
|
||||
internal set
|
||||
{
|
||||
_conditionCode = value._conditionCode;
|
||||
_data = value._data;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -88,13 +88,14 @@ namespace NTwain
|
||||
return stat;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the source status. Only call this at state 4 or higher.
|
||||
/// Gets the source status string. Only call this at state 4 or higher.
|
||||
/// </summary>
|
||||
/// <param name="status">Status from previous calls.</param>
|
||||
/// <returns></returns>
|
||||
public TWStatusUtf8 GetStatusUtf8()
|
||||
public TWStatusUtf8 GetStatusUtf8(TWStatus status)
|
||||
{
|
||||
TWStatusUtf8 stat;
|
||||
_session.DGControl.StatusUtf8.GetSource(out stat);
|
||||
_session.DGControl.StatusUtf8.GetSource(status, out stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
@ -178,30 +179,27 @@ namespace NTwain
|
||||
get
|
||||
{
|
||||
byte[] value = null;
|
||||
if (Capabilities.CapCustomDSData.GetCurrent() == BoolType.True)
|
||||
|
||||
TWCustomDSData data;
|
||||
if (DGControl.CustomDSData.Get(out data) == ReturnCode.Success && data.InfoLength > 0)
|
||||
{
|
||||
TWCustomDSData data;
|
||||
if (DGControl.CustomDSData.Get(out data) == ReturnCode.Success && data.InfoLength > 0)
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
value = new byte[data.InfoLength];
|
||||
var ptr = PlatformInfo.Current.MemoryManager.Lock(data.hData);
|
||||
Marshal.Copy(ptr, value, 0, (int)data.InfoLength);
|
||||
}
|
||||
finally
|
||||
{
|
||||
PlatformInfo.Current.MemoryManager.Unlock(data.hData);
|
||||
PlatformInfo.Current.MemoryManager.Free(data.hData);
|
||||
}
|
||||
value = new byte[data.InfoLength];
|
||||
var ptr = PlatformInfo.Current.MemoryManager.Lock(data.hData);
|
||||
Marshal.Copy(ptr, value, 0, (int)data.InfoLength);
|
||||
}
|
||||
finally
|
||||
{
|
||||
PlatformInfo.Current.MemoryManager.Unlock(data.hData);
|
||||
PlatformInfo.Current.MemoryManager.Free(data.hData);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != null && value.Length > 0 &&
|
||||
Capabilities.CapCustomDSData.GetCurrent() == BoolType.True)
|
||||
if (value != null && value.Length > 0)
|
||||
{
|
||||
TWCustomDSData data = new TWCustomDSData
|
||||
{
|
||||
|
@ -116,9 +116,10 @@ namespace NTwain
|
||||
TWStatus GetStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the source status. Only call this at state 4 or higher.
|
||||
/// Gets the source status string. Only call this at state 4 or higher.
|
||||
/// </summary>
|
||||
/// <param name="status">Status from previous calls.</param>
|
||||
/// <returns></returns>
|
||||
TWStatusUtf8 GetStatusUtf8();
|
||||
TWStatusUtf8 GetStatusUtf8(TWStatus status);
|
||||
}
|
||||
}
|
||||
|
@ -168,10 +168,11 @@ namespace NTwain
|
||||
TWStatus GetStatus();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the manager status. Only call this at state 3 or higher.
|
||||
/// Gets the manager status string. Only call this at state 3 or higher.
|
||||
/// </summary>
|
||||
/// <param name="status">Status from previous calls.</param>
|
||||
/// <returns></returns>
|
||||
TWStatusUtf8 GetStatusUtf8();
|
||||
TWStatusUtf8 GetStatusUtf8(TWStatus status);
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
@ -23,7 +23,7 @@ namespace NTwain
|
||||
/// <summary>
|
||||
/// The build release version number.
|
||||
/// </summary>
|
||||
public const string Build = "3.5.3"; // change this for each nuget release
|
||||
public const string Build = "3.6.0"; // change this for each nuget release
|
||||
|
||||
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ namespace NTwain.Triplets
|
||||
{
|
||||
Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get);
|
||||
IntPtr z = IntPtr.Zero;
|
||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get, ref z);
|
||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity,
|
||||
DataGroups.Audio, DataArgumentType.AudioFileXfer, Message.Get, ref z);
|
||||
}
|
||||
}
|
||||
}
|
@ -22,7 +22,8 @@ namespace NTwain.Triplets
|
||||
public ReturnCode Get(ref IntPtr handle)
|
||||
{
|
||||
Session.VerifyState(6, 6, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get);
|
||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get, ref handle);
|
||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity,
|
||||
DataGroups.Audio, DataArgumentType.AudioNativeXfer, Message.Get, ref handle);
|
||||
}
|
||||
}
|
||||
}
|
@ -16,9 +16,9 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode GetManager(out TWStatusUtf8 status)
|
||||
public ReturnCode GetManager(TWStatus status, out TWStatusUtf8 utf8status)
|
||||
{
|
||||
status = new TWStatusUtf8();
|
||||
utf8status = new TWStatusUtf8 { Status = status };
|
||||
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get);
|
||||
return Dsm.DsmEntry(Session.AppId, null, Message.Get, status);
|
||||
}
|
||||
@ -29,9 +29,9 @@ namespace NTwain.Triplets
|
||||
/// </summary>
|
||||
/// <param name="status">The status.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode GetSource(out TWStatusUtf8 status)
|
||||
public ReturnCode GetSource(TWStatus status, out TWStatusUtf8 utf8status)
|
||||
{
|
||||
status = new TWStatusUtf8();
|
||||
utf8status = new TWStatusUtf8 { Status = status };
|
||||
Session.VerifyState(3, 7, DataGroups.Control, DataArgumentType.StatusUtf8, Message.Get);
|
||||
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, status);
|
||||
}
|
||||
|
@ -39,6 +39,24 @@ namespace NTwain.Triplets
|
||||
return Dsm.DsmEntry(_session.AppId, _session.CurrentSource.Identity, group, dat, message, ref data);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Direct DSM_Entry call with full arguments for custom values.
|
||||
/// </summary>
|
||||
/// <param name="group">The group.</param>
|
||||
/// <param name="dat">The dat.</param>
|
||||
/// <param name="message">The message.</param>
|
||||
/// <param name="data">The data.</param>
|
||||
/// <returns></returns>
|
||||
public ReturnCode DsmEntry(
|
||||
DataGroups group,
|
||||
DataArgumentType dat,
|
||||
Message message,
|
||||
IntPtr data)
|
||||
{
|
||||
_session.VerifyState(3, 7, group, dat, message);
|
||||
return Dsm.DsmEntry(_session.AppId, _session.CurrentSource.Identity, group, dat, message, data);
|
||||
}
|
||||
// todo: add other data value types?
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,15 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref IntPtr data);
|
||||
|
||||
[DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)]
|
||||
public static extern ReturnCode DsmLinux(
|
||||
[In, Out]TWIdentity origin,
|
||||
[In, Out]TWIdentity destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
IntPtr data);
|
||||
|
||||
[DllImport(LINUX_DSM_PATH, EntryPoint = DSM_ENTRY)]
|
||||
public static extern ReturnCode DsmLinux(
|
||||
[In, Out]TWIdentity origin,
|
||||
|
@ -17,6 +17,15 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref IntPtr data);
|
||||
|
||||
[DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)]
|
||||
public static extern ReturnCode DsmWinNew(
|
||||
[In, Out]TWIdentity origin,
|
||||
[In, Out]TWIdentity destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
IntPtr data);
|
||||
|
||||
[DllImport(WIN_NEW_DSM_NAME, EntryPoint = DSM_ENTRY)]
|
||||
public static extern ReturnCode DsmWinNew(
|
||||
[In, Out]TWIdentity origin,
|
||||
|
@ -17,6 +17,15 @@ namespace NTwain.Triplets
|
||||
Message msg,
|
||||
ref IntPtr data);
|
||||
|
||||
[DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)]
|
||||
public static extern ReturnCode DsmWinOld(
|
||||
[In, Out]TWIdentity origin,
|
||||
[In, Out]TWIdentity destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
IntPtr data);
|
||||
|
||||
[DllImport(WIN_OLD_DSM_NAME, EntryPoint = DSM_ENTRY)]
|
||||
public static extern ReturnCode DsmWinOld(
|
||||
[In, Out]TWIdentity origin,
|
||||
|
@ -37,6 +37,26 @@ namespace NTwain.Triplets
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public static ReturnCode DsmEntry(
|
||||
TWIdentity origin,
|
||||
TWIdentity destination,
|
||||
DataGroups dg,
|
||||
DataArgumentType dat,
|
||||
Message msg,
|
||||
IntPtr data)
|
||||
{
|
||||
if (PlatformInfo.Current.IsWindows)
|
||||
{
|
||||
if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, dg, dat, msg, data); }
|
||||
else { return NativeMethods.DsmWinOld(origin, destination, dg, dat, msg, data); }
|
||||
}
|
||||
else if (PlatformInfo.Current.IsLinux)
|
||||
{
|
||||
return NativeMethods.DsmLinux(origin, destination, dg, dat, msg, data);
|
||||
}
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
||||
public static ReturnCode DsmEntry(
|
||||
TWIdentity origin,
|
||||
TWIdentity destination,
|
||||
@ -161,12 +181,12 @@ namespace NTwain.Triplets
|
||||
{
|
||||
if (PlatformInfo.Current.IsWindows)
|
||||
{
|
||||
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); }
|
||||
if (PlatformInfo.Current.UseNewWinDSM) { return NativeMethods.DsmWinNew(origin, destination, DataGroups.Control, DataArgumentType.Callback2, msg, data); }
|
||||
else { return NativeMethods.DsmWinOld(origin, destination, DataGroups.Control, DataArgumentType.Callback2, msg, data); }
|
||||
}
|
||||
else if (PlatformInfo.Current.IsLinux)
|
||||
{
|
||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback, msg, data);
|
||||
return NativeMethods.DsmLinux(origin, destination, DataGroups.Control, DataArgumentType.Callback2, msg, data);
|
||||
}
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
|
@ -78,6 +78,17 @@ namespace NTwain
|
||||
#region ITwainSession Members
|
||||
|
||||
|
||||
DGCustom _dgCustom;
|
||||
DGCustom ITripletControl.DGCustom { get { return DGCustom; } }
|
||||
public DGCustom DGCustom
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dgCustom == null) { _dgCustom = new DGCustom(this); }
|
||||
return _dgCustom;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether calls to triplets will verify the current twain session state.
|
||||
/// </summary>
|
||||
@ -362,13 +373,14 @@ namespace NTwain
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the manager status. Only call this at state 3 or higher.
|
||||
/// Gets the manager status string. Only call this at state 3 or higher.
|
||||
/// </summary>
|
||||
/// <param name="status">Status from previous calls.</param>
|
||||
/// <returns></returns>
|
||||
public TWStatusUtf8 GetStatusUtf8()
|
||||
public TWStatusUtf8 GetStatusUtf8(TWStatus status)
|
||||
{
|
||||
TWStatusUtf8 stat;
|
||||
((ITwainSessionInternal)this).DGControl.StatusUtf8.GetManager(out stat);
|
||||
((ITwainSessionInternal)this).DGControl.StatusUtf8.GetManager(status, out stat);
|
||||
return stat;
|
||||
}
|
||||
|
||||
|
@ -138,17 +138,6 @@ namespace NTwain
|
||||
}
|
||||
}
|
||||
|
||||
DGCustom _dgCustom;
|
||||
DGCustom ITripletControl.DGCustom { get { return DGCustom; } }
|
||||
protected DGCustom DGCustom
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dgCustom == null) { _dgCustom = new DGCustom(this); }
|
||||
return _dgCustom;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Enables the source to start transferring.
|
||||
|
Loading…
Reference in New Issue
Block a user