VintaSoft Twain .NET SDK v10.2
Vintasoft.Twain Namespace / DeviceCapabilityCollection Class
Members Example




In This Topic
    DeviceCapabilityCollection Class
    In This Topic
    Class that represents a collection of capabilities supported by device.
    Object Model
    DeviceCapabilityCollection ClassDeviceCapability Class
    Syntax
    'Declaration
     
    <DefaultMemberAttribute("Item")>
    Public NotInheritable Class DeviceCapabilityCollection 
       Inherits System.Collections.ReadOnlyCollectionBase
    'Usage
     
    Dim instance As DeviceCapabilityCollection
    [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 example shows how to get information about all pixel types supported by the device.
    Private Shared Sub GetPixelTypesInfo()
        Using deviceManager As New DeviceManager()
            ' open the device manager
            deviceManager.Open()
                
            ' get reference to the deafult device
            Dim device As Device = deviceManager.DefaultDevice
                
            ' open the device
            device.Open()
                
            ' get reference to object that manipulates IPixelType capability
            Dim pixelTypeCap As DeviceCapability = device.Capabilities.Find(DeviceCapabilityId.IPixelType)
            ' if IPixelType capability supported
            If pixelTypeCap IsNot Nothing Then
                ' get information about current, default and supported values of capability
                Dim capValue As TwainValueContainerBase = pixelTypeCap.GetValue()
                
                Select Case capValue.ContainerType
                    Case TwainValueContainerType.[Enum]
                        Dim capValueAsEnum As TwainEnumValueContainer = DirectCast(capValue, 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 (DeviceManager deviceManager = new DeviceManager())
        {
            // open the device manager
            deviceManager.Open();
                
            // get reference to the deafult device
            Device device = deviceManager.DefaultDevice;
            
            // open the device
            device.Open();
                
            // get reference to object that manipulates IPixelType capability
            DeviceCapability pixelTypeCap = device.Capabilities.Find(DeviceCapabilityId.IPixelType);
            // if IPixelType capability supported
            if (pixelTypeCap != null)
            {
                // get information about current, default and supported values of capability
                TwainValueContainerBase capValue = pixelTypeCap.GetValue();
                
                switch (capValue.ContainerType)
                {
                    case TwainValueContainerType.Enum:
                        TwainEnumValueContainer capValueAsEnum = (TwainEnumValueContainer)capValue;
                        Array enumValues = 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 (int i = 0; i < enumValues.Length; i++)
                            Console.Write(string.Format(" {0}", enumValues.GetValue(i)));
                        break;
                }
                
                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: Windows 8, Windows 7, Windows Vista, Windows XP, Windows Server 2012, Windows Server 2008, Windows Server 2003

    See Also