Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic OnArrowModifying: Constraining ControlPoints (Read 3199 times)
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
OnArrowModifying: Constraining ControlPoints
Dec 12th, 2007 at 12:36pm
Print Post  
Hello again!

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

I'm giving the user a possibility to draw their charts with PolyLine arrows with one segment to start with, so a straight line will always be what they draw from one box to another. Then they have the option to insert control points, which is standard functionality of FC.NET.

I also use "snap to grid" to allow them to more easily align objects to each other.

This snap to grid causes some problems when users move control points of an arrow. When a user wants to connect to point exactly to the side of a table or box sometimes the snap to grid forces the point to be outside of the table. Because I do not allow unconnected arrows, the point snaps back to it's original position when released.

So I added the option for them to hold the shift key while modifying these points. This key temporarily disabled the snap to grid option. This allows them to more accuratly place an arrow endpoint to the side of a table or box. However, because there is no snap to grid it's hard to get straight lines.

I know the Cascading option will allow ONLY straight lines to be drawn, but this is not an option, as they whish to be able to draw straight lines to other boxes.

What I'm really missing is (basically) an option that when the user is modifying the points, they automatically position themselves so that they for a straight line with the next and previous point. Very much like in Illustrator and Photoshop, where pressing shift (or something) makes sure you can only draw lines at certain angles.

I've done a basic attempt by implementing some code in the ArrowModifying event, but you can't really position the point the user is modifying... am I right?

Here is what I was playing with:

Code
Select All
    Private Sub OnArrowModifying(ByVal sender As System.Object, ByVal e As MindFusion.Diagramming.WinForms.ArrowConfirmArgs) Handles mMainFlowChart.ArrowModifying
        ' First we need to see what point is being modified
        Dim c As Integer = e.Arrow.ControlPoints.Count
        Dim lPointIndex As Integer = 0
        For i As Integer = 0 To c - 1
            If e.Arrow.ControlPoints(i).Equals(e.Point) Then
                lPointIndex = i
                Exit For
            End If
        Next

        Me.SetStatusBarText("The index: " & lPointIndex)

        e.Arrow.ControlPoints(lPointIndex) = New PointF(0, 0)
        e.Arrow.UpdateFromPoints()
    End Sub
 



Here I'm trying to force the point the user is modifying to go to the top left corner, but the code does nothing at all...

Any tips on how I could make this kind of functionality happen anyway?

Quite a long post, sorry about that!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: OnArrowModifying: Constraining ControlPoints
Reply #1 - Dec 12th, 2007 at 2:30pm
Print Post  
Hi,

Doing that from the ArrowModifying event handler does not work, because this event is raised just before Flowchart.NET updates the arrow points according to the current mouse position. So the control immediately overrides the points you are setting in the handler with new ones.

You can align the points in the Modified handler, but the user won't see how the arrow will be aligned until they release the mouse button.

Stoyan
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: OnArrowModifying: Constraining ControlPoints
Reply #2 - Dec 13th, 2007 at 6:25am
Print Post  
Thanks,

I thought it would be difficult for the user to understand what was happening if he didn't see the result in real time. But now I'm just using a treshold of GridSize and if the x and y is withing that treshold, align the point to the closest point. Could use some fine-tuning but at least it solves the problem of not being able to get straight lines.

Now for the other situation... can you set a margin around a box of table so that if the endpoint of an arrow is dragged just outside a box, the arrow jumps to the border to connect to it? At this moment whenever I'm even 1 pixel outside the box or table a "no-go" symbol appears and I can't move the arrow endpoint to that box. I'd like a margin: "if the arrow is moved at least 2 pixels near to the box, connect to it." or something like that.

Haven't found a way to do it, when forbidding unconnected arrows Sad
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: OnArrowModifying: Constraining ControlPoints
Reply #3 - Dec 13th, 2007 at 10:18am
Print Post  
Have you tried the SnapToNodeBroders property? If it is enabled, the arrow will snap to the nearest point from the node outlines.  However at this time you can't set a margin - the mouse pointer should still be inside the node.

Stoyan
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: OnArrowModifying: Constraining ControlPoints
Reply #4 - Dec 17th, 2007 at 7:07am
Print Post  
That is indeed the alternative I'll be using. The problem I have with snap to borders is that it will ALWAYS snap to the border. I'd have liked it to only snap to the border.

Might code it myself if I have some time.

Thanks very much for the clear replies Stoyo!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: OnArrowModifying: Constraining ControlPoints
Reply #5 - Dec 17th, 2007 at 7:39am
Print Post  
Do you mean you need the links to do that selectively, e.g. when Shift is down? The link's modification code checks SnapToBorders upon each MouseMove event, so you might toggle the property value in response to KeyDown / KeyUp events for the link being currently modified.

Stoyan
  
Back to top
 
IP Logged
 
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: OnArrowModifying: Constraining ControlPoints
Reply #6 - Dec 17th, 2007 at 12:41pm
Print Post  
That's exactly what I'm currently doing for the snap to grid property. And it's probably a good option for the snap to border thing as well.

However, what I actually meant was that when you drop an enpoint say 10 px or closer to a node border, it snaps to it... but drop it further and the snap to border dissapears.

Ofcourse I could make something like that with the boundingrectangle... I'll consider that as well.

For now I'm settling for the snap to border thing, all the time.

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