当前位置: 首页>>代码示例>>C#>>正文


C# PrintPreviewDialog.ShowDialog方法代码示例

本文整理汇总了C#中System.Windows.Forms.PrintPreviewDialog.ShowDialog方法的典型用法代码示例。如果您正苦于以下问题:C# PrintPreviewDialog.ShowDialog方法的具体用法?C# PrintPreviewDialog.ShowDialog怎么用?C# PrintPreviewDialog.ShowDialog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.PrintPreviewDialog的用法示例。


在下文中一共展示了PrintPreviewDialog.ShowDialog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InializePrinting

        public static void InializePrinting(List<BarCode> barCodeList, string printType)
        {
            _barCodeList = barCodeList;
            _printType = printType;
            var printPreviewDialog =
                new PrintPreviewDialog
                {
                    WindowState = FormWindowState.Maximized,
                    FormBorderStyle = FormBorderStyle.None,
                    UseAntiAlias = true,
                    Document = PrintDocument
                };

            if (AppContext.Counter != null)
                PrintDocument.PrinterSettings.PrinterName = AppContext.Counter.BarCodePrinter;

            PrintDocument.BeginPrint += PrintDocBeginPrint;
            if (Resources.ConstBarCodeTemplate5.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample5_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample5_PrintPage;
            }
            else if (Resources.ConstBarCodeTemplate4.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample4_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample4_PrintPage;
            }
            else if (Resources.ConstBarCodeTemplate3.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample3_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample3_PrintPage;
            }
            else if (Resources.ConstBarCodeTemplate2.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample2_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample2_PrintPage;
            }
            else if (Resources.ConstBarCodeTemplate1.Equals(_printType))
            {
                PrintDocument.PrintPage += BarcodeSample1_PrintPage;
                printPreviewDialog.ShowDialog();
                PrintDocument.PrintPage -= BarcodeSample1_PrintPage;
            }
            PrintDocument.BeginPrint -= PrintDocBeginPrint;
        }
开发者ID:ViniciusConsultor,项目名称:campos,代码行数:49,代码来源:PrintBarCode.cs

示例2: print

        public void print()
        {
            PrintDialog pd = new PrintDialog();
            PrintDocument pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font =new Font("Arial",12);
            PaperSize psize = new PaperSize("Custome", 100, 200);
            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;
            pdoc.DefaultPageSettings.PaperSize.Height = 320;
            pdoc.DefaultPageSettings.PaperSize.Width = 200;
            pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog ppd = new PrintPreviewDialog();
                ppd.Document = pdoc;
                result = ppd.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();

                }
            }



        }
开发者ID:neyosuraj,项目名称:thisistestRepository,代码行数:28,代码来源:orderlist.cs

示例3: print

        public void print()
        {
            PrintDialog pd = new PrintDialog();
            pdoc = new PrintDocument();
            PrinterSettings ps = new PrinterSettings();
            Font font = new Font("Courier New", 15);

            PaperSize psize = new PaperSize("Custom", 300, 100);
            ps.DefaultPageSettings.PaperSize = psize;

            pd.Document = pdoc;
            pd.Document.DefaultPageSettings.PaperSize = psize;

            pdoc.DefaultPageSettings.PaperSize = psize;

            pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog pp = new PrintPreviewDialog();
                pp.Document = pdoc;

                result = pp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();
                }
            }
        }
开发者ID:hydrohead,项目名称:MWSZonBarcode,代码行数:30,代码来源:Printing.cs

示例4: printPreview

        public void printPreview(PrinteModel model)
        {
            if (model != null)
            {
                printModel = model;
            }
            else
            {
                return;
            }
            try
            {
                init();
                PrintPreviewDialog previewDialog = new PrintPreviewDialog();
                previewDialog.Document = docToPrint;
                var result = previewDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    docToPrint.Print();
                }
            }
            catch (Exception ex)
            {

            }
        }
开发者ID:vigorlu,项目名称:Mova.Printer,代码行数:26,代码来源:PrintHelper.cs

示例5: filePrintPreviewMenuItem_Click

		private void filePrintPreviewMenuItem_Click(Object sender , 
			EventArgs e) 
		{
			PrintPreviewDialog dlg = new PrintPreviewDialog();
			dlg.Document = printDoc;
			dlg.ShowDialog();
		}
开发者ID:hitswa,项目名称:winforms,代码行数:7,代码来源:swf-printing.cs

示例6: buttonPrintImage_Click

        private void buttonPrintImage_Click(object sender, EventArgs e)
        {
            try
            {
                PrintDialog printDialog = new PrintDialog();
                printDialog.Document = this.printDocument1;
                if (printDialog.ShowDialog() != DialogResult.OK)
                {
                    throw new Exception();
                }
                /*
                PageSetupDialog pageSetupDialog = new PageSetupDialog();
                pageSetupDialog.Document = printDocument1;
                if (pageSetupDialog.ShowDialog() != DialogResult.OK)
                {
                    throw new Exception();
                }
                */
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = this.printDocument1;
                printPreviewDialog.ShowDialog();

            }
            catch (Exception)
            {
                MessageBox.Show("打印已经取消");
            }
        }
