SetValue(String) Метод (SaneLocalDeviceOption)
Установите строковое значение этой SANE опции.
Вот C#/VB.NET код, который демонстрирует, как установить значение параметра SANE устройства.
''' <summary>
''' Sets value of SANE device option.
''' </summary>
Public Sub SetValueOfSaneDeviceOption()
' create SANE device manager
Using deviceManager As New Vintasoft.Sane.SaneLocalDeviceManager()
' open SANE device manager
deviceManager.Open()
' get count of SANE devices
Dim deviceCount As Integer = deviceManager.Devices.Count
If deviceCount = 0 Then
System.Console.WriteLine("Devices are not found.")
Return
End If
' select the first SANE device
Dim device As Vintasoft.Sane.SaneLocalDevice = deviceManager.Devices(0)
' open SANE device
device.Open()
System.Console.WriteLine("Device name: " + device.Name)
' get SANE device option with name "source"
Dim sourceOption As Vintasoft.Sane.SaneLocalDeviceOption = device.Options.Find("source")
' if option is found
If sourceOption IsNot Nothing Then
' set new value for option
sourceOption.SetValue("Flatbed")
End If
' close SANE device
device.Close()
' close SANE device manager
deviceManager.Close()
End Using
System.Console.ReadLine()
End Sub
/// <summary>
/// Sets value of SANE device option.
/// </summary>
public void SetValueOfSaneDeviceOption()
{
// create SANE device manager
using (Vintasoft.Sane.SaneLocalDeviceManager deviceManager = new Vintasoft.Sane.SaneLocalDeviceManager())
{
// open SANE device manager
deviceManager.Open();
// get count of SANE devices
int deviceCount = deviceManager.Devices.Count;
if (deviceCount == 0)
{
System.Console.WriteLine("Devices are not found.");
return;
}
// select the first SANE device
Vintasoft.Sane.SaneLocalDevice device = deviceManager.Devices[0];
// open SANE device
device.Open();
System.Console.WriteLine("Device name: " + device.Name);
// get SANE device option with name "source"
Vintasoft.Sane.SaneLocalDeviceOption sourceOption = device.Options.Find("source");
// if option is found
if (sourceOption != null)
{
// set new value for option
sourceOption.SetValue("Flatbed");
}
// close SANE device
device.Close();
// close SANE device manager
deviceManager.Close();
}
System.Console.ReadLine();
}
Целевые платформы: .NET 8; .NET 7; .NET 6