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


C# Printing.PrintPageEventArgs類代碼示例

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


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

示例1: m_printDocument_PrintPage

        void m_printDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            SelectedMealCollection colData = (SelectedMealCollection)this.FindResource("SelectedMealCollectionData");
            float leftMargin = e.MarginBounds.Left;
            float rightMargin = e.MarginBounds.Right;
            float topMargin = e.MarginBounds.Top;
          
            float yPos = leftMargin;
            float xPos = 0;
            float centrePos = 2 * (rightMargin - leftMargin) / 5;
            float rightPos =  4 * (rightMargin - leftMargin) / 5;
            int count = 0;

            System.Drawing.Font printFont = new System.Drawing.Font("Arial", 10);
            System.Drawing.SolidBrush myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

            // Work out the number of lines per page, using the MarginBounds.
            float linesPerPage = e.MarginBounds.Height / printFont.GetHeight(e.Graphics);
            float lineCount = 0;
            foreach (var selectedMeal in colData)
            {
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Date, printFont, myBrush, xPos, yPos);
                lineCount++;
   
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                e.Graphics.DrawString(selectedMeal.Meal, printFont, myBrush, xPos + 20, yPos);

                lineCount++;

                if (lineCount > linesPerPage) { break; }
            }

            lineCount = 0;
            count = 0;

            SelectedIngredientsCollection ingredientData = (SelectedIngredientsCollection)this.FindResource("SelectedIngredientsCollectionData");

            foreach (SelectedIngredient ingredient in ingredientData)
            {               
                // calculate the next line position based on the height of the font according to the printing device
                yPos = topMargin + (count++ * printFont.GetHeight(e.Graphics));
                xPos = centrePos;
                if (lineCount > linesPerPage) xPos = rightPos;
                e.Graphics.DrawString(ingredient.Ingredient, printFont, myBrush, xPos, yPos);
                lineCount++;
            }

            // If there are more lines, print another page.
            if (lineCount > linesPerPage)
            {
           //     e.HasMorePages = true;
            }
            else
            {
                e.HasMorePages = false;
                myBrush.Dispose();
            }
        }
開發者ID:jscott7,項目名稱:SuperMarketPlanner,代碼行數:60,代碼來源:MainWindow.xaml.cs

示例2: pdDocument_PrintPage

        void pdDocument_PrintPage(object sender, PrintPageEventArgs e)
        {
            int x = 10;
            int y = 80;
            e.Graphics.DrawString(binfo.tabName, new Font("Arial", 15), Brushes.Black, 150, 5);
            e.Graphics.DrawString(printType, new Font("Arial", 15), Brushes.Black, 50, 5);
            e.Graphics.DrawString(CommService.GetCompanyName(), new Font("Arial", 10), Brushes.Black, 40, 35);

            e.Graphics.DrawString("商品名稱", new Font("Arial", 10), Brushes.Black, x, y);
            e.Graphics.DrawString("數量", new Font("Arial", 10), Brushes.Black, 120, y);
            e.Graphics.DrawString("單價", new Font("Arial", 10), Brushes.Black, 160, y);
            e.Graphics.DrawString("贈送", new Font("Arial", 10), Brushes.Black, 240, y);
            double sum = 0;
            for (int i = 0; i < billDetailInfos.Count; i++)
            {
                BillDetailInfo dInfo = billDetailInfos[i];
                e.Graphics.DrawString(dInfo.FoodCnName, new Font("Arial", 10), Brushes.Black, x, y + i * 25 + 20);
                e.Graphics.DrawString(dInfo.foodCount.ToString(), new Font("Arial", 10), Brushes.Black, 120, y + i * 25 + 20);
                e.Graphics.DrawString(dInfo.FoodPrice.ToString(), new Font("Arial", 10), Brushes.Black, 160, y + i * 25 + 20);
                e.Graphics.DrawString(dInfo.Handsel.ToString(), new Font("Arial", 10), Brushes.Black, 240, y + i * 25 + 20);
                sum += dInfo.FoodPrice * dInfo.foodCount;
            }

            e.Graphics.DrawString(string.Format("總額:{0}", sum + "元"), new Font("Arial", 10), Brushes.Black, 10, 50 + (billDetailInfos.Count + 2) * 25);
            e.Graphics.DrawString(string.Format("賬單號:{0}", binfo.billKey), new Font("Arial", 10), Brushes.Black, 10, 50 + (billDetailInfos.Count + 3) * 25);
            e.Graphics.DrawString(string.Format("下單時間:{0}", binfo.billtime), new Font("Arial", 10), Brushes.Black, 10, 50 + (billDetailInfos.Count + 4) * 25);
        }
開發者ID:JimDeng,項目名稱:WenJiaPC,代碼行數:27,代碼來源:KitchenBillPrinter.cs

示例3: OnEndPage

 public override void OnEndPage(
     PrintDocument document,
     PrintPageEventArgs e
     )
 {
     this.OriginController.OnEndPage(document, e);
 }
開發者ID:renyh1013,項目名稱:dp2,代碼行數:7,代碼來源:NewPrintController.cs

示例4: PrintDocument_PrintPage

 private static void PrintDocument_PrintPage(object sender, PrintPageEventArgs e)
 {
     var g = e.Graphics;
     //歡迎文字
     var y = 0;
     var lineH = 25;
     var config = ConfigProfile.Instance;
     if (!config.Welcome.IsEmpty())
     {
         e.Graphics.DrawString(config.Welcome, printFont, Brushes.Black, new Point(65, y));
         y += lineH;
     }
     if (!config.DateTime.IsEmpty())
     {
         var dt = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
         e.Graphics.DrawString(dt, printTimeFont, Brushes.Black, new Point(40, y));
         y += lineH;
     }
     if (!config.Guide.IsEmpty())
     {
         e.Graphics.DrawString(config.Guide, printFont, Brushes.Black, new Point(52, y));
         y += lineH;
     }
     //二維碼圖像
     g.DrawImage(_barcodeImage, new Rectangle(45, y, IMAGE_SIZE, IMAGE_SIZE));
     DisposeImage();
 }
開發者ID:ysjr-2002,項目名稱:BJ-Benz,代碼行數:27,代碼來源:BrotherPrinter.cs

示例5: OnPrintPage

		//Override the OnPrintPage to provide the printing logic for the document
		protected override void OnPrintPage(PrintPageEventArgs ev) 
		{
			base.OnPrintPage(ev);
			labelDocument.DocumentSizeXPixels = ev.PageBounds.Width;
			labelDocument.DocumentSizeYPixels = ev.PageBounds.Height;

			foreach (Structs.Competitor competitor in competitors)
			{
				PrintLabel label;
				try
				{
					label = labelDocument.GetLabel(labelCount);
				}
				catch (PrintLabelDoesNotExistException)
				{
					labelCount = 0;
					ev.HasMorePages = true;
					return;
				}
				printCompetitor(ev, competitor, label);
				labelCount++;    
			}


			ev.HasMorePages = false;
		}
開發者ID:WinShooter,項目名稱:WinShooter-Legacy,代碼行數:27,代碼來源:CPrintResultLabels.cs

