Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic DiagramLinks based on UML shapes (Read 2835 times)
Necroman
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
DiagramLinks based on UML shapes
Jul 28th, 2009 at 2:39pm
Print Post  
I'm looking for some help how to create basic UML links as DiagramLinks. Is there any table with examples or guide what constructor parameters to use? For example what Pens and Arrow heads to use from the available set?
I guess this is quite common topic and some helper class for creating UML DiagramLinks might be even in MindFusion library Smiley.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DiagramLinks based on UML shapes
Reply #1 - Jul 29th, 2009 at 9:03am
Print Post  
Here is a helper method to create a Generalization connector:

Code
Select All
DiagramLink CreateGeneralization(DiagramNode typeNode, DiagramNode baseTypeNode)
{
	DiagramLink link = diagram.Factory.CreateDiagramLink(typeNode, baseTypeNode);
	link.HeadShape = ArrowHead.Triangle;
	link.CascadeOrientation = Orientation.Vertical;
	link.SegmentCount = 3;
	link.Style = LinkStyle.Cascading;
	link.Brush = new SolidBrush(Color.White);

	PointCollection points = link.ControlPoints;
	RectangleF r1 = typeNode.Bounds;
	RectangleF r2 = baseTypeNode.Bounds;
	points[0] = new PointF(r1.X + r1.Width / 2, r1.Top);
	points[points.Count - 1] = new PointF(r2.X + r2.Width / 2, r2.Bottom);
	link.UpdateFromPoints();
	link.Route();

	return link;
}
 



Feel free to use it as a template for the other types Wink

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


I love YaBB 1G - SP1!

Posts: 49
Joined: Jul 27th, 2009
Re: DiagramLinks based on UML shapes
Reply #2 - Jul 30th, 2009 at 1:47pm
Print Post  
That look good, thanks.

Another issue I got - I use AlignToGrid diagram property for aligning nodes and links to grid, but still when my diagram is generated and used Arrange method, some links ar elaid out of grid and therefore, if I move these links, I can't move them back to its previous position.

Is there a way how to set up and arrange diagram to be sure, that all links and nodes are really aligned to grid?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: DiagramLinks based on UML shapes
Reply #3 - Jul 30th, 2009 at 3:05pm
Print Post  
You could use the AlignPointToGrid method to align items to the grid from code, eg:

PointF p = diagram.AlignPointToGrid(node.Bounds.Location);
node.Move(p.X, p.Y);

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