mirror of
https://github.com/soukoku/ntwain.git
synced 2025-10-08 00:14:38 +08:00
Expanded source disabled event args.
This commit is contained in:
34
src/NTwain/CustomEventArgs.cs
Normal file
34
src/NTwain/CustomEventArgs.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains data for a TWAIN source event.
|
||||
/// </summary>
|
||||
public class DeviceEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the detailed device event.
|
||||
/// </summary>
|
||||
public TW_DEVICEEVENT Data { get; internal set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Contains data when data source came down from being enabled.
|
||||
/// </summary>
|
||||
public class SourceDisabledEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the affected source.
|
||||
/// </summary>
|
||||
public DataSource Source { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether the source was enabled with UI-only (no transfer).
|
||||
/// The app could do something different if this is <code>true</code>, such as
|
||||
/// getting the <see cref="TW_CUSTOMDSDATA"/>.
|
||||
/// </summary>
|
||||
public bool UIOnly { get; internal set; }
|
||||
}
|
||||
}
|
@@ -980,14 +980,14 @@ namespace NTwain.Data
|
||||
/// <summary>
|
||||
/// Allows for a data source and application to pass custom data to each other.
|
||||
/// </summary>
|
||||
partial struct TW_CUSTOMDSDATA
|
||||
public partial struct TW_CUSTOMDSDATA
|
||||
{
|
||||
/// <summary>
|
||||
/// Length, in bytes, of data.
|
||||
/// </summary>
|
||||
public uint InfoLength { get { return _infoLength; } set { _infoLength = value; } }
|
||||
/// <summary>
|
||||
/// Handle to memory containing InfoLength bytes of data.
|
||||
/// Handle to memory containing <see cref="InfoLength"/> bytes of data.
|
||||
/// </summary>
|
||||
public IntPtr Data { get { return _hData; } set { _hData = value; } }
|
||||
}
|
||||
|
@@ -1,17 +0,0 @@
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
|
||||
namespace NTwain
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains data for a TWAIN source event.
|
||||
/// </summary>
|
||||
public class DeviceEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the detailed device event.
|
||||
/// </summary>
|
||||
/// <value>The device event.</value>
|
||||
public TW_DEVICEEVENT Data { get; internal set; }
|
||||
}
|
||||
}
|
@@ -10,7 +10,7 @@ namespace NTwain.Triplets.Control
|
||||
{
|
||||
internal UserInterface(TwainSession session) : base(session) { }
|
||||
|
||||
public ReturnCode DisableDS(ref TW_USERINTERFACE ui)
|
||||
public ReturnCode DisableDS(ref TW_USERINTERFACE ui, bool wasUIonly)
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
|
||||
@@ -42,7 +42,11 @@ namespace NTwain.Triplets.Control
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Session.State = TwainState.S4;
|
||||
Session.OnSourceDisabled(EventArgs.Empty);
|
||||
Session.OnSourceDisabled(new SourceDisabledEventArgs
|
||||
{
|
||||
Source = Session.CurrentSource,
|
||||
UIOnly = wasUIonly
|
||||
});
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
@@ -35,9 +35,10 @@ namespace NTwain
|
||||
DoTransferRoutine();
|
||||
break;
|
||||
case Message.CloseDSReq:
|
||||
DGControl.UserInterface.DisableDS(ref _lastEnableUI);
|
||||
DGControl.UserInterface.DisableDS(ref _lastEnableUI, false);
|
||||
break;
|
||||
case Message.CloseDSOK:
|
||||
DGControl.UserInterface.DisableDS(ref _lastEnableUI, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -50,13 +50,13 @@ namespace NTwain
|
||||
/// <summary>
|
||||
/// Occurs when an enabled source has been disabled (back to state 4).
|
||||
/// </summary>
|
||||
public event EventHandler SourceDisabled;
|
||||
public event EventHandler<SourceDisabledEventArgs> SourceDisabled;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="SourceDisabled"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
internal protected virtual void OnSourceDisabled(EventArgs e)
|
||||
internal protected virtual void OnSourceDisabled(SourceDisabledEventArgs e)
|
||||
{
|
||||
var handler = SourceDisabled;
|
||||
handler?.Invoke(this, e);
|
||||
|
Reference in New Issue
Block a user