protected override PrintResults TransactionPrintImpl(PrintOperationCollection collection) { int chars = 0; Window.DisplayText("[Begin transaction]\r\n"); foreach (PrintOperation operation in collection) { string s = ""; Rotation rotation = operation.Rotation; if (operation is PrintNormalOperation) { s = ((PrintNormalOperation)operation).Data; } else if (operation is CutPaperOperation) { s = "Cut paper at: " + ((CutPaperOperation)operation).Percentage.ToString(CultureInfo.CurrentCulture) + "%"; } else if (operation is PrintBitmapOperation) { s = "Bitmap: " + ((PrintBitmapOperation)operation).FileName + "\r\n"; } else if (operation is PrintBarCodeOperation) { s = "BarCode: " + ((PrintBarCodeOperation)operation).Data + "\r\n"; } else if (operation is RotatePrintOperation) { chars += DisplayRotatePrintTransaction(((RotatePrintOperation)operation).Collection); } else { s = "Unexpected operation type.\r\n"; } if (rotation == Rotation.Rotate180) { Window.DisplayText("[Begin " + rotation.ToString() + " rotation]\r\n"); } Window.DisplayText(s); if (rotation == Rotation.Rotate180) { Window.DisplayText("[End " + rotation.ToString() + " rotation]\r\n"); } chars += s.Length; } Window.DisplayText("[End transaction]\r\n"); Thread.Sleep(printDelay); return(GetPrintStats(collection[0].Station, chars)); }
protected override void PreQueuePrintData(PrintOperationCollection printCollection) { // This is a simple example of how to validate async operations before they are added // internal print queue. It's the SO's responsibility to do any required validations // here and throw an appropriate exception if anything in the collection is invalid. // If an exception is not thrown the operation will be added to the internal print // queue and processed in fifo order. RotatePrintCollection rpc = printCollection as RotatePrintCollection; if (rpc != null) { ValidationPrintRotation(rpc); } else { foreach (PrintOperation p in printCollection) { RotatePrintOperation rpo = p as RotatePrintOperation; if (rpo != null) ValidationPrintRotation(rpo.Collection); } } }
protected override PrintResults TransactionPrintImpl(PrintOperationCollection collection) { int chars = 0; Window.DisplayText("[Begin transaction]\r\n"); foreach (PrintOperation operation in collection) { string s = ""; Rotation rotation = operation.Rotation; if (operation is PrintNormalOperation) s = ((PrintNormalOperation) operation).Data; else if (operation is CutPaperOperation) s = "Cut paper at: " + ((CutPaperOperation) operation).Percentage.ToString(CultureInfo.CurrentCulture) + "%"; else if (operation is PrintBitmapOperation) s = "Bitmap: " + ((PrintBitmapOperation) operation).FileName + "\r\n"; else if (operation is PrintBarCodeOperation) s = "BarCode: " + ((PrintBarCodeOperation) operation).Data + "\r\n"; else if (operation is RotatePrintOperation) chars += DisplayRotatePrintTransaction(((RotatePrintOperation)operation).Collection); else s = "Unexpected operation type.\r\n"; if (rotation == Rotation.Rotate180) Window.DisplayText("[Begin " + rotation.ToString() + " rotation]\r\n"); Window.DisplayText(s); if (rotation == Rotation.Rotate180) Window.DisplayText("[End " + rotation.ToString() + " rotation]\r\n"); chars += s.Length; } Window.DisplayText("[End transaction]\r\n"); Thread.Sleep(printDelay); return GetPrintStats(collection[0].Station, chars); }