mirror of
https://github.com/soukoku/ntwain.git
synced 2025-11-09 19:54:47 +08:00
Uses resx string and added updated some properties.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Values;
|
using NTwain.Properties;
|
||||||
|
using NTwain.Values;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -28,7 +29,7 @@ namespace NTwain.Data
|
|||||||
public static CapReadOut ReadValue(TWCapability capability)
|
public static CapReadOut ReadValue(TWCapability capability)
|
||||||
{
|
{
|
||||||
if (capability == null) { throw new ArgumentNullException("capability"); }
|
if (capability == null) { throw new ArgumentNullException("capability"); }
|
||||||
if (capability.Container == IntPtr.Zero) { throw new ArgumentException("Capability contains no data.", "capability"); }
|
if (capability.Container == IntPtr.Zero) { throw new ArgumentException(Resources.CapHasNoData, "capability"); }
|
||||||
|
|
||||||
IntPtr baseAddr = IntPtr.Zero;
|
IntPtr baseAddr = IntPtr.Zero;
|
||||||
try
|
try
|
||||||
@@ -57,7 +58,7 @@ namespace NTwain.Data
|
|||||||
ContainerType = capability.ContainerType,
|
ContainerType = capability.ContainerType,
|
||||||
}.ReadRangeValue(baseAddr);
|
}.ReadRangeValue(baseAddr);
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException(string.Format("Capability has invalid container type {0}.", capability.ContainerType), "capability");
|
throw new ArgumentException(string.Format(Resources.CapHasBadContainer, capability.ContainerType), "capability");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -688,10 +688,10 @@ namespace NTwain.Data
|
|||||||
void SetOneValue(TWOneValue value)
|
void SetOneValue(TWOneValue value)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
if (ContainerType != Values.ContainerType.OneValue) { throw new ArgumentException(Resources.BadContainerType, "value"); }
|
ContainerType = Values.ContainerType.OneValue;
|
||||||
|
|
||||||
// since one value can only house UInt32 we will not allow type size > 4
|
// since one value can only house UInt32 we will not allow type size > 4
|
||||||
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException("Invalid one value type"); }
|
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(Resources.BadValueType, "TWOneValue")); }
|
||||||
|
|
||||||
_hContainer = MemoryManager.Instance.Allocate((uint)Marshal.SizeOf(value));
|
_hContainer = MemoryManager.Instance.Allocate((uint)Marshal.SizeOf(value));
|
||||||
if (_hContainer != IntPtr.Zero)
|
if (_hContainer != IntPtr.Zero)
|
||||||
@@ -704,7 +704,7 @@ namespace NTwain.Data
|
|||||||
void SetEnumValue(TWEnumeration value)
|
void SetEnumValue(TWEnumeration value)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
if (ContainerType != Values.ContainerType.Enum) { throw new ArgumentException(Resources.BadContainerType, "value"); }
|
ContainerType = Values.ContainerType.Enum;
|
||||||
|
|
||||||
|
|
||||||
Int32 valueSize = value.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
|
Int32 valueSize = value.ItemOffset + value.ItemList.Length * TypeReader.GetItemTypeSize(value.ItemType);
|
||||||
@@ -730,10 +730,10 @@ namespace NTwain.Data
|
|||||||
void SetRangeValue(TWRange value)
|
void SetRangeValue(TWRange value)
|
||||||
{
|
{
|
||||||
if (value == null) { throw new ArgumentNullException("value"); }
|
if (value == null) { throw new ArgumentNullException("value"); }
|
||||||
if (ContainerType != Values.ContainerType.Range) { throw new ArgumentException(Resources.BadContainerType, "value"); }
|
ContainerType = Values.ContainerType.Range;
|
||||||
|
|
||||||
// since range value can only house UInt32 we will not allow type size > 4
|
// since range value can only house UInt32 we will not allow type size > 4
|
||||||
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException("Invalid range value type"); }
|
if (TypeReader.GetItemTypeSize(value.ItemType) > 4) { throw new ArgumentException(string.Format(Resources.BadValueType, "TWRange")); }
|
||||||
|
|
||||||
_hContainer = MemoryManager.Instance.Allocate((uint)Marshal.SizeOf(value));
|
_hContainer = MemoryManager.Instance.Allocate((uint)Marshal.SizeOf(value));
|
||||||
if (_hContainer != IntPtr.Zero)
|
if (_hContainer != IntPtr.Zero)
|
||||||
@@ -1297,7 +1297,7 @@ namespace NTwain.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Tag identifying an information.
|
/// Tag identifying an information.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ushort InfoID { get { return _infoID; } }
|
public ExtendedImageInfo InfoID { get { return (ExtendedImageInfo)_infoID; } }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Item data type.
|
/// Item data type.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -42,5 +42,13 @@ namespace NTwain
|
|||||||
/// The final image information.
|
/// The final image information.
|
||||||
/// </value>
|
/// </value>
|
||||||
public TWImageInfo ImageInfo { get; internal set; }
|
public TWImageInfo ImageInfo { get; internal set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the extended image information if applicable.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The extended image information.
|
||||||
|
/// </value>
|
||||||
|
public TWExtImageInfo ExImageInfo { get; internal set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
|
using NTwain.Properties;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -52,7 +53,7 @@ namespace NTwain
|
|||||||
|
|
||||||
if (retVal == IntPtr.Zero)
|
if (retVal == IntPtr.Zero)
|
||||||
{
|
{
|
||||||
throw new OutOfMemoryException("Failed to allocate requested memory.");
|
throw new OutOfMemoryException(Resources.MemAllocError);
|
||||||
}
|
}
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Triplets;
|
using NTwain.Properties;
|
||||||
|
using NTwain.Triplets;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@@ -65,14 +66,14 @@ namespace NTwain
|
|||||||
|
|
||||||
public void BeginInvoke(Action action)
|
public void BeginInvoke(Action action)
|
||||||
{
|
{
|
||||||
if (_dispatcher == null) { throw new InvalidOperationException("Message loop has not started yet."); }
|
if (_dispatcher == null) { throw new InvalidOperationException(Resources.MsgLoopUnavailble); }
|
||||||
|
|
||||||
_dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
|
_dispatcher.BeginInvoke(DispatcherPriority.Normal, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Invoke(Action action)
|
public void Invoke(Action action)
|
||||||
{
|
{
|
||||||
if (_dispatcher == null) { throw new InvalidOperationException("Message loop has not started yet."); }
|
if (_dispatcher == null) { throw new InvalidOperationException(Resources.MsgLoopUnavailble); }
|
||||||
|
|
||||||
if (_dispatcher.CheckAccess())
|
if (_dispatcher.CheckAccess())
|
||||||
{
|
{
|
||||||
|
|||||||
53
NTwain/Properties/Resources.Designer.cs
generated
53
NTwain/Properties/Resources.Designer.cs
generated
@@ -1,7 +1,7 @@
|
|||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
// <auto-generated>
|
// <auto-generated>
|
||||||
// This code was generated by a tool.
|
// This code was generated by a tool.
|
||||||
// Runtime Version:4.0.30319.18034
|
// Runtime Version:4.0.30319.34014
|
||||||
//
|
//
|
||||||
// Changes to this file may cause incorrect behavior and will be lost if
|
// Changes to this file may cause incorrect behavior and will be lost if
|
||||||
// the code is regenerated.
|
// the code is regenerated.
|
||||||
@@ -61,11 +61,29 @@ namespace NTwain.Properties {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to The specified container type does not match the data..
|
/// Looks up a localized string similar to Invalid value type for {0}..
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal static string BadContainerType {
|
internal static string BadValueType {
|
||||||
get {
|
get {
|
||||||
return ResourceManager.GetString("BadContainerType", resourceCulture);
|
return ResourceManager.GetString("BadValueType", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Capability has invalid container type {0}..
|
||||||
|
/// </summary>
|
||||||
|
internal static string CapHasBadContainer {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("CapHasBadContainer", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Capability contains no data..
|
||||||
|
/// </summary>
|
||||||
|
internal static string CapHasNoData {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("CapHasNoData", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,5 +95,32 @@ namespace NTwain.Properties {
|
|||||||
return ResourceManager.GetString("MaxStringLengthExceeded", resourceCulture);
|
return ResourceManager.GetString("MaxStringLengthExceeded", resourceCulture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Failed to allocate requested memory..
|
||||||
|
/// </summary>
|
||||||
|
internal static string MemAllocError {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MemAllocError", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Message loop has not started yet..
|
||||||
|
/// </summary>
|
||||||
|
internal static string MsgLoopUnavailble {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("MsgLoopUnavailble", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Source name is required..
|
||||||
|
/// </summary>
|
||||||
|
internal static string SourceRequired {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("SourceRequired", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,10 +117,25 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<data name="BadContainerType" xml:space="preserve">
|
<data name="BadValueType" xml:space="preserve">
|
||||||
<value>The specified container type does not match the data.</value>
|
<value>Invalid value type for {0}.</value>
|
||||||
|
</data>
|
||||||
|
<data name="CapHasBadContainer" xml:space="preserve">
|
||||||
|
<value>Capability has invalid container type {0}.</value>
|
||||||
|
</data>
|
||||||
|
<data name="CapHasNoData" xml:space="preserve">
|
||||||
|
<value>Capability contains no data.</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="MaxStringLengthExceeded" xml:space="preserve">
|
<data name="MaxStringLengthExceeded" xml:space="preserve">
|
||||||
<value>The string value has exceeded the maximum length allowed.</value>
|
<value>The string value has exceeded the maximum length allowed.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="MemAllocError" xml:space="preserve">
|
||||||
|
<value>Failed to allocate requested memory.</value>
|
||||||
|
</data>
|
||||||
|
<data name="MsgLoopUnavailble" xml:space="preserve">
|
||||||
|
<value>Message loop has not started yet.</value>
|
||||||
|
</data>
|
||||||
|
<data name="SourceRequired" xml:space="preserve">
|
||||||
|
<value>Source name is required.</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -14,6 +14,6 @@ namespace NTwain
|
|||||||
// keep this same in majors releases
|
// keep this same in majors releases
|
||||||
public const string Release = "0.11.0.0";
|
public const string Release = "0.11.0.0";
|
||||||
// change this for each nuget release
|
// change this for each nuget release
|
||||||
public const string Build = "0.11.2";
|
public const string Build = "0.11.3";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace NTwain
|
|||||||
public class TransferErrorEventArgs : EventArgs
|
public class TransferErrorEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the return code.
|
/// Gets the return code from the transfer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>
|
/// <value>
|
||||||
/// The return code.
|
/// The return code.
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using NTwain.Values;
|
||||||
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
using System.Security.Permissions;
|
||||||
|
|
||||||
namespace NTwain
|
namespace NTwain
|
||||||
{
|
{
|
||||||
@@ -17,17 +19,22 @@ namespace NTwain
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TwainException" /> class.
|
/// Initializes a new instance of the <see cref="TwainException" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="returnCode">The return code.</param>
|
||||||
/// <param name="message">The message.</param>
|
/// <param name="message">The message.</param>
|
||||||
public TwainException(string message)
|
public TwainException(ReturnCode returnCode, string message)
|
||||||
: base(message) { }
|
: this(returnCode, message, null) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TwainException" /> class.
|
/// Initializes a new instance of the <see cref="TwainException" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <param name="returnCode">The return code.</param>
|
||||||
/// <param name="message">The message.</param>
|
/// <param name="message">The message.</param>
|
||||||
/// <param name="innerException">The inner exception.</param>
|
/// <param name="innerException">The inner exception.</param>
|
||||||
public TwainException(string message, Exception innerException)
|
public TwainException(ReturnCode returnCode, string message, Exception innerException)
|
||||||
: base(message, innerException) { }
|
: base(message, innerException)
|
||||||
|
{
|
||||||
|
ReturnCode = returnCode;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TwainException"/> class.
|
/// Initializes a new instance of the <see cref="TwainException"/> class.
|
||||||
@@ -41,6 +48,42 @@ namespace NTwain
|
|||||||
/// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0).
|
/// The class name is null or <see cref="P:System.Exception.HResult"/> is zero (0).
|
||||||
/// </exception>
|
/// </exception>
|
||||||
protected TwainException(SerializationInfo info, StreamingContext context)
|
protected TwainException(SerializationInfo info, StreamingContext context)
|
||||||
: base(info, context) { }
|
: base(info, context)
|
||||||
|
{
|
||||||
|
if (info != null)
|
||||||
|
{
|
||||||
|
ReturnCode = (ReturnCode)info.GetUInt16("RC");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When overridden in a derived class, sets the <see cref="T:System.Runtime.Serialization.SerializationInfo"/> with information about the exception.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"/> that holds the serialized object data about the exception being thrown.</param>
|
||||||
|
/// <param name="context">The <see cref="T:System.Runtime.Serialization.StreamingContext"/> that contains contextual information about the source or destination.</param>
|
||||||
|
/// <exception cref="T:System.ArgumentNullException">
|
||||||
|
/// The <paramref name="info"/> parameter is a null reference (Nothing in Visual Basic).
|
||||||
|
/// </exception>
|
||||||
|
/// <PermissionSet>
|
||||||
|
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Read="*AllFiles*" PathDiscovery="*AllFiles*"/>
|
||||||
|
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="SerializationFormatter"/>
|
||||||
|
/// </PermissionSet>
|
||||||
|
[SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)]
|
||||||
|
public override void GetObjectData(SerializationInfo info, StreamingContext context)
|
||||||
|
{
|
||||||
|
if (info != null)
|
||||||
|
{
|
||||||
|
info.AddValue("RC", ReturnCode);
|
||||||
|
}
|
||||||
|
base.GetObjectData(info, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the return code from the TWAIN operation if applicable.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>
|
||||||
|
/// The return code.
|
||||||
|
/// </value>
|
||||||
|
public ReturnCode ReturnCode { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using NTwain.Data;
|
using NTwain.Data;
|
||||||
|
using NTwain.Properties;
|
||||||
using NTwain.Triplets;
|
using NTwain.Triplets;
|
||||||
using NTwain.Values;
|
using NTwain.Values;
|
||||||
using System;
|
using System;
|
||||||
@@ -21,7 +22,7 @@ namespace NTwain
|
|||||||
public class TwainSession : ITwainStateInternal, ITwainOperation
|
public class TwainSession : ITwainStateInternal, ITwainOperation
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="TwainSessionOld" /> class.
|
/// Initializes a new instance of the <see cref="TwainSession" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appId">The app id.</param>
|
/// <param name="appId">The app id.</param>
|
||||||
/// <exception cref="System.ArgumentNullException"></exception>
|
/// <exception cref="System.ArgumentNullException"></exception>
|
||||||
@@ -293,7 +294,7 @@ namespace NTwain
|
|||||||
/// <exception cref="ArgumentException">Source name is required.;sourceProductName</exception>
|
/// <exception cref="ArgumentException">Source name is required.;sourceProductName</exception>
|
||||||
public ReturnCode OpenSource(string sourceProductName)
|
public ReturnCode OpenSource(string sourceProductName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(sourceProductName)) { throw new ArgumentException("Source name is required.", "sourceProductName"); }
|
if (string.IsNullOrEmpty(sourceProductName)) { throw new ArgumentException(Resources.SourceRequired, "sourceProductName"); }
|
||||||
|
|
||||||
ReturnCode rc = ReturnCode.Success;
|
ReturnCode rc = ReturnCode.Success;
|
||||||
MessageLoop.Instance.Invoke(() =>
|
MessageLoop.Instance.Invoke(() =>
|
||||||
@@ -517,7 +518,7 @@ namespace NTwain
|
|||||||
/// <typeparam name="TEventArgs">The type of the event arguments.</typeparam>
|
/// <typeparam name="TEventArgs">The type of the event arguments.</typeparam>
|
||||||
/// <param name="onEventFunc">The on event function.</param>
|
/// <param name="onEventFunc">The on event function.</param>
|
||||||
/// <param name="handler">The handler.</param>
|
/// <param name="handler">The handler.</param>
|
||||||
/// <param name="e">The <see cref="TEventArgs"/> instance containing the event data.</param>
|
/// <param name="e">The TEventArgs instance containing the event data.</param>
|
||||||
void SafeSyncableRaiseOnEvent<TEventArgs>(Action<TEventArgs> onEventFunc, EventHandler<TEventArgs> handler, TEventArgs e) where TEventArgs : EventArgs
|
void SafeSyncableRaiseOnEvent<TEventArgs>(Action<TEventArgs> onEventFunc, EventHandler<TEventArgs> handler, TEventArgs e) where TEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
var syncer = SynchronizationContext;
|
var syncer = SynchronizationContext;
|
||||||
@@ -883,6 +884,14 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
State = 7;
|
State = 7;
|
||||||
TWImageInfo imgInfo;
|
TWImageInfo imgInfo;
|
||||||
|
TWExtImageInfo extInfo = null;
|
||||||
|
if (SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
|
||||||
|
{
|
||||||
|
if (DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
|
||||||
|
{
|
||||||
|
extInfo = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
|
if (DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
|
||||||
{
|
{
|
||||||
imgInfo = null;
|
imgInfo = null;
|
||||||
@@ -891,7 +900,13 @@ namespace NTwain
|
|||||||
{
|
{
|
||||||
lockedPtr = MemoryManager.Instance.Lock(dataPtr);
|
lockedPtr = MemoryManager.Instance.Lock(dataPtr);
|
||||||
}
|
}
|
||||||
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs { NativeData = lockedPtr, ImageInfo = imgInfo });
|
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs
|
||||||
|
{
|
||||||
|
NativeData = lockedPtr,
|
||||||
|
ImageInfo = imgInfo,
|
||||||
|
ExImageInfo = extInfo
|
||||||
|
});
|
||||||
|
if (extInfo != null) { extInfo.Dispose(); }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -932,11 +947,25 @@ namespace NTwain
|
|||||||
if (xrc == ReturnCode.XferDone)
|
if (xrc == ReturnCode.XferDone)
|
||||||
{
|
{
|
||||||
TWImageInfo imgInfo;
|
TWImageInfo imgInfo;
|
||||||
|
TWExtImageInfo extInfo = null;
|
||||||
|
if (SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
|
||||||
|
{
|
||||||
|
if (DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
|
||||||
|
{
|
||||||
|
extInfo = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
|
if (DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
|
||||||
{
|
{
|
||||||
imgInfo = null;
|
imgInfo = null;
|
||||||
}
|
}
|
||||||
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs { FileDataPath = filePath, ImageInfo = imgInfo });
|
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs
|
||||||
|
{
|
||||||
|
FileDataPath = filePath,
|
||||||
|
ImageInfo = imgInfo,
|
||||||
|
ExImageInfo = extInfo
|
||||||
|
});
|
||||||
|
if (extInfo != null) { extInfo.Dispose(); }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1000,23 +1029,27 @@ namespace NTwain
|
|||||||
if (xrc == ReturnCode.XferDone)
|
if (xrc == ReturnCode.XferDone)
|
||||||
{
|
{
|
||||||
TWImageInfo imgInfo;
|
TWImageInfo imgInfo;
|
||||||
//TWExtImageInfo extInfo;
|
TWExtImageInfo extInfo = null;
|
||||||
//if (SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
|
if (SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
|
||||||
//{
|
|
||||||
// if (DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
|
|
||||||
// {
|
|
||||||
// extInfo = null;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
if (DGImage.ImageInfo.Get(out imgInfo) == ReturnCode.Success)
|
|
||||||
{
|
{
|
||||||
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs { MemData = xferredData.ToArray(), ImageInfo = imgInfo });
|
if (DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
throw new TwainException("Failed to get image info after ImageMemXfer.");
|
extInfo = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
|
||||||
|
{
|
||||||
|
imgInfo = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs
|
||||||
|
{
|
||||||
|
MemData = xferredData.ToArray(),
|
||||||
|
ImageInfo = imgInfo,
|
||||||
|
ExImageInfo = extInfo
|
||||||
|
});
|
||||||
|
if (extInfo != null) { extInfo.Dispose(); }
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SafeSyncableRaiseOnEvent(OnTransferError, TransferError, new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = this.GetSourceStatus() });
|
SafeSyncableRaiseOnEvent(OnTransferError, TransferError, new TransferErrorEventArgs { ReturnCode = xrc, SourceStatus = this.GetSourceStatus() });
|
||||||
@@ -1168,11 +1201,25 @@ namespace NTwain
|
|||||||
if (File.Exists(finalFile))
|
if (File.Exists(finalFile))
|
||||||
{
|
{
|
||||||
TWImageInfo imgInfo;
|
TWImageInfo imgInfo;
|
||||||
|
TWExtImageInfo extInfo = null;
|
||||||
|
if (SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
|
||||||
|
{
|
||||||
|
if (DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
|
||||||
|
{
|
||||||
|
extInfo = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
|
if (DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
|
||||||
{
|
{
|
||||||
imgInfo = null;
|
imgInfo = null;
|
||||||
}
|
}
|
||||||
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs { FileDataPath = finalFile, ImageInfo = imgInfo });
|
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, new DataTransferredEventArgs
|
||||||
|
{
|
||||||
|
FileDataPath = finalFile,
|
||||||
|
ImageInfo = imgInfo,
|
||||||
|
ExImageInfo = extInfo
|
||||||
|
});
|
||||||
|
if (extInfo != null) { extInfo.Dispose(); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace NTwain
|
|||||||
/// <param name="twainMessage">The twain message used.</param>
|
/// <param name="twainMessage">The twain message used.</param>
|
||||||
/// <param name="message">The message.</param>
|
/// <param name="message">The message.</param>
|
||||||
public TwainStateException(int currentState, int minStateExpected, int maxStateExpected, DataGroups dataGroup, DataArgumentType argumentType, Message twainMessage, string message)
|
public TwainStateException(int currentState, int minStateExpected, int maxStateExpected, DataGroups dataGroup, DataArgumentType argumentType, Message twainMessage, string message)
|
||||||
: base(message)
|
: base(default(ReturnCode), message)
|
||||||
{
|
{
|
||||||
ActualState = currentState;
|
ActualState = currentState;
|
||||||
MinStateExpected = minStateExpected;
|
MinStateExpected = minStateExpected;
|
||||||
|
|||||||
Reference in New Issue
Block a user