static void MoveWithSnapToGrid(UIControllerBox controllerBox, int dx, int dy)
{
//sample move with snap to grid
Point pos = controllerBox.Position;
int newX = pos.X + dx;
int newY = pos.Y + dy;
int gridSize = 5;
float halfGrid = (float)gridSize / 2f;
int nearestX = (int)((newX + halfGrid) / gridSize) * gridSize;
int nearestY = (int)((newY + halfGrid) / gridSize) * gridSize;
controllerBox.SetLocation(nearestX, nearestY);
UIBox targetBox = controllerBox.TargetBox;
if (targetBox != null)
{
int xdiff = nearestX - pos.X;
int ydiff = nearestY - pos.Y;
targetBox.SetLocation(targetBox.Left + xdiff, targetBox.Top + ydiff);
}
}
List<LayoutFarm.UI.UIBox> FindUnderlyingElements(UIControllerBox controllerBox)