VintaSoft Twain .NET SDK 15.5: Documentation for .NET developer
In This Topic
How to enable the ultrasonic detection capability of Kodak scanner?
In This Topic
Kodak scanners have many custom capabilities. Detailed information about all custom capabilities of Kodak scanners can be get from Kodak TWAIN Integrator Kit.

Here is an example that demonstrates how to enable the ultrasonic detection capability of Kodak scanner:
using System;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
            try
            {
                using (Vintasoft.Twain.DeviceManager deviceManager =
                    new Vintasoft.Twain.DeviceManager())
                {
                    // open the device manager
                    deviceManager.Open();

                    // select the scanner using the standard device selection dialog
                    deviceManager.ShowDefaultDeviceSelectionDialog();

                    // get reference to the default device
                    Vintasoft.Twain.Device device = deviceManager.DefaultDevice;

                    // open the device
                    device.Open();

                    // if Kodak scanner is used
                    if (device.Info.ProductName.ToUpperInvariant().StartsWith("KODAK"))
                    {
                        // get the Kodak_UltrasonicSensitivity capability
                        Vintasoft.Twain.DeviceCapability kodakUltrasonicDetectionCap =
                            device.Capabilities.Find((ushort)Vintasoft.Twain.KodakDeviceCapabilityId.Kodak_UltrasonicSensitivity);
                        // if capability is supported
                        if (kodakUltrasonicDetectionCap != null)
                        {
                            // print current value of ultrasonic sensitivity
                            PrintKodakUltrasonicDetectionCurrentValue(kodakUltrasonicDetectionCap);

                            // change value of ultrasonic sensitivity to the High
                            kodakUltrasonicDetectionCap.SetValue(3);

                            // print current value of ultrasonic sensitivity
                            PrintKodakUltrasonicDetectionCurrentValue(kodakUltrasonicDetectionCap);
                        }
                    }

                    // close the device
                    device.Close();

                    // close the device manager
                    deviceManager.Close();
                }
            }
            catch (Vintasoft.Twain.TwainException ex)
            {
                Console.WriteLine("Error: " + ex.Message);
            }

            Console.ReadLine();
        }

        /// <summary>
        /// Prints the current value of Kodak ultrasonic detection capability.
        /// </summary>
        /// <param name="kodakUltrasonicDetectionCap">Kodak ultrasonic detection capability.</param>
        static void PrintKodakUltrasonicDetectionCurrentValue(
            Vintasoft.Twain.DeviceCapability kodakUltrasonicDetectionCap)
        {
            Vintasoft.Twain.TwainValueContainerBase value =
                kodakUltrasonicDetectionCap.GetCurrentValue();

            Console.WriteLine("Current ultrasonic detection current value: {0}",
                ConvertKodakUltrasonicDetectionValueToString(value.GetAsInt32()));
        }

        /// <summary>
        /// Converts the Kodak ultrasonic detection value to a string.
        /// </summary>
        /// <param name="value">Kodak ultrasonic detection value.</param>
        static string ConvertKodakUltrasonicDetectionValueToString(int value)
        {
            switch (value)
            {
                case 0:
                    return "Disabled";
                case 1:
                    return "Low";
                case 2:
                    return "Medium";
                case 3:
                    return "High";
                default:
                    throw new NotImplementedException();
            }
        }

    }
}