private static PrinterMargins GetPrinterMarginsInstance() { if (thePrinterMarginsInstance == null) { thePrinterMarginsInstance = new PrinterMargins(GetPrintDocumentInstance()); } return(thePrinterMarginsInstance); }
public static void Reset() { if (thePrintDocumentInstance != null) { thePrintDocumentInstance.Dispose(); } thePrintDocumentInstance = null; thePrinterMarginsInstance = null; }
/// <summary> /// 页面设置对话框。 /// </summary> public System.Drawing.Printing.PageSettings PageSetup() { PrinterPageSetting printerPageSetting; printerPageSetting = new PrinterPageSetting(mPrintDocument); printerPageSetting.PrintPage += new PrintPageDelegate(this.PrintPageEventHandler); PageSettings pstBack = mPrintDocument.DefaultPageSettings; PageSettings pstNew = printerPageSetting.ShowPageSetupDialog(); if (pstBack != pstNew) { //改变页面设置后,单件重置 PrinterSingleton.PrintDocument = mPrintDocument; mPrinterMargins = new PrinterMargins(mPrintDocument); PrinterSingleton.PrinterMargins = mPrinterMargins; } return(pstNew); }
//还可以将此程序稍微修改,用一个集体管理,动态加载打印对象,形成任意多个网格的组合体,打印任意复杂的网格 public MisGoldPrinterOfReWrite(bool p_IsLandscape, PrinterMargins printerMargins) { PrinterSingleton.Reset(); mCurrentPageIndex = 1; mCurrentRowIndex = 0; //单一模式,全部打印对象使用下面相同的对象,提高打印速度效率 mPrintDocument = PrinterSingleton.PrintDocument; mPrintDocument.DefaultPageSettings.Landscape = p_IsLandscape; mPrinterMargins = PrinterSingleton.PrinterMargins; // mPrintDocument.DocumentName = "MIS金质打印通,欢迎使用!"; _sewing = new Sewing(30, SewingDirectionFlag.Left); mPrinter = new Printer(); _body = new Body(); //主要对象,所以实例化 }
private static void old_acctor_mc() { thePrintDocumentInstance = null; thePrinterMarginsInstance = null; }