答案 0 :(得分:0)
如果我理解你的问题,你需要一种方法,检查两个盒子(矩形)是否对齐(左或右)?这是一个非常快速的解决方案:
public enum Side {
Left,
Right
}
public bool CheckIfAligned(Rect box1, Rect box2, Side side) {
if(side == Side.Left)
return box1.Location.X == box2.Location.X;
else // side == Side.Right
return box1.Location.X + box1.Width == box2.Location.X + box2.Width;
}