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


C# Forms.PrintDialog类代码示例

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


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

示例1: Printing

        public void Printing()
        {
            PrintDialog pDialog = new PrintDialog();
            FileStream fs = new FileStream(@"Szervíz_Feltételek.txt", FileMode.Open, FileAccess.Read);
            StreamReader sr = new StreamReader(fs);

            contract = sr.ReadToEnd();

            try
            {
                try
                {
                    PrintDocument pd = new PrintDocument();
                    pd.PrintPage += new PrintPageEventHandler(pd_PrintRent);

                    if (pDialog.ShowDialog() == DialogResult.OK)
                    {
                        pd.PrinterSettings = pDialog.PrinterSettings;
                        // Print the document.
                        pd.Print();
                    }

                }
                finally
                {

                }
            }
            catch (Exception ex)
            {

            }
        }
开发者ID:sikisuti,项目名称:gyorok,代码行数:33,代码来源:printService.cs

示例2: Run

 public override void Run()
 {
     IWorkbenchWindow activeWorkbenchWindow = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
     if (activeWorkbenchWindow != null)
     {
         if (activeWorkbenchWindow.ViewContent is IPrintable)
         {
             PrintDocument printDocument = ((IPrintable) activeWorkbenchWindow.ViewContent).PrintDocument;
             if (printDocument != null)
             {
                 using (PrintDialog dialog = new PrintDialog())
                 {
                     dialog.Document = printDocument;
                     dialog.AllowSomePages = true;
                     if (dialog.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
                     {
                         printDocument.Print();
                     }
                 }
             }
             else
             {
                 MessageService.ShowError("${res:SkyMap.Net.Commands.Print.CreatePrintDocumentError}");
             }
         }
         else
         {
             MessageService.ShowError("${res:SkyMap.Net.Commands.Print.CantPrintWindowContentError}");
         }
     }
 }
开发者ID:vanloc0301,项目名称:mychongchong,代码行数:31,代码来源:Print.cs

示例3: ConfirmPrinterSettings

        /// <summary>
        /// Confirms the printer settings.
        /// </summary>
        /// <param name="dvPriced">The dv priced.</param>
        /// <param name="dvUnpriced">The dv unpriced.</param>
        /// <param name="stvPrinterName">Name of the STV printer.</param>
        /// <param name="deliveryNotePrinter">The delivery note printer.</param>
        /// <returns></returns>
        private static bool ConfirmPrinterSettings(DataTable dvPriced, DataTable dvUnpriced, out string stvPrinterName,
                                           out string deliveryNotePrinter)
        {
            // get the printer for the stv.
            PrintDialog dialog = new PrintDialog();
            stvPrinterName = deliveryNotePrinter = "";
            if (dvPriced.Rows.Count > 0 && dialog.ShowDialog() == DialogResult.Cancel)
            {
                return false;
            }

            if (dvPriced.Rows.Count > 0)
            {
                stvPrinterName = dialog.PrinterSettings.PrinterName;
            }

            if (dvUnpriced.Rows.Count > 0)
            {
                if (dvPriced.Rows.Count > 0 &&
                    XtraMessageBox.Show(
                        "This transaction contains both priced items and unpriced items (delivery note). Are you sure you want to proceed?",
                        "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
                {
                    return false;
                }

                if (dialog.ShowDialog() == DialogResult.Cancel)
                {
                    return false;
                }
                deliveryNotePrinter = dialog.PrinterSettings.PrinterName;
            }
            return true;
        }
开发者ID:USAID-DELIVER-PROJECT,项目名称:ethiopia-hcmis-warehouse,代码行数:42,代码来源:InvoiceForm.cs

示例4: MapOutPut

        public MapOutPut(AxPageLayoutControl pagecontrol)
        {
            axPageLayoutControl1 = pagecontrol;

            printDialog1 = new System.Windows.Forms.PrintDialog(); //create a print dialog object
            InitializePageSetupDialog(); //intitialize the page setup dialog

            comboBox1.Items.Add("esriPageMappingTile");
            comboBox1.Items.Add("esriPageMappingCrop");
            comboBox1.Items.Add("esriPageMappingScale");
            comboBox1.SelectedIndex = 0;

            // create a new PrintPreviewDialog using constructor
            printPreviewDialog1 = new PrintPreviewDialog();
            //set the size, location, name and the minimum size the dialog can be resized to
            printPreviewDialog1.ClientSize = new System.Drawing.Size(800, 600);
            printPreviewDialog1.Location = new System.Drawing.Point(29, 29);
            printPreviewDialog1.Name = "PrintPreviewDialog1";
            printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
            //set UseAntiAlias to true to allow the operating system to smooth fonts
            printPreviewDialog1.UseAntiAlias = true;

            //associate the event-handling method with the document's PrintPage event
            this.document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(document_PrintPage);
        }
开发者ID:xfgxfg,项目名称:CropWatchField,代码行数:25,代码来源:MapOutPut.cs

示例5: PrintClicked

        private void PrintClicked(object sender, System.EventArgs e)
        {
            if (Viewer == null)
            {
                return;
            }

            PrintDocument pd = new PrintDocument();
            pd.DocumentName = Viewer.SourceFile.LocalPath;
            pd.PrinterSettings.FromPage = 1;
            pd.PrinterSettings.ToPage = Viewer.PageCount;
            pd.PrinterSettings.MaximumPage = Viewer.PageCount;
            pd.PrinterSettings.MinimumPage = 1;
            pd.DefaultPageSettings.Landscape = Viewer.PageWidth > Viewer.PageHeight ? true : false;
            using (PrintDialog dlg = new PrintDialog())
            {
                dlg.Document = pd;
                dlg.AllowSelection = true;
                dlg.AllowSomePages = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Viewer.Print(pd);
                }
            }

        }
开发者ID:myersBR,项目名称:My-FyiReporting,代码行数:26,代码来源:ViewerToolstrip.cs

示例6: 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("Doesn't matter", paperWidth, paperHeight);
              printDocument.DefaultPageSettings.PaperSize = paperSize;

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

              printDialog = new System.Windows.Forms.PrintDialog();
              printDialog.Document = printDocument;
              printDialog.AllowPrintToFile = true;

              pageNumber = 0;
              pageCount = -1;

              if (printDialog.ShowDialog() == DialogResult.OK)
              {
            printDocument.Print();
              }
        }
开发者ID:abibell,项目名称:mysql-workbench,代码行数:34,代码来源:PrintDialog.cs

示例7: btstampa_Click

        private void btstampa_Click(object sender, EventArgs e)
        {
            string imageFilePath = Globalne.pathfolder + "\\priznanica.bmp";
            Bitmap bitmap = (Bitmap)Image.FromFile(imageFilePath);//load the image file

            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                using (Font f = new Font("Times New Roman", 12))
                {
                    Point loc = new Point(480, 262);

                    Size s1 = new Size(134, 31);
                    Rectangle rec = new Rectangle(loc, s1);
                    graphics.DrawString(DateTime.Today.ToString().Substring(0, DateTime.Today.ToString().Length - 12), f, Brushes.Black, rec);
                    rec.X = 485;
                    rec.Y = 303;
                    graphics.DrawString(ukupno.ToString(), f, Brushes.Black, rec);

                }
            }

            bitmap.Save(Globalne.pathfolder + "\\priznanicaP.bmp");

                PrintDialog printDialog = new PrintDialog();
                printDialog.Document = printDocument1;
                printDialog.UseEXDialog = true;
                if (DialogResult.OK == printDialog.ShowDialog())
                {
                    printDocument1.DocumentName = "Račun";
                    printDocument1.Print();
                }
        }
开发者ID:filipxa,项目名称:Molim_te_nemoj_vise,代码行数:32,代码来源:racun.cs

示例8: Print

        private bool Print(bool showPrintDialog, ScintillaPrintDocument doc)
        {
            if (showPrintDialog)
            {
                var pd = new PrintDialog();
                pd.Document = doc;
                pd.UseEXDialog = true;
                pd.AllowCurrentPage = true;
                pd.AllowSelection = true;
                pd.AllowSomePages = true;
                pd.PrinterSettings = doc.DefaultPageSettings.PrinterSettings;

                if (pd.ShowDialog(WB.Form) == DialogResult.OK)
                {
                    doc.PrinterSettings = pd.PrinterSettings;
                    doc.Print();
                    return true;
                }

                return false;
            }

            doc.Print();
            return true;
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:25,代码来源:PrintService.cs

示例9: A4PrintSelectPrint

        public bool A4PrintSelectPrint(string printContent, int printContentLineCount)
        {
            //PrintDocument doc = new TextDocument(printContent, printContentLineCount);
            PrintDocument doc = new TextDocument(printContent);//@Salim

            doc.PrintPage += this.printDocument1_PrintPage;

            PrintDialog printDialog1 = new PrintDialog();

            // pageSetupDialog1 = new PageSetupDialog();

            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                // printDialog1.ShowDialog();

                if (printDialog1.PrinterSettings.PrinterName != null)
                {
                    if (printDialog1.PrinterSettings.PrinterName != null)
                    {
                        doc.DefaultPageSettings.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PrinterName;
                        // doc.DefaultPageSettings.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PaperSizes ;
                    }

                    doc.DefaultPageSettings.Landscape = true;
                    PrintDialog dlgSettings = new PrintDialog();
                    dlgSettings.Document = doc;

                    //if (dlgSettings.ShowDialog() == DialogResult.OK)
                    //{
                    doc.Print();
                }
            }
            return true;
        }
