Leadtools TWAIN(Leadtools.Twainアセンブリ)

フレームを表示

GetDeviceEventDataメソッド






特定のデバイスイベントのために情報を取得します
構文
public TwainDeviceEvent GetDeviceEventData()
'Declaration
 
Public Function GetDeviceEventData() As TwainDeviceEvent
'Usage
 
Dim instance As TwainSession
Dim value As TwainDeviceEvent
 
value = instance.GetDeviceEventData()

            

            
public:
TwainDeviceEvent^ GetDeviceEventData(); 

戻り値

デバイスイベント情報を表すTwainDeviceEventオブジェクト
解説

このメソッド意志は、特定のデバイスイベントのために情報を返します。デバイスイベントごとにステータスを取得して、CAP_DEVICEEVENT機能値を取得するためにGetDeviceEventイベントを発生することを可能にするためにEnableGetDeviceEventプロパティをTRUEに設定して、GetDeviceEventCapabilityメソッドを呼び出して、CAP_DEVICEEVENT機能呼び出しSetDeviceEventCapabilityメソッドを設定するために、また、CAP_DEVICEEVENT capability.\をリセットするために、ResetDeviceEventCapabilityメソッドを呼び出します

このメソッドは、デバイスイベント情報を取得するために、GetDeviceEventイベントの中に呼び出されなければなりません。

サンプル
Copy Code  
Imports Leadtools
      Imports Leadtools.Twain

      Public WithEvents session As TwainSession = New TwainSession()
      Private Sub session_GetDeviceEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles session.GetDeviceEvent
         Try
            Dim deviceEvent As TwainDeviceEvent = session.GetDeviceEventData()
            Dim msg As String = String.Format("Event ={0}{1}Event Name ={2}", deviceEvent.Event, Chr(13), deviceEvent.DeviceName)
            MessageBox.Show(msg)

            If deviceEvent.Event = TwainCapabilityValue.DeviceEventCheckBattery Then
               msg = String.Format("Battery Minutes ={0}{1}Battery Percentage ={2}", deviceEvent.BatteryMinutes, Chr(13), deviceEvent.BatteryPercentage)
               MessageBox.Show(msg)
            ElseIf deviceEvent.Event = TwainCapabilityValue.DeviceEventCheckPowerSupply Then
               msg = String.Format("Power Supply ={0}", deviceEvent.PowerSupply)
               MessageBox.Show(msg)
            ElseIf deviceEvent.Event = TwainCapabilityValue.DeviceEventCheckPowerSupply Then
               msg = String.Format("XResolution ={0}{1}YResolution ={2}", deviceEvent.XResolution, Chr(13), deviceEvent.YResolution)
               MessageBox.Show(msg)
            ElseIf deviceEvent.Event = TwainCapabilityValue.DeviceEventCheckFlash Then
               msg = String.Format("FlashUsed2 ={0}", deviceEvent.FlashUsed2)
               MessageBox.Show(msg)
            ElseIf deviceEvent.Event = TwainCapabilityValue.DeviceEventCheckAutomaticCapture Then
               msg = String.Format("Automatic Capture ={0}{1}Time Before First Capture ={2}{3}Time Between Captures = {4}", deviceEvent.AutomaticCapture, Chr(13), deviceEvent.TimeBeforeFirstCapture, Chr(13), deviceEvent.TimeBetweenCaptures)
               MessageBox.Show(msg)
            End If
         Catch
         End Try
      End Sub

#If Not LEADTOOLS_V19_OR_LATER Then
      Public Sub GetDeviceEventDataExample(ByVal parent As IWin32Window)
#Else
      Public Sub GetDeviceEventDataExample(ByVal parent As IntPtr)
#End If ' #If LEADTOOLS_V19_OR_LATER Then
         Try
            session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None)

            AddHandler session.GetDeviceEvent, AddressOf session_GetDeviceEvent
            session.EnableGetDeviceEvent = True

            session.Acquire(TwainUserInterfaceFlags.Show)
            session.Shutdown()
         Catch
         End Try
      End Sub
using Leadtools;
      using Leadtools.Twain;

      TwainSession session = new TwainSession();
#if !LEADTOOLS_V19_OR_LATER
      public void GetDeviceEventDataExample(IWin32Window parent)
#else
      public void GetDeviceEventDataExample(IntPtr parent)
#endif // #if !LEADTOOLS_V19_OR_LATER
      {
         try
         {
            session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None);
            session.GetDeviceEvent += new EventHandler<EventArgs>(session_GetDeviceEvent);
            session.EnableGetDeviceEvent = true;

            session.Acquire(TwainUserInterfaceFlags.Show);
            session.Shutdown();
         }
         catch
         { }
      }

      void session_GetDeviceEvent(object sender, EventArgs e)
      {
         try
         {
            TwainDeviceEvent deviceEvent = session.GetDeviceEventData();
            string msg = string.Format("Event ={0}\nEvent Name ={1}\n", deviceEvent.Event, deviceEvent.DeviceName);
            MessageBox.Show(msg);

            if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckBattery)
            {
               msg = string.Format("Battery Minutes ={0}\nBattery Percentage ={1}\n", deviceEvent.BatteryMinutes, deviceEvent.BatteryPercentage);
               MessageBox.Show(msg);
            }
            else if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckPowerSupply)
            {
               msg = string.Format("Power Supply ={0}\n", deviceEvent.PowerSupply);
               MessageBox.Show(msg);
            }
            else if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckPowerSupply)
            {
               msg = string.Format("XResolution ={0}\nYResolution ={1}\n", deviceEvent.XResolution, deviceEvent.YResolution);
               MessageBox.Show(msg);
            }
            else if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckFlash)
            {
               msg = string.Format("FlashUsed2 ={0}\n", deviceEvent.FlashUsed2);
               MessageBox.Show(msg);
            }
            else if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckAutomaticCapture)
            {
               msg = string.Format("Automatic Capture ={0}\nTime Before First Capture ={1}\nTime Between Captures = {2}\n", deviceEvent.AutomaticCapture, deviceEvent.TimeBeforeFirstCapture, deviceEvent.TimeBetweenCaptures);
               MessageBox.Show(msg);
            }
         }
         catch
         { }
      }
必要条件

ターゲットプラットホーム

参照

参照

TwainSessionクラス
TwainSessionメンバ
EnableGetDeviceEventプロパティ
SetDeviceEventCapabilityメソッド
GetDeviceEventCapabilityメソッド
ResetDeviceEventCapabilityメソッド
Leadtools.Twain.TwainSession.GetDeviceEvent
TwainDeviceEventクラス