mirror of
https://github.com/soukoku/ntwain.git
synced 2025-09-18 17:47:57 +08:00
Put in file xfer code.
This commit is contained in:
@@ -37,8 +37,6 @@ namespace NTwain
|
||||
/// <value>The pending count.</value>
|
||||
public int PendingTransferCount { get; internal set; }
|
||||
|
||||
#region image use
|
||||
|
||||
/// <summary>
|
||||
/// Gets the tentative image information for the current transfer if applicable.
|
||||
/// This may differ from the final image depending on the transfer mode used.
|
||||
@@ -48,94 +46,6 @@ namespace NTwain
|
||||
/// </value>
|
||||
public TWImageInfo PendingImageInfo { get; internal set; }
|
||||
|
||||
///// <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 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; }
|
||||
|
||||
//private Compression _imageCompression;
|
||||
|
||||
///// <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 the supported file formats for image file xfer.
|
||||
///// </summary>
|
||||
///// <value>
|
||||
///// The supported formats.
|
||||
///// </value>
|
||||
//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>
|
||||
@@ -144,7 +54,5 @@ namespace NTwain
|
||||
/// </value>
|
||||
public TWAudioInfo AudioInfo { get; internal set; }
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@@ -455,7 +455,8 @@ namespace NTwain
|
||||
public event EventHandler<DataTransferredEventArgs> DataTransferred;
|
||||
|
||||
/// <summary>
|
||||
/// Called when <see cref="State"/> changed.
|
||||
/// Called when <see cref="State"/> changed
|
||||
/// and raises the <see cref="StateChanged" /> event.
|
||||
/// </summary>
|
||||
protected virtual void OnStateChanged()
|
||||
{
|
||||
@@ -471,7 +472,8 @@ namespace NTwain
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when <see cref="SourceId"/> changed.
|
||||
/// Called when <see cref="SourceId"/> changed
|
||||
/// and raises the <see cref="SourceChanged" /> event.
|
||||
/// </summary>
|
||||
protected virtual void OnSourceChanged()
|
||||
{
|
||||
@@ -487,7 +489,8 @@ namespace NTwain
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when source has been disabled (back to state 4).
|
||||
/// Called when source has been disabled (back to state 4)
|
||||
/// and raises the <see cref="SourceDisabled" /> event.
|
||||
/// </summary>
|
||||
protected virtual void OnSourceDisabled()
|
||||
{
|
||||
@@ -555,7 +558,7 @@ namespace NTwain
|
||||
|
||||
#endregion
|
||||
|
||||
#region real TWAIN logic during xfer
|
||||
#region TWAIN logic during xfer work
|
||||
|
||||
/// <summary>
|
||||
/// Handles the message from a typical WndProc message loop and check if it's from the TWAIN source.
|
||||
@@ -702,6 +705,7 @@ namespace NTwain
|
||||
do
|
||||
{
|
||||
#region build pre xfer info
|
||||
|
||||
TWAudioInfo audInfo;
|
||||
DGAudio.AudioInfo.Get(out audInfo);
|
||||
|
||||
@@ -784,7 +788,18 @@ namespace NTwain
|
||||
|
||||
private void DoAudioFileXfer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
string filePath = null;
|
||||
TWSetupFileXfer setupInfo;
|
||||
if (DGControl.SetupFileXfer.Get(out setupInfo) == ReturnCode.Success)
|
||||
{
|
||||
filePath = setupInfo.FileName;
|
||||
}
|
||||
|
||||
var xrc = DGAudio.AudioFileXfer.Get();
|
||||
if (xrc == ReturnCode.XferDone)
|
||||
{
|
||||
OnDataTransferred(new DataTransferredEventArgs(IntPtr.Zero, filePath));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -799,24 +814,10 @@ namespace NTwain
|
||||
do
|
||||
{
|
||||
#region build pre xfer info
|
||||
|
||||
TWImageInfo imgInfo;
|
||||
DGImage.ImageInfo.Get(out imgInfo);
|
||||
|
||||
//IList<FileFormat> formats = Enumerable.Empty<FileFormat>().ToList();
|
||||
//IList<Compression> compressions = Enumerable.Empty<Compression>().ToList();
|
||||
//var curFormat = this.GetCurrentCap<FileFormat>(CapabilityId.ICapImageFileFormat);
|
||||
//var curComp = this.GetCurrentCap<Compression>(CapabilityId.ICapCompression);
|
||||
//try
|
||||
//{
|
||||
// formats = this.CapGetImageFileFormat();
|
||||
//}
|
||||
//catch { }
|
||||
//try
|
||||
//{
|
||||
// compressions = this.CapGetCompression();
|
||||
//}
|
||||
//catch { }
|
||||
|
||||
// ask consumer for xfer details
|
||||
var preXferArgs = new TransferReadyEventArgs
|
||||
{
|
||||
@@ -867,7 +868,7 @@ namespace NTwain
|
||||
IntPtr lockedPtr = IntPtr.Zero;
|
||||
try
|
||||
{
|
||||
ReturnCode xrc = DGImage.ImageNativeXfer.Get(ref dataPtr);
|
||||
var xrc = DGImage.ImageNativeXfer.Get(ref dataPtr);
|
||||
if (xrc == ReturnCode.XferDone)
|
||||
{
|
||||
State = 7;
|
||||
@@ -895,34 +896,27 @@ namespace NTwain
|
||||
}
|
||||
}
|
||||
|
||||
private void DoImageFileXfer()
|
||||
{
|
||||
string filePath = null;
|
||||
TWSetupFileXfer setupInfo;
|
||||
if (DGControl.SetupFileXfer.Get(out setupInfo) == ReturnCode.Success)
|
||||
{
|
||||
filePath = setupInfo.FileName;
|
||||
}
|
||||
|
||||
var xrc = DGImage.ImageFileXfer.Get();
|
||||
if (xrc == ReturnCode.XferDone)
|
||||
{
|
||||
OnDataTransferred(new DataTransferredEventArgs(IntPtr.Zero, filePath));
|
||||
}
|
||||
}
|
||||
|
||||
private void DoImageMemoryFileXfer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
private void DoImageFileXfer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
//if (preXferArgs.CanDoFileXfer && !string.IsNullOrEmpty(preXferArgs.OutputFile))
|
||||
//{
|
||||
// var setXferRC = DGControl.SetupFileXfer.Set(new TWSetupFileXfer
|
||||
// {
|
||||
// FileName = preXferArgs.OutputFile,
|
||||
// Format = preXferArgs.ImageFormat
|
||||
// });
|
||||
// if (setXferRC == ReturnCode.Success)
|
||||
// {
|
||||
// mech = XferMech.File;
|
||||
// }
|
||||
//}
|
||||
//xrc = DGImage.ImageFileXfer.Get();
|
||||
//if (File.Exists(preXferArgs.OutputFile))
|
||||
//{
|
||||
// file = preXferArgs.OutputFile;
|
||||
//}
|
||||
}
|
||||
|
||||
private void DoImageMemoryXfer()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -932,8 +926,6 @@ namespace NTwain
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The MSG structure in Windows for TWAIN use.
|
||||
/// </summary>
|
||||
|
Reference in New Issue
Block a user