本文整理汇总了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();
}
}
示例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);
}
示例3: OnEndPage
public override void OnEndPage(
PrintDocument document,
PrintPageEventArgs e
)
{
this.OriginController.OnEndPage(document, e);
}
示例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();
}
示例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;
}
示例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());
}
}
示例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;
}
}
示例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);
}
}
示例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));
}
}
示例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;
}
示例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;
}
}
示例12: OnEndPage
public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
{
//if (ms != null)
//{
// ms.Close();
//}
}
示例13: OnEndPage
public override void OnEndPage(PrintDocument document, PrintPageEventArgs e)
{
this.CheckSecurity();
this.graphics.Dispose();
this.graphics = null;
base.OnEndPage(document, e);
}
示例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;
}
}
示例15: CreateContext
private PageContext CreateContext(PrintPageEventArgs document)
{
return new PageContext(document) {
Horizontal = Horizontal,
Lpi = (float) _lpi.Value,
};
}