1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(pictureBox1.Image, 120, 80);
e.Graphics.DrawString(textBox2.Text, new Font("Arial", 15), Brushes.Black, new Point(15, 20));
Rectangle rect = new Rectangle(10, 10, 340, 207);
using (Pen pen = new Pen(Color.Black, 2))
{
int offset = 3;
Croix c1 = new Croix(rect.Location, offset);
Croix c2 = new Croix(new Point(rect.X + rect.Width, rect.Y), offset);
Croix c3 = new Croix(new Point(rect.X, rect.Y - rect.Height), offset);
Croix c4 = new Croix(new Point(rect.X + rect.Width, rect.Y - rect.Height), offset);
c1.DrawCroix(e.Graphics, pen);
c2.DrawCroix(e.Graphics, pen);
c3.DrawCroix(e.Graphics, pen);
c4.DrawCroix(e.Graphics, pen);
}
}
public class Croix
{
public readonly Point p1 = Point.Empty;
public readonly Point p2 = Point.Empty;
public readonly Point p3 = Point.Empty;
public readonly Point p4 = Point.Empty;
public Croix(Point pPoint, int pOffset)
{
p1 = new Point(pPoint.X, pPoint.Y - pOffset);
p2 = new Point(pPoint.X + pOffset, pPoint.Y);
p3 = new Point(pPoint.X, pPoint.Y + pOffset);
p4 = new Point(pPoint.X - pOffset, pPoint.Y - pOffset);
}
public void DrawCroix(Graphics pGraph, Pen pPen)
{
pGraph.DrawLine(pPen, p1, p3);
pGraph.DrawLine(pPen, p2, p4);
}
} |
Partager