我试图用一些公式来编写一个基本的绘图应用程序,这需要我保持我的点精确。
一切都运作良好,但有一部分将允许我继续这个计划。
我需要使用Control.GetChildAtPoint
方法查看该行的某个点是否有某个对象,但我的所有点都在pointF
(float
)中。
这是一段应该有意义的代码。
if (poscount > 15) {
//to see if point is close to an object
if (this.GetChildAtPoint(point2) != null) {
label1.Text = "I found an object";
} else label1.Text = " no object found";
}
抱歉愚蠢的例子,但在point2 (which is a
pointF ) it gives an error that I cant convert from a
float to
System.Drawing.Point .
I cant find a way to convert it and keep the accuracy.
Is there a way I can use
GetChildAtPoint with a
float`?
答案 0 :(得分:0)
参数可以转换如下。
if (poscount > 15)
{
// to see if point is close to an object
Point iPoint = new Point((int)point2.X, (int)point2.Y);
if (this.GetChildAtPoint(iPoint) != null)
{
label1.Text = "I found an object";
}
else
{
label1.Text = " no object found";
}
}