JobControl Свойство (Device)
В этом разделе
Разрешает несколько заданий в пакетном режиме.
Синтаксис
Исключения
Ремарки
Вызывайте это свойство только при открытии устройства (State == DeviceState.Opened).
Поддерживаемые значения яркости можно получить с помощью метода GetSupportedJobControlValues.
Пример
Вот C#/VB.NET код, который демонстрирует, как обнаружить разделители заданий во время сканирования.
Private _deviceManager As Vintasoft.Twain.DeviceManager
Private _device As Vintasoft.Twain.Device
Private _jobCounter As Integer = -1
Public Sub ScanImageWithJobControl()
Try
' create and open device manager
_deviceManager = New Vintasoft.Twain.DeviceManager()
_deviceManager.Open()
' get reference to the default device
_device = _deviceManager.DefaultDevice
' subscribe to device events
AddHandler _device.ImageAcquired, New System.EventHandler(Of Vintasoft.Twain.ImageAcquiredEventArgs)(AddressOf _device1_ImageAcquired)
AddHandler _device.ScanCompleted, New System.EventHandler(AddressOf _device1_ScanCompleted)
AddHandler _device.ScanCanceled, New System.EventHandler(AddressOf _device1_ScanCanceled)
AddHandler _device.ScanFailed, New System.EventHandler(Of Vintasoft.Twain.ScanFailedEventArgs)(AddressOf _device1_ScanFailed)
AddHandler _device.ScanFinished, New System.EventHandler(AddressOf _device_ScanFinished)
_device.ShowUI = False
_device.DisableAfterAcquire = True
' open the device
_device.Open()
' set scanning settings
_device.JobControl = Vintasoft.Twain.JobControl.DetectAndIncludeJobSeparatorAndContinueScanning
_jobCounter = _jobCounter + 1
' acquire images from device
_device.Acquire()
Catch ex As Vintasoft.Twain.TwainException
System.Console.WriteLine(ex.Message)
End Try
End Sub
Private Sub _device1_ImageAcquired(sender As Object, e As Vintasoft.Twain.ImageAcquiredEventArgs)
If _device.EndOfJob Then
_jobCounter = _jobCounter + 1
Else
Try
' save the acquired image
e.Image.Save(String.Format("c:\job{0}.tif", _jobCounter))
' dispose the acquired image
e.Image.Dispose()
Catch ex As System.Exception
System.Console.WriteLine(ex.Message)
End Try
End If
End Sub
Private Sub _device1_ScanCompleted(sender As Object, e As System.EventArgs)
System.Console.WriteLine("Scan is completed.")
End Sub
Private Sub _device1_ScanCanceled(sender As Object, e As System.EventArgs)
System.Console.WriteLine("Scan is canceled.")
End Sub
Private Sub _device1_ScanFailed(sender As Object, e As Vintasoft.Twain.ScanFailedEventArgs)
System.Console.WriteLine(String.Format("Scan is failed: {0}", e.ErrorString))
End Sub
Private Sub _device_ScanFinished(sender As Object, e As System.EventArgs)
' close the device
_device.Close()
End Sub
Vintasoft.Twain.DeviceManager _deviceManager;
Vintasoft.Twain.Device _device;
int _jobCounter = -1;
public void ScanImageWithJobControl()
{
try
{
// create and open device manager
_deviceManager = new Vintasoft.Twain.DeviceManager();
_deviceManager.Open();
// get reference to the default device
_device = _deviceManager.DefaultDevice;
// subscribe to device events
_device.ImageAcquired += new System.EventHandler<Vintasoft.Twain.ImageAcquiredEventArgs>(_device1_ImageAcquired);
_device.ScanCompleted += new System.EventHandler(_device1_ScanCompleted);
_device.ScanCanceled += new System.EventHandler(_device1_ScanCanceled);
_device.ScanFailed += new System.EventHandler<Vintasoft.Twain.ScanFailedEventArgs>(_device1_ScanFailed);
_device.ScanFinished += new System.EventHandler(_device_ScanFinished);
_device.ShowUI = false;
_device.DisableAfterAcquire = true;
// open the device
_device.Open();
// set scanning settings
_device.JobControl = Vintasoft.Twain.JobControl.DetectAndIncludeJobSeparatorAndContinueScanning;
_jobCounter = _jobCounter + 1;
// acquire images from device
_device.Acquire();
}
catch (Vintasoft.Twain.TwainException ex)
{
System.Console.WriteLine(ex.Message);
}
}
private void _device1_ImageAcquired(object sender, Vintasoft.Twain.ImageAcquiredEventArgs e)
{
if (_device.EndOfJob)
_jobCounter = _jobCounter + 1;
else
{
try
{
// save the acquired image
e.Image.Save(string.Format(@"c:\job{0}.tif", _jobCounter));
// dispose the acquired image
e.Image.Dispose();
}
catch (System.Exception ex)
{
System.Console.WriteLine(ex.Message);
}
}
}
private void _device1_ScanCompleted(object sender, System.EventArgs e)
{
System.Console.WriteLine("Scan is completed.");
}
private void _device1_ScanCanceled(object sender, System.EventArgs e)
{
System.Console.WriteLine("Scan is canceled.");
}
private void _device1_ScanFailed(object sender, Vintasoft.Twain.ScanFailedEventArgs e)
{
System.Console.WriteLine(string.Format("Scan is failed: {0}", e.ErrorString));
}
void _device_ScanFinished(object sender, System.EventArgs e)
{
// 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
Смотрите также