VintaSoft Twain .NET SDK v10.2
ImageAcquiringProgressValue Property (Device)
Example 




Vintasoft.WpfTwain Namespace > Device Class : ImageAcquiringProgressValue Property
Gets the progress, in percents, of synchronous image acquisition process.
Syntax
'Declaration
 
<ReadOnlyAttribute(True)>
<BrowsableAttribute(False)>
Public ReadOnly Property ImageAcquiringProgressValue As Integer
'Usage
 
Dim instance As Device
Dim value As Integer
 
value = instance.ImageAcquiringProgressValue
[ReadOnly(true)]
[Browsable(false)]
public int ImageAcquiringProgressValue {get;}
[ReadOnly(true)]
[Browsable(false)]
public: __property int get_ImageAcquiringProgressValue();
[ReadOnly(true)]
[Browsable(false)]
public:
property int ImageAcquiringProgressValue {
   int get();
}
Remarks
Use this property only with the AcquireModal method.
Example
This example shows how to synchronously acquire images from the device.
Public Shared Sub AcquireImageModal()
    Try
        ' create the device manager
        Using deviceManager As New DeviceManager()
            ' open the device manager
            deviceManager.Open()
            
            ' get reference to the default device
            Dim device As Device = deviceManager.DefaultDevice
            
            device.ShowUI = False
            device.DisableAfterAcquire = True
            
            ' open the device
            device.Open()
            
            ' set acquisition parameters
            device.TransferMode = TransferMode.Memory
            device.PixelType = PixelType.BW
            
            ' create directory for TIFF file
            Dim directoryForImages As String = Path.GetDirectoryName(Directory.GetCurrentDirectory())
            directoryForImages = Path.Combine(directoryForImages, "Images")
            If Not Directory.Exists(directoryForImages) Then
                Directory.CreateDirectory(directoryForImages)
            End If
            
            Dim multipageTiffFilename As String = Path.Combine(directoryForImages, "multipage.tif")
            
            ' acquire image(s) from the device
            Dim acquireModalState1 As AcquireModalState = AcquireModalState.None
            Dim imageIndex As Integer = 0
            Do
                acquireModalState1 = device.AcquireModal()
                Select Case acquireModalState1
                    Case AcquireModalState.ImageAcquiring
                        ' output current state
                        Console.Write(String.Format("Image is acquiring ", System.Math.Max(System.Threading.Interlocked.Increment(imageIndex), imageIndex - 1)))
                        Exit Select
            
                    Case AcquireModalState.ImageAcquiringProgress
                        ' output current state
                        Console.Write(String.Format("{0}% ", device.ImageAcquiringProgressValue))
                        Exit Select
            
                    Case AcquireModalState.ImageAcquired
                        ' save the acquired image to a file
                        device.AcquiredImage.Save(multipageTiffFilename)
                        ' dispose the acquired image
                        device.AcquiredImage.Dispose()
                        ' output current state
                        Console.WriteLine(String.Format("Image{0} is saved.", System.Math.Max(System.Threading.Interlocked.Increment(imageIndex), imageIndex - 1)))
                        Exit Select
            
                    Case AcquireModalState.ScanCompleted
                        ' output current state
                        Console.WriteLine("Scan is completed.")
                        Exit Select
            
                    Case AcquireModalState.ScanCanceled
                        ' output current state
                        Console.WriteLine("Scan is canceled.")
                        Exit Select
            
                    Case AcquireModalState.ScanFailed
                        ' output current state
                        Console.WriteLine(String.Format("Scan is failed: {0}", device.ErrorString))
                        Exit Select
                End Select
            Loop While acquireModalState1 <> AcquireModalState.None
            
            ' close the device
            device.Close()
            
            ' close the device manager
            deviceManager.Close()
        End Using
    Catch ex As TwainException
        Console.WriteLine("Error: " + ex.Message)
    End Try
End Sub
public static void AcquireImageModal()
{
    try
    {
        // create the device manager
        using (DeviceManager deviceManager = new DeviceManager())
        {
            // open the device manager
            deviceManager.Open();
            
            // get reference to the default device
            Device device = deviceManager.DefaultDevice;
            
            device.ShowUI = false;
            device.DisableAfterAcquire = true;
            
            // open the device
            device.Open();
            
            // set acquisition parameters
            device.TransferMode = TransferMode.Memory;
            device.PixelType = PixelType.BW;
            
            // create directory for TIFF file
            string directoryForImages = Path.GetDirectoryName(Directory.GetCurrentDirectory());
            directoryForImages = Path.Combine(directoryForImages, "Images");
            if (!Directory.Exists(directoryForImages))
                Directory.CreateDirectory(directoryForImages);
            
            string multipageTiffFilename = Path.Combine(directoryForImages, "multipage.tif");
            
            // acquire image(s) from the device
            AcquireModalState acquireModalState = AcquireModalState.None;
            int imageIndex = 0;
            do
            {
                acquireModalState = device.AcquireModal();
                switch (acquireModalState)
                {
                    case AcquireModalState.ImageAcquiring:
                        // output current state
                        Console.Write(string.Format("Image is acquiring ", imageIndex++));
                        break;
            
                    case AcquireModalState.ImageAcquiringProgress:
                        // output current state
                        Console.Write(string.Format("{0}% ", device.ImageAcquiringProgressValue));
                        break;
            
                    case AcquireModalState.ImageAcquired:
                        // save the acquired image to a file
                        device.AcquiredImage.Save(multipageTiffFilename);
                        // dispose the acquired image
                        device.AcquiredImage.Dispose();
                        // output current state
                        Console.WriteLine(string.Format("Image{0} is saved.", imageIndex++));
                        break;
            
                    case AcquireModalState.ScanCompleted:
                        // output current state
                        Console.WriteLine("Scan is completed.");
                        break;
            
                    case AcquireModalState.ScanCanceled:
                        // output current state
                        Console.WriteLine("Scan is canceled.");
                        break;
            
                    case AcquireModalState.ScanFailed:
                        // output current state
                        Console.WriteLine(string.Format("Scan is failed: {0}", device.ErrorString));
                        break;
                }
            }
            while (acquireModalState != AcquireModalState.None);
            
            // close the device
            device.Close();
            
            // close the device manager
            deviceManager.Close();
        }
    }
    catch (TwainException ex)
    {
        Console.WriteLine("Error: " + ex.Message);
    }
}
Requirements

Target Platforms: Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

See Also

Reference

Device Class
Device Members
AcquireModal Method