mirror of
https://github.com/soukoku/ntwain.git
synced 2025-04-05 05:01:57 +08:00
Add a TransferCanceled event
This commit is contained in:
parent
25b612633c
commit
3807f69584
@ -41,6 +41,7 @@ namespace NTwain.Internals
|
||||
ReturnCode DisableSource();
|
||||
|
||||
void SafeSyncableRaiseEvent(DataTransferredEventArgs e);
|
||||
void SafeSyncableRaiseEvent(TransferCanceledEventArgs e);
|
||||
void SafeSyncableRaiseEvent(TransferErrorEventArgs e);
|
||||
void SafeSyncableRaiseEvent(TransferReadyEventArgs e);
|
||||
|
||||
|
@ -145,9 +145,11 @@ namespace NTwain.Internals
|
||||
{
|
||||
case ReturnCode.Success:
|
||||
case ReturnCode.XferDone:
|
||||
case ReturnCode.Cancel:
|
||||
// ok to keep going
|
||||
break;
|
||||
case ReturnCode.Cancel:
|
||||
session.SafeSyncableRaiseEvent(new TransferCanceledEventArgs());
|
||||
break;
|
||||
default:
|
||||
var status = session.CurrentSource.GetStatus();
|
||||
session.SafeSyncableRaiseEvent(new TransferErrorEventArgs(rc, status));
|
||||
|
17
src/NTwain/TransferCanceledEventArgs.cs
Normal file
17
src/NTwain/TransferCanceledEventArgs.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates a transfer cancellation, e.g. if the user pressed the "Cancel" button.
|
||||
/// </summary>
|
||||
public class TransferCanceledEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TransferCanceledEventArgs"/> class.
|
||||
/// </summary>
|
||||
public TransferCanceledEventArgs()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -482,6 +482,10 @@ namespace NTwain
|
||||
/// </summary>
|
||||
public event EventHandler<DataTransferredEventArgs> DataTransferred;
|
||||
/// <summary>
|
||||
/// Occurs when a transfer was canceled.
|
||||
/// </summary>
|
||||
public event EventHandler<TransferCanceledEventArgs> TransferCanceled;
|
||||
/// <summary>
|
||||
/// Occurs when an error has been encountered during transfer.
|
||||
/// </summary>
|
||||
public event EventHandler<TransferErrorEventArgs> TransferError;
|
||||
@ -680,6 +684,12 @@ namespace NTwain
|
||||
/// <param name="e">The <see cref="DataTransferredEventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnDataTransferred(DataTransferredEventArgs e) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when a transfer was canceled.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="TransferCanceledEventArgs"/> instance containing the event data.</param>
|
||||
protected virtual void OnTransferCanceled(TransferCanceledEventArgs e) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when an error has been encountered during transfer.
|
||||
/// </summary>
|
||||
|
@ -96,6 +96,10 @@ namespace NTwain
|
||||
{
|
||||
SafeSyncableRaiseOnEvent(OnDataTransferred, DataTransferred, e);
|
||||
}
|
||||
void ITwainSessionInternal.SafeSyncableRaiseEvent(TransferCanceledEventArgs e)
|
||||
{
|
||||
SafeSyncableRaiseOnEvent(OnTransferCanceled, TransferCanceled, e);
|
||||
}
|
||||
void ITwainSessionInternal.SafeSyncableRaiseEvent(TransferErrorEventArgs e)
|
||||
{
|
||||
SafeSyncableRaiseOnEvent(OnTransferError, TransferError, e);
|
||||
|
Loading…
Reference in New Issue
Block a user