VintaSoft Twain .NET SDK 14.1: Documentation for .NET developer
Vintasoft.Twain Namespace / DeviceCapabilityCollection Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    DeviceCapabilityCollection Class
    In This Topic
    Class that represents a collection of capabilities supported by device.
    Object Model
    DeviceCapability DeviceCapabilityCollection
    Syntax
    'Declaration
    
    <DefaultMemberAttribute("Item")>
    Public NotInheritable Class DeviceCapabilityCollection
       Inherits System.Collections.ReadOnlyCollectionBase
    
    
    [DefaultMember("Item")]
    public sealed class DeviceCapabilityCollection : System.Collections.ReadOnlyCollectionBase
    
    
    [DefaultMember("Item")]
    public __gc __sealed class DeviceCapabilityCollection : public System.Collections.ReadOnlyCollectionBase*
    
    
    [DefaultMember("Item")]
    public ref class DeviceCapabilityCollection sealed : public System.Collections.ReadOnlyCollectionBase^
    
    
    Example

    This C#/VB.NET code shows how to get information about all pixel types supported by the device.

    
    Private Shared Sub GetPixelTypesInfo()
        Using deviceManager As New Vintasoft.Twain.DeviceManager()
            ' open the device manager
            deviceManager.Open()
    
            ' get reference to the deafult device
            Dim device As Vintasoft.Twain.Device = deviceManager.DefaultDevice
    
            ' open the device
            device.Open()
    
            ' get reference to object that manipulates IPixelType capability
            Dim pixelTypeCap As Vintasoft.Twain.DeviceCapability = device.Capabilities.Find(Vintasoft.Twain.DeviceCapabilityId.IPixelType)
            ' if IPixelType capability supported
            If pixelTypeCap IsNot Nothing Then
                ' get information about current, default and supported values of capability
                Dim capValue As Vintasoft.Twain.TwainValueContainerBase = pixelTypeCap.GetValue()
    
                Select Case capValue.ContainerType
                    Case Vintasoft.Twain.TwainValueContainerType.[Enum]
                        Dim capValueAsEnum As Vintasoft.Twain.TwainEnumValueContainer = DirectCast(capValue, Vintasoft.Twain.TwainEnumValueContainer)
                        Dim enumValues As Array = capValueAsEnum.EnumValues
    
                        ' output the capability values in human readable format
                        Console.WriteLine(String.Format("Current pixel type: {0}", enumValues.GetValue(capValueAsEnum.ValueIndex)))
                        Console.WriteLine(String.Format("Default pixel type: {0}", enumValues.GetValue(capValueAsEnum.DefaultValueIndex)))
                        Console.Write("Supported pixel types:")
                        For i As Integer = 0 To enumValues.Length - 1
                            Console.Write(String.Format(" {0}", enumValues.GetValue(i)))
                        Next
                        Exit Select
                End Select
    
                Console.WriteLine()
            End If
    
            ' close the device
            device.Close()
    
            ' close the device manager
            deviceManager.Close()
        End Using
    End Sub
    
    
    
    private static void GetPixelTypesInfo()
    {
        using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
        {
            // open the device manager
            deviceManager.Open();
    
            // get reference to the deafult device
            Vintasoft.Twain.Device device = deviceManager.DefaultDevice;
            
            // open the device
            device.Open();
    
            // get reference to object that manipulates IPixelType capability
            Vintasoft.Twain.DeviceCapability pixelTypeCap = device.Capabilities.Find(Vintasoft.Twain.DeviceCapabilityId.IPixelType);
            // if IPixelType capability supported
            if (pixelTypeCap != null)
            {
                // get information about current, default and supported values of capability
                Vintasoft.Twain.TwainValueContainerBase capValue = pixelTypeCap.GetValue();
    
                switch (capValue.ContainerType)
                {
                    case Vintasoft.Twain.TwainValueContainerType.Enum:
                        Vintasoft.Twain.TwainEnumValueContainer capValueAsEnum = (Vintasoft.Twain.TwainEnumValueContainer)capValue;
                        System.Array enumValues = capValueAsEnum.EnumValues;
    
                        // output the capability values in human readable format
                        System.Console.WriteLine(string.Format("Current pixel type: {0}", enumValues.GetValue(capValueAsEnum.ValueIndex)));
                        System.Console.WriteLine(string.Format("Default pixel type: {0}", enumValues.GetValue(capValueAsEnum.DefaultValueIndex)));
                        System.Console.Write("Supported pixel types:");
                        for (int i = 0; i < enumValues.Length; i++)
                            System.Console.Write(string.Format(" {0}", enumValues.GetValue(i)));
                        break;
                }
    
                System.Console.WriteLine();
            }
    
            // close the device
            device.Close();
    
            // close the device manager
            deviceManager.Close();
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       System.Collections.ReadOnlyCollectionBase
          Vintasoft.Twain.DeviceCapabilityCollection

    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