Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Drawing Lines (Read 2904 times)
Aaron
YaBB Newbies
*
Offline


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Drawing Lines
Jan 11th, 2008 at 12:53pm
Print Post  
Hello,

I'm still using FC.NET 4.0.3

Next to links between nodes I also want to be able to draw lines, no free form lines. Just drag from one point of the chart to another and get a line between them.

It almost works now, but I have to keep setting the origin en destination to DummyNode (and reset the controlpoints) so that they don't connect to the nodes when I drop the enpoints on top of a node.

Now the only problem remaining is that when I create a new arrow (that is a "line") and drag the endpoint over a node, the endpoint jumps to the border of that node.

This behaviour was also present with the startpoint (so the first endpoint) but I've been able to disable that behaviour with:

Code
Select All
    Private Sub OnArrowCreated(ByVal sender As System.Object, ByVal e As MindFusion.Diagramming.WinForms.ArrowEventArgs) Handles mMainFlowChart.ArrowCreated
	  e.Arrow.Tag = Me.mBusiness.DrawingMode
	  If e.Arrow.Origin.Equals(e.Arrow.Destination) AndAlso _
		    Me.mBusiness.DrawingMode = DrawingModes.Normal Then
		Me.mMainFlowChart.DeleteObject(e.Arrow)
	  Else
		If Me.mBusiness.DrawingMode = DrawingModes.Line Then
		    ' When line, we don't want anything connecting anything:
		    Dim mStartPoint As PointF = e.Arrow.ControlPoints(0)
		    Dim mEndPoint As PointF = e.Arrow.ControlPoints(e.Arrow.ControlPoints.Count - 1)
		    e.Arrow.Origin = New DummyNode(Me.mMainFlowChart)
		    e.Arrow.ControlPoints(0) = mStartPoint
		    e.Arrow.Destination = New DummyNode(Me.mMainFlowChart)
		    e.Arrow.ControlPoints(e.Arrow.ControlPoints.Count - 1) = mEndPoint
		    ' Also, make sure the crossings are never drawn
		    e.Arrow.DrawCrossings = False
		    e.Arrow.UpdateFromPoints()
		End If
		Me.mBusiness.HandleCreatedArrow(e.Arrow)
		Me.SetDirty()
	  End If
    End Sub
 



I do the same kind of stuf in ArrowModified.

SnapToAnchor is in "OnCreate" (I wish I wish there was a "None" with that one) and the border snapping is turned off when I'm in the "line drawing mode".


However, isn't there a more convenient way to just draw a line that is not related to an arrow?

I'm thinking about inheriting my own arrow class or even start from a lower object... but that's probably to much work in the time span I have.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing Lines
Reply #1 - Jan 11th, 2008 at 1:23pm
Print Post  
Hi,

An easy way to implement the draw-lines mode is to lock all items, set AllowUnconnectedArrows = true and Behavior = CreateArrow. (That's Diagram.AllowUnconnectedLinks and DiagramView.Behavior = DrawLinks for the version 5 users out there)

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


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Drawing Lines
Reply #2 - Jan 14th, 2008 at 5:51am
Print Post  
Works like a charm, thanks.

One last question, any idea on how to set the arrows so that you can move the entire arrow at once and not just the end points? Can't seem to find it, HandleStyles isn't enough it seems.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing Lines
Reply #3 - Jan 14th, 2008 at 6:31am
Print Post  
In Flowchart.NET 5 this can be done by overriding the UpdateModify method of DiagramLink and offsetting all points in the CotrolPoints collection. In version 4 you might try to do that  from the ArrowModifying event handler, which is raised for each mouse movement while the user is dragging a control point.

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


Looking for support

Posts: 44
Joined: Nov 9th, 2007
Re: Drawing Lines
Reply #4 - Jan 14th, 2008 at 1:08pm
Print Post  
Thanks, you helped me a lot.

Just one little I noticed maybe a bit off topic though: when creating a new arrow, am I correct to assume that "AlignToGrid" has no effect? (I'm pretty sure I'm not setting it to false anywhere)

It's a bit inconvenient, it would be good if on arrow creation, the new points would also align to the grid (I'm quite surprised this is not possible, so I'm thinking I'm doing something wrong).
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Drawing Lines
Reply #5 - Jan 14th, 2008 at 1:32pm
Print Post  
Well yes, links ignore the grid since the node borders and anchor points are not aligned to the grid in the general case. Yet it makes sense to align unconnected links to the grid. Until we implement that, you can do that yourself using the public AlignPointToGrid method.

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