开发者ID:FieldSoft-HelloClyde,项目名称:MedicalRecordManagementSystem,代码行数:28,代码来源:ImageWindow.cs

示例7: Execute

        /// <summary>
        /// A utility method to print preview and print an Aspose.Words document.
        /// </summary>
        internal static void Execute(Document document)
        {
            // This operation can take some time (for the first page) so we set the Cursor to WaitCursor.
            Cursor cursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            PrintPreviewDialog previewDlg = new PrintPreviewDialog();

            // Initialize the Print Dialog with the number of pages in the document.
            PrintDialog printDlg = new PrintDialog();
            printDlg.AllowSomePages = true;
            printDlg.PrinterSettings = new PrinterSettings();
            printDlg.PrinterSettings.MinimumPage = 1;
            printDlg.PrinterSettings.MaximumPage = document.PageCount;
            printDlg.PrinterSettings.FromPage = 1;
            printDlg.PrinterSettings.ToPage = document.PageCount;

            // Restore cursor.
            Cursor.Current = cursor;

            // Interesting, but PrintDialog will not show and will always return cancel
            // if you run this application in 64-bit mode.
            if (!printDlg.ShowDialog().Equals(DialogResult.OK))
                return;

            // Create the Aspose.Words' implementation of the .NET print document
            // and pass the printer settings from the dialog to the print document.
            AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(document);
            awPrintDoc.PrinterSettings = printDlg.PrinterSettings;

            // Pass the Aspose.Words' print document to the .NET Print Preview dialog.
            previewDlg.Document = awPrintDoc;

            previewDlg.ShowDialog();
        }
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:38,代码来源:Preview.cs

示例8: Execute

        public override void Execute()
        {
            printDocument = new PrintDocument();

              printDocument.OriginAtMargins = true;
              printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint);
              printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);

              Dictionary<String, Object> paperSettings = Printing.getPaperSettings(grtArguments);
              printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape";

              // Sizes must be given in inch * 100 (sigh).
              int paperWidth = (int)Math.Round((double)paperSettings["width"] / 0.254);
              int paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254);
              PaperSize paperSize = new PaperSize("Ignored anyway", paperWidth, paperHeight);

              if ((bool)paperSettings["marginsSet"])
            printDocument.DefaultPageSettings.Margins =
              new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"],
            (int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]);

              System.Windows.Forms.PrintPreviewDialog preview = new System.Windows.Forms.PrintPreviewDialog();

              preview.Document = printDocument;
              preview.UseAntiAlias = true;

              preview.ShowDialog();
        }
开发者ID:abibell,项目名称:mysql-workbench,代码行数:28,代码来源:PrintPreviewDialog.cs

示例9: Print_DataGridView

        public static void Print_DataGridView(DataGridView dgv1, string printTitle, bool printAllRows, bool fitToPageWidth)
        {
            PrintPreviewDialog ppvw;
            try
            {

                // Getting DataGridView object to print
                dgv = dgv1;

                // Getting all Coulmns Names in the DataGridView
                AvailableColumns.Clear();
                foreach (DataGridViewColumn c in dgv.Columns)
                {
                    if (!c.Visible) continue;
                    AvailableColumns.Add(c.HeaderText);
                }

                // Showing the PrintOption Form
                //PrintOptions dlg = new PrintOptions(AvailableColumns);
                //if (dlg.ShowDialog() != DialogResult.OK) return;

                PrintTitle = printTitle;
                PrintAllRows = printAllRows;
                FitToPageWidth = fitToPageWidth;
                SelectedColumns = AvailableColumns;

                RowsPerPage = 0;

                ppvw = new PrintPreviewDialog();
                PageSetupDialog psd = new PageSetupDialog();
                psd.Document = printDoc;
                psd.ShowDialog();
                printDoc.DefaultPageSettings = psd.PageSettings;
                ppvw.Document = printDoc;

                // Showing the Print Preview Page
                printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                //printDoc.QueryPageSettings += new System.Drawing.Printing.QueryPageSettingsEventHandler(printDoc_QueryPageSettings);
                if (ppvw.ShowDialog() != DialogResult.OK)
                {
                    printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                    printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                    return;
                }

                // Printing the Documnet
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

            }
        }
开发者ID:Avaruz,项目名称:Avaruz.FrameWork,代码行数:60,代码来源:PrintDV.cs

