Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to create default object on flowchart (Read 3063 times)
belfaigore
YaBB Newbies
*
Offline


Life is so wonderfull

Posts: 19
Joined: Apr 11th, 2007
How to create default object on flowchart
Apr 11th, 2007 at 6:04am
Print Post  
Hi, I'am french user using FlowChart.NET in VS2005

My flowchart behavior property is set to "Flowchart", in order to build diagramme. I have objects "Arrow", "Box", "Table" wich are default object I would like the FlowChart to build.
How can I set my object as default to the flowchart ?

I know the properties like "Arrow...", "Table...", of the FlowChart object but properties are not as many as the real object "Arrow" or "Table"
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to create default object on flowchart
Reply #1 - Apr 11th, 2007 at 7:47am
Print Post  
Hi,

Item properties that do not have corresponding default-value properties in the FlowChart class can be set from the Initialize[Box/Arrow/Table] events.

Another possibility is to keep some prototype objects initialized with the default values you need, and use your own Behavior class. From the Behavior.StartDraw method return new items initialized from the prototypes using the respective copy constructor. Currently the standard Behavior classes initialize new items using the

Box(FlowChart parent)
Arrow(FlowChart parent)
Table(FlowChart parent)

constructors, which copy the attribute values from the FlowChart. Instead them, try using the

Box(Box prototype)
Arrow(Arrow prototype)
Table(Table prototype)

constructors.

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


Life is so wonderfull

Posts: 19
Joined: Apr 11th, 2007
Re: How to create default object on flowchart
Reply #2 - Apr 11th, 2007 at 10:48am
Print Post  
Thanks that realy help me much.

I've create my own Class wich inherits Behaviors.Behavior and I overrides SetMouseCursor,StartDraw,GetTargetNode methodes.

Another question is :
How to create an arrow from a prototype unknow source and destination node ? The goal is to add a property to my own class behavior to set a default arrow ; so I don't know the source and destination node.

Sample :

Dim DefautArrow as New arrow(MyFlowchart)
Dim NewArrow as new Arrow(DefautArrow, ?SrcNode?, ?DestNode?)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to create default object on flowchart
Reply #3 - Apr 11th, 2007 at 12:04pm
Print Post  
It seems you cannot have null source and destination, so try if that will work with the  DummyNode class -

new Arrow(prototypeArrow, new DummyNode(), new DummyNode());

The DummyNode objects are what you get as a source and/or destination when you draw unconnected arrows. In this case, they should be replaced with the real nodes once the arrow creation comlpetes.

Stoyan
  
Back to top
 
IP Logged
 
belfaigore
YaBB Newbies
*
Offline


Life is so wonderfull

Posts: 19
Joined: Apr 11th, 2007
Re: How to create default object on flowchart
Reply #4 - Apr 12th, 2007 at 8:27am
Print Post  
I don't know if it work well because I'll had on runtime an "Not instancied object" exception, and I can't find where the exception occure in step by step debugging mode.

I'll try to find the trouble and I'll back to give you more information.
  
Back to top
 
IP Logged
 
belfaigore
YaBB Newbies
*
Offline


Life is so wonderfull

Posts: 19
Joined: Apr 11th, 2007
Re: How to create default object on flowchart
Reply #5 - Apr 12th, 2007 at 12:32pm
Print Post  
It doesn't work, here is my "StartDraw" overrides behavior methode :
Code
Select All
Public Overrides Function StartDraw(ByVal point As System.Drawing.PointF) As MindFusion.Diagramming.WinForms.InteractionState

	  Dim Node As MindFusion.Diagramming.WinForms.Node = FlowChart.GetNodeAt(point, True, False)

	  If Node IsNot Nothing Then

		Dim FlowChartObject As MindFusion.Diagramming.WinForms.ChartObject = FlowChart.GetObjectAt(point, False)

		If FlowChartObject IsNot Nothing AndAlso FlowChartObject.Selected Then
		    Return New MindFusion.Diagramming.WinForms.InteractionState(FlowChartObject, 8, MindFusion.Diagramming.WinForms.Action.Modify)
		Else
		    'Me.DefaultArrow.ControlPoints.Clear()
		    'Return New MindFusion.Diagramming.WinForms.InteractionState(Me._Default_Arrow, -1, MindFusion.Diagramming.WinForms.Action.Create)
		    Try

			  Dim ArrowTest As New Arrow(FlowChart, Node)

			  Dim ArrowTest1 As New Arrow(Me.DefaultArrow, Node, New DummyNode(Me.FlowChart))
			  Dim ArrowTest2 As New Arrow(Me.DefaultArrow, Node, New DummyNode(Me.FlowChart))
			  'ArrowTest2.Destination = Nothing
			  ArrowTest2.ControlPoints.Clear()
			  ArrowTest2.ControlPoints.Add(New System.Drawing.PointF(0, 0))
			  ArrowTest2.ControlPoints.Add(New System.Drawing.PointF(0, 0))

			  Return New MindFusion.Diagramming.WinForms.InteractionState(ArrowTest, -1, MindFusion.Diagramming.WinForms.Action.Create)

		    Catch ex As Exception
			  MsgBox(ex.StackTrace)
			  Return Nothing
		    End Try

		End If


	  Else
		Dim Table As New MindFusion.Diagramming.WinForms.Table(FlowChart)
		Return New MindFusion.Diagramming.WinForms.InteractionState(Table, -1, MindFusion.Diagramming.WinForms.Action.Create)
	  End If

    End Function 


Node is the variable wich represent the node under the mouse
ArrowTest is an Arrow I want to create whose work fine
ArrowTest1 and ArrowTest2 are Arrows I want to create whose doesn't work
So I'll try to fine the difference between ArrowTest and ArrowTest1 & 2 with Debugging spy

ArrowTest.Destination = nothing
ArrowTest.Destination <> nothing

How can I set my arrow destination property to nothing; i'll try ArrowTest.Destination = nothing
but it doesn't work.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to create default object on flowchart
Reply #6 - Apr 12th, 2007 at 2:08pm
Print Post  
At this time you cannot set the Destination to Nothing. The control requires arrows to always have some valid destination node. What we could do is change the Destination setter, so it creates a dummy node internally when you assign Nothing to the property.

The cascading arrow style requires at least two segments, so clearing the points collection and adding only two points might not be a good idea, depending on what the default style is.  Try also updating the SegmentCount property and calling the UpdateFromPoints method after setting the point coordinates.

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