// Print - draw the rule... public void Draw(PrintEngine engine, float yPos, Graphics graphics, Rectangle elementBounds) { // draw a line... Pen pen = new Pen(engine.PrintBrush, 1); graphics.DrawLine(pen, elementBounds.Left, yPos + 2, elementBounds.Right, yPos + 2); }
public float CalculateHeight(PrintEngine engine, Graphics graphics) { // loop through the print height... float height = 0; foreach (IPrintPrimitive primitive in _printPrimitives) { // get the height... height += primitive.CalculateHeight(engine, graphics); } // return the height... return height; }
// Draw - draw the element on a graphics object... public void Draw(PrintEngine engine, float yPos, Graphics graphics, Rectangle pageBounds) { // where... float height = CalculateHeight(engine, graphics); Rectangle elementBounds = new Rectangle(pageBounds.Left, (int)yPos, pageBounds.Right - pageBounds.Left, (int)height); // now, tell the primitives to print themselves... foreach (IPrintPrimitive primitive in _printPrimitives) { // render it... primitive.Draw(engine, yPos, graphics, elementBounds); // move to the next line... yPos += primitive.CalculateHeight(engine, graphics); } }
// CalculateHeight - work out how tall the primitive is... public float CalculateHeight(PrintEngine engine, Graphics graphics) { // we're always five units tall... return 5; }
public void Draw(PrintEngine engine, float yPos, Graphics graphics, Rectangle elementBounds) { graphics.DrawImage(i, elementBounds.X, elementBounds.Y); }
public float CalculateHeight(PrintEngine engine, Graphics graphics) { return (i.Height / i.HorizontalResolution) * 100; }
// Print - draw the text... public void Draw(PrintEngine engine, float yPos, Graphics graphics, Rectangle elementBounds) { // draw it... graphics.DrawString(engine.ReplaceTokens(Text), engine.PrintFont, engine.PrintBrush, elementBounds.Left, yPos, new StringFormat()); }
// CalculateHeight - work out how tall the primitive is... public float CalculateHeight(PrintEngine engine, Graphics graphics) { // return the height... return engine.PrintFont.GetHeight(graphics); }