public void huashizhi()
{
int j;
const int t = 3;
Graphics hx = pictureBox1.CreateGraphics();
hx.DrawLine(new Pen(Color.Red, 1), 0, pictureBox1.Height/2, pictureBox1.Width, pictureBox1.Height/2);
for (int i = 1; i < pictureBox1.Width/5; i++)
{
if ((i % 10) == 0)
{ j = t;}
else
{ j = 0; }
hx.DrawLine(new Pen(Color.Red, 1+(j/t)), 5 * i, (pictureBox1.Height / 2) -5-j, 5 * i, (pictureBox1.Height / 2) );
}
hx.DrawLine(new Pen(Color.Red, 1), pictureBox1.Width / 2, 0, pictureBox1.Width/2, pictureBox1.Height);
for (int i = 1; i < pictureBox1.Width / 5; i++)
{
if ((i % 10) == 0)
{ j = t; }
else
{ j = 0; }
hx.DrawLine(new Pen(Color.Red, 1+(j/t)), (pictureBox1.Width / 2) - 5 - j, i * 5, (pictureBox1.Width / 2), i * 5);
}
hx.Dispose();
Grapics在pictrurebox控件中画十字原理
最新推荐文章于 2023-04-19 11:26:23 发布