本文整理汇总了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;
}
}
}
}
}
}
示例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;
}
}
}
}