I am using two panel box for drawing a ruler along the side(top & left) of a picture box. I am able to succeed in it. Now my requirement is to flip the direction of the ruler so as to line starts from the picture box and the text(numbers) on the top. How can i do this
private void panel2_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
int step = 1;
int length = panelleft.Height / 3;
int small = 5;
int big = 10;
int number = 10;
int scale = 10;
float stroke = 2.5f;
for (int i = 0; i < length; i += step)
{
float d = 1;
if (i % small == 0)
{
if (i % big == 0)
{
d = 3;
}
else
{
d = 2;
}
}
g.DrawLine(this.pen, 0f, i,d * stroke, i);
if ((i % number) == 0)
{
string text = (i / scale).ToString();
SizeF size = g.MeasureString(text, this.Font, length, this.format);
g.DrawString(text, this.Font, Brushes.Black,d * stroke, i - size.Width-1 / 2 , this.format);
}
}
}
private void panel3_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
g.PageUnit = GraphicsUnit.Millimeter;
int step = 1;
int length = paneltop.Width / 3;
int small = 5;
int big = 10;
int number = 10;
float stroke = 2.5f;
for (int i = 0; i < length; i += step)
{
float d = 1;
if (i % small == 0)
{
if (i % big == 0)
{
d = 3;
}
else
{
d = 2;
}
}
g.DrawLine(this.pen, i, 0f, i, d * stroke);
if ((i % number) == 0)
{
string text = (i / number).ToString();
SizeF size = g.MeasureString(text, this.Font, length, this.format);
g.DrawString(text, this.Font, Brushes.Black, i - size.Width / 2, d * stroke, this.format);
}
}
}
and more help when user moves mouse over the image a horizontal and vertical line should be visible and it must be pointed to the ruler. Screen shot of the form can be visible on this link
http://i.stack.imgur.com/2WLgD.png[
^]
Thanks in advance