Upgrading guide from version 8.0 to 8.1
In This Topic
How to upgrade your code from version 8.0 to 8.1
Example 1: This example shows how to get information about supported resolutions of scanner in version 8.0 and 8.1.
Code for version 8.1 is bigger but it is more flexible and gives the developer more opportunities.
Version 8.0 |
Version 8.1 |
Shared Function GetSupportedXResolutions(ByVal device1 As Device) As Single()
' return an array of supported XRes values
GetSupportedXResolutions = device1.GetSupportedHorizontalResolutions
End Function
|
Shared Function GetSupportedXResolutions(ByVal device1 As Device) As Single()
Dim supportedXRes As Single() = Nothing
' get information about current, default and supported values of capability
Dim capValue As DeviceCapabilityValueBase = device1.GetSupportedHorizontalResolutions
Select Case capValue.ContainerType
Case DeviceCapabilityContainerType.Array, _
DeviceCapabilityContainerType.Enum, _
DeviceCapabilityContainerType.OneValue
' get an array of supported XRes values
supportedXRes = capValue.GetAsFloatArray
Case DeviceCapabilityContainerType.Range
Dim capValueAsRange As RangeDeviceCapabilityValue = _
CType(capValue, RangeDeviceCapabilityValue)
' get information about values of range
Dim minXRes As Single = CType(capValueAsRange.MinValue, Fix32).ToFloat
Dim maxXRes As Single = CType(capValueAsRange.MaxValue, Fix32).ToFloat
Dim stepSizeXRes As Single = CType(capValueAsRange.StepSize, Fix32).ToFloat
' calculate number of supported XRes values
Dim supportedXResLen As Integer = Int((maxXRes - minXRes) / stepSizeXRes) + 1
' create an array for supported XRes values
supportedXRes = Array.CreateInstance(GetType(Single), supportedXResLen)
' fill the array of supported XRes values
Dim i As Integer = 0
While (minXRes <= maxXRes) And (i < supportedXResLen)
supportedXRes(i) = minXRes
minXRes = minXRes + stepSizeXRes
i = i + 1
End While
End Select
' return an array of supported XRes values
GetSupportedXResolutions = supportedXRes
End Function
|
Example 2: This example shows how to generate log-file in version 8.0 and 8.1.
Version 8.0 |
Version 8.1 |
Public Shared Sub EnableLogging(ByVal deviceManager As DeviceManager)
deviceManager.Logger = New DeviceManagerLogger("d:\vstwain.log")
deviceManager.Logger.Enabled = True
deviceManager.Logger.LogInfoLevel = LogInfoLevel.Extended
End Sub
|
Public Shared Sub EnableLogging()
TwainEnvironment.EnableDebugging("d:\vstwain.log")
TwainEnvironment.DebugLevel = DebugLevel.Debug
End Sub
|