2014-04-20 16:57:38 -04:00
|
|
|
|
using NTwain.Data;
|
|
|
|
|
|
using NTwain.Internals;
|
2014-04-17 19:11:11 -04:00
|
|
|
|
using System;
|
2014-04-02 19:01:21 -04:00
|
|
|
|
|
|
|
|
|
|
namespace NTwain.Triplets
|
|
|
|
|
|
{
|
2014-04-04 22:19:16 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents <see cref="DataArgumentType.Parent"/>.
|
|
|
|
|
|
/// </summary>
|
2014-09-15 07:24:13 -04:00
|
|
|
|
sealed class Parent : TripletBase
|
2014-04-02 19:01:21 -04:00
|
|
|
|
{
|
2014-04-20 18:42:51 -04:00
|
|
|
|
internal Parent(ITwainSessionInternal session) : base(session) { }
|
2014-04-02 19:01:21 -04:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// When the application has closed all the Sources it had previously opened, and is finished with
|
|
|
|
|
|
/// the Source Manager (the application plans to initiate no other TWAIN sessions), it must close
|
|
|
|
|
|
/// the Source Manager.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="handle">The handle. On Windows = points to the window handle (hWnd) that will act as the Source’s
|
|
|
|
|
|
/// "parent". On Macintosh = should be a NULL value.</param>
|
|
|
|
|
|
/// <returns></returns>
|
2014-04-05 18:33:21 -04:00
|
|
|
|
public ReturnCode CloseDsm(IntPtr handle)
|
2014-04-02 19:01:21 -04:00
|
|
|
|
{
|
2014-04-20 20:45:08 -04:00
|
|
|
|
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Parent, Message.CloseDSM);
|
|
|
|
|
|
var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.CloseDSM, ref handle);
|
2014-04-02 19:01:21 -04:00
|
|
|
|
if (rc == ReturnCode.Success)
|
|
|
|
|
|
{
|
2014-04-04 07:25:11 -04:00
|
|
|
|
Session.ChangeState(2, true);
|
2014-04-02 19:01:21 -04:00
|
|
|
|
}
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Causes the Source Manager to initialize itself. This operation must be executed before any other
|
|
|
|
|
|
/// operations will be accepted by the Source Manager.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="handle">The handle. On Windows = points to the window handle (hWnd) that will act as the Source’s
|
|
|
|
|
|
/// "parent". On Macintosh = should be a NULL value.</param>
|
|
|
|
|
|
/// <returns></returns>
|
2014-04-05 18:33:21 -04:00
|
|
|
|
public ReturnCode OpenDsm(IntPtr handle)
|
2014-04-02 19:01:21 -04:00
|
|
|
|
{
|
2014-04-20 20:45:08 -04:00
|
|
|
|
Session.VerifyState(1, 2, DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM);
|
|
|
|
|
|
var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.OpenDSM, ref handle);
|
2014-04-02 19:01:21 -04:00
|
|
|
|
if (rc == ReturnCode.Success)
|
|
|
|
|
|
{
|
2014-04-04 07:25:11 -04:00
|
|
|
|
Session.ChangeState(3, true);
|
2014-04-02 19:01:21 -04:00
|
|
|
|
}
|
|
|
|
|
|
return rc;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|