當前位置: 首頁>>代碼示例>>C#>>正文


C# Forms.PrintPreviewDialog類代碼示例

本文整理匯總了C#中System.Windows.Forms.PrintPreviewDialog的典型用法代碼示例。如果您正苦於以下問題:C# PrintPreviewDialog類的具體用法?C# PrintPreviewDialog怎麽用?C# PrintPreviewDialog使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


PrintPreviewDialog類屬於System.Windows.Forms命名空間,在下文中一共展示了PrintPreviewDialog類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PrintClass

 /// <summary>
 /// 打印信息的初始化
 /// </summary>
 /// <param datagrid="DataGridView">打印數據</param>
 /// <param PageS="int">紙張大小</param>
 /// <param lendscape="bool">是否橫向打印</param>
 public PrintClass(DataGridView datagrid, int PageS, bool lendscape)
 {
     this.datagrid = datagrid;//獲取打印數據
     this.PageSheet = PageS;//紙張大小
     printdocument = new PrintDocument();//實例化PrintDocument類
     pagesetupdialog = new PageSetupDialog();//實例化PageSetupDialog類
     pagesetupdialog.Document = printdocument;//獲取當前頁的設置
     printpreviewdialog = new PrintPreviewDialog();//實例化PrintPreviewDialog類
     printpreviewdialog.Document = printdocument;//獲取預覽文檔的信息
     printpreviewdialog.FormBorderStyle = FormBorderStyle.Fixed3D;//設置窗體的邊框樣式
     //橫向打印的設置
     if (PageSheet >= 0)
     {
         if (lendscape == true)
         {
             printdocument.DefaultPageSettings.Landscape = lendscape;//橫向打印
         }
         else
         {
             printdocument.DefaultPageSettings.Landscape = lendscape;//縱向打印
         }
     }
     pagesetupdialog.Document = printdocument;
     printdocument.PrintPage += new PrintPageEventHandler(this.printdocument_printpage);//事件的重載
 }
開發者ID:mahuidong,項目名稱:c-1200-II,代碼行數:31,代碼來源:PrintClass.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: 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

示例5: btnPrint_Click

        private void btnPrint_Click(object sender, EventArgs e)
        {
            gcOptions.Visible = false;

            using (System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument())
            {
                printDocument.PrintPage += printDocument_PrintPage;
                printDocument.DefaultPageSettings.Landscape = true;
                printDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("FalseX", 500, 1000);
                //Resize
                Size = new Size(974, 507);
                CaptureScreen();
                try
                {
                    //printDocument.Print();
                    PrintPreviewDialog PPdlg = new PrintPreviewDialog() { Document = printDocument };
                    PPdlg.Show();
                }
                catch (Exception ex)
                {
                    Program.ShowMsg(ex.Message, true, this);
                    Program.Logger.LogThis(null, Text, FXFW.Logger.OpType.fail, ex, null, this);
                }
            }
            Size = new Size(974, 589);
            gcOptions.Visible = true;
        }
開發者ID:EgyFalseX-EESoft-WinForm,項目名稱:School,代碼行數:27,代碼來源:QryWeekTeacherTableFrm.cs

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

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

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

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

示例10: InitializeComponent

 private void InitializeComponent()
 {
     this.printDocument1 = new System.Drawing.Printing.PrintDocument();
     //
     //Main DataSet Initialization
     //
     this.printPreviewDialog1 = new PrintPreviewDialog();
     this.maindataset = new SupremeTransport.maindataset();
     //
     //Table Adapter Initialization
     //
     this.mainbillTableAdapter = new SupremeTransport.maindatasetTableAdapters.mainbillTableAdapter();
     this.billTableAdapter = new SupremeTransport.maindatasetTableAdapters.billTableAdapter();
     // 
     // printDocument1
     // 
     this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
     // 
     // printPreviewDialog1
     // 
     this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
     this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
     this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
     this.printPreviewDialog1.Enabled = true;
     this.printPreviewDialog1.Name = "printPreviewDialog1";
     this.printPreviewDialog1.Visible = false;
 }
開發者ID:EdiCarlos,項目名稱:MyPractices,代碼行數:27,代碼來源:PrintingClass.cs

示例11: bPay_Click

 private void bPay_Click(object sender, EventArgs e)
 {
     DB.Instance.Insert("order", new Parameter("customer_id", cid), new Parameter("dt", DateTime.Now), new Parameter("status", OrderStatus.New));
     uint oid = 0;
     using (MySqlDataReader reader = DB.Instance.SelectReader("select max(id) from order"))
     {
         if(reader != null && reader.Read()){
             oid = reader.GetUInt32(0);
         }
     }
     foreach (var item in Role.Instance.ShopCart)
     {
         DB.Instance.Insert("order_inventory", new Parameter("order_id", oid), new Parameter("inventory_id", item.ID), new Parameter("amount", item.Qty));
     }
     var dr = MessageBox.Show("Order Placed. Would you like to pay now?", "Payment", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     if (dr == DialogResult.Yes)
     {
         new Payment().ShowDialog();
     }
     else if(dr == DialogResult.No)
     {
         var ppd = new PrintPreviewDialog();
         PrintDocument pd = new PrintDocument();
         ppd.Document = pd;
         pd.PrintPage += Pd_PrintPage;
         ppd.ShowDialog();
     }
 }
開發者ID:redlive,項目名稱:csis3275,代碼行數:28,代碼來源:Checkout.cs

示例12: PrintPreviewTree

 /// <summary>
 ///     Shows a PrintPreview dialog displaying the Tree control passed in.
 /// </summary>
 /// <param name="tree">TreeView to print preview</param>
 /// <param name="reportTitle"></param>
 public void PrintPreviewTree(TreeView tree, string reportTitle)
 {
     this.title = reportTitle;
     this.PrepareTreeImage(tree);
     var pp = new PrintPreviewDialog { Document = this.printDoc };
     pp.Show();
 }
開發者ID:jilamilani,項目名稱:PrintTreeView,代碼行數:12,代碼來源:PrintHelper.cs

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

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

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


注:本文中的System.Windows.Forms.PrintPreviewDialog類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。