ImageGear for Silverlight
Scanner Selection
Send Feedback
ImageGear for Silverlight User Guide > Using ImageGear for Silverlight > Using ImageGear.Isis Namespace > Scanner Selection

Glossary Item Box

A scanner must first be selected by calling the ImGearIsisScannerSession.SetScannerAsync method in order for the ImGearIsisScannerSession.ScanAsync method to work or any of the ImGearIsisScanner methods to work. When a scanner is selected, the ImGearIsisScanner.Selected property returns True. A scanner can be unloaded by calling the UnloadAsync method.

The SetScannerAsync method has two overloads. You can specify a load option for a scanner selection dialog or to specify that the currently selected scanner should be used. This is demonstrated below:

C# Example Copy Code
            // Show the scanner selection dialog with a list of connected drivers.
            m_ScannerSession.SetScannerAsync(ImGearIsisLoadScannerOption.ShowConnectedDriverList, (setScannerStatus) =>
            {
                if (setScannerStatus.Status == ImGearIsisStatus.Completed)
                {
                    buttonScan.IsEnabled = true;
 
                    // Display the name of the selected scanner.
                    labelSelectedScanner.Content = m_ScannerSession.Scanner.Name;
 
                    // You could use the GetTagAsync method or GetAllTagsAsync method here
                    // to get the current scanner settings and display them.
                }
            });

 

VB.NET Example Copy Code
        ' Show the scanner selection dialog with a list of connected drivers.
        m_ScannerSession.SetScannerAsync(
            ImGearIsisLoadScannerOption.ShowConnectedDriverList,
            Function(setScannerStatus)
                If setScannerStatus.Status = ImGearIsisStatus.Completed Then
                    buttonScan.IsEnabled = True
 
                    ' Display the name of the selected scanner.
 
                    ' You could use the GetTagAsync method or GetAllTagsAsync method here
                    ' to get the current scanner settings and display them.
                    labelSelectedScanner.Content = m_ScannerSession.Scanner.Name
                End If
 
                Return Nothing
 
            End Function)

Or you can pass an ImGearIsisScanner object to set the specified scanner. You can get a collection of connected scanners and a collection of undetected scanners by calling the ImGearIsisScannerSession.GetScannersAsync method. This is demonstrated below:

C# Example Copy Code
        private void buttonGetScanners_Click(object sender, RoutedEventArgs e)
        {
            // Get the connected scanners and add them to a list box.
            m_ScannerSession.GetScannersAsync((connected, undetected, status) =>
            {
                if (status.Status != ImGearIsisStatus.Completed)
                {
                    MessageBox.Show(status.StatusMessage);
                    return;
                }
                foreach (ImGearIsisScanner scanner in connected)
                {
                    listBox1.Items.Add(scanner);
                }
 
                // You could also get the undetected scanners.
                //foreach (ImGearIsisScanner scanner in undetected)
                //{
                //    listBox2.Items.Add(scanner);
                //}
                buttonSetConnectedScanner.IsEnabled = true;
            });
       }
 
        private void buttonSetConnectedScanner_Click(object sender, RoutedEventArgs e)
        {
            // Set the scanner that is selected in the connected list.
            if (listBox1.SelectedItem != null)
            {
                m_ScannerSession.SetScannerAsync(listBox1.SelectedItem as ImGearIsisScanner, (status) =>
                {
                    if (status.Status != ImGearIsisStatus.Completed)
                    {
                        MessageBox.Show(status.StatusMessage);
                        return;
                    }
                    buttonScan.IsEnabled = true;
 
                    // Display the name of the selected scanner.
                    labelSelectedScanner.Content = m_ScannerSession.Scanner.Name;
 
                    // You could use the GetTagAsync method or GetAllTagsAsync method here
                    // to get the current scanner settings and display them.
                });
            }
        }


VB.NET Example Copy Code
    Private Sub buttonGetScanners_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button3.Click
        ' Get the connected scanners and add them to a list box.
        m_ScannerSession.GetScannersAsync(
            Function(connected, undetected, status)
                If status.Status <> ImGearIsisStatus.Completed Then
                    MessageBox.Show(status.StatusMessage)
                    Return Nothing
                End If
                For Each scanner As ImGearIsisScanner In connected
                    listBox1.Items.Add(scanner)
                Next
 
                ' You could also get the undetected scanners.
                'foreach (ImGearIsisScanner scanner in undetected)
                '{
                '    listBox2.Items.Add(scanner);
                '}
                buttonSetConnectedScanner.IsEnabled = True
 
                Return Nothing
 
            End Function)
    End Sub
 
    Private Sub buttonSetConnectedScanner_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button4.Click
        ' Set the scanner that is selected in the connected list.
        If listBox1.SelectedItem IsNot Nothing Then
            m_ScannerSession.SetScannerAsync(
                TryCast(listBox1.SelectedItem, ImGearIsisScanner),
                Function(status)
                    If status.Status <> ImGearIsisStatus.Completed Then
                        MessageBox.Show(status.StatusMessage)
                        Return Nothing
                    End If
                    buttonScan.IsEnabled = True
 
                    ' Display the name of the selected scanner.
 
                    ' You could use the GetTagAsync method or GetAllTagsAsync method here
                    ' to get the current scanner settings and display them.
                    labelSelectedScanner.Content = m_ScannerSession.Scanner.Name
 
                    Return Nothing
 
                End Function)
        End If
    End Sub

 

©2013. Accusoft Corporation. All Rights Reserved.