Click or drag to resize

SettingsProvider Interface

Interface that provides access to device related settings.

Namespace: Zebra.Sdk.Settings
Assembly: SdkApi.Core (in SdkApi.Core.dll) Version: 3.0.3271
Syntax
public interface SettingsProvider

The SettingsProvider type exposes the following members.

Methods
 NameDescription
Public methodGetAllSettings Retrieve all settings and their attributes.
Public methodGetAllSettingValues Retrieves all of the device's setting values.
Public methodGetAvailableSettings Retrieve all of the setting identifiers for a device.
Public methodGetSettingRange Retrieves the allowable range for a setting.
Public methodGetSettingsValues Retrieves the device's setting values for a list of setting IDs.
Public methodGetSettingType Returns the data type of the setting.
Public methodGetSettingValue Retrieves the device's setting value for a setting id.
Public methodIsSettingReadOnly Returns true if the setting is read only.
Public methodIsSettingValid Returns true if value is valid for the given setting.
Public methodIsSettingWriteOnly Returns true if the setting is write only.
Public methodProcessSettingsViaMap Change or retrieve printer settings.
Public methodSetSetting Sets the setting to the given value.
Public methodSetSettings Set more than one setting.
Top
Example
C#
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