示例6: PrintPage

        private void PrintPage(object o, PrintPageEventArgs e)
        {
            try
            {
            button1.Visible = false;
            int x = SystemInformation.WorkingArea.X;
            int y = SystemInformation.WorkingArea.Y;

            int width = this.Width;
            int height = this.Height;

            Rectangle bounds = new Rectangle(x, y, width, height);

            Bitmap img = new Bitmap(width, height);

            this.DrawToBitmap(img, bounds);
            string date = DateTime.Now.ToString("yyyyMMddhhmmss");

            //img.Save(date + ".bmp");
            //Point loc = new Point(100, 100);
            e.Graphics.DrawImage(img, bounds);
             }
             catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
開發者ID:vivektarwan,項目名稱:JSSRISf,代碼行數:27,代碼來源:Printpatientinfo.cs

示例7: OnPrintPage

            protected override void OnPrintPage(PrintPageEventArgs e)
            {
                base.OnPrintPage(e);

                Stream pageToPrint = m_pages[m_currentPage];
                pageToPrint.Position = 0;

                // Load each page into a Metafile to draw it.
                using (Metafile pageMetaFile = new Metafile(pageToPrint))
                {
                    Rectangle adjustedRect = new Rectangle(
                            e.PageBounds.Left - (int)e.PageSettings.HardMarginX,
                            e.PageBounds.Top - (int)e.PageSettings.HardMarginY,
                            e.PageBounds.Width,
                            e.PageBounds.Height);

                    // Draw a white background for the report
                    e.Graphics.FillRectangle(Brushes.White, adjustedRect);

                    // Draw the report content
                    e.Graphics.DrawImage(pageMetaFile, adjustedRect);

                    // Prepare for next page.  Make sure we haven't hit the end.
                    m_currentPage++;
                    e.HasMorePages = m_currentPage < m_pages.Count;
                }
            }
開發者ID:FJSOTO,項目名稱:Tienda-Plaza,代碼行數:27,代碼來源:AutoPrintCls.cs

示例8: pdDocument_PrintPage

 void pdDocument_PrintPage(object sender, PrintPageEventArgs e)
 {
     int x = 10;
     int y = 80;
     //double sx = Convert.ToDouble(tb_Cash.Text) + Convert.ToDouble(tb_Vesa.Text) + Convert.ToDouble(tb_Card.Text) + Convert.ToDouble(tb_cashCoupon.Text);
     e.Graphics.DrawString(bInfo.tabName, new Font("Arial", 20), Brushes.Black, 200, 5);
     e.Graphics.DrawString("消費小票", new Font("Arial", 20), Brushes.Black, 60, 5);
     e.Graphics.DrawString(CommService.GetCompanyName(), new Font("Arial", 10), Brushes.Black, 50, 40);
     //e.Graphics.DrawString(String.Format("房間號碼:{0}",bInfo.billRmNo), new Font("Arial", 10), Brushes.Black, 10, 60);
     e.Graphics.DrawString("商品名稱", new Font("Arial", 10), Brushes.Black, x, y);
     e.Graphics.DrawString("數量", new Font("Arial", 10), Brushes.Black, 120, y);
     e.Graphics.DrawString("單價", new Font("Arial", 10), Brushes.Black, 180, y);
     e.Graphics.DrawString("贈送", new Font("Arial", 10), Brushes.Black, 240, y);
     for (int i = 0; i < detailInfos.Count; i++)
     {
         BillDetailInfo dInfo = detailInfos[i];
         e.Graphics.DrawString(dInfo.FoodCnName, new Font("Arial", 10), Brushes.Black, x, y + i * 25 + 20);
         e.Graphics.DrawString(dInfo.foodCount.ToString(), new Font("Arial", 10), Brushes.Black, 120, y + i * 25 + 20);
         e.Graphics.DrawString(dInfo.FoodPrice.ToString(), new Font("Arial", 10), Brushes.Black, 190, y + i * 25 + 20);
         e.Graphics.DrawString(dInfo.Handsel.ToString(), new Font("Arial", 10), Brushes.Black, 240, y + i * 25 + 20);
     }
     //domain.RechargeCardInfo cinfo = service.RechargeCardService.GetRechargeCardInfoByCardId(bInfo.cardId);
     e.Graphics.DrawString(string.Format("總金額:{0}元  賬單號:{1}", bInfo.billMoney, bInfo.billKey), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 2) * 25);
     e.Graphics.DrawString(string.Format("折扣:{0}  折扣金額:{1} 元", bInfo.discount, bInfo.billMoney - bInfo.SHmoney), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 3) * 25);
     e.Graphics.DrawString(string.Format("應收金額:{0}元 結帳方式:{1} ", bInfo.SHmoney, bInfo.paymethod), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 4) * 25);
     //e.Graphics.DrawString(string.Format("結帳方式:{0}元 ", bInfo.paymethod), new Font("Arial", 10), Brushes.Black, 10, 50 + (bInfo.detailInfos.Count + 5) * 25);
     if (type == 1)
     {
         //e.Graphics.DrawString(string.Format("易享卡卡號:{0}", bInfo.vipNo), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 5) * 25);
         //e.Graphics.DrawString(string.Format("充值卡號:{0} 充值卡餘額:{1}元", bInfo.cardId, cinfo == null ? "0.0" : (cinfo.Balance + cinfo.FHBalance).ToString()), new Font("Arial", 10), Brushes.Black, 10, 50 + (bInfo.detailInfos.Count + 6) * 25);
         e.Graphics.DrawString(string.Format("實收金額:{0}元,找零{1}元", bInfo.SHmoney, bInfo.zl), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 5) * 25);
         e.Graphics.DrawString(string.Format("結賬時間:{0}", bInfo.checktime), new Font("Arial", 10), Brushes.Black, 10, 50 + (detailInfos.Count + 6) * 25);
     }
 }
