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

Glossary Item Box

The ImGearIsisScanner.ShowUIAsync method can be used to show a configuration dialog for the scanner, as demonstrated below:

C# Example Copy Code
            m_ScannerSession.Scanner.ShowUIAsync((status) =>
            {
                if (status.Status != ImGearIsisStatus.Completed)
                {
                    MessageBox.Show(status.StatusMessage);
                    return;
                }
            });

 

VB.NET Example Copy Code
        m_ScannerSession.Scanner.ShowUIAsync(
            Function(status)
                If status.Status <> ImGearIsisStatus.Completed Then
                    MessageBox.Show(status.StatusMessage)
                End If
 
                Return Nothing
 
            End Function)

The GetTagAsync method can be used to get the value of an ISIS tag and the SetTagAsync method can be used to set the value of an ISIS tag, as demonstrated below:

C# Example Copy Code
            // Get the page size tag options and add them to a combo box.
            // Select the current value in the combo box.
            m_ScannerSession.Scanner.GetTagAsync(ImGearIsisTag.PageSize, 0,
                (tagId, tagType, tagChoice, tagValue, status) =>
                {
                    comboBoxPageSize.ItemsSource = tagChoice.StringList;
                    comboBoxPageSize.SelectedItem = tagValue.StringValue;
                });
 
            // Get the X resolution tag options and add them to a combo box.
            // Select the current value in the combo box.
            m_ScannerSession.Scanner.GetTagAsync(ImGearIsisTag.XResolution, 0,
                (tagId, tagType, tagChoice, tagValue, status) =>
                {
                    if (tagChoice.ChoiceKind == ImGearIsisChoiceKind.List)
                    {
                        string[] stringList = new string[tagChoice.IntegerList.Count];
                        int i = 0;
                        foreach (int num in tagChoice.IntegerList)
                        {
                            stringList[i] = tagChoice.IntegerList[i].ToString() + "/" + tagChoice.RationalDenominatorList[i].ToString();
                            i++;
                        }
                        comboBoxResolution.ItemsSource = stringList;
                        comboBoxResolution.SelectedItem = tagValue.IntegerValue.ToString() + "/" + tagValue.DenominatorValue.ToString();
                    }
                    else if (tagChoice.ChoiceKind == ImGearIsisChoiceKind.Range)
                    {
                        System.Collections.Generic.List<string> stringList = new List<string>();
                        for (int i = tagChoice.MinValue; i <= tagChoice.MaxValue; i = i + tagChoice.StepValue)
                        {
                            stringList.Add(i.ToString() + "/" + tagChoice.StepDenominatorValue.ToString());
                        }
                        comboBoxResolution.ItemsSource = stringList;
                        comboBoxResolution.SelectedItem = tagValue.IntegerValue.ToString() + "/" + tagValue.DenominatorValue.ToString();
                    }
                });

 

VB.NET Example Copy Code
        ' Get the page size tag options and add them to a combo box.
        ' Select the current value in the combo box.
        m_ScannerSession.Scanner.GetTagAsync(
            ImGearIsisTag.PageSize,
            0,
            Function(tagId, tagType, tagChoice, tagValue, status)
                comboBoxPageSize.ItemsSource = tagChoice.StringList
                comboBoxPageSize.SelectedItem = tagValue.StringValue
 
                Return Nothing
 
            End Function)
 
        ' Get the X resolution tag options and add them to a combo box.
        ' Select the current value in the combo box.
        m_ScannerSession.Scanner.GetTagAsync(
            ImGearIsisTag.XResolution,
            0,
            Function(tagId, tagType, tagChoice, tagValue, status)
                If tagChoice.ChoiceKind = ImGearIsisChoiceKind.List Then
                    Dim stringList As String() = New String(tagChoice.IntegerList.Count - 1) {}
                    Dim i As Integer = 0
                    For Each num As Integer In tagChoice.IntegerList
                        stringList(i) = tagChoice.IntegerList(i).ToString() & "/" & tagChoice.RationalDenominatorList(i).ToString()
                        i += 1
                    Next
                    comboBoxResolution.ItemsSource = stringList
                    comboBoxResolution.SelectedItem = tagValue.IntegerValue.ToString() & "/" & tagValue.DenominatorValue.ToString()
                ElseIf tagChoice.ChoiceKind = ImGearIsisChoiceKind.Range Then
                    Dim stringList As System.Collections.Generic.List(Of String) = New List(Of String)()
                    Dim i As Integer = tagChoice.MinValue
                    While i <= tagChoice.MaxValue
                        stringList.Add(i.ToString() & "/" & tagChoice.StepDenominatorValue.ToString())
                        i = i + tagChoice.StepValue
                    End While
                    comboBoxResolution.ItemsSource = stringList
                    comboBoxResolution.SelectedItem = tagValue.IntegerValue.ToString() & "/" & tagValue.DenominatorValue.ToString()
                End If
 
                Return Nothing
 
            End Function)

 

