SettingsProvider Interface |
Namespace: Zebra.Sdk.Settings
The SettingsProvider type exposes the following members.
Name | Description | |
---|---|---|
GetAllSettings |
Retrieve all settings and their attributes.
| |
GetAllSettingValues |
Retrieves all of the device's setting values.
| |
GetAvailableSettings |
Retrieve all of the setting identifiers for a device.
| |
GetSettingRange |
Retrieves the allowable range for a setting.
| |
GetSettingsValues |
Retrieves the device's setting values for a list of setting IDs.
| |
GetSettingType |
Returns the data type of the setting.
| |
GetSettingValue |
Retrieves the device's setting value for a setting id.
| |
IsSettingReadOnly |
Returns true if the setting is read only.
| |
IsSettingValid |
Returns true if value is valid for the given setting.
| |
IsSettingWriteOnly |
Returns true if the setting is write only.
| |
ProcessSettingsViaMap |
Change or retrieve printer settings.
| |
SetSetting |
Sets the setting to the given value.
| |
SetSettings |
Set more than one setting.
|
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()) { 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)}"); } } }