Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Arrows Connect to rows after loading from XML (Read 3169 times)
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Arrows Connect to rows after loading from XML
Nov 12th, 2007 at 2:09pm
Print Post  
I'm using FlowChart.NET 4.3.1 and .NET 2.0

I'm drawing tables with several rows. I allow users to connect the tables with arrows.

I also allow users to edit the content of my tables (using a configuration window). To update the tables, it is convenient to remove all rows and add the new rows in their place.

This works fine until I save the chart to XML and then reload it. I can still edit the rows, and even update the table. But any arrows connected to the table now seemed to be disconnected and floating around.

I noticed I was removing the rows in the wrong way (direct access to the collections). So I'm now removing them with "DeleteRow()". But now the arrow dissapears. I found out the arrow was now actually connected to a row of that table instead of the table itself.

So I tried to solve it by looking if any of the rows to be removed had incomming or outgoing arrows (which they had). I then used fc.CreateArrow() to create a new arrow with the same destination and origin as the arrow connected to the row, except ofcourse the table instead of the row.

However, I must be forgetting something because the arrow isn't showing up. I can't Add it to the collection of the incomming and outgoing arrows of the table because that creates weird behaviour (arrow dissapearing). The Outgoing and Incomming arrow collection of the I used as destination or origin remain empty after the CreateArrow() call.

Code
Select All
Me.mFlowChart.CreateArrow(iTable, iTable.Rows(iRowIndex).OutgoingArrows(i).Destination) 



iTable is the table containing the row...

Why is an arrow previously connected to a table suddenly connected to a row after loading it from XML? Is this my fault or a problem?

What else am I forgetting to create an arrow? Do I need to do anything to make the created arrow visible? Why doesn't it show up in the tables Outgoing or Incomming Arrows Collections?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrows Connect to rows after loading from XML
Reply #1 - Nov 12th, 2007 at 5:25pm
Print Post  
Hi,

If you need to update tables by removing their rows and adding them again, try to disconnect the arrows before that operation, and connecting them again after that.

For each outgoing arrow save its OriginIndex, and for incoming arrows save the DestIndex. These properties specify which table row is connected to an arrow. You can save their value in the arrows' Tag, or in a hashtable.

Disconnect the arrows from the table by setting their Origin or Destination to 'new DummyNode()' (in Flowchart.NET 5, you can simply set them to null). Now deleting a row will not delete the related arrows.

Once you add the rows again, set the arrows' Origin/Destination back to the table, and restore the Origin/DestIndex property values.

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


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Arrows Connect to rows after loading from XML
Reply #2 - Nov 13th, 2007 at 6:19am
Print Post  
Thanks Stoyo.

I'm now doing what you described. The arrow isn't removed anymore. However, when I reset the orgIndex or destIndex it connects to the wrong anchorpoint of the table.

First it was connected to the bottom anchorpoint, or at least, that's where the arrow was visually connected to. I save the index and later on, when all rows are removed and added I once again set it. I checked and the index value was 4 when I saved it, and I reset it to 4 in the end.

The arrow is now connected to the correct table, however it is connected to the anchorpoint on the left. Additionally, the anchor point of the destination (or origin) also seems to change to a different anchorpoint.

For incomming arrows I'm not touching the origin, and for outgoing I'm not touching the destination at any point.

Maybe I should mention my rows do not have and anchorpattern, well, they have an empty array as anchorpattern. Which would be the same as none.

Also, I can't restore origin/destindex "when I add the rows again", because it could even be possible all rows are removed and only one or even none are added again.

So what I really want to do is make the arrows connect to the table, and on the same place as they were before the update.

Thanks
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Arrows Connect to rows after loading from XML
Reply #3 - Nov 13th, 2007 at 6:29am
Print Post  
By the way, the originAnchor property is set to -1 after I reload it from an xml (it's 3 in the XML itself). I tried setting the OriginAnchor to 3 manually in code, but that still gives me the same result.

I still don't understand why the arrow is connected to a row after reloading the XML. Can you force it so that an arrow never connects to a row?
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Arrows Connect to rows after loading from XML
Reply #4 - Nov 13th, 2007 at 6:37am
Print Post  
Here's some stuff from the XML:

Code
Select All
    <Arrow Id="3" ZIndex="3" From="1" RowFrom="-1" To="2" RowTo="-1">
...
<DestAnchor>1</DestAnchor>
...
<OrgnAnchor>3</OrgnAnchor>
 



Somehow, the actual arrow object on the chart is connected to a row and the table itself has no incomming or outgoing arrows. Additionally, DestAnchor and OrgnAnchor are -1, while this is different in the XML and the original chart (the chart before save and reload works perfectly fine, removing rows does nothing to my arrows).
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Arrows Connect to rows after loading from XML
Reply #5 - Nov 13th, 2007 at 6:48am
Print Post  
Okay, I found why hard coding my anchor point didn't work, I was resetting the anchorpattern for some reason. I stopped doing that, now the anchorpoint is correct when I'm hardcoding the AnchorIndex.

But that's no solution obviously, it's still comming wrong out of the XML.

However, I would even like to be able to connect the arrow anywhere on the table. Reconnecting it will move it back to an anchorpoint, am I right? If the arrow was never connected to a row, I'd be out of the woods.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrows Connect to rows after loading from XML
Reply #6 - Nov 13th, 2007 at 7:07am
Print Post  
Do you need the arrows to be regarded as connections between the tables (as simple nodes), and not between their rows? In that case, set the tables LinkStyle mode to "Table", and the links drawn by the user will never connect to a row. Then you would not need to deal with the arrows at all when deleting or adding rows.

If you need to create such arrows programmatically, call CreateArrow(orgtable, -1, desttable, -1) to make sure the arrow won't connect to a row.

Stoyan
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Arrows Connect to rows after loading from XML
Reply #7 - Nov 13th, 2007 at 7:48am
Print Post  
Wow, that seems to be working! Can't believe it was as simple as that.

Thanks very much!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Arrows Connect to rows after loading from XML
Reply #8 - Nov 13th, 2007 at 8:50am
Print Post  
8)
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint