Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic AnchorPoint and Shape position change (Read 5133 times)
praveenbattula
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 22
Joined: Apr 6th, 2010
AnchorPoint and Shape position change
Apr 6th, 2010 at 12:40pm
Print Post  
Hi guys,
Hope someone got the same problem as me. I am successfully customized and using the diagram component for Silverlight. But, now I have a special requirement that when user is changing the shape position I need to re write the anchorpoints.

Here is the simple explanation,
While generating the diagram, I am creating the shapes and setting anchorpoints. So, two shapes are linking with a line at some anchorpoint. And now when i change the position of a shape then I need to find the minimum distance between two shapes and put the line which is close to the other shape anchor point. But, how to change the anchor point here? Do we have any events for share position changed? and change the anchor point?

By default the shapes are generated and the anchor point is close at top, so they are joined with line. Now, when I moved the second shape from bottom to left of the first shape then anchorpoint should link the line at right of the shape moved, so that they will be very close and the line come close. Right now, what it is doing is, drawing the line to top anchor point and looks like not really good.

This is a bit urgent and I don't have any idea of what to tell client. So, please respond me as soon as possible.

Any ideas are most welcome.
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AnchorPoint and Shape position change
Reply #1 - Apr 6th, 2010 at 1:08pm
Print Post  
Hi Praveen,

There is the NodeModified event raised when shape position changes. From the handler you could set a links' OriginIndex and DestinationIndex properties to connect the link to a different point. You might also check the links' Dynamic property; it sounds close enough to your requirements.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
praveenbattula
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 22
Joined: Apr 6th, 2010
Re: AnchorPoint and Shape position change
Reply #2 - Apr 6th, 2010 at 1:39pm
Print Post  
Wow, excellent.
I am using NodeModified event for diagram control and successfully going to event when I changed the shape position on UI.

But, actually my question is, how to change the anchorpoint?
I mean the line or connector which is connecting two shapes to use a particular anchor point? I need to tell the line to draw and connect to the shape at specific point. Can you help me?

-Praveen
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AnchorPoint and Shape position change
Reply #3 - Apr 6th, 2010 at 1:53pm
Print Post  
If your nodes have their AnchorPattern property set, you can just assign to the link's OriginIndex and DestinationIndex to change the point. Otherwise assign new Point instances to link.ControlPoints[0] and link.ControlPoints[count - 1] and call link.UpdateFromPoints().

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
praveenbattula
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 22
Joined: Apr 6th, 2010
Re: AnchorPoint and Shape position change
Reply #4 - Apr 6th, 2010 at 2:44pm
Print Post  
I tried all the ways, the only problem is how to detect the nearest anchorpoint in the positioned changed shape.
Let's take an example,
I have moved shape1 close to shape2, and actually link given is to the left of the shape1 ad I have moved close to shape2, I should detect the right side anchorpoint of the shape1 and start the connection there. But, the question is how to detect the right side anchorpoint? If I moved shape1 to above shape2, then the connector link should start from the bottom of shape1 anchorpoint.
I am really facing problem on how to solve this problem. And you are right if we put dynamic =true to the link then the source shape is working correct. But destination shape is not working as expected. Please help me out.

If any example or tutorial a big help.
Have a good day.
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AnchorPoint and Shape position change
Reply #5 - Apr 6th, 2010 at 3:54pm
Print Post  
You could call node.GetOutlinePoly() to get a list of points describing the node outline and find the nearest point from that list.

Link.Dynamic works fine for me. What version of the control are you using?

Stoyan
  
Back to top
 
IP Logged
 
praveenbattula
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 22
Joined: Apr 6th, 2010
Re: AnchorPoint and Shape position change
Reply #6 - Apr 6th, 2010 at 4:06pm
Print Post  
Slowly one by one I am getting clues. Thanks for the nice responses. I think I am very close to solution.
Yes, you are right, I am getting the points now with the method. And the big question is how to know the closest point? Do I need to write any formula to detect that? Or do you have any easier way to get it?

I am using version 1.3 now, and when I set dynamic = true, as I said, only one source Shape it is setting correct, but other shape [Link connector as incoming link] is not setting. It is set to one point by default. Always that is the point setting up. It's not changing where I moved the shape.

I am very close, Hope will get solution soon.
Thanks for all your support. That is so valuable to me now.
  
Back to top
WWW  
IP Logged
 
praveenbattula
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 22
Joined: Apr 6th, 2010
Re: AnchorPoint and Shape position change
Reply #7 - Apr 6th, 2010 at 4:51pm
Print Post  
Hi,
I have tried with the method to get all points and find the shortest distance. Below is the result.
Whatever I have placed the shape on the surface, below are the points coming.

57.5999984741211,0
115.199996948242,38.4000015258789
115.199996948242,38.4000015258789
57.5999984741211,76.8000030517578
57.5999984741211,76.8000030517578
0,38.4000015258789
0,38.4000015258789
57.5999984741211,0

So, always it fails to find the correct points. Can you tell me what could be the problem.
I used this to get all points.
PointCollection nodePoints = e.Node.GetOutlinePoly();

-Praveen
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: AnchorPoint and Shape position change
Reply #8 - Apr 6th, 2010 at 7:00pm
Print Post  
Hi,

It seems these points are given in coordinates local to the node. Add node.Bounds.X and Y to them to get the diagram coordinates.

Stoyan
  
Back to top
 
IP Logged
 
praveenbattula
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 22
Joined: Apr 6th, 2010
Re: AnchorPoint and Shape position change
Reply #9 - Apr 6th, 2010 at 7:36pm
Print Post  
I have already added this. And now getting correct points. Thanks for the reply.

Seems like I need to do too much customization here. It's not so easy as expected.

There are more than one incoming or outgoing links from a shape. And when I move the shape, I need to rebuild the connectors or links again to all shapes linked the current shape.

So, I don't know how much time it will take and how hard it is.

So far, I appreciate your help on the post replies and great tips. Good day.
  
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint