【发布时间】:2016-01-26 20:09:41
【问题描述】:
目前我正在根据显示的图像制作房间/办公室的搜索程序。
我想在 2D 地图上显示一条线的程序遇到问题,在该程序中将使用按钮连接线的每个坐标。但是在搜索了一个房间后,不会出现任何线条。
private void button2_Click(object sender, EventArgs e)
{
System.Drawing.Pen myPen;
myPen = new System.Drawing.Pen(System.Drawing.Color.Red, 5);
System.Drawing.Graphics frmGraphics = pictureBox1.CreateGraphics();
if (textBox1.Text == "")
{
MessageBox.Show("Nothing to Search!", "", MessageBoxButtons.OK);
}
else
{
if (radioButton2.Checked == true)
{
if(textBox1.Text == "dental clinic")
{
frmGraphics.DrawLine(myPen, path1.Location.X, path1.Location.Y, path2.Location.X, path2.Location.Y);
Thread.Sleep(500);
frmGraphics.DrawLine(myPen, path2.Location.X, path2.Location.Y, path3.Location.X, path3.Location.Y);
Thread.Sleep(500);
frmGraphics.DrawLine(myPen, path3.Location.X, path3.Location.Y, path4.Location.X, path4.Location.Y);
lbres.Text = "Dental Clinic";
lbloc.Text = "OutPatient Department";
OPDView opdfrm = new OPDView();
dview = opdfrm;
}
else
{
MessageBox.Show("No Results Found!", "", MessageBoxButtons.OK);
}
myPen.Dispose();
frmGraphics.Dispose();
return;
}
}
我有 4 个按钮,它们被重命名为 path1 - path4,并希望将它们全部连接起来。我需要一些帮助,谢谢。
【问题讨论】:
标签: c# winforms coordinates picturebox