Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Tree Layout (Read 1251 times)
digit
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Jul 23rd, 2008
Tree Layout
Jul 23rd, 2008 at 10:29pm
Print Post  
I currently use the following code to layout nodes in a tree:

treeLayout = New TreeLayout
treeLayout.LinkStyle = TreeLayoutLinkType.Cascading3
treeLayout.Root = Me.startNode
treeLayout.Direction = TreeLayoutDirection.LeftToRight
treeLayout.Type = TreeLayoutType.Centered
treeLayout.LevelDistance = 10
treeLayout.NodeDistance = 10

This produces a tree looking like this:


We would like the tree layout to look like this:


Is there any way to overide the tree layout or alter the properties to achieve this?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Tree Layout
Reply #1 - Jul 24th, 2008 at 11:02am
Print Post  
Try this:

Code
Select All
Dim tl As New TreeLayout()

tl.Direction = TreeLayoutDirection.LeftToRight
tl.LayoutNode = New LayoutNode(AddressOf OnLayoutNode)
tl.LinkStyle = TreeLayoutLinkType.Cascading3

nodes = New List(Of DiagramNode)()
tl.Arrange(Diagram1)

nodes.Reverse()

For Each node As DiagramNode In nodes
	Dim c As RectangleF = RectangleF.Empty

	For Each outg As DiagramLink In node.OutgoingLinks

		Dim child As DiagramNode = outg.Destination
		If (c.IsEmpty) Then
			c = child.Bounds
		Else
			c = RectangleF.Union(c, child.Bounds)
		End If

	Next

	If Not c.IsEmpty Then

		Dim b As RectangleF = node.Bounds
		b.Y = c.Top
		node.Bounds = b

	End If

Next
' .........................
Private nodes As List(Of DiagramNode)
Private Sub OnLayoutNode(ByVal node As DiagramNode, ByVal r As RectangleF)
	nodes.Add(node)
End Sub
 



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