Skip to content

Commit

Permalink
Create Print.md
Browse files Browse the repository at this point in the history
  • Loading branch information
swharden authored Sep 1, 2020
1 parent edaead7 commit 94bed7a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Csharp/Print.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Printing in WinForms

```cs
private void PrintPage(object sender, PrintPageEventArgs e)
{
formsPlot1.plt.Resize(e.MarginBounds.Width, (int)(e.MarginBounds.Width * .5));
formsPlot1.plt.Style(figBg: Color.White);
e.Graphics.DrawImage(formsPlot1.plt.GetBitmap(), e.MarginBounds.Left, e.MarginBounds.Top);
}

private void Print_Click(object sender, EventArgs e)
{
var pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(PrintPage);
if (new PrintDialog { Document = pd }.ShowDialog() == DialogResult.OK)
pd.Print();
}

private void PrintPreview_Click(object sender, EventArgs e)
{
var pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(PrintPage);
new PrintPreviewDialog { Document = pd }.ShowDialog();
}
```

0 comments on commit 94bed7a

Please sign in to comment.