C# Example Copy Code
        // In the combo box selection changed event, call SetTagAsync to set the selected tag value.
        private void comboBoxPageSize_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxPageSize.SelectedItem != null)
            {
                string tagValue = comboBoxPageSize.SelectedValue as string;
                m_ScannerSession.Scanner.SetTagAsync(ImGearIsisTag.PageSize, tagValue,
                    (status) =>
                    {
                        if (status.Status != ImGearIsisStatus.Completed)
                            MessageBox.Show(status.StatusMessage);
                    });
            }
        }
 
        private void comboBoxResolution_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (comboBoxResolution.SelectedItem != null)
            {
                string rationalString = (string)comboBoxResolution.SelectedItem;
                string[] splitRational = rationalString.Split('/');
                m_ScannerSession.Scanner.SetTagAsync(ImGearIsisTag.XResolution, Convert.ToInt32(splitRational[0]), Convert.ToInt32(splitRational[1]), 0, (status) =>
                {
                    if (status.Status != ImGearIsisStatus.Completed)
                        MessageBox.Show(status.StatusMessage);
                });
            }
        }

 

VB.NET Example Copy Code
    Private Sub comboBoxPageSize_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles comboBoxPageSize.SelectionChanged
        If comboBoxPageSize.SelectedItem IsNot Nothing Then
            Dim tagValue As String = TryCast(comboBoxPageSize.SelectedValue, String)
            m_ScannerSession.Scanner.SetTagAsync(
                ImGearIsisTag.PageSize,
                tagValue,
                Function(status)
                    If status.Status <> ImGearIsisStatus.Completed Then
                        MessageBox.Show(status.StatusMessage)
                    End If
 
                    Return Nothing
 
                End Function)
        End If
    End Sub
 
    Private Sub comboBoxResolution_SelectionChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.SelectionChangedEventArgs) Handles comboBoxResolution.SelectionChanged
        If comboBoxResolution.SelectedItem IsNot Nothing Then
            Dim rationalString As String = DirectCast(comboBoxResolution.SelectedItem, String)
            Dim splitRational As String() = rationalString.Split("/"c)
            m_ScannerSession.Scanner.SetTagAsync(
                ImGearIsisTag.XResolution,
                Convert.ToInt32(splitRational(0)),
                Convert.ToInt32(splitRational(1)),
                0,
                Function(status)
                    If status.Status <> ImGearIsisStatus.Completed Then
                        MessageBox.Show(status.StatusMessage)
                    End If
 
                    Return Nothing
 
                End Function)
        End If
    End Sub

To get or set all of the ISIS tag settings you can use the GetAllTagsAsync and SetAllTagsAsync methods, as demonstrated below:

C# Example Copy Code
            // Get all tag settings and save them to isolated storage.
            m_ScannerSession.Scanner.GetAllTagsAsync((settings, status) =>
            {
                if (status.Status != ImGearIsisStatus.Completed)
                    MessageBox.Show(status.StatusMessage);
                System.IO.IsolatedStorage.IsolatedStorageFile isoStore = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
                System.IO.StreamWriter writer = new System.IO.StreamWriter(isoStore.OpenFile("tags.txt", System.IO.FileMode.OpenOrCreate));
                writer.Write(settings);
                writer.Close();
            });

 

VB.NET Example Copy Code
        ' Get all tag settings and save them to isolated storage.
        m_ScannerSession.Scanner.GetAllTagsAsync(
            Function(settings, status)
                If status.Status <> ImGearIsisStatus.Completed Then
                    MessageBox.Show(status.StatusMessage)
                End If
                Dim isoStore As System.IO.IsolatedStorage.IsolatedStorageFile = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()
                Dim writer As New System.IO.StreamWriter(isoStore.OpenFile("tags.txt", System.IO.FileMode.OpenOrCreate))
                writer.Write(settings)
                writer.Close()
 
                Return Nothing
 
            End Function)

 

C# Example Copy Code
            string settings = "";
 
            // Check if tag settings were stored in isolated storage.
            try
            {
                System.IO.IsolatedStorage.IsolatedStorageFile isoStore = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication();
                if (isoStore.FileExists("tags.txt") == false)
                {
                    MessageBox.Show("Stored tag file does not exist.");
                    return;
                }
                System.IO.StreamReader reader = new System.IO.StreamReader(isoStore.OpenFile("tags.txt", System.IO.FileMode.Open));
                settings = reader.ReadToEnd();
                reader.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
 
            // Set the tag settings.
            m_ScannerSession.Scanner.SetAllTagsAsync(settings, (status) =>
            {
                if (status.Status != ImGearIsisStatus.Completed)
                    MessageBox.Show(status.StatusMessage);
            });

 

VB.NET Example Copy Code
        Dim settings As String = ""
 
        ' Check if tag settings were stored in isolated storage.
        Try
            Dim isoStore As System.IO.IsolatedStorage.IsolatedStorageFile = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication()
            If isoStore.FileExists("tags.txt") = False Then
                MessageBox.Show("Stored tag file does not exist.")
                Return
            End If
            Dim reader As New System.IO.StreamReader(isoStore.OpenFile("tags.txt", System.IO.FileMode.Open))
            settings = reader.ReadToEnd()
            reader.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            Return
        End Try
 
        ' Set the tag settings.
        m_ScannerSession.Scanner.SetAllTagsAsync(
            settings,
            Function(status)
                If status.Status <> ImGearIsisStatus.Completed Then
                    MessageBox.Show(status.StatusMessage)
                End If
 
                Return Nothing
 
            End Function)
©2013. Accusoft Corporation. All Rights Reserved.