mirror of
https://github.com/soukoku/ntwain.git
synced 2025-10-08 00:14:38 +08:00
Added DAT_USERINTERFACE calls.
This commit is contained in:
130
src/NTwain/Triplets/Control/UserInterface.cs
Normal file
130
src/NTwain/Triplets/Control/UserInterface.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace NTwain.Triplets.Control
|
||||
{
|
||||
sealed class UserInterface : BaseTriplet
|
||||
{
|
||||
internal UserInterface(TwainSession session) : base(session) { }
|
||||
|
||||
public ReturnCode DisableDS(ref TW_USERINTERFACE ui)
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
|
||||
if (Is32Bit)
|
||||
{
|
||||
if (IsWin)
|
||||
rc = NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS, ref ui);
|
||||
else if (IsLinux)
|
||||
rc = NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS, ref ui);
|
||||
else if (IsMac)
|
||||
rc = NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS, ref ui);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsWin)
|
||||
rc = NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS, ref ui);
|
||||
else if (IsLinux)
|
||||
rc = NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS, ref ui);
|
||||
else if (IsMac)
|
||||
rc = NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS, ref ui);
|
||||
}
|
||||
|
||||
if (rc == ReturnCode.Success)
|
||||
{
|
||||
Session.State = TwainState.S4;
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
public ReturnCode EnableDS(ref TW_USERINTERFACE ui)
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
if (Session.State == TwainState.S4)
|
||||
{
|
||||
Session.State = TwainState.S5; //tentative
|
||||
|
||||
if (Is32Bit)
|
||||
{
|
||||
if (IsWin)
|
||||
rc = NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDS, ref ui);
|
||||
else if (IsLinux)
|
||||
rc = NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDS, ref ui);
|
||||
else if (IsMac)
|
||||
rc = NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDS, ref ui);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsWin)
|
||||
rc = NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDS, ref ui);
|
||||
else if (IsLinux)
|
||||
rc = NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDS, ref ui);
|
||||
else if (IsMac)
|
||||
rc = NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.DisableDS, ref ui);
|
||||
}
|
||||
|
||||
if (!(rc == ReturnCode.Success &&
|
||||
(!ui.ShowUI && rc == ReturnCode.CheckStatus)))
|
||||
{
|
||||
Session.State = TwainState.S4;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
public ReturnCode EnableDSUIOnly(ref TW_USERINTERFACE ui)
|
||||
{
|
||||
var rc = ReturnCode.Failure;
|
||||
if (Session.State == TwainState.S4)
|
||||
{
|
||||
Session.State = TwainState.S5; //tentative
|
||||
|
||||
if (Is32Bit)
|
||||
{
|
||||
if (IsWin)
|
||||
rc = NativeMethods.DsmWin32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly, ref ui);
|
||||
else if (IsLinux)
|
||||
rc = NativeMethods.DsmLinux32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly, ref ui);
|
||||
else if (IsMac)
|
||||
rc = NativeMethods.DsmMac32(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly, ref ui);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IsWin)
|
||||
rc = NativeMethods.DsmWin64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly, ref ui);
|
||||
else if (IsLinux)
|
||||
rc = NativeMethods.DsmLinux64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly, ref ui);
|
||||
else if (IsMac)
|
||||
rc = NativeMethods.DsmMac64(Session.Config.App32, Session.CurrentSource.Identity32,
|
||||
DataGroups.Control, DataArgumentType.UserInterface, Message.EnableDSUIOnly, ref ui);
|
||||
}
|
||||
|
||||
if (rc != ReturnCode.Success)
|
||||
{
|
||||
Session.State = TwainState.S4;
|
||||
}
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
}
|
@@ -39,6 +39,9 @@ namespace NTwain.Triplets
|
||||
DeviceEvent _devEvent;
|
||||
internal DeviceEvent DeviceEvent => _devEvent ?? (_devEvent = new DeviceEvent(Session));
|
||||
|
||||
UserInterface _ui;
|
||||
internal UserInterface UserInterface => _ui ?? (_ui = new UserInterface(Session));
|
||||
|
||||
XferGroup _xferGroup;
|
||||
/// <summary>
|
||||
/// Gets the operations defined for DAT_XFERGROUP.
|
||||
|
Reference in New Issue
Block a user