1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
private void MenuImprimer(object sender, EventArgs e)
{
PrintDocument printDocument1 = new PrintDocument();
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
printDocument1.DefaultPageSettings.Landscape = true;
printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("PaperA4", 826, 1169);
printPreviewDialog1.Document = printDocument1;
/* printPreviewDialog1.PrintPreviewControl.AutoZoom = true;*/
FormBorderStyle = FormBorderStyle.None;
menuStrip1.Visible = false;
Refresh();
CaptureScreen();
FormBorderStyle = FormBorderStyle.Sizable;
menuStrip1.Visible = true;
printPreviewDialog1.ShowDialog();
}
private void printDocument1_PrintPage(System.Object sender,System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(memoryImage, 0, 0);
}
Bitmap memoryImage;
private void CaptureScreen()
{
Graphics myGraphics = this.CreateGraphics();
Size s = this.Size;
memoryImage = new Bitmap(s.Width, s.Height, myGraphics);
memoryImage.SetResolution(165, 165);
/* memoryImage = new Bitmap(memoryImage1, new Size(s.Width / 2, s.Height/2)); */
Graphics memoryGraphics = Graphics.FromImage(memoryImage);
memoryGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, s);
}
} |
Partager