// OnPrintPage - called when printing needs to be done... protected override void OnPrintPage(PrintPageEventArgs e) { float headerHeight = Header.CalculateHeight(this, e.Graphics); Header.Draw(this, 10, e.Graphics, e.MarginBounds); Rectangle pageBounds = new Rectangle(15, (int)(e.MarginBounds.Top + headerHeight), e.MarginBounds.Width, (int)(e.MarginBounds.Height - headerHeight)); float yPos = 50; int elementsOnPage = 0; while (_printIndex < _printElements.Count) { // get the element... PrintElement element = (PrintElement)_printElements[_printIndex]; // how tall is the primitive? float height = element.CalculateHeight(this, e.Graphics); element.Draw(this, yPos, e.Graphics, pageBounds); // move the ypos... yPos += height; // next... _printIndex++; elementsOnPage++; } // do we have more pages? //e.HasMorePages = morePages; }
// Print... public void Print(PrintElement element) { // tell the engine to draw a header... element.AddHeader("Customer"); // now, draw the data... element.AddData("Customer ID", Id.ToString()); element.AddData("Name", FirstName + " " + LastName); element.AddData("Company", Company); element.AddData("E-mail", Email); element.AddData("Phone", Phone); // finally, add a blank line... element.AddBlankLine(); }
public PrintEngine() { // create the header... Header = new PrintElement(null); Header.AddTitle("云南人才市场"); //Header.AddText("Page: [pagenum]"); Header.AddHorizontalRule(); //Header.AddBlankLine(); // create the footer... // Footer = new PrintElement(null); // Footer.AddBlankLine(); // Footer.AddHorizontalRule(); //Footer.AddText("Confidential"); }
// OnBeginPrint - called when printing starts protected override void OnBeginPrint(PrintEventArgs e) { // reset... _printElements = new ArrayList(); _pageNum = 0; _printIndex = 0; // go through the objects in the list and create print elements for each one... foreach (IPrintable printObject in _printObjects) { // create an element... PrintElement element = new PrintElement(printObject); _printElements.Add(element); // tell it to print... //element.Print(); printObject.Print(element); } }
// Print... public void Print(PrintElement element) { element.AddSeat(cnvcBillType); if (cnvcJobInfo.Trim().Length > 0) { element.AddInfo(cnvcJobInfo); element.AddInfo("服务台签到有效"); } element.AddHorizontalRule(); element.AddData("会员卡号", cnvcMemberCardNo); element.AddData("原卡号", cnvcOldMemberCardNo); element.AddData("会员密码", cnvcMemberPwd); element.AddData("单位名称", cnvcMemberName); element.AddData("工商注册号", cnvcPaperNo); element.AddData("会员资格", cnvcMemberRight); //产品多条分开显示,逗号分隔各项,|竖线分割各个产品 if (cnvcProduct.Trim().Length > 0) { string[] strProducts = cnvcProduct.Split('|'); element.AddHeader("服务产品"); foreach (string strProduct in strProducts) { if (strProduct.Trim().Length > 0) { string[] strItems = strProduct.Split(','); if (strItems.Length > 3) { element.AddData(" 名称", strItems[0]); element.AddData(" 单价", strItems[1]); element.AddData(" 折扣", strItems[2]); element.AddData(" 数量", strItems[3]); element.AddData(" 金额", strItems[4]); } ///element.AddData(" 金额",strItems[5]); //strItems[3]. } } element.AddHorizontalRule(); } else { element.AddHorizontalRule(); } if (cnvcBillType == ConstApp.Bill_Type_Provide) { element.AddData("单位名称", cnvcMemberName); } element.AddData("会员费", cnnMemberFee.ToString("F2")); //element.AddData("折扣",cnvcDiscount); if (!cnbFeeType) { //element.AddData("场次", cnvcFree); //} //else //{ element.AddData("上次余额", cnnLastBalance.ToString("F2")); element.AddData("金额", cnnPrepay.ToString("F2")); element.AddData("赠送金额", cnnDonate.ToString("F2")); element.AddData("当前余额", cnnBalance.ToString("F2")); //if (!string.IsNullOrEmpty(cnvcDiscount)) //{ element.AddData("折扣", cnvcDiscount); // + "折"); //} } element.AddData("卡使用时限", cndEndDate); element.AddData("展厅", cnvcShow); element.AddSeatData("展位", cnvcSeat); if (cnbFeeType) { element.AddData("剩余场次", cnvcFreeLast); } //element.AddData("操作员",cnvcOperName); element.AddData("同步标志", cnvcSynch); element.AddData("操作时间", cndOperDate.ToString("yyyy-MM-dd hh:mm")); if (cnvcBillType == ConstApp.Bill_Type_SignIn) { element.AddHorizontalRule(); element.AddBlack("请到四号窗口领取参会资料"); } element.AddBlankLine(); element.AddBlankLine(); element.AddBlankLine(); element.AddBlankLine(); element.AddHorizontalRule(); }