示例10: GetPrinters_Click

        private void GetPrinters_Click(object sender, EventArgs e)
        {
            //PrintDocument pd = new PrintDocument();
            //pd.DefaultPageSettings.Bounds = new
            //pd.Print();

            PrintPreviewDialog ppd = new PrintPreviewDialog();
            PrintDocument pd = new PrintDocument();
            //设置边距
            Margins margin = new Margins(200, 20, 20, 0);
            pd.DefaultPageSettings.Margins = margin;
            //纸张设置默认
            PaperSize pageSize = new PaperSize("First custom size", getYc(58), 100);
            pd.DefaultPageSettings.PaperSize = pageSize;
            //打印事件设置
            pd.PrintPage += pd_PrintPage;
            ppd.Document = pd;
            ppd.ShowDialog();
            //try
            //{
            //    pd.Print();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //    pd.PrintController.OnEndPrint(pd, new PrintEventArgs());
            //}
        }
开发者ID:ysjr-2002,项目名称:DeviceTest,代码行数:28,代码来源:FrmDefaultPrint.cs

示例11: ShowPrintPreviewDialog

 /// <summary>
 /// Shows the print preview dialog</summary>
 public void ShowPrintPreviewDialog()
 {
     PrintPreviewDialog dialog = new PrintPreviewDialog();
     PrintDocument printDocument = GetPrintDocument();
     dialog.Document = printDocument;
     dialog.ShowDialog();
 }
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:9,代码来源:StandardPrintCommands.cs

示例12: PrintTokens

        public void PrintTokens(List<TokenPrint> tokens, Form parentDialog, string PrinterName, bool showPrintPreview)
        {
            _tokensToPrint = tokens;
            _pageCounter = 0;
            //bool showPrintPreview = true;
            PrintDocument pd = new PrintDocument();
            PrintDocument pd1 = new PrintDocument();

            pd.DefaultPageSettings.PaperSize = paperSize;
            pd.PrintPage += printDoc_PrintPage;
            pd.PrinterSettings.PrinterName = PrinterName;

            //ToDo: can remove preview in the actual production.
            if (showPrintPreview)
            {
                var ppDlg = new PrintPreviewDialog();
                ppDlg.SetBounds(30, 30, 1024, 500);
                ppDlg.PrintPreviewControl.AutoZoom = true;
                ppDlg.PrintPreviewControl.Zoom = 0.75;
                ppDlg.Document = pd;
                var dr = ppDlg.ShowDialog(parentDialog);
            }
            else
            {
                pd.Print();
            }
        }
开发者ID:akhilnaruto,项目名称:WinApp,代码行数:27,代码来源:PrintHelper.cs

示例13: Print_DataGridView

        private static int TotalWidth; // Summation of Columns widths

        #endregion Fields

        #region Methods

        public static void Print_DataGridView(DataGridView dgv1)
        {
            PrintPreviewDialog ppvw;
            try
            {
                // Getting DataGridView object to print
                dgv = dgv1;

                // Getting all Coulmns Names in the DataGridView
                AvailableColumns.Clear();
                foreach (DataGridViewColumn c in dgv.Columns)
                {
                    if (!c.Visible) continue;
                    AvailableColumns.Add(c.HeaderText);
                }

                // Showing the PrintOption Form
                PrintOptions dlg = new PrintOptions(AvailableColumns);
                if (dlg.ShowDialog() != DialogResult.OK) return;

                PrintAllRows = dlg.PrintAllRows;
                FitToPageWidth = dlg.FitToPageWidth;
                SelectedColumns = dlg.GetSelectedColumns();

                RowsPerPage = 0;

                ppvw = new PrintPreviewDialog();
                ppvw.Document = printDoc;

                // Showing the Print Preview Page
                printDoc.BeginPrint +=new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                printDoc.DefaultPageSettings.Landscape = true;
                PaperSize paperSize = new PaperSize("Letter", 850, 1100);
                paperSize.RawKind = (int)PaperKind.Custom;
                printDoc.DefaultPageSettings.PaperSize = paperSize;
                if (ppvw.ShowDialog() != DialogResult.OK)
                {
                    printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                    printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
                    return;
                }

                // Printing the Documnet
                printDoc.DefaultPageSettings.Landscape = true;
                printDoc.DefaultPageSettings.PaperSize = paperSize;
                printDoc.Print();
                printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
                printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {

            }
        }
开发者ID:jayoreilly,项目名称:Geoex,代码行数:65,代码来源:PrintDGV.cs

示例14: PrintPreview

 public DialogResult PrintPreview()
 {
     var ppd = new PrintPreviewDialog();
     ppd.WindowState = FormWindowState.Maximized;
     ppd.Icon = ((Form)window).Icon;
     ppd.Document = PrintDocument;
     return ppd.ShowDialog(window);
 }
开发者ID:rizwan3d,项目名称:elalang,代码行数:8,代码来源:PrintHelper.cs

示例15: Preview

 // The Print Preview Button
 public void Preview(string title)
 {
     if (Setup(title))
       {
     var myPrintPreviewDialog = new PrintPreviewDialog {Document = printDocument};
     myPrintPreviewDialog.ShowDialog();
       }
 }
开发者ID:romanbdev,项目名称:quickroute-gps,代码行数:9,代码来源:LapGridViewPrinter.cs


注:本文中的System.Windows.Forms.PrintPreviewDialog.ShowDialog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。