Bonsoir,

Je faits un logiciel de dessin et je veux avoir un apercu avant impression ceci en paysage et où ma zone dessin remplit entierement l apercu voila!!

si les bonnes âmes peuvent m aider??

Merci!

je donne le bout de code que j ai essayé de faire aboutir


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
46
47
48
49
 
       private void aperçuavantimpressionToolStripMenuItem_Click(object sender, EventArgs e)
        {
                PrintPreviewDialog ppd = new PrintPreviewDialog();
 
        //Set the size, location, and name.
        ppd.ClientSize =
            new System.Drawing.Size(400, 300);
        ppd.Location =
            new System.Drawing.Point(29, 29);
        ppd.Name = "PrintPreviewDialog1";
 
        // Associate the event-handling method with the 
        // document's PrintPage event.
        this.document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage);
 
        // Set the minimum size the dialog can be resized to.
        ppd.MinimumSize =
            new System.Drawing.Size(375, 250);
 
        // Set the UseAntiAlias property to true, which will allow the 
        // operating system to smooth fonts.
        ppd.UseAntiAlias = true;
        ppd.Document = document;
        ppd.Document.DefaultPageSettings.Landscape = true; 
 
        ppd.ShowDialog();
        }
 
        private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {
            Bitmap impr = new Bitmap(panel1.Width, panel1.Height);
            panel1.DrawToBitmap(impr, panel1.ClientRectangle);
 
            float f2 = (float)e.MarginBounds.Height / (float)impr.Height; 
            float f1 = (float)e.MarginBounds.Width / (float)impr.Width;
            e.Graphics.ScaleTransform(f1, f2);
 
            e.Graphics.DrawImage(impr, 0, 0);
 
            /*			Bitmap impr = new Bitmap(panel1.Width, panel1.Height);
			panel1.DrawToBitmap(impr, panel1.ClientRectangle);
 
			float factech = Math.Min(((float)e.MarginBounds.Height / (float)impr.Height), ((float)e.MarginBounds.Width / (float)impr.Width));
			e.Graphics.ScaleTransform(factech, factech);
 
			e.Graphics.DrawImage(impr, 0 , 0);
             * */
        }