//Override OnBeginPrint to set up the font we are going to use protected override void OnBeginPrint(PrintEventArgs ev) { base.OnBeginPrint(ev); printHeaderFont = new Font("Arial", 16, System.Drawing.FontStyle.Bold); PrintDocumentStd settings = CommonCode.Settings.PrinterSettings.PaperResultDocument; const int nrOfExpectedFonts = 3; if (settings.Fonts.Count < nrOfExpectedFonts) { throw new ApplicationException("Not enough fonts in PaperResultDocument. It is " + settings.Fonts.Count.ToString() + " and should be " + nrOfExpectedFonts.ToString()); } printCompetitorHeaderFont = settings.Fonts[0].PrintFont; printCompetitorFont = settings.Fonts[1].PrintFont; printAllbergFont = settings.Fonts[2].PrintFont; if (uclass != Structs.ShootersClass.Okänd) { currentUClass = (int)uclass; getCurrentResults(); } else { currentUClass = 0; moreClassesPages(); } }
private void createDefaultPrintouts() { paperResultDocument = new PrintDocumentStd(210, 297, 10, 10); paperResultDocument.Fonts.Add(new FontInfo(new System.Drawing.Font("Arial", 14, System.Drawing.FontStyle.Bold & System.Drawing.FontStyle.Underline), "Rubrik")); //printCompetitorHeaderFont - Rubrik paperResultDocument.Fonts.Add(new FontInfo(new System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Regular), "Tävlande")); //printCompetitorFont - Tävlande paperResultDocument.Fonts.Add(new FontInfo(new System.Drawing.Font("Arial", 8, System.Drawing.FontStyle.Regular), "Copyright")); //printAllbergFont- Copyright paperResultDocument.Columns.Add(new PrintColumnInfo(8, "Pl")); paperResultDocument.Columns.Add(new PrintColumnInfo(47, "Namn")); paperResultDocument.Columns.Add(new PrintColumnInfo(50, "Klubb")); paperResultDocument.Columns.Add(new PrintColumnInfo(42, "Resultat")); paperResultDocument.Columns.Add(new PrintColumnInfo(13, "Tot")); paperResultDocument.Columns.Add(new PrintColumnInfo(5, "P")); paperResultDocument.Columns.Add(new PrintColumnInfo(15, "Stm")); paperResultTeamDocument = new PrintDocumentStd(210, 297, 10, 10); paperResultTeamDocument.Fonts.Add(new FontInfo(new System.Drawing.Font("Arial", 14, System.Drawing.FontStyle.Bold & System.Drawing.FontStyle.Underline), "printCompetitorHeaderFont")); //printCompetitorHeaderFont paperResultTeamDocument.Fonts.Add(new FontInfo(new System.Drawing.Font("Arial", 12, System.Drawing.FontStyle.Regular), "printCompetitorFont")); //printCompetitorFont paperResultTeamDocument.Fonts.Add(new FontInfo(new System.Drawing.Font("Arial", 8, System.Drawing.FontStyle.Regular), "Copyright")); //printAllbergFont paperResultTeamDocument.Columns.Add(new PrintColumnInfo(8, "Pl")); paperResultTeamDocument.Columns.Add(new PrintColumnInfo(53, "Klubb")); paperResultTeamDocument.Columns.Add(new PrintColumnInfo(45, "Lagnamn")); paperResultTeamDocument.Columns.Add(new PrintColumnInfo(50, "Resultat")); paperResultTeamDocument.Columns.Add(new PrintColumnInfo(13, "Tot")); paperResultTeamDocument.Columns.Add(new PrintColumnInfo(10, "P")); }
//Override the OnPrintPage to provide the printing logic for the document protected override void OnPrintPage(PrintPageEventArgs ev) { PrintDocumentStd printSettings = CommonCode.Settings.PrinterSettings.PaperResultDocument; printSettings.DocumentSizeXPixels = ev.PageBounds.Width; printSettings.DocumentSizeYPixels = ev.PageBounds.Height; this.RightMargin = ev.PageBounds.Right - 50; this.LeftMargin = 50; base.OnPrintPage(ev); float topMargin = ev.PageBounds.Top + 45; // Org = 25 float yPos = topMargin; float width = this.RightMargin - this.LeftMargin; colIndividPlace = LeftMargin; colIndividName = colIndividPlace + printSettings.Columns[0].SizeDpi; colIndividClub = colIndividName + printSettings.Columns[1].SizeDpi; colIndividResult = colIndividClub + printSettings.Columns[2].SizeDpi; colIndividResultTot = colIndividResult + printSettings.Columns[3].SizeDpi; colIndividPoints = colIndividResultTot + printSettings.Columns[4].SizeDpi; colIndividStdMed = colIndividPoints + printSettings.Columns[5].SizeDpi; colIndividPrice = colIndividStdMed + printSettings.Columns[6].SizeDpi; colIndividResultMaxWidth = colIndividResultTot; PrintDocumentStd printTeamSettings = CommonCode.Settings.PrinterSettings.PaperResultTeamDocument; printTeamSettings.DocumentSizeXPixels = ev.PageBounds.Width; printTeamSettings.DocumentSizeYPixels = ev.PageBounds.Height; colTeamPlace = LeftMargin; colTeamClub = colTeamPlace + printTeamSettings.Columns[0].SizeDpi; colTeamName = colTeamClub + printTeamSettings.Columns[1].SizeDpi; colTeamResult = colTeamName + printTeamSettings.Columns[2].SizeDpi; colTeamResultTot = colTeamResult + printTeamSettings.Columns[3].SizeDpi; colTeamPoints = colTeamResultTot + printTeamSettings.Columns[4].SizeDpi; colTeamResultMaxWidth = colTeamResultTot; int tab = 140; if (individualsPrintDone == false) { printIndividual(ev, ref yPos, tab); if (ev.HasMorePages == false) { individualsPrintDone = true; if (CommonCode.ResultsGetTeams(this.wclass, this.competition).Length > 0) { ev.HasMorePages = true; } } } else { // Print teams. ev.HasMorePages = printTeamResults(ev, ref yPos, tab); } }