''' <summary>
''' Displays information about all options of SANE device.
''' </summary>
Public Sub DisplayInformationAboutAllOptionsOfSaneDevice()
' create SANE device manager
Using deviceManager As New Vintasoft.Sane.SaneLocalDeviceManager()
' open SANE device manager
deviceManager.Open()
' get count of SANE devices
Dim deviceCount As Integer = deviceManager.Devices.Count
If deviceCount = 0 Then
System.Console.WriteLine("Devices are not found.")
Return
End If
' select the first SANE device
Dim device As Vintasoft.Sane.SaneLocalDevice = deviceManager.Devices(0)
' open SANE device
device.Open()
System.Console.WriteLine("Device name: " + device.Name)
' for each option of SANE device
For Each [option] As Vintasoft.Sane.SaneLocalDeviceOption In device.Options
System.Console.WriteLine(String.Format("- Option Name='{0}', Title='{1}', Description='{2}', Type={3}, Unit={4}, ValueSize={5}, CanSet={6}, CanBeAutomatic={7}, IsActive={8}, Capabilities={9}", [option].Name, [option].Title, [option].Description, [option].Type, [option].Unit, _
[option].ValueSize, [option].CanSet, [option].CanBeAutomatic, [option].IsActive, [option].Capabilities))
Dim value As Object
Try
value = [option].GetValue()
System.Console.WriteLine(String.Format(" DefaultValue={0}", value))
Catch ex As System.Exception
System.Console.WriteLine(" Cannot get the default value: " & ex.Message)
Continue For
End Try
Select Case [option].Type
Case Vintasoft.Sane.SaneType.[Integer]
Dim supportedIntValues As Object = [option].GetSupportedValues()
If supportedIntValues Is Nothing Then
System.Console.WriteLine(" Supported values are not limited.")
Else
If TypeOf supportedIntValues Is Vintasoft.Sane.SaneIntArray Then
Dim array As Vintasoft.Sane.SaneIntArray = DirectCast(supportedIntValues, Vintasoft.Sane.SaneIntArray)
System.Console.Write(" Supported values: ")
For i As Integer = 0 To array.Values.Length - 1
System.Console.Write(array.Values(i) + " ")
Next
System.Console.WriteLine()
Else
Dim range As Vintasoft.Sane.SaneIntRange = TryCast(supportedIntValues, Vintasoft.Sane.SaneIntRange)
System.Console.WriteLine(((" Supported range: Min=" + range.Min & ", Max=") + range.Max & ", Step=") + range.[Step])
End If
End If
Exit Select
Case Vintasoft.Sane.SaneType.Fixed
Dim supportedFixedValues As Object = [option].GetSupportedValues()
If supportedFixedValues Is Nothing Then
System.Console.WriteLine(" Supported values are not limited.")
Else
If TypeOf supportedFixedValues Is Vintasoft.Sane.SaneFixedArray Then
Dim array As Vintasoft.Sane.SaneFixedArray = DirectCast(supportedFixedValues, Vintasoft.Sane.SaneFixedArray)
System.Console.Write(" Supported values: ")
For i As Integer = 0 To array.Values.Length - 1
System.Console.Write(array.Values(i) + " ")
Next
System.Console.WriteLine()
Else
Dim range As Vintasoft.Sane.SaneFixedRange = TryCast(supportedFixedValues, Vintasoft.Sane.SaneFixedRange)
System.Console.WriteLine(((" Supported range: Min=" + range.Min & ", Max=") + range.Max & ", Step=") + range.[Step])
End If
End If
Exit Select
Case Vintasoft.Sane.SaneType.[String]
Dim supportedStringValues As Object = [option].GetSupportedValues()
If supportedStringValues Is Nothing Then
System.Console.WriteLine(" Supported values are not limited.")
Else
Dim array As Vintasoft.Sane.SaneStringArray = TryCast(supportedStringValues, Vintasoft.Sane.SaneStringArray)
If array IsNot Nothing Then
System.Console.Write(" Supported values: ")
For i As Integer = 0 To array.Values.Length - 1
System.Console.Write(String.Format("'{0}' ", array.Values(i)))
Next
System.Console.WriteLine()
End If
End If
Exit Select
End Select
Next
' close SANE device
device.Close()
' close SANE device manager
deviceManager.Close()
End Using
System.Console.ReadLine()
End Sub