This is a migrated thread and some comments may be shown as answers.

How to Limit the RadDiagramShape's movement within its Container range?

10 Answers 35 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
wu
Top achievements
Rank 1
Veteran
wu asked on 22 Jan 2020, 08:09 AM
How to Limit the RadDiagramShape's movement within its Container range,
or just can move the shape between two Containers?

10 Answers, 1 is accepted

Sort by
0
Vladimir Stoyanov
Telerik team
answered on 24 Jan 2020, 04:47 PM

Hello Wu,

Can you check out the Restrict the Draggable Area article in our documentation? It demonstrates how to limit the area, where a shape can be dragged. 

I hope you find this helpful.

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
wu
Top achievements
Rank 1
Veteran
answered on 25 Jan 2020, 03:03 AM
oh,I have look the document,when running the demo,if zoom in the area, the shape will exceed the range,unless moving the shape again,and the limit area is fix,can't zoom out/zoom in/move,maybe modify code resolve,but it also limit move the shape between two Containers,how to exclude the situation.
0
Vladimir Stoyanov
Telerik team
answered on 29 Jan 2020, 02:06 PM

Hi Wu,

Can you check out the How to prevent dragging out of shapes from container forum thread, where a similar question was discussed? The approach from the article linked in my previous reply is adapted inside the attached project to prevent dragging out of the parent container. 

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
wu
Top achievements
Rank 1
Veteran
answered on 01 Feb 2020, 12:42 AM
thank your answer very much,mayby I don't express the problem clearly,
I holp limit move the shape exceed the container  range(yes, the above demo Realized),
but can't limit the shape move from one container to another,
the  above demo also  limit move the shape between two Containers,
In practice,the shape must exist parent container,but can change the parent container from one to another.
0
Vladimir Stoyanov
Telerik team
answered on 05 Feb 2020, 10:33 AM

Hello Wu,

Thank you for the update.

It seems to me that the notion of limiting the dragging of a shape within its container contradicts with the functionality of being able to drag a shape from one parent container to another. Can you share how you envision this functionality? You can send over some sample pictures/videos of the expected behavior. 

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
wu
Top achievements
Rank 1
Veteran
answered on 05 Feb 2020, 11:56 AM
oh,I think about the RadTreeView DragDrop behavior.
for example,can't drag the TreeViewItem to the spare area(like can't position the diagram shape outside the  container ),
but can drop to the other RadTreeView object(like from one container  to the another).
0
Accepted
Vladimir Stoyanov
Telerik team
answered on 10 Feb 2020, 10:39 AM

Hello Wu,

I am attaching a sample project that demonstrates a possible way of achieving the described functionality. It uses the PreviewDrag and Drag events of the RadDiagram along with the Drop event of the DraggingService.

Of course, feel free to adapt or extend the approach so that it suits your exact scenario.

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
wu
Top achievements
Rank 1
Veteran
answered on 11 Feb 2020, 09:56 AM

there is a small problem:after moving the shape to the spare area,then the shape return to previous positions automatic,

but the shape don't belongs to its parent container,so when moving the parent container,the shape will not move follow

0
Vladimir Stoyanov
Telerik team
answered on 13 Feb 2020, 02:51 PM

Hello Wu,

Indeed there is logic in the RadDiagram that removes the shape once it is dropped outside of the container. There isn't a convenient way to modify this as the logic is private to the DraggingTool.

I am attaching the sample project modified to demonstrate how you can extract and update the source code of the DraggingTool in order to prevent the removal of the child shape from the parent container (in scenarios where a drop is attempted on the diagram surface). It involves modifying the CompleteDrag method of the DraggingTool and I have included a comment, in the place where I introduced a change.

Note, that the demonstrated approach is a customization and I have not tested it extensively. That said, I do hope that you will find it useful as a starting point. Of course, feel free to adapt the demonstrated approach to your exact scenario. 

Regards,
Vladimir Stoyanov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
wu
Top achievements
Rank 1
Veteran
answered on 14 Feb 2020, 11:45 AM

thank you very much!

Before that,I save the shape's parent Container like your code which save the shape's position,

then add agian: 

shapeParentContainer[shape.GetHashCode()].AddItem(shape);

maybe your method is better.

Tags
Diagram
Asked by
wu
Top achievements
Rank 1
Veteran
Answers by
Vladimir Stoyanov
Telerik team
wu
Top achievements
Rank 1
Veteran
Share this question
or