开发者ID:Jusharra,项目名称:RMS,代码行数:34,代码来源:PrintUtility.cs

示例10: 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

示例11: 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

示例12: Print

 public override void Print(bool ShowDialog)
 {
     printDoc = new PrintDocument();
         printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
         pd = new PrintDialog();
         pd.Document = printDoc;
         pd.AllowSomePages = true;
         if ((!ShowDialog) || (pd.ShowDialog() == DialogResult.OK))
         {
             printDoc.DocumentName = "debuglog-" + DateTime.Now.Date.ToShortDateString() + ".txt";
             strPrintText = RawTrafficText.Text.Length > 0 ? RawTrafficText.Text : " ";
             switch (pd.PrinterSettings.PrintRange)
             {
                 case PrintRange.AllPages:
                     startPage = 1;
                     totalPages = pd.PrinterSettings.MaximumPage;
                     break;
                 case PrintRange.SomePages:
                     startPage = pd.PrinterSettings.FromPage;
                     totalPages = pd.PrinterSettings.ToPage - startPage + 1;
                     break;
             }
             // start printing
             pageNumber = 1;
             printDoc.Print();
         }
 }
开发者ID:HBelusca,项目名称:NasuTek-Odyssey-Tools,代码行数:27,代码来源:RawTraffic.cs

示例13: 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", 219, 1000);
            pd.Document = pdoc;
            //pd.Document.DefaultPageSettings.PaperSize = psize;

            if (pd.Document.DefaultPageSettings.PaperSize.Width <= 284)
            {
                k = Convert.ToDouble(pd.Document.DefaultPageSettings.PaperSize.Width) / 284;
            }

            pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);

            DialogResult result = pd.ShowDialog();
            if (result == DialogResult.OK)
            {
                PrintPreviewDialog pp = new PrintPreviewDialog();
                pp.Document = pdoc;
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
                pp.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
                pp.PrintPreviewControl.Zoom = 1f;
                result = pp.ShowDialog();
                if (result == DialogResult.OK)
                {
                    pdoc.Print();
                }
            }
        }
开发者ID:ochirpurev,项目名称:CSPosAPI,代码行数:33,代码来源:MainForm.cs

