PurplePen.BasicPrinting.PrintPreview C# (CSharp) Method

PrintPreview() public method

public PrintPreview ( Size dialogSize ) : void
dialogSize System.Drawing.Size
return void
        public void PrintPreview(Size dialogSize)
        {
            // Set up and position everything.
            SetupPrinting();
            printPreviewInProgress = true;

            using (PrintDocument printDocument = CreatePrintDocument()) {
                PrintPreviewDialog dialog = new PrintPreviewDialog();
                dialog.UseAntiAlias = true;
                dialog.Document = printDocument;
                dialog.StartPosition = FormStartPosition.CenterParent;
                dialog.Size = dialogSize;
                dialog.SizeGripStyle = SizeGripStyle.Show;
                dialog.ShowIcon = false;

                // Remove the "print" button.
                foreach (Control ctl in dialog.Controls) {
                    ToolStrip strip = ctl as ToolStrip;
                    if (strip != null) {
                        var button = strip.Items[0];
                        if (button.Name == "printToolStripButton")
                            strip.Items.Remove(button);
                    }
                }

                dialog.ShowDialog();
                dialog.Dispose();
            }
        }