这更像是一个为什么这个工作不起作用的问题。我显然必须遗漏一些东西,因为我一生都无法弄清楚为什么计算宽度和高度值会给我与开始时相同的静态值。但是当我替换硬编码值时,它工作得很好。所以很明显我的计算很糟糕,但我似乎无法弄清楚为什么。任何人都可以帮忙吗?如果您需要更多信息,请询问。
if(objectList[selectedIndex].Selected == true)
{
//The width would be mouselocationx - objectlocationx
//The height would be mouselocationy - objectlocationy
//Off set the position so it doesnt snap to mouse location
//WHY THE *%$!! DOESNT THIS WORK!!?!?!?!?!?!?
//int width = e.X - objectList[selectedIndex].X;
//int height = e.Y - objectList[selectedIndex].Y;
//Why is this so hard??
//Point location = objectList[selectedIndex].Location;
//location.X = e.X - (e.X - objectList[selectedIndex].Location.X);
//location.Y = e.Y - (e.Y - objectList[selectedIndex].Location.Y);
objectList[selectedIndex].X = e.Location.X - 12;
objectList[selectedIndex].Y = e.Location.Y - 12;
objectLocationXLabel.Text = "OBJX: " + objectList[selectedIndex].X.ToString();
objectLocationYLabel.Text = "OBJY: " + objectList[selectedIndex].Y.ToString();
panel1.Invalidate();
}