/// <summary> /// Print a single line text for many controls. Do some formatting /// </summary> /// <param name="c">Control to print (must have these properties :font, text, width and height)</param> /// <param name="mp">Graphics object (printed page)</param> /// <param name="x">X position</param> /// <param name="y">Y position</param> /// <param name="tbBoxed">Draw a box arround text</param> /// <param name="inBold">use bold font</param> /// <param name="verticalCentering">Adjust vertical to obtain precise alignment from different type of control</param> /// <param name="hAlignment">Horizontal alignment of text in control print area</param> public void PrintText(System.Windows.Forms.Control c, MultiPageManagement mp, Single x, Single y, bool tbBoxed, bool inBold, bool verticalCentering, HorizontalAlignment hAlignment) { Single yAdjusted = y; //Box if (tbBoxed) mp.DrawRectangle(_Pen, x, y, c.Width, c.Height); //Text Font printFont; if (inBold) printFont = new Font(c.Font.Name, c.Font.Size, FontStyle.Bold); else printFont = new Font(c.Font.Name, c.Font.Size); if (verticalCentering) { Single fontHeight = printFont.GetHeight(mp.Graphics()); Single deltaHeight = (c.Height - fontHeight) / 2; yAdjusted += deltaHeight; } else yAdjusted += 2; mp.DrawString(c.Text, printFont, _Brush, x, yAdjusted, c.Width, c.Height, BuildFormat(hAlignment)); }
public void PrintCheckBox(System.Windows.Forms.Control c, ParentControlPrinting typePrint, MultiPageManagement mp, Single x, Single y, ref Single extendedHeight, out bool ScanForChildControls) { ScanForChildControls = false; Single h = mp.FontHeight(new Font(c.Font.Name, c.Font.Size)); extendedHeight = mp.BeginPrintUnit(y, h); mp.DrawRectangle(_Pen, x, y, h, h); if ( ((CheckBox) c).Checked ) { Single d = 3; mp.DrawLines(_Pen, x + d, y + d, x + h - d, y + h - d); PointF[] points2 = new PointF[] {new PointF(x + h - d, y + d), new PointF(x + d, y + h - d)}; mp.DrawLines(_Pen, x + h - d, y + d, x + d, y + h - d); } PrintText(c, mp, (float) (x + (h * 1.4)), (float) y - 2, false, false, false, HorizontalAlignment.Left); mp.EndPrintUnit(); }