//通过指令ID获取打印机设置信息 public static string GetPrinterSettingValus(string settingID) { if (printerHTTP != null && linkOsPrinter != null) { return(linkOsPrinter.GetSettingValue(settingID)); } return(""); }
/// <summary> /// /// head.resolution.in_dpi:203 /// zpl.label_length:590 /// odometer.label_dot_length:590 /// media.width_sense.in_mm:104.1 /// media.width_sense.in_cm:10.41 /// media.width_sense.in_dots:832 /// media.width_sense.in_inches:4.099 /// sensor.width.cur:209 /// sensor.width.in_dots:832 /// /// </summary> /// <param name="c"></param> 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)}"); } }