Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Moving a selection of boxes (Read 1364 times)
J Bolster
Guest


Moving a selection of boxes
Jul 18th, 2006 at 2:29pm
Print Post  
Hi,

I am looking to move multiple selected boxes using code. I am calculating the middle point of the selection rectangle and the point the center should move to. THen working out the difference and going through each box (in FC.Selection.Objects) and using the box.move function to move them.

However, if I try to move the same selection of boxes twice, it fails. I have worked out that the flowchart component isn't updating the BoundingRect property of the selection.

Is there a way to force this property to update to the new location? Or would it require a reselection?

Thanks,
Jonathon
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Moving a selection of boxes
Reply #1 - Jul 18th, 2006 at 2:58pm
Print Post  
Hi Jonathon,

Selection.BoundingRect returns a cached value which is not updated when boxes are moved via the API. Instead of that property, you could copy the following method from the Selection class and use it to find the selection bounds:

private void recalcRect()
{
rect = new RectangleF(0, 0, 0, 0);
foreach (ChartObject obj in selectedItems)
rect = Utilities.unionNonEmptyRects(rect, obj.BoundingRect);
}

Or you might call selection.Toggle twice for some box to force the selection BoundingRect to update.

Stoyan
  
Back to top
 
IP Logged
 
J Bolster
Guest


Re: Moving a selection of boxes
Reply #2 - Jul 18th, 2006 at 8:12pm
Print Post  
That's perfect! Thanks a lot

Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint