Some text and eximageinfo correctness update.

This commit is contained in:
soukoku 2014-05-23 18:41:18 -04:00
parent 3b31c465e6
commit b0142127d7
12 changed files with 155 additions and 61 deletions

View File

@ -1348,11 +1348,11 @@ namespace NTwain.Data
/// <summary> /// <summary>
/// Tag identifying an information. /// Tag identifying an information.
/// </summary> /// </summary>
public ExtendedImageInfo InfoID { get { return (ExtendedImageInfo)_infoID; } } public ExtendedImageInfo InfoID { get { return (ExtendedImageInfo)_infoID; } set { _infoID = (ushort)value; } }
/// <summary> /// <summary>
/// Item data type. /// Item data type.
/// </summary> /// </summary>
public ItemType ItemType { get { return (ItemType)_itemType; } } public ItemType ItemType { get { return (ItemType)_itemType; } set { _itemType = (ushort)value; } }
/// <summary> /// <summary>
/// Number of items. /// Number of items.
/// </summary> /// </summary>
@ -1388,7 +1388,10 @@ namespace NTwain.Data
/// </summary> /// </summary>
public sealed partial class TWExtImageInfo : IDisposable public sealed partial class TWExtImageInfo : IDisposable
{ {
internal TWExtImageInfo() { } internal TWExtImageInfo()
{
_info = new TWInfo[200];
}
/// <summary> /// <summary>
/// Number of information that application is requesting. This is filled by the /// Number of information that application is requesting. This is filled by the
@ -1396,7 +1399,7 @@ namespace NTwain.Data
/// image information. The application should allocate memory and fill in the /// image information. The application should allocate memory and fill in the
/// attribute tag for image information. /// attribute tag for image information.
/// </summary> /// </summary>
public uint NumInfos { get { return _numInfos; } } public uint NumInfos { get { return _numInfos; } set { _numInfos = value; } }
/// <summary> /// <summary>
/// Array of information. /// Array of information.
/// </summary> /// </summary>

View File

@ -17,6 +17,9 @@ namespace NTwain.Data
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1028:EnumStorageShouldBeInt32")]
public enum ContainerType : ushort public enum ContainerType : ushort
{ {
/// <summary>
/// The default value for this enum.
/// </summary>
Invalid = 0, Invalid = 0,
/// <summary> /// <summary>
/// The container is <see cref="TWArray"/>. /// The container is <see cref="TWArray"/>.
@ -34,6 +37,9 @@ namespace NTwain.Data
/// The container is <see cref="TWRange"/>. /// The container is <see cref="TWRange"/>.
/// </summary> /// </summary>
Range = 6, Range = 6,
/// <summary>
/// The don't care value.
/// </summary>
DontCare = TwainConst.DontCare16, DontCare = TwainConst.DontCare16,
} }

View File

@ -45,12 +45,12 @@ namespace NTwain
/// </value> /// </value>
public TWImageInfo ImageInfo { get; internal set; } public TWImageInfo ImageInfo { get; internal set; }
/// <summary> ///// <summary>
/// Gets the extended image information if applicable. ///// Gets the extended image information if applicable.
/// </summary> ///// </summary>
/// <value> ///// <value>
/// The extended image information. ///// The extended image information.
/// </value> ///// </value>
public TWExtImageInfo ExImageInfo { get; internal set; } //public TWExtImageInfo ExImageInfo { get; internal set; }
} }
} }

View File

@ -414,14 +414,14 @@ namespace NTwain.Internals
static void DoImageXferredEventRoutine(ITwainSessionInternal session, IntPtr dataPtr, byte[] dataArray, string filePath) static void DoImageXferredEventRoutine(ITwainSessionInternal session, IntPtr dataPtr, byte[] dataArray, string filePath)
{ {
TWImageInfo imgInfo; TWImageInfo imgInfo;
TWExtImageInfo extInfo = null; //TWExtImageInfo extInfo = null;
if (session.CurrentSource.SupportedCaps.Contains(CapabilityId.ICapExtImageInfo)) //if (session.CurrentSource.SupportedCaps.Contains(CapabilityId.ICapExtImageInfo))
{ //{
if (session.DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success) // if (session.DGImage.ExtImageInfo.Get(out extInfo) != ReturnCode.Success)
{ // {
extInfo = null; // extInfo = null;
} // }
} //}
if (session.DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success) if (session.DGImage.ImageInfo.Get(out imgInfo) != ReturnCode.Success)
{ {
imgInfo = null; imgInfo = null;
@ -432,9 +432,9 @@ namespace NTwain.Internals
MemData = dataArray, MemData = dataArray,
FileDataPath = filePath, FileDataPath = filePath,
ImageInfo = imgInfo, ImageInfo = imgInfo,
ExImageInfo = extInfo //ExImageInfo = extInfo
}); });
if (extInfo != null) { extInfo.Dispose(); } //if (extInfo != null) { extInfo.Dispose(); }
} }
#endregion #endregion

View File

@ -6,15 +6,15 @@ namespace NTwain.Triplets
/// <summary> /// <summary>
/// Represents <see cref="DataArgumentType.AudioInfo"/>. /// Represents <see cref="DataArgumentType.AudioInfo"/>.
/// </summary> /// </summary>
public sealed class AudioInfo : OpBase sealed class AudioInfo : OpBase
{ {
internal AudioInfo(ITwainSessionInternal session) : base(session) { } internal AudioInfo(ITwainSessionInternal session) : base(session) { }
/// <summary> /// <summary>
/// Used to get the information of the current audio data ready to transfer. /// Used to get the information of the current audio data ready to transfer.
/// </summary> /// </summary>
/// <param name="info">The info.</param> /// <param name="info">The info.</param>
/// <returns></returns> /// <returns></returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
public ReturnCode Get(out TWAudioInfo info) public ReturnCode Get(out TWAudioInfo info)
{ {
Session.VerifyState(6, 7, DataGroups.Audio, DataArgumentType.AudioInfo, Message.Get); Session.VerifyState(6, 7, DataGroups.Audio, DataArgumentType.AudioInfo, Message.Get);

View File

@ -27,7 +27,7 @@ namespace NTwain.Triplets
} }
AudioInfo _audioInfo; AudioInfo _audioInfo;
public AudioInfo AudioInfo internal AudioInfo AudioInfo
{ {
get get
{ {

View File

@ -35,6 +35,9 @@ namespace NTwain.Triplets
} }
} }
Capability _capability; Capability _capability;
/// <summary>
/// Gets the operations defined for DAT_CAPABILITY.
/// </summary>
public Capability Capability public Capability Capability
{ {
get get
@ -44,6 +47,9 @@ namespace NTwain.Triplets
} }
} }
CapabilityCustom _capabilityCust; CapabilityCustom _capabilityCust;
/// <summary>
/// Gets the operations defined for a custom DAT_* value with capability data.
/// </summary>
public CapabilityCustom CapabilityCustom public CapabilityCustom CapabilityCustom
{ {
get get
@ -53,6 +59,9 @@ namespace NTwain.Triplets
} }
} }
CustomDSData _customDSData; CustomDSData _customDSData;
/// <summary>
/// Gets the operations defined for DAT_CUSTOMDSDATA.
/// </summary>
public CustomDSData CustomDSData public CustomDSData CustomDSData
{ {
get get
@ -89,6 +98,9 @@ namespace NTwain.Triplets
} }
} }
FileSystem _fileSys; FileSystem _fileSys;
/// <summary>
/// Gets the operations defined for DAT_FILESYSTEM.
/// </summary>
public FileSystem FileSystem public FileSystem FileSystem
{ {
get get
@ -116,6 +128,9 @@ namespace NTwain.Triplets
} }
} }
PassThru _passThru; PassThru _passThru;
/// <summary>
/// Gets the operations defined for DAT_PASSTHRU.
/// </summary>
public PassThru PassThru public PassThru PassThru
{ {
get get
@ -134,6 +149,9 @@ namespace NTwain.Triplets
} }
} }
SetupFileXfer _setupFileXfer; SetupFileXfer _setupFileXfer;
/// <summary>
/// Gets the operations defined for DAT_SETUPFILEXFER.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")]
public SetupFileXfer SetupFileXfer public SetupFileXfer SetupFileXfer
{ {
@ -144,6 +162,9 @@ namespace NTwain.Triplets
} }
} }
SetupMemXfer _setupMemXfer; SetupMemXfer _setupMemXfer;
/// <summary>
/// Gets the operations defined for DAT_SETUPMEMXFER.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mem")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Mem")]
public SetupMemXfer SetupMemXfer public SetupMemXfer SetupMemXfer
{ {
@ -181,6 +202,9 @@ namespace NTwain.Triplets
} }
} }
XferGroup _xferGroup; XferGroup _xferGroup;
/// <summary>
/// Gets the operations defined for DAT_XFERGROUP.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Xfer")]
public XferGroup XferGroup public XferGroup XferGroup
{ {

View File

@ -10,11 +10,15 @@ namespace NTwain.Triplets
{ {
internal ExtImageInfo(ITwainSessionInternal session) : base(session) { } internal ExtImageInfo(ITwainSessionInternal session) : base(session) { }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] /// <summary>
public ReturnCode Get(out TWExtImageInfo info) /// This operation is used by the application to query the data source for extended image attributes.
/// The application is responsible for creating and disiposing the info object.
/// </summary>
/// <param name="info">The information.</param>
/// <returns></returns>
public ReturnCode Get(TWExtImageInfo info)
{ {
Session.VerifyState(7, 7, DataGroups.Image, DataArgumentType.ExtImageInfo, Message.Get); Session.VerifyState(7, 7, DataGroups.Image, DataArgumentType.ExtImageInfo, Message.Get);
info = new TWExtImageInfo();
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, info); return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, info);
} }
} }

