VintaSoft Twain .NET SDK 15.1: Руководство для .NET разработчика
Vintasoft.Twain Namespace / Device Class / StopFeeder() Method
Синтаксис Exceptions Example Требования Смотрите также
    StopFeeder() Метод (Device)
    Отправляет на устройство команду остановки устройства подачи документов (податчик документов не будет остановлен сразу после выполнения этого метода).
    Синтаксис
    'Declaration
    
    Public Sub StopFeeder()
    
    
     
    Исключения
    ИсключениеОписание
    Выбрасывается, если используется .NET отладчик и для оценки функции требуется, чтобы все потоки выполнялись.
    Выбрасывается, если устройство не передает изображения ИЛИ устройство не поддерживает функцию автоматического сканирования.
    Пример

    Это C#/VB. NET-код показывает, как приостановить получение изображения из устройства подачи (остановить устройство подачи) и возобновить получение изображения из устройства подачи.

    Class SyncScan_StopFeeder
    
        ''' <summary>
        ''' This method scans the first image, stops the document feeder,
        ''' scans the second image.
        ''' </summary>
        Public Shared Sub ScanImage_StopFeeder_ScanImage()
            Dim imageCount As Integer = 0
    
            ' create the device manager
            Using deviceManager As New Vintasoft.Twain.DeviceManager()
                deviceManager.IsTwain2Compatible = True
                ' open the device manager
                deviceManager.Open()
    
                ' get the device
                Dim deviceName As String = "KODAK Scanner: i5000"
                Dim device As Vintasoft.Twain.Device = deviceManager.Devices.Find(deviceName)
                If device Is Nothing Then
                    Throw New ApplicationException(String.Format("Device '{0}' is not found.", deviceName))
                End If
    
                ' disable device UI
                device.ShowUI = False
                ' specify that device must be closed after scan
                device.DisableAfterAcquire = True
    
                ' open the device
                device.Open()
                ' specify that 2 images must be acquired from scanner
                device.XferCount = 2
    
                ' run synchronous image acquisition
                Dim acquireModalState1 As Vintasoft.Twain.AcquireModalState = Vintasoft.Twain.AcquireModalState.None
                Do
                    acquireModalState1 = device.AcquireModal()
                    Select Case acquireModalState1
                        Case Vintasoft.Twain.AcquireModalState.ImageAcquired
                            Console.WriteLine("Image is acquired.")
                            If device.AcquiredImage IsNot Nothing Then
                                device.AcquiredImage.Dispose()
                            End If
    
                            imageCount += 1
    
                            ' stop the feeder
                            device.StopFeeder()
                            Exit Select
    
                        Case Vintasoft.Twain.AcquireModalState.ScanCompleted
                            Console.WriteLine("Scan is completed.")
                            Exit Select
    
                        Case Vintasoft.Twain.AcquireModalState.ScanCanceled
                            Console.WriteLine("Scan is canceled.")
                            Exit Select
    
                        Case Vintasoft.Twain.AcquireModalState.ScanFailed
                            Console.WriteLine(String.Format("Scan is failed: {0}.", device.ErrorString))
                            Exit Select
                    End Select
                Loop While acquireModalState1 <> Vintasoft.Twain.AcquireModalState.None
    
                If imageCount <> 1 Then
                    Throw New ApplicationException("Wrong acquired image count.")
                End If
    
                If device.State <> Vintasoft.Twain.DeviceState.TransferReady Then
                    Throw New ApplicationException("Feeder is NOT stopped.")
                End If
                Console.WriteLine("Feeder is stopped.")
    
                ' continue asynchronous image acquisition
                Do
                    acquireModalState1 = device.AcquireModal()
                    Select Case acquireModalState1
                        Case Vintasoft.Twain.AcquireModalState.ImageAcquired
                            Console.WriteLine("Image is acquired.")
    
                            If device.AcquiredImage IsNot Nothing Then
                                device.AcquiredImage.Dispose()
                            End If
    
                            imageCount = imageCount + 1
                            Exit Select
    
                        Case Vintasoft.Twain.AcquireModalState.ScanCompleted
                            Console.WriteLine("Scan is completed.")
                            Exit Select
    
                        Case Vintasoft.Twain.AcquireModalState.ScanCanceled
                            Console.WriteLine("Scan is canceled.")
                            Exit Select
    
                        Case Vintasoft.Twain.AcquireModalState.ScanFailed
                            Console.WriteLine(String.Format("Scan is failed: {0}.", device.ErrorString))
                            Exit Select
                    End Select
                Loop While acquireModalState1 <> Vintasoft.Twain.AcquireModalState.None
    
                If imageCount <> 2 Then
                    Throw New ApplicationException("Wrong acquired image count.")
                End If
    
                ' close the device
                device.Close()
            End Using
        End Sub
    
    End Class
    
    
    namespace TwainExamples_CSharp
    {
        class SyncScan_StopFeeder
        {
    
            /// <summary>
            /// This method scans the first image, stops the document feeder,
            /// scans the second image.
            /// </summary>
            public static void ScanImage_StopFeeder_ScanImage()
            {
                int imageCount = 0;
    
                // create the device manager
                using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
                {
                    deviceManager.IsTwain2Compatible = true;
                    // open the device manager
                    deviceManager.Open();
    
                    // get the device
                    string deviceName = "KODAK Scanner: i5000";
                    Vintasoft.Twain.Device device = deviceManager.Devices.Find(deviceName);
                    if (device == null)
                        throw new System.ApplicationException(string.Format("Device '{0}' is not found.", deviceName));
    
                    // disable device UI
                    device.ShowUI = false;
                    // specify that device must be closed after scan
                    device.DisableAfterAcquire = true;
    
                    // open the device
                    device.Open();
                    // specify that 2 images must be acquired from scanner
                    device.XferCount = 2;
    
                    // run asynchronous image acquisition
                    Vintasoft.Twain.AcquireModalState acquireModalState = Vintasoft.Twain.AcquireModalState.None;
                    do
                    {
                        acquireModalState = device.AcquireModal();
                        switch (acquireModalState)
                        {
                            case Vintasoft.Twain.AcquireModalState.ImageAcquired:
                                System.Console.WriteLine("Image is acquired.");
                                if (device.AcquiredImage != null)
                                    device.AcquiredImage.Dispose();
    
                                imageCount++;
    
                                // stop the feeder
                                device.StopFeeder();
                                break;
    
                            case Vintasoft.Twain.AcquireModalState.ScanCompleted:
                                System.Console.WriteLine("Scan is completed.");
                                break;
    
                            case Vintasoft.Twain.AcquireModalState.ScanCanceled:
                                System.Console.WriteLine("Scan is canceled.");
                                break;
    
                            case Vintasoft.Twain.AcquireModalState.ScanFailed:
                                System.Console.WriteLine(string.Format("Scan is failed: {0}.", device.ErrorString));
                                break;
                        }
                    }
                    while (acquireModalState != Vintasoft.Twain.AcquireModalState.None);
    
                    if (imageCount != 1)
                        throw new System.ApplicationException("Wrong acquired image count.");
    
                    if (device.State != Vintasoft.Twain.DeviceState.TransferReady)
                        throw new System.ApplicationException("Feeder is NOT stopped.");
                    System.Console.WriteLine("Feeder is stopped.");
    
                    // continue asynchronous image acquisition
                    do
                    {
                        acquireModalState = device.AcquireModal();
                        switch (acquireModalState)
                        {
                            case Vintasoft.Twain.AcquireModalState.ImageAcquired:
                                System.Console.WriteLine("Image is acquired.");
    
                                if (device.AcquiredImage != null)
                                    device.AcquiredImage.Dispose();
    
                                imageCount++;
                                break;
    
                            case Vintasoft.Twain.AcquireModalState.ScanCompleted:
                                System.Console.WriteLine("Scan is completed.");
                                break;
    
                            case Vintasoft.Twain.AcquireModalState.ScanCanceled:
                                System.Console.WriteLine("Scan is canceled.");
                                break;
    
                            case Vintasoft.Twain.AcquireModalState.ScanFailed:
                                System.Console.WriteLine(string.Format("Scan is failed: {0}.", device.ErrorString));
                                break;
                        }
                    }
                    while (acquireModalState != Vintasoft.Twain.AcquireModalState.None);
    
                    if (imageCount != 2)
                        throw new System.ApplicationException("Wrong acquired image count.");
    
                    // close the device
                    device.Close();
                }
            }
    
        }
    }
    
    

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также