Add(UInt16) Method (DeviceCapabilityCollection)
In This Topic
Adds the "custom" capability to the list of capabilities.
Syntax
Parameters
- id
- An identifier of capability.
Exceptions
Remarks
By default device provides the identifiers of supported capabilities and SDK automatically adds all capabilities, which are supported by device, to the capability list.
Some "bad" devices does not provide the identifiers of supported capabilities or provide wrong identifiers of supported capabilities. This method is intended for solving this problem. Use the method only if you really need add capability to the capability list.
Example
This C#/VB.NET code shows how to add the "custom" capability to the list of capabilities.
''' <summary>
''' Adds the "custom" capability to the device capability collection.
''' </summary>
Public Shared Sub AddCustomDeviceCapability(device As Vintasoft.Twain.Device)
' open the device
device.Open()
Dim customCapId As System.UInt16 = 30000
' add the "custom" capability to the device capability collection
device.Capabilities.Add(customCapId)
' get the "custom" capability
Dim cap30000 As Vintasoft.Twain.DeviceCapability = device.Capabilities.Find(customCapId)
Try
' set the current value of "custom" capability to True
cap30000.SetValue(True)
Catch ex As System.Exception
System.Console.WriteLine(String.Format("Error: {0}", ex.Message))
End Try
End Sub
/// <summary>
/// Adds the "custom" capability to the device capability collection.
/// </summary>
public static void AddCustomDeviceCapability(Vintasoft.Twain.Device device)
{
// open the device
device.Open();
System.UInt16 customCapId = 30000;
// add the "custom" capability to the device capability collection
device.Capabilities.Add(customCapId);
// get the "custom" capability
Vintasoft.Twain.DeviceCapability cap30000 = device.Capabilities.Find(customCapId);
try
{
// set the current value of "custom" capability to True
cap30000.SetValue(true);
}
catch (System.Exception ex)
{
System.Console.WriteLine(string.Format("Error: {0}", ex.Message));
}
}
Requirements
Target Platforms: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5
See Also