SettingsProvider Interface
|
Interface that provides access to device related settings.
Namespace: Zebra.Sdk.SettingsAssembly: SdkApi.Core (in SdkApi.Core.dll) Version: 3.0.3271
Syntax public interface SettingsProvider
Public Interface SettingsProvider
public interface class SettingsProvider
The SettingsProvider type exposes the following members.
Methods Example using System;
using System.Collections.Generic;
using Zebra.Sdk.Comm;
using Zebra.Sdk.Device;
using Zebra.Sdk.Printer;
using Zebra.Sdk.Printer.Discovery;
using Zebra.Sdk.Settings;
public class SettingsProviderExample {
public static void Main(string[] args) {
try {
foreach (DiscoveredUsbPrinter usbPrinter in UsbDiscoverer.GetZebraUsbPrinters(new ZebraPrinterFilter())) {
Connection c = usbPrinter.GetConnection();
c.Open();
if (c.Connected) {
DisplaySettings(c);
}
c.Close();
}
} catch (SettingsException e) {
Console.WriteLine(e.ToString());
} catch (ConnectionException e) {
Console.WriteLine(e.ToString());
} catch (ZebraPrinterLanguageUnknownException e) {
Console.WriteLine(e.ToString());
} catch (ZebraIllegalArgumentException e) {
Console.WriteLine(e.ToString());
}
}
private static void DisplaySettings(Connection c) {
ZebraPrinter genericPrinter = ZebraPrinterFactory.GetInstance(c);
ZebraPrinterLinkOs linkOsPrinter = ZebraPrinterFactory.CreateLinkOsPrinter(genericPrinter);
if (linkOsPrinter != null) {
Console.WriteLine("Available Settings for myDevice");
HashSet<string> availableSettings = linkOsPrinter.GetAvailableSettings();
foreach (string setting in availableSettings) {
Console.WriteLine($"{setting}: Range = ({linkOsPrinter.GetSettingRange(setting)})");
}
Console.WriteLine("\nCurrent Setting Values for myDevice");
Dictionary<string, string> allSettingValues = linkOsPrinter.GetAllSettingValues();
foreach (string settingName in allSettingValues.Keys) {
Console.WriteLine($"{settingName}:{allSettingValues[settingName]}");
}
string darknessSettingId = "print.tone";
string newDarknessValue = "10.0";
if (availableSettings.Contains(darknessSettingId) &&
linkOsPrinter.IsSettingValid(darknessSettingId, newDarknessValue) &&
linkOsPrinter.IsSettingReadOnly(darknessSettingId) == false) {
linkOsPrinter.SetSetting(darknessSettingId, newDarknessValue);
}
Console.WriteLine($"\nNew {darknessSettingId} Value = {linkOsPrinter.GetSettingValue(darknessSettingId)}");
}
}
}
See Also