Click or drag to resize

ITwainDataStructure Interface

This interface is used for data classes sent to the SendCommand(TwainTriplet, TwainIdentity, ITwainDataStructure) method.

Namespace:  Atalasoft.Twain
Assembly:  Atalasoft.DotTwain (in Atalasoft.DotTwain.dll) Version: 11.4.0.9.0.377 (.NET 4.5.2, x86)
Syntax
public interface ITwainDataStructure

The ITwainDataStructure type exposes the following members.

Methods
  NameDescription
Public methodCode exampleGetStructurePointer
Creates the memory pointer containing data sent to TWAIN.
Public methodCode exampleIsSupportedCommand
Returns a value indicating whether the implementing class supports a specific TwainTriplet command.
Public methodCode exampleProcessResult
Receives the TwainMemory created by GetStructurePointer(TwainMemory) after being processed by TWAIN.
Top
Remarks

Use this interface for custom Twain calls not implemented by DotTwain.

Implementors of this class should not dispose of the TwainMemory sent to ProcessResult(TwainMemory). The TwainController will dispose of the memory created by GetStructurePointer(TwainMemory).

Examples
ITwainDataCS (C#)
public class TwainHandle : ITwainDataStructure
{
    private IntPtr _handle = IntPtr.Zero;

    public TwainHandle(IntPtr handle)
    {
        _handle = handle;
    }

    public IntPtr Handle
    {
        get { return _handle; }
    }

    #region ITwainDataStructure Members

    public void GetStructurePointer(TwainMemory memory)
    {
        memory.Allocate(IntPtr.Size);
        memory.WriteIntPtr(_handle);
    }

    public void ProcessResult(TwainMemory memory)
    {
        _handle = memory.ReadIntPtr();
    }

    public bool IsSupportedCommand(Atalasoft.Twain.TwainTriplet command)
    {
        return (command == TwainTriplet.AudioNativeXferGet);
    }

    #endregion
}
ITwainDataVB (Visual Basic)
Public Class TwainHandle
    Implements ITwainDataStructure
    Private _handle As IntPtr = IntPtr.Zero

    Public Sub New(ByVal handle As IntPtr)
        _handle = handle
    End Sub

    Public Readonly Property Handle() As IntPtr
        Get
            Return _handle
        End Get
    End Property

    #Region "ITwainDataStructure Members"

    Public Sub GetStructurePointer(ByVal memory As TwainMemory)
        memory.Allocate(IntPtr.Size)
        memory.WriteIntPtr(_handle)
    End Sub

    Public Sub ProcessResult(ByVal memory As TwainMemory)
        _handle = memory.ReadIntPtr()
    End Sub

    Public Function IsSupportedCommand(ByVal command As Atalasoft.Twain.TwainTriplet) As Boolean
        Return (command Is TwainTriplet.AudioNativeXferGet)
    End Function

    #End Region
End Class
See Also