We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Delimit space into the DiagramWebControl for some Rectangles

Hi,
First at all, thanks for your quick answear to my last post.


I would like to know if it is posible to create one or more small rectangles into a big rectangle and let the user to move the smallers into the big one, but not to allowing him to move them out of the big one.
What I need is to use a big rectangle to delimited a space into the DiagramWebControl, but this limit should be resized by the user.


Thanks.


1 Reply

AD Administrator Syncfusion Team March 12, 2009 06:21 AM UTC

Hi Rod,
Sorry for the delay in response. Please check the code snippet given below which uses the grouping concept to achieve you requirement and it does not allow the node in a group to be placed away from its bounds.

private RectangleF groupBound;
private bool flagOnce;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
flagOnce = true;
this.DiagramWebControl1.Model.EventSink.PinPointChanged += new PinPointChangedEventHandler(EventSink_PinPointChanged);
Group boundGroup = new Group();
for (int nodeCount = 1; nodeCount < 5; nodeCount++)
{
sRectange rectangle = new sRectange(100, nodeCount * 50, 100, 25);
rectangle.Name = "Node" + nodeCount.ToString();
this.DiagramWebControl1.Model.AppendChild(rectangle);
}
boundGroup.ShowResizeHandles();
this.DiagramWebControl1.Model.AppendChild(boundGroup);
groupBound = boundGroup.BoundingRectangle;
}
}

void EventSink_PinPointChanged(PinPointChangedEventArgs evtArgs)
{
Node node = (Node)evtArgs.NodeAffected;
if (!(groupBound.IntersectsWith(node.BoundingRectangle)))
{
if (flagOnce)
{
flagOnce = false;
node.PinPoint = new PointF(node.PinPoint.X - evtArgs.Offset.Width, node.PinPoint.Y - evtArgs.Offset.Height);
}

}
}

Please let me know if there is any concerns in this regard.

Regards,
Dinesh



Loader.
Live Chat Icon For mobile
Up arrow icon