開發者ID:JimDeng,項目名稱:WenJiaPC,代碼行數:34,代碼來源:CheckoutPrinter.cs

示例9: OnPrintPage

        protected override void OnPrintPage(PrintPageEventArgs ev)
        {
            base.OnPrintPage(ev);

            ev.Graphics.PageUnit = GraphicsUnit.Millimeter;
            Font font; // = new Font(new FontFamily("Arial"), 7.0f, GraphicsUnit.Millimeter);

            Rectangle bodyRect = new Rectangle(3, 3, 184, 272);             // DVD Cover size 272x184
            Rectangle middleRect = new Rectangle(3, 129 + 3, 184, 14);      // DVD Covert side size, 14x184

            // Draw dotted rectable
            Pen borderPen = new Pen(System.Drawing.Color.Black, 0.3f);
            borderPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Custom;
            borderPen.DashPattern = new float[] {0.3F, 45F};
            ev.Graphics.DrawRectangle(borderPen, bodyRect);

            // Draw dotted rectable in middle
            //ev.Graphics.DrawRectangle(borderPen, middleRect);

            // Draw small "L" markers on cut positions
            Pen linePen = new Pen(System.Drawing.Color.Black, 0.3f);
            ev.Graphics.DrawLine(linePen, 3, 3, 6, 3);
            ev.Graphics.DrawLine(linePen, 3, 3, 3, 6);

            ev.Graphics.DrawLine(linePen, 184+3, 3, 181+3, 3);
            ev.Graphics.DrawLine(linePen, 184+3, 3, 184+3, 6);

            ev.Graphics.DrawLine(linePen, 3, 272+3, 6, 272+3);
            ev.Graphics.DrawLine(linePen, 3, 272+3, 3, 269+3);

            ev.Graphics.DrawLine(linePen, 184 + 3, 272 + 3, 181+3, 272 + 3);
            ev.Graphics.DrawLine(linePen, 184 + 3, 272 + 3, 184+3, 269 + 3);

            float startpos = middleRect.X + 2.0f;
            if (text1 != null)
            {
                font = new Font(new FontFamily("Arial"), size1, GraphicsUnit.Millimeter);
                startpos += DrawSideText(ev, font, 0, text1, startpos, middleRect.Y + ((middleRect.Height-size1) / 2.0f));
            }
            if (text2 != null)
            {
                font = new Font(new FontFamily("Arial"), size2, GraphicsUnit.Millimeter);
                startpos += DrawSideText(ev, font, 1, text2, startpos, middleRect.Y + ((middleRect.Height - size2) / 2.0f));
            }
            if (text3 != null)
            {
                font = new Font(new FontFamily("Arial"), size3, GraphicsUnit.Millimeter);
                startpos += DrawSideText(ev, font, 2, text3, startpos, middleRect.Y + ((middleRect.Height - size3) / 2.0f));
            }
            if (text4 != null)
            {
                font = new Font(new FontFamily("Arial"), size4, GraphicsUnit.Millimeter);
                startpos += DrawSideText(ev, font, 3, text4, startpos, middleRect.Y + ((middleRect.Height - size4) / 2.0f));
            }
            if (textnumber != null)
            {
                font = new Font(new FontFamily("Arial"), sizenumber, GraphicsUnit.Millimeter);
                startpos += DrawNumberText(ev, font, numbercolor, textnumber, middleRect.X + middleRect.Width - 2.0f, middleRect.Y + ((middleRect.Height - sizenumber) / 2.0f));
            }
        }
開發者ID:RangelReale,項目名稱:DVDCoverPrinter,代碼行數:60,代碼來源:CoverPrint.cs

