VintaSoft Twain .NET SDK 15.3: Руководство для .NET разработчика
Vintasoft.Twain Namespace / DeviceCapabilityCollection Class / Add(UInt16) Method
Синтаксис Exceptions Ремарки Example Требования Смотрите также
В этом разделе
    Add(UInt16) Метод (DeviceCapabilityCollection)
    В этом разделе
    Adds the "custom" capability to the list of capabilities.
    Синтаксис
    '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.
    Исключения
    ИсключениеОписание
    Thrown if the capability with specified identifier exists already.
    Ремарки

    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.

    Пример

    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));
        }
    }
    
    

    Требования

    Целевые платформы: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также