示例14: SetupThePrinting

        // The printing setup function
        private bool SetupThePrinting()
        {
            PrintDialog MyPrintDialog = new PrintDialog();
               MyPrintDialog.AllowCurrentPage = false;
               MyPrintDialog.AllowPrintToFile = false;
               MyPrintDialog.AllowSelection = false;
               MyPrintDialog.AllowSomePages = false;
               MyPrintDialog.PrintToFile = false;
               MyPrintDialog.ShowHelp = false;
               MyPrintDialog.ShowNetwork = false;

               if (MyPrintDialog.ShowDialog() != DialogResult.OK)
            return false;
               MyPrintDocument.DocumentName = "Planilla de ventas peluquería";
               MyPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; //página horizontal
               //MyPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = false; //página vertical
               MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings;
               MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings;
               MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);

               //if (MessageBox.Show("¿Desea centrar el reporte en la pagina?",
               // "InvoiceManager - Center on Page", MessageBoxButtons.YesNo,
               // MessageBoxIcon.Question) == DialogResult.Yes)
               // MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView,
               // MyPrintDocument, true, true, "Listado Completo de Facturas", new Font("Tahoma", 15,
               // FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
               //else
               string encabezado = "Vendedor: Cecilia Toscani             Zona: " + txtZona.Text + "               Fecha: " + DateTime.Now.ToLongDateString();
            MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView,
            MyPrintDocument, false, true, encabezado, new Font("Tahoma", 13,
            FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
               return true;
        }
开发者ID:numenio,项目名称:Sistema-Ventas-Peluqueria,代码行数:34,代码来源:frmImprimir.cs

示例15: StartPrint

        //Stream streamToPrint, string streamType
        //2�����Print��ӡ����
        public void StartPrint()
        {
            //����ֵ��PageSettings A4\A5
            PageSettings ps = new PageSettings();
            //��ʾ���ô�ӡҳ�Ի���
            PageSetupDialog Psdl = new PageSetupDialog();
            //��ӡ������ã�ע�⣬�÷��������printpage�������档
            PrintDialog pt = new PrintDialog();
            pt.AllowCurrentPage = true;
            pt.AllowSomePages = true;
            pt.AllowPrintToFile = true;
            //       StreamToPrint = streamToPrint;//��ӡ���ֽ���
            //       StreamType = streamType; //��ӡ������
            //       printDocument1.DocumentName = Filename; //��ӡ���ļ���
            Psdl.Document = printDocument1;
            //       PrintPreview.Document = printDocument1;
            pt.Document = printDocument1;
            Psdl.PageSettings = printDocument1.DefaultPageSettings;
            try
            {
                //ҳ�����öԻ���
                if (Psdl.ShowDialog() == DialogResult.OK)
                {
                    ps = Psdl.PageSettings;
                    printDocument1.DefaultPageSettings = Psdl.PageSettings;
                }
                //ѡ���ӡ���Ի���
                if (pt.ShowDialog() == DialogResult.OK)
                {
                    printDocument1.PrinterSettings.Copies = pt.PrinterSettings.Copies;
                    //printDocument1.Print();
                    if (!checkBoxAll.Checked)
                    {
                        printDocument1.Print();
                    }
                    else
                    {
                        for (int i = 0; i < dataGridView1.RowCount; i++)
                        {
                            ShowTag(i);
                            printDocument1.Print();
                        }
                    }

                }
                ////��ӡԤ���Ի���
                //if (PrintPreview.ShowDialog() == DialogResult.OK)
                //{
                //    //���ô�ӡ
                //    printDocument1.Print();
                //}

                //PrintDocument�����Print()������PrintController����ִ��PrintPage�¼���
            }
            catch (InvalidPrinterException ex)
            {
                MessageBox.Show(ex.Message, "Simple Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
开发者ID:chutinhha,项目名称:asset-management-system,代码行数:62,代码来源:PrintDlg.cs


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