示例10: OnStartPage

        public override Graphics OnStartPage(PrintDocument document, PrintPageEventArgs e)
        {
            Bitmap bmp = new Bitmap(1, 1);

            Graphics bmpg = Graphics.FromImage(bmp);
            IntPtr hdc = bmpg.GetHdc();
            ms = new MemoryStream();
            Metafile meta = new Metafile(ms, hdc, EmfType.EmfPlusDual);
            bmpg.ReleaseHdc(hdc);

            this.pic.Image = meta;

            Graphics g = Graphics.FromImage(meta);

            PaperSize size = e.PageSettings.PaperSize;
            int height = size.Height * dpi / 100;
            int width = size.Width * dpi / 100;

            if (e.PageSettings.Landscape)
            {
                g.FillRectangle(Brushes.White, 0, 0, height, width);
                g.SetClip(new Rectangle(0, 0, height - 16, width - 16));
            }
            else
            {
                g.FillRectangle(Brushes.White, 0, 0, width, height);
                g.SetClip(new Rectangle(0, 0, width - 16, height - 16));
            }

            return g;
        }
開發者ID:JosonYang,項目名稱:aojreporter,代碼行數:31,代碼來源:AojPrintPreviewControl.cs

示例11: PrintDoc_PrintPage

        private void PrintDoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            if (m_currentPrintSet == null)
            {
                m_currentPrintSet = new List<PictureViewBox>(m_pictureViewPanel.GetSelected());
                m_currentPrintSetItem = 0;
            }

            PictureViewBox pvb = m_currentPrintSet[m_currentPrintSetItem];
            Image image = pvb.Image;
            e.Graphics.DrawImage(image, 0, 0);
            image.Dispose();

            m_currentPrintSetItem++;

            if (m_currentPrintSetItem < m_currentPrintSet.Count)
            {
                e.HasMorePages = true;
            }
            else
            {
                m_currentPrintSetItem = 0;
                m_currentPrintSet = null;
                e.HasMorePages = false;
            }
        }
開發者ID:ewertons,項目名稱:PhotoPrinter,代碼行數:26,代碼來源:Form1.cs

示例12: OnEndPage

 public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
 {
     //if (ms != null)
     //{
     //    ms.Close();
     //}
 }
開發者ID:JosonYang,項目名稱:aojreporter,代碼行數:7,代碼來源:AojPrintPreviewControl.cs

示例13: OnEndPage

 public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
 {
     this.CheckSecurity();
     this.graphics.Dispose();
     this.graphics = null;
     base.OnEndPage(document, e);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:7,代碼來源:PreviewPrintController.cs

示例14: pDoc_PrintPage

        void pDoc_PrintPage(object sender, PrintPageEventArgs e)
        {
            Graphics g = e.Graphics;
            int x = -110;
            int y = 30;
            int cell_height = 0;
            dGrid.ColumnHeadersVisible = true;
            int colCount = dGrid.ColumnCount;
            int rowCount = dGrid.RowCount;
            int current_col = 0;
            int current_row = 0;
            string value = "";
            Rectangle cell_border;
            SolidBrush brush = new SolidBrush(Color.Black);
            while (current_row < rowCount)
            {
                while (current_col < colCount)
                {
                    x += dGrid[current_col, current_row].Size.Width;
                    cell_height = dGrid[current_col, current_row].Size.Height;
                    cell_border = new Rectangle(x, y, dGrid[current_col, current_row].Size.Width, dGrid[current_col, current_row].Size.Height);
                    value = dGrid[current_col, current_row].Value.ToString();
                    g.DrawRectangle(new Pen(Color.Black), cell_border);
                    g.DrawString(value, new Font("tahoma", 6), brush, x, y);
                    current_col++;      //increment the currnet column
                }

                current_col = 0;
                current_row++;          //increment the current row
                x = -110;
                y += cell_height;
            }
        }
開發者ID:iMutex,項目名稱:EBusiness,代碼行數:33,代碼來源:PrintReports.cs

示例15: CreateContext

 private PageContext CreateContext(PrintPageEventArgs document)
 {
     return new PageContext(document) {
         Horizontal = Horizontal,
         Lpi = (float) _lpi.Value,
     };
 }
開發者ID:atomicguy,項目名稱:Lenticuprint,代碼行數:7,代碼來源:Form1.cs


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