Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Lane Diagram (Read 2386 times)
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Lane Diagram
Apr 13th, 2009 at 7:47am
Print Post  
Hi
Am trying to delete a lane in the lanediagram and i am using the following code to delete the lane and it works fine but it is not removing the nodes and links belongs to that lane.

Can you pls help me in this regards.


Dim grid As Grid = docGanttChart.LaneGrid
Dim hdrToRemove As Header
hdrToRemove = grid.RowHeaders(dbGridTasks.RowBookmark(dbGridTasks.Row))

grid.RowHeaders.Remove(hdrToRemove)

Thanks
Hamid
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Lane Diagram
Reply #1 - Apr 13th, 2009 at 11:04am
Print Post  
You have to manually remove the nodes whose bounding rectangles intersect with the bounding rectangle of the removed row. Here is a code snippet that illustrates how. You have to place this code before removing the row:

Code
Select All
Dim r As RectangleF = grid.GetCellBounds(grid(Nothing, hdrToRemove))

Dim toDelete As New List(Of DiagramNode)
For Each node As DiagramNode In docGanttChart.Nodes

      Dim inter As RectangleF = node.Bounds
      inter.Intersect(r)

      If (Not inter.IsEmpty) Then

            toDelete.Add(node)

      End If

Next

For Each node As DiagramNode In toDelete
      docGanttChart.Nodes.Remove(node)
Next 


Regards,
Meppy
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Lane Diagram
Reply #2 - Apr 13th, 2009 at 12:35pm
Print Post  
Dear Meppy

Thanks for your help.

I tried your code, It works Great... Thanks again.

And if i am removing the first row or middle row then i have problem of remaining nodes which are not belongs to removed lane(other lanes after removed lane), that they all are not in the respective lanes(Actual Parent Lane).

Could you pls help me to move the nodes to the respective lanes after the lane removed.

For example

1. I have 4 lanes with one node in each lane.
2. Now i delete the lane no 2 and its node
3. Now lane 3 will become new lane2 and lane4 will become new lane3, here i want the node of the actual lane3 should move to new lane2 and node of actual lane4 shoud move to new lane3.


Thanks
Hamid

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Lane Diagram
Reply #3 - Apr 13th, 2009 at 2:04pm
Print Post  
The best solution would be to establish a relationship between the nodes and the grid cells they belong to, then handle the Lane.CellBoundsChanged event and ensure that the nodes retain position relative to their associated cells. However, while trying to implement this solution, I have found a bug, resulting in inaccurate values in the argument of the above mentioned event. This bug has been fixed, but until the fix is released, you can use the following code as a workaround. Insert the code right before the row removal:

Code
Select All
Dim total As RectangleF
Dim i As Integer = grid.GetRowIndex(hdrToRemove)
For row As Integer = i + 1 To grid.RowHeaders.Count

      Dim rowBounds As RectangleF = _
            grid.GetCellBounds(grid(Nothing, grid.GetRow(row)))

      If total.IsEmpty Then
            total = rowBounds
      Else
            total = RectangleF.Union(rowBounds, total)
      End If

Next

Dim toMove As New List(Of DiagramNode)
For Each node As DiagramNode In docGanttChart.Nodes

      Dim inter As RectangleF = node.Bounds
      inter.Intersect(total)

      If (Not inter.IsEmpty) Then

            toMove.Add(node)

      End If

Next

For Each node As DiagramNode In toMove

      Dim nodeBounds As RectangleF = node.Bounds
      nodeBounds.Offset(0, -hdrToRemove.Height)
      node.Bounds = nodeBounds

Next 


Regards,
Meppy
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Lane Diagram
Reply #4 - Apr 13th, 2009 at 3:08pm
Print Post  
Dear Meppy

Thanks for your help.

As you said i inserted the code, but when i delete a row i get the remaining nodes are moved to wrong lanes.

One more thing i would like tell you is each lane will have one main node attached with child node and both the nodes are locked and grouped together.
Likewise all the rows has 1 main node and 1 attached node. some times some row may have only the main node not the child node attached to it.

With this code the attached nodes are moved apart (seperated) from the main node. and i need to move the nodes which are coming after the removed row node.

Here when i remove the 2nd row the node in the first row is moved to the col header area, which is not suppose to.

Could you pls help me in this regards

Thanks
Hamid


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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Lane Diagram
Reply #5 - Apr 14th, 2009 at 6:21am
Print Post  
There was a mistake in the above code. Here is the complete, fixed version:

Code
Select All
Dim r As RectangleF = grid.GetCellBounds(grid(Nothing, hdrToRemove))

Dim toDelete As New List(Of DiagramNode)
For Each node As DiagramNode In docGanttChart.Nodes

      Dim inter As RectangleF = node.Bounds
      inter.Intersect(r)

      If (Not inter.IsEmpty) Then

            toDelete.Add(node)

      End If

Next

For Each node As DiagramNode In toDelete
      docGanttChart.Nodes.Remove(node)
Next

Dim total As RectangleF
Dim i As Integer = grid.GetRowIndex(hdrToRemove)
For row As Integer = i To grid.RowHeaders.Count - 1

      Dim rowBounds As RectangleF = _
            grid.GetCellBounds(grid(Nothing, grid.GetRow(row)))

      If total.IsEmpty Then
            total = rowBounds
      Else
            total = RectangleF.Union(rowBounds, total)
      End If

Next

Dim toMove As New List(Of DiagramNode)
For Each node As DiagramNode In docGanttChart.Nodes

      Dim inter As RectangleF = node.Bounds
      inter.Intersect(total)

      If (Not inter.IsEmpty) Then

            If (node.MasterGroup Is Nothing) Then
                  toMove.Add(node)
            End If

      End If

Next

For Each node As DiagramNode In toMove

      Dim nodeBounds As RectangleF = node.Bounds
      nodeBounds.Offset(0, -hdrToRemove.Height)
      node.Bounds = nodeBounds

Next

grid.RowHeaders.Remove(hdrToRemove) 


Regards,
Meppy
  
Back to top
 
IP Logged
 
muthuhamid
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 60
Joined: Feb 1st, 2009
Re: Lane Diagram
Reply #6 - Apr 14th, 2009 at 6:41am
Print Post  
Hi Meppy

Your help is Great and the code works Superb.

Thanks & Regards
Hamid
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint