Refactoring different xfer modes and types.

This commit is contained in:
soukoku
2014-04-06 07:08:52 -04:00
parent 4c3e2a50b3
commit 69feecde8d
4 changed files with 384 additions and 309 deletions

View File

@@ -2,6 +2,7 @@
using NTwain.Data;
using NTwain.Values;
using System.Collections.Generic;
using System.Linq;
namespace NTwain
{
@@ -10,50 +11,6 @@ namespace NTwain
/// </summary>
public class TransferReadyEventArgs : EventArgs
{
/// <summary>
/// Initializes a new instance of the <see cref="TransferReadyEventArgs" /> class.
/// </summary>
/// <param name="pending">The pending data.</param>
/// <param name="supportedFormats">The formats.</param>
/// <param name="currentFormat">The current format.</param>
/// <param name="supportedCompressions">The compressions.</param>
/// <param name="currentCompression">The current compression.</param>
/// <param name="canDoFileXfer">if set to <c>true</c> then allow file xfer properties.</param>
/// <param name="imageInfo">The image info.</param>
internal TransferReadyEventArgs(TWPendingXfers pending, IList<FileFormat> supportedFormats, FileFormat currentFormat,
IList<Compression> supportedCompressions, Compression currentCompression, bool canDoFileXfer, TWImageInfo imageInfo)
{
PendingCount = pending.Count;
EndOfJob = pending.EndOfJob == 0;
_imageCompression = currentCompression;
SupportedCompressions = supportedCompressions;
_imageFormat = currentFormat;
SupportedFormats = supportedFormats;
CanDoFileXfer = canDoFileXfer;
ImageInfo = imageInfo;
}
/// <summary>
/// Gets the image info for the current transfer.
/// </summary>
/// <value>
/// The image info.
/// </value>
public TWImageInfo ImageInfo { get; private set; }
/// <summary>
/// Gets the known pending transfer count. This may not be appilicable
/// for certain scanning modes.
/// </summary>
/// <value>The pending count.</value>
public int PendingCount { get; private set; }
/// <summary>
/// Gets a value indicating whether current transfer signifies an end of job.
/// </summary>
/// <value><c>true</c> if transfer is end of job; otherwise, <c>false</c>.</value>
public bool EndOfJob { get; private set; }
/// <summary>
/// Gets or sets a value indicating whether the current transfer should be canceled
/// and continue next transfer if there are more data.
@@ -68,97 +25,126 @@ namespace NTwain
public bool CancelAll { get; set; }
/// <summary>
/// Gets or sets a value indicating whether file transfer is supported.
/// Gets a value indicating whether current transfer signifies an end of job in TWAIN world.
/// </summary>
/// <value>
/// <c>true</c> if this instance can do file transfer; otherwise, <c>false</c>.
/// </value>
public bool CanDoFileXfer { get; private set; }
/// <value><c>true</c> if transfer is end of job; otherwise, <c>false</c>.</value>
public bool EndOfJob { get; internal set; }
/// <summary>
/// Gets or sets the desired output file path if file transfer is supported.
/// Note that not all sources will support the specified image type and compression
/// when file transfer is used.
/// Gets the known pending transfer count. This may not be appilicable
/// for certain scanning modes.
/// </summary>
/// <value>
/// The output file.
/// </value>
public string OutputFile { get; set; }
/// <value>The pending count.</value>
public int PendingTransferCount { get; internal set; }
#region image use
/// <summary>
/// Gets the supported compression for image xfer.
/// Gets the tentative image information for the current transfer if applicable.
/// This may differ from the final image depending on the transfer mode used.
/// </summary>
/// <value>
/// The supported compressions.
/// The image info.
/// </value>
public IList<Compression> SupportedCompressions { get; private set; }
public TWImageInfo PendingImageInfo { get; internal set; }
private Compression _imageCompression;
///// <summary>
///// Gets or sets a value indicating whether file transfer is supported.
///// </summary>
///// <value>
///// <c>true</c> if this instance can do file transfer; otherwise, <c>false</c>.
///// </value>
//public bool CanDoFileXfer { get; private set; }
/// <summary>
/// Gets or sets the image compression for image xfer.
/// </summary>
/// <value>
/// The image compression.
/// </value>
/// <exception cref="System.NotSupportedException"></exception>
public Compression ImageCompression
{
get { return _imageCompression; }
set
{
if (SupportedCompressions.Contains(value))
{
_imageCompression = value;
}
else
{
throw new NotSupportedException(string.Format("{0} is not supported.", value));
}
}
}
///// <summary>
///// Gets or sets the desired output file path if file transfer is supported.
///// Note that not all sources will support the specified image type and compression
///// when file transfer is used.
///// </summary>
///// <value>
///// The output file.
///// </value>
//public string OutputFile { get; set; }
///// <summary>
///// Gets the supported compression for image xfer.
///// </summary>
///// <value>
///// The supported compressions.
///// </value>
//public IList<Compression> SupportedImageCompressions { get; internal set; }
/// <summary>
/// Gets the supported file formats for image file xfer.
/// </summary>
/// <value>
/// The supported formats.
/// </value>
public IList<FileFormat> SupportedFormats { get; private set; }
//private Compression _imageCompression;
private FileFormat _imageFormat;
/// <summary>
/// Gets or sets the image format for image xfer.
/// </summary>
/// <value>
/// The image format.
/// </value>
/// <exception cref="System.NotSupportedException"></exception>
public FileFormat ImageFormat
{
get { return _imageFormat; }
set
{
if (SupportedFormats.Contains(value))
{
_imageFormat = value;
}
else
{
throw new NotSupportedException(string.Format("{0} is not supported.", value));
}
}
}
///// <summary>
///// Gets or sets the image compression for image xfer.
///// </summary>
///// <value>
///// The image compression.
///// </value>
///// <exception cref="System.NotSupportedException"></exception>
//public Compression ImageCompression
//{
// get { return _imageCompression; }
// set
// {
// if (SupportedImageCompressions.Contains(value))
// {
// _imageCompression = value;
// }
// else
// {
// throw new NotSupportedException(string.Format("{0} is not supported.", value));
// }
// }
//}
///// <summary>
///// Gets or sets the audio file format if <see cref="OutputFile"/> is specified
///// and the data to be transferred is audio.
///// Gets the supported file formats for image file xfer.
///// </summary>
///// <value>
///// The audio file format.
///// The supported formats.
///// </value>
//public AudioFileFormat AudioFileFormat { get; set; }
//public IList<FileFormat> SupportedImageFormats { get; internal set; }
//private FileFormat _imageFormat;
///// <summary>
///// Gets or sets the image format for image xfer.
///// </summary>
///// <value>
///// The image format.
///// </value>
///// <exception cref="System.NotSupportedException"></exception>
//public FileFormat ImageFormat
//{
// get { return _imageFormat; }
// set
// {
// if (SupportedImageFormats.Contains(value))
// {
// _imageFormat = value;
// }
// else
// {
// throw new NotSupportedException(string.Format("{0} is not supported.", value));
// }
// }
//}
#endregion
#region audio use
/// <summary>
/// Gets the audio information for the current transfer if applicable.
/// </summary>
/// <value>
/// The audio information.
/// </value>
public TWAudioInfo AudioInfo { get; internal set; }
#endregion
}
}