Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Move Entire Selection (Read 2748 times)
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Move Entire Selection
Nov 15th, 2007 at 2:37pm
Print Post  
Okay, I'm asking a lot of questions, but this is a good way to make sure I'm using the component correctly.

Anyway, I'm still using FC.NET 4.3.1.

I want to select everything in the chart and move the selection down for a certain amount of dx and dy.

This works, but I do this by looping trough all selected objects and then moving each one down. For arrows, I move their segmentpoints one by one.

However, this only sometimes works. Because if a box is moved, sometimes the arrows move as well.

Is there a way to easily move an entire selection?

Additionally, is there a way to disable the movement of the points of arrows when a table - for instance - to which it is connected is moved? Without losing the connections...

(or can you undo these disconnections?)

This is what I'm doing:

Code
Select All
    Public Sub MoveSelected(ByVal iDx As Single, ByVal iDy As Single)
        Dim c As Integer = Me.mFlowChart.Selection.Objects.Count
        For i As Integer = 0 To c - 1
            If TypeOf Me.mFlowChart.Selection.Objects(i) Is Arrow Then
                Dim lArrow As Arrow = CType(Me.mFlowChart.Selection.Objects(i), Arrow)
                For j As Integer = 1 To lArrow.ControlPoints.Count - 2
                    lArrow.ControlPoints(j) = New PointF(lArrow.ControlPoints(j).X + iDx, lArrow.ControlPoints(j).Y + iDy)
                Next
                lArrow.UpdateFromPoints()
            ElseIf TypeOf Me.mFlowChart.Selection.Objects(i) Is Node Then
                Dim lNode As Node = CType(Me.mFlowChart.Selection.Objects(i), Node)
                lNode.Move(lNode.BoundingRect.X + iDx, lNode.BoundingRect.Y + iDy)
            End If
        Next
    End Sub
 

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Move Entire Selection
Reply #1 - Nov 15th, 2007 at 4:32pm
Print Post  
Hi,

Moving a node also moves the link end points, so the easiest solution is to move all items in two phases. First, move all selected nodes - this also offsets the end points of the links. Next, offset all control points of all selected links, except the end points (the end points have been moved with the nodes).

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


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Move Entire Selection
Reply #2 - Nov 19th, 2007 at 8:07am
Print Post  
Okay, I did move both types in a seperate time, but I also had to call "Route()" on all routed arrows after I loaded the chart from XML. Because moving a box sometimes caused control points to dissapear.

It works fine now.
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Move Entire Selection
Reply #3 - Nov 21st, 2007 at 7:38am
Print Post  
Oh dear, it doesn't work fine after all.

All is well as long as arrows are either autorouted or not autorouted.

However, when I call Route() (on an autorouted arrow) and then disable its "autoroute" property. It seems that the start and enpoint are no longer the first and last point in the controlpoints the collection.

Is there another way to figure out which two points are the enpoint of an arrow? So I can decide NOT to move those two?

I'm doing it like this now:

Code
Select All
        c = Me.mFlowChart.Selection.Arrows.Count
        For i As Integer = 0 To c - 1
            Dim lArrow As Arrow = CType(Me.mFlowChart.Selection.Arrows(i), Arrow)
            For j As Integer = 1 To lArrow.ControlPoints.Count - 2
                lArrow.ControlPoints(j) = New PointF(lArrow.ControlPoints(j).X + iDx, lArrow.ControlPoints(j).Y + iDy)
            Next
            If lArrow.AutoRoute Then
                lArrow.Route()
            End If
            lArrow.UpdateFromPoints()
        Next
 





There's another problem that relates to changing from autoroute to not autoroute.

So I have my arrow and I set it to autoroute, it gets rerouted perfectly fine. Then I disable autoroute. The arrow still looks fine. Now when I move a box around, alle points of the arrow except the two endpoints are removed. So I end up with an arrow of 1 segment.

What I want to happen is that the arrow stays in the form the autoroute had put it.

What I'm thinking of doing is calling Route() when I disable autoroute as well... however, then any changes to the segments of the arrow would have to be disabled when in autoroute mode. At this time, one can add segments with auto routing on. Calling Route() again will remove those segments again. Wanted behavior would be that if the user has added some segments and then disables autoroute, the segments remain.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Move Entire Selection
Reply #4 - Nov 21st, 2007 at 8:29am
Print Post  
Quote:
So I have my arrow and I set it to autoroute, it gets rerouted perfectly fine. Then I disable autoroute. The arrow still looks fine. Now when I move a box around, alle points of the arrow except the two endpoints are removed. So I end up with an arrow of 1 segment. What I want to happen is that the arrow stays in the form the autoroute had put it.


Usually the control preserves the form of the arrow that was set by the routing function. Please check if there isn't some code in the BoxModified or ArrowModified event handler that modifies the arrow's SegmentCount or Style.

Quote:
However, when I call Route() (on an autorouted arrow) and then disable its "autoroute" property. It seems that the start and enpoint are no longer the first and last point in the controlpoints the collection.


The arrow is drawn by calling Graphics.DrawLines(arrow.ControlPoints), so what you have in that collection is what you get on the screen. I cannot see how the start and end points can become different from the ones in the collection. Could you email a saved flowchart file and a sample project that shows the problem to support@mindfusion.eu?

Stoyan
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Move Entire Selection
Reply #5 - Nov 22nd, 2007 at 6:34am
Print Post  
I don't think I'm touching the segment count anywhere.

But still, the problem is on hold now (apparently auto routing is not wanted at this moment). But I'll see if I can e-mail you when I find some time.

Thanks allready.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint