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