/// <summary> /// 跳到下一页 /// </summary> public void NextPage() { if (myCurrentPage == null) { MoveToPage(0); } else { MoveToPage(_Pages.IndexOf(myCurrentPage) + 1); } }
/// <summary> /// 已重载:开始打印文档 /// </summary> /// <param name="e">事件参数</param> protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e) { if (CheckContent()) { // 指定打印机 string printerName = this.PrinterName; if (printerName == null || printerName.Trim().Length == 0) { if (this.CurrentDocumentPage != null) { printerName = this.CurrentDocumentPage.PageSettings.PrinterName; } } if (printerName != null && printerName.Trim().Length > 0) { printerName = printerName.Trim(); foreach (string name in PrinterSettings.InstalledPrinters) { if (string.Compare(printerName, name, true) == 0) { //this.PrinterSettings.PrinterName = name; base.DefaultPageSettings.PrinterSettings.PrinterName = name; base.PrinterSettings.PrinterName = name; break; } } } // 指定纸张设置 string paperSource = this.PaperSourceName; if (paperSource != null && paperSource.Trim().Length > 0) { foreach (System.Drawing.Printing.PaperSource source in base.DefaultPageSettings.PrinterSettings.PaperSources) { if (source.SourceName != null && string.Compare( source.SourceName.Trim(), paperSource.Trim(), true) == 0) { base.DefaultPageSettings.PaperSource = source; break; } } //e.PageSettings.PaperSource.SourceName = paperSource; } int startIndex = 0; if (this.JumpPrint.Enabled && this.JumpPrint.Page != null) { startIndex = myPages.IndexOf(this.JumpPrint.Page); } System.Collections.ArrayList pages = new System.Collections.ArrayList(); switch (this.PrinterSettings.PrintRange) { case PrintRange.Selection: case PrintRange.AllPages: for (int iCount = startIndex; iCount < myPages.Count; iCount++) { pages.Add(myPages[iCount]); } break; case PrintRange.CurrentPage: pages.Add(this.CurrentDocumentPage); break; case PrintRange.SomePages: int endIndex = Math.Min(myPages.Count - 1, this.PrinterSettings.ToPage); for (int iCount = Math.Max(startIndex, this.PrinterSettings.FromPage); iCount <= endIndex; iCount++) { pages.Add(myPages[iCount]); } break; } if (pages.Count == 0) { // 没有打印页,立即取消打印操作 e.Cancel = true; return; } else { myPageEnumerator = pages.GetEnumerator(); myPageEnumerator.MoveNext(); } } else { //intCurrentPrintPageIndex = 0 ; } if (this.PreparePrintJob) { this.myPrintJob = null; this.DocumentName = this.DocumentName + "$" + System.Environment.TickCount; } base.OnBeginPrint(e); }