/// <summary> /// Sets the location of this item and propagates it to the hosted shape element if allowed. /// </summary> /// <param name="proposedLocation">Location to apply.</param> /// <param name="bResizeParentIfRequired">Resize parent if required.</param> /// <remarks> /// This function needs to be called withing a modeling transaction. /// </remarks> public virtual void SetLocation(PointD proposedLocation, bool bResizeParentIfRequired) { PointD newLocation = proposedLocation; if (this.IsRelativeChildShape) { // correct the proposed location if (this.MovementBehaviour == ShapeMovementBehaviour.PositionOnEdgeOfParent) { if (this.Parent != null) { newLocation = NodeShape.CorrectPortLocation(this.Parent, this, proposedLocation); } } } PointD oldLocation = this.Location; this.Location = newLocation; this.UpdateAbsoluteLocation(); if (bResizeParentIfRequired) { this.ResizeParentIfRequired(); } }
/// <summary> /// Verifies if the position of the specified shape is acceptable. /// </summary> /// <param name="shape">Node shape.</param> public static bool IsShapePositionAcceptable(NodeShape shape) { if (!shape.IsRelativeChildShape) { if (shape.Parent != null) { if (shape.AbsoluteLocation.X < shape.Parent.AbsoluteLocation.X || shape.AbsoluteLocation.Y < shape.Parent.AbsoluteLocation.Y || shape.AbsoluteBounds.Right > shape.Parent.AbsoluteBounds.Right || shape.AbsoluteBounds.Bottom > shape.Parent.AbsoluteBounds.Bottom) { return(false); } } } else if (shape.Parent != null) { PointD location = NodeShape.CorrectPortLocation(shape.Parent, shape, shape.AbsoluteLocation); if (location != shape.AbsoluteLocation) { return(false); } } return(true); }