private void getListOfAllFormats() { Invoke(new ButtonEnablingEventHandler(toggleButtonEnabled), false); updateGuiFromWorkerThread("Retrieving Formats...", Color.Gold); ZebraPrinter printer = getPrinter(); try { String[] formats; PrinterLanguage pl = printer.GetPrinterControlLanguage(); if (pl == PrinterLanguage.ZPL) { formats = new String[] { "ZPL" }; } else { formats = new String[] { "FMT", "LBL" }; } String[] formatNames = printer.GetFileUtil().RetrieveFileNames(formats); StringBuilder sb = new StringBuilder(); sb.Append("Printer Format Files:\r\n"); foreach (String formatName in formatNames) { sb.Append("\r\n" + formatName); } updateGuiFromWorkerThread("Done Retrieving Formats...", Color.Lime); Thread.Sleep(500); Invoke(new ListBoxEventHandler(displayNames), sb.ToString()); } catch (ZebraException) { updateGuiFromWorkerThread("Error Retrieving Formats", Color.Red); } Invoke(new ButtonEnablingEventHandler(toggleButtonEnabled), true); }
public void sendFileContents(string filePath, IMethodResult oResult) { Logger.Write("sendFileContents call"); Logger.Write("fileParh: " + filePath); if (m_connection != null && m_connection.IsConnected() && m_printer != null) { m_printer.GetFileUtil().SendFileContents(filePath); oResult.set(ZebraConstants.PRINTER_STATUS_SUCCESS); } else { oResult.set(ZebraConstants.PRINTER_STATUS_ERR_NOT_CONNECTED); } }
private void GetListOfFormats() { ZebraPrinterConnection connection = getConnection(); ZebraPrinter printer = ZebraPrinterFactory.GetInstance(connection); String[] zplFormatExtensions = new String[] { "ZPL" }; String[] cpclFormatExtensions = new String[] { "FMT", "LBL" }; String[] extensions = printer.GetPrinterControlLanguage() == PrinterLanguage.ZPL ? zplFormatExtensions : cpclFormatExtensions; List <String> formatList = new List <String>(); foreach (String format in printer.GetFileUtil().RetrieveFileNames(extensions)) { formatList.Add(format); } Invoke(new FormatListEventHandler(DisplayNames), new object[] { formatList }); }
private void getListOfAllFiles() { Invoke(new ButtonEnablingEventHandler(toggleButtonEnabled), false); updateGuiFromWorkerThread("Retrieving Files...", Color.Gold); ZebraPrinter printer = getPrinter(); try { String[] fileNames = printer.GetFileUtil().RetrieveFileNames(); StringBuilder sb = new StringBuilder(); sb.Append("All Files:\r\n"); foreach (String fileName in fileNames) { sb.Append("\r\n" + fileName); } updateGuiFromWorkerThread("Done Retrieving Files...", Color.Lime); Thread.Sleep(500); Invoke(new ListBoxEventHandler(displayNames), sb.ToString()); } catch (ZebraException) { updateGuiFromWorkerThread("Error Retrieving Files", Color.Red); } Invoke(new ButtonEnablingEventHandler(toggleButtonEnabled), true); }
/***************************************************************************************************** Desc: This function is called when Retrieve button is clicked. Gets the list of label formats stored * at printer and display that list on UI using combobox. ******************************************************************************************************/ private void getListOfAllFormats() { //Get the instance of ZebraPrinter to obtain properties of Zebra printer if (zebraPrinterConnection != null) printer = ZebraPrinterFactory.GetInstance(zebraPrinterConnection); else { MessageBox.Show("Device isn't Connected."); return; } try { if (printer != null && isConnected) { String[] formats; /** * MADE CHANGES HERE!!!!!!!**************************** * * **/ //String printerLanguage = SGD.GET("device.languages", zebraPrinterConnection); PrinterLanguage lang = printer.GetPrinterControlLanguage(); // select the format type according to printer language // if ( printerLanguage == "zpl" ) if(lang == PrinterLanguage.ZPL) { formats = new String[] { "ZPL" }; } else { formats = new String[] { "FMT", "LBL" }; } /** * END CHANGES * **/ // Retrieve the list of format files store at printer and display it in combobox String[] formatNames = printer.GetFileUtil().RetrieveFileNames(formats); cbFormatList.DataSource = formatNames; } else { MessageBox.Show("Device isn't Connected."); return; } } catch (ZebraPrinterLanguageUnknownException) { MessageBox.Show("Printer Control Language Error: \r\n Make sure that printer has supported control language."); return; } catch (ZebraPrinterConnectionException) { MessageBox.Show("Communication Error:\r\n Check Printer is on Or Connection has been established.\r\n"); return; } catch (ZebraException) { MessageBox.Show("Zebra Printer Error: Can't retrieve formats stored at printer"); return; } catch (Exception) { MessageBox.Show("Error in Retrieving Formats"); return; } }