Click or drag to resize

TwainDeviceEvent Class

This class is used with SendCommand to obtain information about a device event when the TwainEventMessage retrieved from ProcessEvent(Message, TwainEventMessage) is MSG_DEVICEEVENT.
Inheritance Hierarchy
SystemObject
  Atalasoft.TwainTwainDeviceEvent

Namespace:  Atalasoft.Twain
Assembly:  Atalasoft.DotTwain (in Atalasoft.DotTwain.dll) Version: 11.0.0.0.0.297 (.NET 4.5.2, x86)
Syntax
public class TwainDeviceEvent : ITwainDataStructure

The TwainDeviceEvent type exposes the following members.

Constructors
  NameDescription
Public methodTwainDeviceEvent
Creates a new instance of TwainDeviceEvent.
Top
Properties
  NameDescription
Public propertyCode exampleAutomaticCapture
Number of images camera will capture.
Public propertyCode exampleBatteryMinutes
Minutes of battery power remaining.
Public propertyCode exampleBatteryPercentage
Percentage of battery power remaining.
Public propertyCode exampleEvent
The event that was raised.
Public propertyCode exampleFlashUsed2
Current flash setting.
Public propertyCode exampleName
The name of the device.
Public propertyCode examplePowerSupply
Current power supply in use.
Public propertyCode exampleTimeBeforeFirstCapture
Number of seconds before first capture.
Public propertyCode exampleTimeBetweenCaptures
Hundredths of a second between captures.
Public propertyCode exampleXResolution
Current X Resolution.
Public propertyCode exampleYResolution
Current Y Resolution.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetStructurePointer
Creates the memory pointer containing data sent to Twain.
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodIsSupportedCommand
Returns a value indicating whether the implementing class supports a specific TwainTriplet command.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodProcessResult
Receives the data pointer created by GetStructurePointer(TwainMemory) after being processed by Twain.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks
Use this with the DeviceEventGetTwainTriplet to get detailed information about a device event during acquisition.
Examples
TwainDeviceEventCS (C#)
public bool PreFilterMessage(ref Message m)
{
    try
    {
        TwainEventMessage msg;
        TwainReturnCode ret = this.twain.ProcessEvent(m, out msg);

        if (ret == TwainReturnCode.TWRC_DSEVENT)
        {
            switch(msg)
            {
                case TwainEventMessage.MSG_DEVICEEVENT:
                    if (this.DeviceEvent != null)
                    {
                        // Find out what ever fired.
                        TwainDeviceEvent devEvent = new TwainDeviceEvent();
                        ret = this.twain.SendCommand(TwainTriplet.DeviceEventGet, this._id, devEvent);

                        if ((ret & TwainReturnCode.TWRC_FAILURE) != TwainReturnCode.TWRC_FAILURE)
                        {
                            DeviceEventArgs e = null;
                            switch(devEvent.Event) 
                            {
                                .....
                            }
                        }
                    }
                    break;
            }
        }
    }
    catch
    {
    }
}
TwainDeviceEventVB (Visual Basic)
Public Function PreFilterMessage(ByRef m As Message) As Boolean
    Try
        Dim msg As TwainEventMessage
        Dim ret As TwainReturnCode =  Me.twain.ProcessEvent(m,out msg) 

        If ret = TwainReturnCode.TWRC_DSEVENT Then
            Select Case msg
                Case TwainEventMessage.MSG_DEVICEEVENT
                    If Not Me.DeviceEvent Is Nothing Then
                        ' Find out what ever fired.
                        Dim devEvent As TwainDeviceEvent =  New TwainDeviceEvent()
                        ret = Me.twain.SendCommand(TwainTriplet.DeviceEventGet, Me._id, devEvent)

                        If (ret & TwainReturnCode.TWRC_FAILURE) <> TwainReturnCode.TWRC_FAILURE Then
                            Dim e As DeviceEventArgs =  Nothing 
                            Select Case devEvent.Event
                                .....
                            End Select
                        End If
                    End If
                    Exit Function
            End Select
        End If
    End Try
End Function
Examples
TwainDeviceEventCS (C#)
public bool PreFilterMessage(ref Message m)
{
    try
    {
        TwainEventMessage msg;
        TwainReturnCode ret = this.twain.ProcessEvent(m, out msg);

        if (ret == TwainReturnCode.TWRC_DSEVENT)
        {
            switch(msg)
            {
                case TwainEventMessage.MSG_DEVICEEVENT:
                    if (this.DeviceEvent != null)
                    {
                        // Find out what ever fired.
                        TwainDeviceEvent devEvent = new TwainDeviceEvent();
                        ret = this.twain.SendCommand(TwainTriplet.DeviceEventGet, this._id, devEvent);

                        if ((ret & TwainReturnCode.TWRC_FAILURE) != TwainReturnCode.TWRC_FAILURE)
                        {
                            DeviceEventArgs e = null;
                            switch(devEvent.Event) 
                            {
                                .....
                            }
                        }
                    }
                    break;
            }
        }
    }
    catch
    {
    }
}
TwainDeviceEventVB (Visual Basic)
Public Function PreFilterMessage(ByRef m As Message) As Boolean
    Try
        Dim msg As TwainEventMessage
        Dim ret As TwainReturnCode =  Me.twain.ProcessEvent(m,out msg) 

        If ret = TwainReturnCode.TWRC_DSEVENT Then
            Select Case msg
                Case TwainEventMessage.MSG_DEVICEEVENT
                    If Not Me.DeviceEvent Is Nothing Then
                        ' Find out what ever fired.
                        Dim devEvent As TwainDeviceEvent =  New TwainDeviceEvent()
                        ret = Me.twain.SendCommand(TwainTriplet.DeviceEventGet, Me._id, devEvent)

                        If (ret & TwainReturnCode.TWRC_FAILURE) <> TwainReturnCode.TWRC_FAILURE Then
                            Dim e As DeviceEventArgs =  Nothing 
                            Select Case devEvent.Event
                                .....
                            End Select
                        End If
                    End If
                    Exit Function
            End Select
        End If
    End Try
End Function
See Also