2014-04-18 07:11:11 +08:00
|
|
|
|
using NTwain.Values;
|
|
|
|
|
using System;
|
2014-04-03 07:01:21 +08:00
|
|
|
|
|
|
|
|
|
namespace NTwain.Triplets
|
|
|
|
|
{
|
2014-04-05 10:19:16 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents <see cref="DataArgumentType.Parent"/>.
|
|
|
|
|
/// </summary>
|
2014-04-03 07:01:21 +08:00
|
|
|
|
sealed class Parent : OpBase
|
|
|
|
|
{
|
2014-04-06 04:48:28 +08:00
|
|
|
|
internal Parent(ITwainStateInternal session) : base(session) { }
|
2014-04-03 07:01:21 +08: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-06 06:33:21 +08:00
|
|
|
|
public ReturnCode CloseDsm(IntPtr handle)
|
2014-04-03 07:01:21 +08:00
|
|
|
|
{
|
|
|
|
|
Session.VerifyState(3, 3, DataGroups.Control, DataArgumentType.Parent, Message.CloseDsm);
|
2014-04-16 18:53:05 +08:00
|
|
|
|
var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.CloseDsm, ref handle);
|
2014-04-03 07:01:21 +08:00
|
|
|
|
if (rc == ReturnCode.Success)
|
|
|
|
|
{
|
2014-04-04 19:25:11 +08:00
|
|
|
|
Session.ChangeState(2, true);
|
2014-04-03 07:01:21 +08: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-06 06:33:21 +08:00
|
|
|
|
public ReturnCode OpenDsm(IntPtr handle)
|
2014-04-03 07:01:21 +08:00
|
|
|
|
{
|
|
|
|
|
Session.VerifyState(1, 2, DataGroups.Control, DataArgumentType.Parent, Message.OpenDsm);
|
2014-04-16 18:53:05 +08:00
|
|
|
|
var rc = Dsm.DsmEntry(Session.AppId, null, DataGroups.Control, DataArgumentType.Parent, Message.OpenDsm, ref handle);
|
2014-04-03 07:01:21 +08:00
|
|
|
|
if (rc == ReturnCode.Success)
|
|
|
|
|
{
|
2014-04-04 19:25:11 +08:00
|
|
|
|
Session.ChangeState(3, true);
|
2014-04-03 07:01:21 +08:00
|
|
|
|
}
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|