Пример #1
0
        void UpdatePreviewControl()
        {
            if (showPreview)
            {
                visualControlPrintPreview.Visible = false;

                originalForPdf = ForPdf;
                ForPdf         = false;
                UpdatePagePrintSize(Controller, originalForPdf);

                previewControl = new PrintPreviewControl
                {
                    Document = printDocument,
                    Dock     = DockStyle.Fill
                };

                Controls.Add(previewControl);
                previewControl.BringToFront();
            }
            else
            {
                if (previewControl != null)
                {
                    ForPdf = originalForPdf;
                    UpdatePagePrintSize(Controller);

                    previewControl.Dispose();
                    previewControl = null;
                }
                visualControlPrintPreview.Visible = true;
            }
        }
    private void toolStripButtonPageSetup_Click(object sender, EventArgs e)
    {
        PageSetupDialog pageSetupDialog = new PageSetupDialog();

        pageSetupDialog.AllowOrientation = false;
        pageSetupDialog.EnableMetric     = true;

        pageSetupDialog.PageSettings = printPreviewControl.Document.DefaultPageSettings;

        pageSetupDialog.Document = printPreviewControl.Document;

        if (pageSetupDialog.ShowDialog() == DialogResult.OK)
        {
            System.Drawing.Printing.PrintDocument printDocument = printPreviewControl.Document;

            printPreviewControl.Dispose();
            printPreviewControl = null;

            printPreviewControl = new PrintPreviewControl();
            Controls.Add(printPreviewControl);

            printPreviewControl.Dock         = System.Windows.Forms.DockStyle.Fill;
            printPreviewControl.Location     = new System.Drawing.Point(0, 25);
            printPreviewControl.UseAntiAlias = true;
            printPreviewControl.BringToFront();

            printPreviewControl.Document = printDocument;
        }
        ;
    }
Пример #3
0
        private void btnPageSetup_Click(object sender, EventArgs e)
        {
            pageSetupDialog1.Document = Document;

            if (pageSetupDialog1.ShowDialog() == DialogResult.OK)
            {
                Document.DefaultPageSettings.PrinterResolution.X     =
                    Document.DefaultPageSettings.PrinterResolution.Y = (int)numResolution.Value;

                this.Controls.Remove(printPreviewControl1);
                printPreviewControl1      = new PrintPreviewControl();
                printPreviewControl1.Dock = DockStyle.Fill;
                this.Controls.Add(printPreviewControl1);
                printPreviewControl1.BringToFront();
                printPreviewControl1.Document = pageSetupDialog1.Document;
            }
        }