View File

@ -10,6 +10,13 @@ namespace NTwain.Triplets
{ {
internal ImageLayout(ITwainSessionInternal session) : base(session) { } internal ImageLayout(ITwainSessionInternal session) : base(session) { }
/// <summary>
/// Gets both the size and placement of the image on the scanner. The
/// coordinates on the scanner and the extents of the image are expressed in the unit of measure
/// currently negotiated for ICAP_UNITS (default is inches).
/// </summary>
/// <param name="layout">The layout.</param>
/// <returns></returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
public ReturnCode Get(out TWImageLayout layout) public ReturnCode Get(out TWImageLayout layout)
{ {
@ -18,6 +25,14 @@ namespace NTwain.Triplets
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, layout); return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Get, layout);
} }
/// <summary>
/// returns the default information on the layout of an image. This is the size and
/// position of the image that will be acquired from the Source if the acquisition is started with the
/// Source (and the device it is controlling) in its power-on state (for instance, most flatbed scanners
/// will capture the entire bed).
/// </summary>
/// <param name="layout">The layout.</param>
/// <returns></returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
public ReturnCode GetDefault(out TWImageLayout layout) public ReturnCode GetDefault(out TWImageLayout layout)
{ {
@ -26,6 +41,11 @@ namespace NTwain.Triplets
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, layout); return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.GetDefault, layout);
} }
/// <summary>
/// This operation sets the image layout information for the next transfer to its default settings.
/// </summary>
/// <param name="layout">The layout.</param>
/// <returns></returns>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1021:AvoidOutParameters", MessageId = "0#")]
public ReturnCode Reset(out TWImageLayout layout) public ReturnCode Reset(out TWImageLayout layout)
{ {
@ -34,6 +54,15 @@ namespace NTwain.Triplets
return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, layout); return Dsm.DsmEntry(Session.AppId, Session.CurrentSource.Identity, Message.Reset, layout);
} }
/// <summary>
/// This operation sets the layout for the next image transfer. This allows the application to specify
/// the physical area to be acquired during the next image transfer (for instance, a frame-based
/// application would pass to the Source the size of the frame the user selected within the
/// application—the helpful Source would present a selection region already sized to match the
/// layout frame size).
/// </summary>
/// <param name="layout">The layout.</param>
/// <returns></returns>
public ReturnCode Set(TWImageLayout layout) public ReturnCode Set(TWImageLayout layout)
{ {
Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.ImageLayout, Message.Set); Session.VerifyState(4, 4, DataGroups.Image, DataArgumentType.ImageLayout, Message.Set);

View File

@ -16,6 +16,9 @@ namespace NTwain.Triplets
} }
CieColor _cieColor; CieColor _cieColor;
/// <summary>
/// Gets the operations defined for DAT_CIECOLOR.
/// </summary>
public CieColor CieColor public CieColor CieColor
{ {
get get
@ -27,6 +30,9 @@ namespace NTwain.Triplets
ExtImageInfo _extImgInfo; ExtImageInfo _extImgInfo;
/// <summary>
/// Gets the operations defined for DAT_EXTIMAGEINFO.
/// </summary>
public ExtImageInfo ExtImageInfo public ExtImageInfo ExtImageInfo
{ {
get get
@ -38,6 +44,9 @@ namespace NTwain.Triplets
Filter _filter; Filter _filter;
/// <summary>
/// Gets the operations defined for DAT_FILTER.
/// </summary>
public Filter Filter public Filter Filter
{ {
get get
@ -48,6 +57,9 @@ namespace NTwain.Triplets
} }
GrayResponse _grayResponse; GrayResponse _grayResponse;
/// <summary>
/// Gets the operations defined for DAT_GRAYRESPONSE.
/// </summary>
public GrayResponse GrayResponse public GrayResponse GrayResponse
{ {
get get
@ -58,6 +70,9 @@ namespace NTwain.Triplets
} }
IccProfile _iccProfile; IccProfile _iccProfile;
/// <summary>
/// Gets the operations defined for DAT_ICCPROFILE.
/// </summary>
public IccProfile IccProfile public IccProfile IccProfile
{ {
get get
@ -88,6 +103,9 @@ namespace NTwain.Triplets
} }
ImageLayout _imgLayout; ImageLayout _imgLayout;
/// <summary>
/// Gets the operations defined for DAT_IMAGELAYOUT.
/// </summary>
public ImageLayout ImageLayout public ImageLayout ImageLayout
{ {
get get
@ -128,6 +146,9 @@ namespace NTwain.Triplets
} }
JpegCompression _jpegComp; JpegCompression _jpegComp;
/// <summary>
/// Gets the operations defined for DAT_JPEGCOMPRESSION.
/// </summary>
public JpegCompression JpegCompression public JpegCompression JpegCompression
{ {
get get
@ -138,6 +159,9 @@ namespace NTwain.Triplets
} }
Palette8 _palette8; Palette8 _palette8;
/// <summary>
/// Gets the operations defined for DAT_PALETTE8.
/// </summary>
public Palette8 Palette8 public Palette8 Palette8
{ {
get get
@ -148,6 +172,9 @@ namespace NTwain.Triplets
} }
RgbResponse _rgbResp; RgbResponse _rgbResp;
/// <summary>
/// Gets the operations defined for DAT_RGBRESPONSE.
/// </summary>
public RgbResponse RgbResponse public RgbResponse RgbResponse
{ {
get get

View File

@ -50,6 +50,20 @@ namespace NTwain
TWIdentity _appId; TWIdentity _appId;
TWUserInterface _twui; TWUserInterface _twui;
static readonly Dictionary<string, TwainSource> __ownedSources = new Dictionary<string, TwainSource>();
internal static TwainSource GetSourceInstance(ITwainSessionInternal session, TWIdentity sourceId)
{
var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}", sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName);
if (__ownedSources.ContainsKey(key))
{
return __ownedSources[key];
}
return __ownedSources[key] = new TwainSource(session, sourceId);
}
/// <summary> /// <summary>
/// Gets or sets the optional synchronization context. /// Gets or sets the optional synchronization context.
/// This allows events to be raised on the thread /// This allows events to be raised on the thread
@ -139,7 +153,7 @@ namespace NTwain
TWIdentity id; TWIdentity id;
if (DGControl.Identity.GetDefault(out id) == ReturnCode.Success) if (DGControl.Identity.GetDefault(out id) == ReturnCode.Success)
{ {
return TwainSource.GetInstance(this, id); return GetSourceInstance(this, id);
} }
return null; return null;
} }
@ -162,7 +176,7 @@ namespace NTwain
TWIdentity id; TWIdentity id;
if (DGControl.Identity.UserSelect(out id) == ReturnCode.Success) if (DGControl.Identity.UserSelect(out id) == ReturnCode.Success)
{ {
return TwainSource.GetInstance(this, id); return GetSourceInstance(this, id);
} }
return null; return null;
} }
@ -303,7 +317,6 @@ namespace NTwain
/// Gets list of sources available in the system. /// Gets list of sources available in the system.
/// Only call this at state 2 or higher. /// Only call this at state 2 or higher.
/// </summary> /// </summary>
/// <param name="session">The session.</param>
/// <returns></returns> /// <returns></returns>
public IEnumerable<TwainSource> GetSources() public IEnumerable<TwainSource> GetSources()
{ {
@ -311,7 +324,7 @@ namespace NTwain
var rc = DGControl.Identity.GetFirst(out srcId); var rc = DGControl.Identity.GetFirst(out srcId);
while (rc == ReturnCode.Success) while (rc == ReturnCode.Success)
{ {
yield return TwainSource.GetInstance(this, srcId); yield return GetSourceInstance(this, srcId);
rc = DGControl.Identity.GetNext(out srcId); rc = DGControl.Identity.GetNext(out srcId);
} }
} }

View File

@ -16,21 +16,9 @@ namespace NTwain
/// </summary> /// </summary>
public partial class TwainSource : INotifyPropertyChanged public partial class TwainSource : INotifyPropertyChanged
{ {
static readonly Dictionary<string, TwainSource> __globalInstances = new Dictionary<string, TwainSource>();
internal static TwainSource GetInstance(ITwainSessionInternal session, TWIdentity sourceId)
{
var key = string.Format(CultureInfo.InvariantCulture, "{0}|{1}|{2}", sourceId.Manufacturer, sourceId.ProductFamily, sourceId.ProductName);
if (__globalInstances.ContainsKey(key))
{
return __globalInstances[key];
}
return __globalInstances[key] = new TwainSource(session, sourceId);
}
ITwainSessionInternal _session; ITwainSessionInternal _session;
private TwainSource(ITwainSessionInternal session, TWIdentity sourceId) internal TwainSource(ITwainSessionInternal session, TWIdentity sourceId)
{ {
_session = session; _session = session;
Identity = sourceId; Identity = sourceId;