當前位置: 首頁>>代碼示例>>C#>>正文


C# PrintDocument._OnBeginPrint方法代碼示例

本文整理匯總了C#中System.Drawing.Printing.PrintDocument._OnBeginPrint方法的典型用法代碼示例。如果您正苦於以下問題:C# PrintDocument._OnBeginPrint方法的具體用法?C# PrintDocument._OnBeginPrint怎麽用?C# PrintDocument._OnBeginPrint使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Drawing.Printing.PrintDocument的用法示例。


在下文中一共展示了PrintDocument._OnBeginPrint方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Print

 internal void Print(PrintDocument document)
 {
     PrintAction printToPreview;
     IntSecurity.SafePrinting.Demand();
     if (this.IsPreview)
     {
         printToPreview = PrintAction.PrintToPreview;
     }
     else
     {
         printToPreview = document.PrinterSettings.PrintToFile ? PrintAction.PrintToFile : PrintAction.PrintToPrinter;
     }
     PrintEventArgs e = new PrintEventArgs(printToPreview);
     document._OnBeginPrint(e);
     if (e.Cancel)
     {
         document._OnEndPrint(e);
     }
     else
     {
         this.OnStartPrint(document, e);
         if (e.Cancel)
         {
             document._OnEndPrint(e);
             this.OnEndPrint(document, e);
         }
         else
         {
             bool flag = true;
             try
             {
                 flag = this.PrintLoop(document);
             }
             finally
             {
                 try
                 {
                     try
                     {
                         document._OnEndPrint(e);
                         e.Cancel = flag | e.Cancel;
                     }
                     finally
                     {
                         this.OnEndPrint(document, e);
                     }
                 }
                 finally
                 {
                     if (!IntSecurity.HasPermission(IntSecurity.AllPrinting))
                     {
                         IntSecurity.AllPrinting.Assert();
                         document.PrinterSettings.PrintDialogDisplayed = false;
                     }
                 }
             }
         }
     }
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:59,代碼來源:PrintController.cs

示例2: Print

        internal void Print(PrintDocument document) {
            IntSecurity.SafePrinting.Demand();
            // Most of the printing security is left to the individual print controller

            //
            // Get the PrintAction for this event
            PrintAction printAction;
            if (IsPreview)
            {
                printAction = PrintAction.PrintToPreview;
            }
            else {
                printAction = document.PrinterSettings.PrintToFile ? PrintAction.PrintToFile : PrintAction.PrintToPrinter;
            }

            // Check that user has permission to print to this particular printer
            PrintEventArgs printEvent = new PrintEventArgs(printAction);
            document._OnBeginPrint(printEvent);
            if (printEvent.Cancel) {
                document._OnEndPrint(printEvent);
                return;
            }

            OnStartPrint(document, printEvent);
            if (printEvent.Cancel) {
                document._OnEndPrint(printEvent);
                OnEndPrint(document, printEvent);
                return;
            }

            bool canceled = true;

            try {
                canceled = PrintLoop(document);
            }
            finally {
                try {
                    try {
                        document._OnEndPrint(printEvent);
                        printEvent.Cancel = canceled | printEvent.Cancel;
                    }
                    finally {
                        OnEndPrint(document, printEvent);
                    }
                }
                finally {
                    if (!IntSecurity.HasPermission(IntSecurity.AllPrinting)) {
                        // Ensure programs with SafePrinting only get to print once for each time they
                        // throw up the PrintDialog.
                        IntSecurity.AllPrinting.Assert();
                        document.PrinterSettings.PrintDialogDisplayed = false;
                    }
                }
            }
        }
開發者ID:JianwenSun,項目名稱:cc,代碼行數:55,代碼來源:PrintController.cs


注:本文中的System.Drawing.Printing.PrintDocument._OnBeginPrint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。