/// <summary> /// Opens a connection to a discovered printer /// </summary> /// <returns>true if connection is successful</returns> public bool OpenConnection() { bool connected = false; try { connection = UsbPrinter.GetConnection(); if (connection == null) { throw new Exception("Unable to connect to an USB printer"); } connection.Open(); printer = ZebraCardPrinterFactory.GetZmotifPrinter(connection); if (printer == null) { throw new Exception("Unable to get an instance to an USB printer"); } connected = true; } catch (Exception ex) { connection = null; printerError = ex.Message; } return(connected); }
private string GetConfigurationSettings(ref string errMsg) { string xmlDoc = string.Empty; try { ZebraPrinterZmotif zmotifPrn = ZebraCardPrinterFactory.GetZmotifPrinter(connection); xmlDoc = zmotifPrn.SettingsHelper.GetConfiguration(); } catch (Exception ex) { errMsg = ex.Message; } return(xmlDoc); }
private bool SetContactlessHFLFSmartCardOffset(int value, out string errMsg) { bool wasSet = false; errMsg = string.Empty; try { ZebraPrinterZmotif zmotifPrn = ZebraCardPrinterFactory.GetZmotifPrinter(connection); zmotifPrn.SettingsHelper.SetContactlessSmartCardOffset("MIFARE", value); wasSet = true; } catch (Exception ex) { errMsg = ex.Message; } return(wasSet); }
/// <summary> /// Gets smart card offset ranges based on card type /// </summary> /// <param name="cardType">contact or contactless</param> /// <param name="min">minimum offset value</param> /// <param name="max">maximum offset value</param> /// <returns>true if successful</returns> public bool GetSmartOffsetRange(string cardType, out int min, out int max) { bool gotRange = false; min = max = 0; try { string range = string.Empty; ZebraPrinterZmotif zmotifPrn = ZebraCardPrinterFactory.GetZmotifPrinter(this.connection); switch (cardType) { case "contact": range = zmotifPrn.GetSettingRange("mech_adjustments.card_smart_card_x_offset"); break; case "hf": range = zmotifPrn.GetSettingRange("mech_adjustments.card_smart_card_hf_x_offset"); break; case "lf": range = zmotifPrn.GetSettingRange("mech_adjustments.card_smart_card_lf_x_offset"); break; case "uhf": range = zmotifPrn.GetSettingRange("mech_adjustments.card_smart_card_uhf_x_offset"); break; } string[] strArray = range.Split('-'); if (strArray.Length.Equals(3)) { min = Convert.ToInt32(strArray[1]) * -1; max = Convert.ToInt32(strArray[2]); gotRange = true; } } catch { } return(gotRange); }