public async void Print(AbstractBill bill, int type = 58, int repeatPrintNum = 1) { try { if (repeatPrintNum == 0) { repeatPrintNum = 1; } if (repeatPrintNum > 2) { repeatPrintNum = 2; } if (bill == null) { //测试 var content = MainActivity.Instance.ApplicationContext; PrintQueue.GetQueue(content).Clear(); var podm = new PrintOrderDataMaker(content, "", type, PrinterWriter.HEIGHT_PARTING_DEFAULT); if (podm != null) { var printData = podm.GetPrintData(type); if (printData != null && printData.Any()) { for (int p = 0; p < repeatPrintNum; p++) { PrintQueue.GetQueue(content).Add(printData); //System.Diagnostics.Debug.Print($"Print---------------------->{p}"); } } } } else { var content = MainActivity.Instance.ApplicationContext; PrintQueue.GetQueue(content).Clear(); var podm = new PrintOrderDataMaker(content, "", type, PrinterWriter.HEIGHT_PARTING_DEFAULT); if (podm != null) { var printData = podm.GetBillPrintData(type, bill); if (printData != null && printData.Any()) { for (int p = 0; p < repeatPrintNum; p++) { PrintQueue.GetQueue(content).Add(printData); //System.Diagnostics.Debug.Print($"Print---------------------->{p}"); } } } } } catch (Exception) { await UserDialogs.Instance.AlertAsync("拒绝操作,请确保打印机连接适配"); } }
public void PrintStop() { try { var content = MainActivity.Instance.ApplicationContext; PrintQueue.GetQueue(content).Disconnect(); } catch (Exception) { //e.printStackTrace(); } }