//Bounds checking by element public virtual SizeF BoundsCheck(Element element, SizeF delta) { //Return pass if the controller does not have boundary checking or the delta is empty if (!CheckBounds) { return(delta); } if (delta.IsEmpty) { return(delta); } Element action = element.ActionElement; bool contains = false; //If the original (action) is contained in the container contains = (Model.Contains(new PointF(action.Bounds.X + delta.Width, action.Bounds.Y + delta.Height))); // && container.Contains(new PointF(action.Rectangle.Right + container.Offset.X + delta.Width, action.Rectangle.Bottom + container.Offset.Y + delta.Height), container.Margin)); contains = contains && (Model.Contains(new PointF(action.Bounds.Right + delta.Width, action.Bounds.Bottom + delta.Height))); if (contains) { return(delta); } return(SizeF.Empty); }
//Bounds checking by point public virtual bool BoundsCheck(PointF action, float dx, float dy) { //Return pass if the diagram does not have boundary checking if (!CheckBounds) { return(true); } //If the original (action) is contained in the container if (Model.Contains(new PointF(action.X, action.Y))) { //Check top left if (!Model.Contains(new PointF(action.X + dx, action.Y + dy))) { return(false); } } return(true); }