VintaSoft Twain .NET SDK 15.0: Documentation for .NET developer
Vintasoft.WpfTwain Namespace / DeviceCapabilityCollection Class / Add(UInt16) Method
Syntax Exceptions Remarks Example Requirements SeeAlso
In This Topic
    Add(UInt16) Method (DeviceCapabilityCollection)
    In This Topic
    Adds the "custom" capability to the list of capabilities.
    Syntax
    'Declaration
    
    Public Sub Add( _
    ByVal id
    An identifier of capability.
    As UShort _
    )
    public void Add(
    ushort id
    )
    public: void Add(
    ushort id
    )
    public:
    void Add(
    ushort id
    )

    Parameters

    id
    An identifier of capability.
    Exceptions
    ExceptionDescription
    Thrown if the capability with specified identifier exists already.
    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 8, .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also