Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Links (Read 10344 times)
tclaffy
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Location: Chesterfield, Mo
Joined: Aug 21st, 2008
Links
Aug 22nd, 2008 at 6:26pm
Print Post  
Newbie here. How do I know what the origin anchor is when a user draws a link with the mouse between 2 shape nodes? I put a tag in the origin anchor but I can't seem to get to it for the LinkCreated or LinkCreating event. Am I going about this wrong?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links
Reply #1 - Aug 25th, 2008 at 10:13am
Print Post  
Hi,

If you need to do this in the LinkCreated event handler

Code
Select All
DiagramLink link = e.Link;
int i = link.OriginAnchor;
AnchorPoint ap = link.Origin.AnchorPattern.Points[i];
object tag = ap.Tag;
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links
Reply #2 - Aug 25th, 2008 at 7:24pm
Print Post  
Node.Bounds.Y should reflect the new node position when NodeModified is raised. It should be up-to-date even while the modification is in progress (in NodeModifying event handlers).
  
Back to top
 
IP Logged
 
tclaffy
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Location: Chesterfield, Mo
Joined: Aug 21st, 2008
Re: Links
Reply #3 - Aug 25th, 2008 at 7:25pm
Print Post  
Yes, thanks. I have that working also.
  
Back to top
 
IP Logged
 
tclaffy
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Location: Chesterfield, Mo
Joined: Aug 21st, 2008
Re: Links
Reply #4 - Aug 25th, 2008 at 7:31pm
Print Post  
Lets say I hae 3 vertical decision shapes that all point back to the top shape if they fail. Can I make the links merge so there is only one rather than 3 separate ones?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links
Reply #5 - Aug 26th, 2008 at 7:43am
Print Post  
Use the ControlPoints collection to make the end segments of links merge:

Code
Select All
RectangleF r = topShape.Bounds;
float X = r.X + r.Width / 2;
float Y = r.Bottom;
foreach (DiagramLink link in topShape.IncomingLinks)
{
	int c = link.ControlPoints.Count - 1;
	link.ControlPoints[c] = new PointF(X, Y);
	link.ControlPoints[c-1] = new PointF(X, Y - 20);
	link.UpdateFromPoints();
}
 



You might have to modify this, depending on the Style of links and the direction they are coming from.

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


I love YaBB 1G - SP1!

Posts: 12
Location: Chesterfield, Mo
Joined: Aug 21st, 2008
Re: Links
Reply #6 - Aug 28th, 2008 at 12:33pm
Print Post  
1. I would like to highlight the active item. How do I paint a link and shape node in different colors?

2. Can I make the anchor points larger?

3. When I allowSelfLoops and draw a link from and outgoing anchor to an incoming anchor, the link origin and destination ends up being the incoming anchor rather than from the outgoing link to the incoming link. Any ideas on this? Am I going to be able to trap for this and manually redraw it or??
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links
Reply #7 - Aug 28th, 2008 at 1:28pm
Print Post  
1. Set the Pen and Brush properties.

2. Only by custom-drawing them.

3. Such links are always drawn as loops over nodes, and ignore anchor points. You can set ControlPoints from the LinkCreated event to work around that.

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


I love YaBB 1G - SP1!

Posts: 12
Location: Chesterfield, Mo
Joined: Aug 21st, 2008
Re: Links
Reply #8 - Aug 28th, 2008 at 2:03pm
Print Post  
Okay I have this code but the origin is considerable left of the node so the x is not right. An help on how I convert the anchorpoint.x to the correct pointf.x?

      Dim newAnchorPoint As MindFusion.Diagramming.AnchorPoint = e.Link.Origin.AnchorPattern.Points(e.Link.OriginAnchor)
   If e.Link.Origin Is e.Link.Destination Then
           'self loop - set this so it does not draw a loop over itself which is the default
           e.Link.ControlPoints(0) = New System.Drawing.PointF(newAnchorPoint.X, newAnchorPoint.Y)
           e.Link.UpdateFromPoints()
       End If
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links
Reply #9 - Aug 29th, 2008 at 7:27am
Print Post  
AnchorPoint coordinates are percents of the node Bounds, so

linkPoint.X = node.Bounds.X + anchorPoint.X * node.Bounds.Width;
// same with Y and Height

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


I love YaBB 1G - SP1!

Posts: 12
Location: Chesterfield, Mo
Joined: Aug 21st, 2008
Re: Links
Reply #10 - Aug 29th, 2008 at 1:16pm
Print Post  
Thanks Stoyan,

This actually works:    Dim x As Single = e.Link.Origin.Bounds.X
           Dim y As Single = e.Link.Origin.Bounds.Y + (e.Link.Origin.Bounds.Height / 2)
           e.Link.ControlPoints(0) = New System.Drawing.PointF(x, y)

Now the line is being drawn as a bezier i think. I want it to be just another cascading link with my text. Any help?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links
Reply #11 - Aug 29th, 2008 at 2:30pm
Print Post  
Set link.Style = Cascading before changing ControlPoints, and either call link.Route() or set the positions of the other points where you'd like them to be.

Stoyan
  
Back to top
 
IP Logged
 
tclaffy
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Location: Chesterfield, Mo
Joined: Aug 21st, 2008
Re: Links
Reply #12 - Sep 3rd, 2008 at 2:33pm
Print Post  
Stoyan,

It's getting close. Thanks for the help. Now, the left mouse still draws an ojbect on the diagram. It is immediately discarded but this is a little sloppy. Any wa to disable this?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links
Reply #13 - Sep 3rd, 2008 at 3:10pm
Print Post  
Hi,

If you need to disable drawing items with the mouse, set DiagramView.Behavior = DoNothing.

Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Links
Reply #14 - Sep 3rd, 2008 at 3:20pm
Print Post  
Hi,

DrawLinks should not let you create nodes. Perhaps you are seeing the selection rectangle? If you want to disable it, try setting AllowUnconnectedLinks = true, and calling args.CancelDrag from the LinkCreating handler if you detect that there is no node at the link origin.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint