/// <summary> /// Drukuje nr strony na górnym lub dolnym marginesie /// </summary> /// <param name="PageNumber">Nr strony</param> /// <param name="x">współrzędna x</param> /// <param name="y">współrzędna y</param> /// <param name="PrintWidth">Szerokość obszaru wydruku</param> /// <param name="Location">Lokalizacja nr strony (górny lub dolny margines)</param> /// <param name="HorizontalAlignment">Poziome położenie nr strony</param> public void DrawPageNumber(string PageNumber, float x, float y, float PrintWidth, CustomType.PageNumberLocation Location, byte HorizontalAlignment = 1) { x += Settings.Default.XCaliber; y += Settings.Default.YCaliber; var M = new CalcHelper.Math(); var BaseFont = new Font("Arial", 8, FontStyle.Regular, GraphicsUnit.Point); if (Location == CustomType.PageNumberLocation.Header) { y -= M.MMtoIN(5) + BaseFont.GetHeight(G); } else { y += M.MMtoIN(5) + BaseFont.GetHeight(G); } var strFormat = new StringFormat(); strFormat.LineAlignment = StringAlignment.Center; strFormat.Alignment = (StringAlignment)HorizontalAlignment; G.DrawString(PageNumber, BaseFont, Brushes.Black, new Rectangle((int)x, (int)y, (int)PrintWidth, (int)BaseFont.GetHeight(G)), strFormat); }
/// <summary> /// Drukuje stopkę dokumentu na dolnym marginesie strony /// </summary> /// <param name="x">Współrzędna początkowa pozioma</param> /// <param name="y">Współrzędna początkowa pionowa</param> /// <param name="PrintWidth">Szerokość obszaru wydruku</param> public void DrawFooter(float x, float y, float PrintWidth) { x += Settings.Default.XCaliber; y += Settings.Default.YCaliber; var DotPen = new Pen(Color.Black); var M = new CalcHelper.Math(); var FooterFont = new Font("Arial", 8, FontStyle.Italic, GraphicsUnit.Point); y += M.MMtoIN(5); G.DrawLine(DotPen, x, y, x + PrintWidth, y); y += FooterFont.GetHeight(G) / 2; var strFormat = new StringFormat(); strFormat.LineAlignment = StringAlignment.Center; strFormat.Alignment = StringAlignment.Near; G.DrawString(System.Windows.Forms.Application.ProductName + " (wersja " + System.Windows.Forms.Application.ProductVersion + ")", FooterFont, Brushes.Black, new Rectangle((int)x, (int)y, (int)PrintWidth, (int)FooterFont.GetHeight(G)), strFormat); strFormat.Alignment = StringAlignment.Far; G.DrawString(DateTime.Now.ToString(), FooterFont, Brushes.Black, new Rectangle((int)x, (int)y, (int)PrintWidth, (int)FooterFont.GetHeight(G)), strFormat); }
/// <summary> /// Drukuje nagłówek dokumentu na górnym marginesie strony /// </summary> /// <param name="x">Współrzędna początkowa pozioma</param> /// <param name="y">Współrzędna początkowa pionowa</param> /// <param name="PrintWidth">Szerokość obszaru wydruku</param> public void DrawHeader(float x, float y, float PrintWidth) { x += Settings.Default.XCaliber; y += Settings.Default.YCaliber; var DotPen = new Pen(Color.Black); var M = new CalcHelper.Math(); var HeaderFont = new Font("Arial", 8, FontStyle.Italic, GraphicsUnit.Point); y -= M.MMtoIN(5); G.DrawLine(DotPen, x, y, x + PrintWidth, y); y -= HeaderFont.GetHeight(G); var strFormat = new StringFormat(); strFormat.LineAlignment = StringAlignment.Center; strFormat.Alignment = StringAlignment.Near; G.DrawString(Settings.Default.SchoolName, HeaderFont, Brushes.Black, new Rectangle((int)x, (int)y, (int)PrintWidth, (int)HeaderFont.GetHeight(G)), strFormat); strFormat.Alignment = StringAlignment.Far; G.DrawString("Rok szkolny: " + Settings.Default.SchoolYear, HeaderFont, Brushes.Black, new Rectangle((int)x, (int)y, (int)PrintWidth, (int)HeaderFont.GetHeight(G)), strFormat); }