Here is example that shows how to enable the ultrasonic detection capability of Kodak scanner:
Code: Select all
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();
}
}
}
}