Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Re-anchoring existing links (Read 4437 times)
bdevost
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Sep 24th, 2009
Re-anchoring existing links
Sep 24th, 2009 at 2:33pm
Print Post  
Hi,

I want to give the user the ability to re-anchor an existing link to another node of even another anchor on the same node (the idea being that the user could re-assign only one end of the link).

I've already written a lot of code to make sure links don't jump from AnchorPoint to AnchorPoint (which it did a lot) by assigning the links to custom ConnectionPoints instead of your anchors.

Since pretty much everything I've done up to now has not been supported by the library (no harm intended, I just got some weirds uses for a library that wasn't thought out for what I need), I decided to do the anchoring manually. I've drawn new handles on my links (at either end if them), hid the regular handles, then changed the behavior so that clicking and moving from any of the two handles would disconnect the link and enable you to connect it to another.

Here's the trouble, now; To make things simpler, I thought of using the Connection information of the old link, passing it to the new one I've instanciated in the behavior (first by using CreateLink(), then by creating links using the multiple given constructors) then removing the old link.

After 6 hours of trying every conceivable (and not internal) trick in or out the book, I cannot make the remaining end of the link stick to the ConnectionPoint the old one was attached to. The problem seems to be that when I return the InteractionState with a Create action, it systematically ignores any Origin/Destination information I put in the Link.

What's wrong is; in DiagramLink.StartCreate(), you automatically set your own origin/ConnectionPoint and all this, without any way for me to input my own data in there. Everything, from GetAnchor() to the StartCreate() method itself is internal. Even the UpdateFromPoint in the ConnectionPoint is internal.

As of now, the ONLY way I have of doing this is by moving the mouse over the connection point, then return to the original location once StartCreate() has been called. I obviously don't want to do this Tongue

Is there ANY WAY for me to prevent it from reassigning its own origin?

Thanks in advance,
Benoit Devost
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Re-anchoring existing links
Reply #1 - Sep 24th, 2009 at 2:53pm
Print Post  
Hi Benoit,

Looking at the StartCreate method, it seems it should preserve the OriginConnection if it's already set, but will call its UpdateFromPoint method.

Code
Select All
if (orgnConnectionPoint == null)
	orgnConnectionPoint = orgNode.CreateConnectionPoint(this, org, false);
else if (orgnConnectionPoint.LinkChanges(orgNode, org))
	orgnConnectionPoint.UpdateFromPoint(org);
 



I suppose you have the code and can step into that method - could you check if orgnConnectionPoint is set at that point?

Stoyan
  
Back to top
 
IP Logged
 
bdevost
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Sep 24th, 2009
Re: Re-anchoring existing links
Reply #2 - Sep 24th, 2009 at 3:25pm
Print Post  
Of course, depending on I set the Origin and Destination at the DiagramLink's constuction (or using SetOrgAndDest().

I think what you mean is, I could theoretically give is a good connection point, override the LinkChanges to make sure it returns false, then (after the StartCreate(), ie in the LinkCreating event) reaffect the ControlPoints for the link?

Good idea - I guess this could work, I'll give it a try.
  
Back to top
 
IP Logged
 
bdevost
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Sep 24th, 2009
Re: Re-anchoring existing links
Reply #3 - Sep 24th, 2009 at 5:46pm
Print Post  
I'm still struggling to find a way around the

Code
Select All
org = orgNode.GetAnchor(org, this, false, ref originAnchor);
base.StartCreate(org);
 



which basically automatically sets the Location of the DiagramItem at the computed point. Since Bounds is so cleverly disguised as a variable but is not, I can't find any efficient way of telling the DiagramItem to actually start at some precise location. Overriding the ControlPoints aren't sufficient to move the Link around, since they don't modify the bounds. And I can't figure out a way to change ptOrg or ptEnd programmatically.

Is there one?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Re-anchoring existing links
Reply #4 - Sep 24th, 2009 at 6:05pm
Print Post  
I can't understand what you are trying to do, but if it differs that much fromthe built-in logic, can't you override DiagramLink.StartCreate and just keep the OriginConnection intact without calling base.StartCreate?
  
Back to top
 
IP Logged
 
bdevost
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Sep 24th, 2009
Re: Re-anchoring existing links
Reply #5 - Sep 24th, 2009 at 6:11pm
Print Post  
That's what I'd like to do, but since it's internal, I would have to compile my very own version of the dll, which I'm reluctant to do.

What I'm actually trying to do is create a link from a specific point that is neither the nearest anchor on a node or the current cursor position. I need to specify my own position, and all the internal stuff is preventing me from doing this easily.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Re-anchoring existing links
Reply #6 - Sep 24th, 2009 at 6:22pm
Print Post  
It's "internal protected" so you should be able to override it. You might also handle the ValidateAnchorPoint event and prevent the control from using the anchor points if there's a link being created at this time.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint