Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Reorganised printing methods

Signed-off-by: Peter Nelson <peter@peterdn.com>
  • Loading branch information...
commit 7213306e6f0d2da56e6079f429629193e8a34542 1 parent 0bb7364
Peter Nelson peterdn authored
Showing with 17 additions and 14 deletions.
  1. +17 −14 WebKitCore/WebKitBrowserCore.cs
31 WebKitCore/WebKitBrowserCore.cs
View
@@ -918,17 +918,16 @@ public object GetGlobalScriptContext()
return null;
}
- // printing methods
+ #endregion Public Methods
+
+ #region Printing Methods
/// <summary>
/// Prints the document using the current print and page settings.
/// </summary>
public void Print()
{
- PrintDocument doc = new PrintDocument();
- doc.DocumentName = this.DocumentTitle;
- doc.DefaultPageSettings = PageSettings;
- doc.OriginAtMargins = true;
+ PrintDocument doc = this.GetCommonPrintDocument();
PrintManager pm = new PrintManager(doc, this, false);
pm.Print();
}
@@ -953,10 +952,7 @@ public void ShowPageSetupDialog()
public void ShowPrintDialog()
{
PrintDialog printDlg = new PrintDialog();
- PrintDocument doc = new PrintDocument();
- doc.DocumentName = this.DocumentTitle;
- doc.DefaultPageSettings = PageSettings;
- doc.OriginAtMargins = true;
+ PrintDocument doc = this.GetCommonPrintDocument();
printDlg.Document = doc;
if (printDlg.ShowDialog() == DialogResult.OK)
@@ -973,17 +969,24 @@ public void ShowPrintPreviewDialog()
{
// TODO: find out why it apparently only shows the first page on the preview...
PrintPreviewDialog printDlg = new PrintPreviewDialog();
- PrintDocument doc = new PrintDocument();
- doc.DocumentName = this.DocumentTitle;
- doc.DefaultPageSettings = PageSettings;
- doc.OriginAtMargins = true;
+ PrintDocument doc = this.GetCommonPrintDocument();
printDlg.Document = doc;
PrintManager pm = new PrintManager(doc, this, true);
pm.Print();
printDlg.ShowDialog();
}
- #endregion Public Methods
+ // Gets a PrintDocument with the current default settings.
+ private PrintDocument GetCommonPrintDocument()
+ {
+ PrintDocument doc = new PrintDocument();
+ doc.DocumentName = this.DocumentTitle;
+ doc.DefaultPageSettings = PageSettings;
+ doc.OriginAtMargins = true;
+ return doc;
+ }
+
+ #endregion
public void Dispose(bool disposing)
{
Please sign in to comment.
Something went wrong with that request. Please try again.