资源介绍
画图,圆形,直线,多边形,等等
Graphics gs = Graphics.FromImage(img);
Pen newPen = new Pen(Color.Red, 1);
if (Ept.X <= 500 && Ept.Y <= 500)
{
if (radioButton2.Checked)//画直线
{
gs.DrawLine(newPen, Spt, Ept);
}
if (radioButton3.Checked)//画矩形
{
gs.DrawRectangle(newPen, Spt.X, Spt.Y, Ept.X - Spt.X, Ept.Y - Spt.Y);
if (Ept.X < Spt.X && Ept.Y < Spt.Y)
{
gs.DrawRectangle(newPen, Ept.X, Ept.Y, Spt.X - Ept.X, Spt.Y - Ept.Y);
}
if (Ept.X < Spt.X)
{
gs.DrawRectangle(newPen, Ept.X, Spt.Y, Spt.X - Ept.X, Ept.Y - Spt.Y);
}
if (Ept.Y < Spt.Y)
{
gs.DrawRectangle(newPen, Spt.X, Ept.Y, Ept.X - Spt.X, Spt.Y - Ept.Y);
}
}
if (radioButton4.Checked)//画圆形
{
gs.DrawEllipse(newPen, Spt.X, Spt.Y, Ept.X - Spt.X, Ept.Y - Spt.Y);
CursorD = false;
return;
}
if (radioButton5.Checked)//画多边型
{
if (!TwoClick)
{
gs.DrawLine(newPen, Spt, Ept);
Mpt = Ept;
TwoClick = true;
}
else
{
gs.DrawLine(newPen, Mpt, Ept);
Mpt = Ept;
}
}
if (radioButton7.Checked)//画曲线
{
if (TwoClick == false && DoubleClick == false)
{
Mpt = Ept;
TwoClick = true;
}
if (TwoClick == true && DoubleClick == false)
{
DoubleClick = true;
}
if (TwoClick && DoubleClick)
{
gs.DrawBezier(newPen, Fpt, Spt, Ept, Mpt);
}
}
CursorD = false;
}
else { return; }