本文整理汇总了C#中System.Drawing.Printing.PrintDocument._OnPrintPage方法的典型用法代码示例。如果您正苦于以下问题:C# PrintDocument._OnPrintPage方法的具体用法?C# PrintDocument._OnPrintPage怎么用?C# PrintDocument._OnPrintPage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Printing.PrintDocument
的用法示例。
在下文中一共展示了PrintDocument._OnPrintPage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrintLoop
private bool PrintLoop(PrintDocument document)
{
PrintPageEventArgs args2;
QueryPageSettingsEventArgs e = new QueryPageSettingsEventArgs((PageSettings) document.DefaultPageSettings.Clone());
do
{
document._OnQueryPageSettings(e);
if (e.Cancel)
{
return true;
}
args2 = this.CreatePrintPageEvent(e.PageSettings);
Graphics graphics = this.OnStartPage(document, args2);
args2.SetGraphics(graphics);
try
{
document._OnPrintPage(args2);
this.OnEndPage(document, args2);
}
finally
{
args2.Dispose();
}
if (args2.Cancel)
{
return true;
}
}
while (args2.HasMorePages);
return false;
}
示例2: PrintLoop
// Returns true if print was aborted.
// WARNING: if you have nested PrintControllers, this method won't get called on the inner one
// Add initialization code to StartPrint or StartPage instead.
private bool PrintLoop(PrintDocument document) {
QueryPageSettingsEventArgs queryEvent = new QueryPageSettingsEventArgs((PageSettings) document.DefaultPageSettings.Clone());
for (;;) {
document._OnQueryPageSettings(queryEvent);
if (queryEvent.Cancel) {
return true;
}
PrintPageEventArgs pageEvent = CreatePrintPageEvent(queryEvent.PageSettings);
Graphics graphics = OnStartPage(document, pageEvent);
pageEvent.SetGraphics(graphics);
try {
document._OnPrintPage(pageEvent);
OnEndPage(document, pageEvent);
}
finally {
pageEvent.Dispose();
}
if (pageEvent.Cancel) {
return true;
}
else if (!pageEvent.HasMorePages) {
return false;
}
else {
// loop
}
}
}