private void ShiftMap(Rect deltaOrigin, Vector delta) { // move all elements to the left/right of the origin left/right by the given delta foreach (var element in Project.Current.Elements) { if (element is Room) { var room = (Room) element; var bounds = room.InnerBounds; if (delta.X < 0) { if (bounds.Center.X < deltaOrigin.Right) { room.Position = new Vector(room.Position.X + delta.X, room.Position.Y); } } else if (delta.X > 0) { if (bounds.Center.X > deltaOrigin.Left) { room.Position = new Vector(room.Position.X + delta.X, room.Position.Y); } } } } // move all elements above/below the origin up/down by the given delta foreach (var element in Project.Current.Elements) { if (element is Room) { var room = (Room) element; var bounds = room.InnerBounds; if (delta.Y < 0) { if (bounds.Center.Y < deltaOrigin.Bottom) { room.Position = new Vector(room.Position.X, room.Position.Y + delta.Y); } } else if (bounds.Center.Y > deltaOrigin.Top) { if (bounds.Bottom > deltaOrigin.Y) { room.Position = new Vector(room.Position.X, room.Position.Y + delta.Y); } } } } }
public static double CalcRadianForEllipse(CompassPoint point, Rect rect) { var angleIncrement = 360.0/16.0; var i = getPointIntegerValue(point); return (i * angleIncrement) * (Math.PI / 180); }
public bool IntersectsWith(Rect rect) { if (rect.Contains(Start) || rect.Contains(End)) { return true; } var a = new LineSegment(new Vector(rect.Left, rect.Top), new Vector(rect.Right, rect.Top)); var b = new LineSegment(new Vector(rect.Right, rect.Top), new Vector(rect.Right, rect.Bottom)); var c = new LineSegment(new Vector(rect.Right, rect.Bottom), new Vector(rect.Left, rect.Bottom)); var d = new LineSegment(new Vector(rect.Left, rect.Bottom), new Vector(rect.Left, rect.Top)); List<LineSegmentIntersect> intersects; if (Intersect(a, false, out intersects) || Intersect(b, false, out intersects) || Intersect(c, false, out intersects) || Intersect(d, false, out intersects)) { return true; } return false; }