private void CheckRightSnap(Rect dragRectangle, SnapTarget target, ref double currentHorizontalOffset, ref bool isSnap) { if ((Math.Abs(target.Rectangle.Left - dragRectangle.Right) <= Math.Abs(currentHorizontalOffset))) { currentHorizontalOffset = target.Rectangle.Left - dragRectangle.Right; isSnap = true; } if ((Math.Abs(target.Rectangle.Right - dragRectangle.Right) <= Math.Abs(currentHorizontalOffset))) { currentHorizontalOffset = target.Rectangle.Right - dragRectangle.Right; isSnap = true; } }
private void CheckBottomSnap(Rect dragRectangle, SnapTarget target, ref double currentVerticalOffset, ref bool isSnap) { if ((Math.Abs(target.Rectangle.Top - dragRectangle.Bottom) <= Math.Abs(currentVerticalOffset))) { currentVerticalOffset = target.Rectangle.Top - dragRectangle.Bottom; isSnap = true; } if ((Math.Abs(target.Rectangle.Bottom - dragRectangle.Bottom) <= Math.Abs(currentVerticalOffset))) { currentVerticalOffset = target.Rectangle.Bottom - dragRectangle.Bottom; isSnap = true; } }