TemplatePrintModel CreateDemoTemplatePrintModel() { //Graphics gs = new Graphics(); TemplatePrintModel model1 = new TemplatePrintModel(); model1.BarCodeStr = "11111111111"; model1.FilmName = "电影名称"; model1.HallFieldCode = "00"; model1.HallName = "影厅名称"; model1.RowNumber = "0"; model1.SeatNumber = "0"; model1.SellTime = DateTime.Now.ToString(); model1.StaffNumber = "000110011"; model1.TheaterName = "影院名称"; model1.TicketDate = DateTime.Now.ToShortDateString(); model1.TicketPrice = "80.00元"; model1.TicketTime = DateTime.Now.ToShortTimeString(); model1.TicketType = "电影票"; model1.PayType = "现金"; model1.SeatNumberStr = "0排0座"; model1.CheckingType = "对号入座"; BarcodeControl = new Cobainsoft.Windows.Forms.BarcodeControl(); BarcodeControl.BarcodeType = Cobainsoft.Windows.Forms.BarcodeType.CODE128C; BarcodeControl.CopyRight = ""; BarcodeControl.ShowCode39StartStop = true; BarcodeControl.StretchText = true; BarcodeControl.TextPosition = Cobainsoft.Windows.Forms.BarcodeTextPosition.Below; return(model1); }
public TemplatePrintCore(Template template, TemplatePrintModel templatePrintModel) { try { this.template = template; this.model = templatePrintModel; printDialog1 = new System.Windows.Forms.PrintDialog(); printDocument1 = new System.Drawing.Printing.PrintDocument(); printDocument1.PrinterSettings.PrinterName = template.PrintSetting.PrintModule; //printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("123", (int)(template.Background.ImageWidth / 2.54), (int)(template.Background.ImageHeight / 2.54)); printDocument1.DefaultPageSettings.PaperSize = new PaperSize("comaond", 433, 219); x = GetX(printDocument1.DefaultPageSettings.HardMarginX); y = GetY(printDocument1.DefaultPageSettings.HardMarginY); printDocument1.DefaultPageSettings.Margins.Left = 0; //printDocument1.DefaultPageSettings.Margins.Left -=(int) printDocument1.DefaultPageSettings.HardMarginX; //printDocument1.DefaultPageSettings.Margins.Right -= (int)printDocument1.DefaultPageSettings.HardMarginY; //printDocument1.DefaultPageSettings.Margins.Top = 0; //printDocument1.DefaultPageSettings.HardMarginX printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printDocument1_PrintPage); } catch (Exception ex) { throw ex; } }
private void TemplateNameComboBox_SelectedIndexChanged(object sender, EventArgs e) { TemplateObj templateObj = TemplateNameComboBox.SelectedItem as TemplateObj; template = templateObj.Template; //printPreviewControl1.Width = (int)MillimetersToPixelsWidth(template.Background.ImageWidth); //printPreviewControl1.Height = (int)MillimetersToPixelsWidth(template.Background.ImageHeight); printPreviewControl1.Document = printDocument1; // printDocument1.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("123", (int)(template.Background.ImageWidth/2.54), (int)(template.Background.ImageHeight/2.54)); if (!voucher) { printDocument1.DefaultPageSettings.PaperSize = new PaperSize("comaond", 433, 219); } else { printDocument1.DefaultPageSettings.PaperSize = new PaperSize("comaond", (int)(template.Background.ImageWidth / 2.54), (int)(template.Background.ImageHeight / 2.54)); } this.model = CreateDemoTemplatePrintModel(); //printDocument1.Print(); printDocument1.PrinterSettings.PrinterName = template.PrintSetting.PrintModule; printPreviewControl1.InvalidatePreview(); }