using System;
using System.Drawing;
using System.Windows.Forms;
namespace TenCentimeterRuler
{
class Form1: PrintableForm
{
public new static void Main()
{
Application.Run(new Form1());
}
public Form1()
{
Text = "Ten-Centimeter Ruler";
}
protected override void DoPage(Graphics g)
{
Pen pen = new Pen(Color.Black, 0.25f);
Brush brush = new SolidBrush(Color.Black);
const int xOffset = 10;
const int yOffset = 10;
g.PageUnit = GraphicsUnit.Millimeter;
g.PageScale = 1;
for (int i = 0; i <= 100; i++) //each millimeter
{
if (i % 10 == 0) // Centimeter markings
{
g.DrawLine(pen,
new PointF(xOffset + i, yOffset),
new PointF(xOffset + i, yOffset + 5));
g.DrawString((i/10).ToString(), Font, brush,
new PointF(xOffset + i, yOffset + 5));
}
else if (i % 5 == 0) // Half-centimeter markings
{
g.DrawLine(pen,
new PointF(xOffset + i, yOffset),
new PointF(xOffset + i, yOffset + 3));
}
else // Millimeter markings
{
g.DrawLine(pen,
new PointF(xOffset + i, yOffset),
new PointF(xOffset + i, yOffset + 2.5f));
}
}
}
}
}