Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Run Time Drag and Drop (Read 6931 times)
SC
YaBB Newbies
*
Offline



Posts: 37
Joined: Jan 18th, 2008
Run Time Drag and Drop
Jan 18th, 2008 at 4:44pm
Print Post  
Hi
I have downloaded of FlowChart.NET (trial version) to play with-

I couldn't figure out how to drag and drop at run time from my toolbox. I need to be able show all the diagramming compoennts on leftside panel at run tiem and should be able to drag n drop from there to the canvas on the right side panel.

Also I need to be able to combine tables(dbschema) and differnt shapes on the same canvas by simply dragging them from toolbox at runtime.

Is it possible to do these run time drag n drops and mixing different components together.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Run Time Drag and Drop
Reply #1 - Jan 19th, 2008 at 7:48am
Print Post  
Hi,

Quote:
I couldn't figure out how to drag and drop at run time from my toolbox. I need to be able show all the diagramming components on leftside panel at run tiem and should be able to drag n drop from there to the canvas on the right side panel.


The Flowcharter sample project shows how to create a toolbox that allows drag-and-drop creation of diagram nodes.

Quote:
Also I need to be able to combine tables(dbschema) and differnt shapes on the same canvas by simply dragging them from toolbox at runtime.


It should be easy to extend the toolbox code from the Flowcharter sample to support other types of nodes. E.g. add a new string property to the NodeDragItem class that identifies the type of node - "Shape", "Table", etc. or your custom type id. In the diagramView_DragDrop handler create a node instance of the respective type, as specified in the NodeDragItem objects extracted from e.Data.

Quote:
Is it possible to do these run time drag n drops and mixing different components together.


Yes, you can mix nodes from different types in the same diagram.

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



Posts: 37
Joined: Jan 18th, 2008
Re: Run Time Drag and Drop
Reply #2 - Jan 21st, 2008 at 2:46am
Print Post  
How Can I create add table to the toolbox of flowcharter sample so that i can drag and drop.
I added new property to the NodeDragItem class but I am not sure how to proceed.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Run Time Drag and Drop
Reply #3 - Jan 21st, 2008 at 6:58am
Print Post  
There are only a few changes needed. This modified MainForm.cs adds a table to the top of the toolbox:

https://mindfusion.org/_samples/MainForm.zip

Below are outlined the differences between it and the original sample.

First, the Listbox.Sort property is now set to false in order to allow displaying the table at the top. The table item is added like this:

_nodes = new Node[]
{
     new Node("Table", "Entity"),
     ...

The OnDrawItem handler checks the NodeType property, and if it's a "Table" the drawing code looks like this:

t = _hidden.Factory.CreateTableNode(1, 1, 24, 24);
t.Brush = new SolidBrush(Color.White);

The DragDrop handler adds a case for NodeType == "Table" too:

TableNode t = diagram.Factory.CreateTableNode(pt, new SizeF(30, 40));
t.Brush = new SolidBrush(Color.White);

And the Node class has a new string NodeType property and a new overloaded constructor to initialize it:

public Node(AnchorPattern anchor,
     Shape template, string name)
{
     _anchor = anchor;
     _template = template;
     _name = name;
     nodeType = "Shape";
}

public Node(string nodeType, string name)
{
     _anchor = null;
     _template = null;
     _name = name;
     this.nodeType = nodeType;
}

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



Posts: 37
Joined: Jan 18th, 2008
Re: Run Time Drag and Drop
Reply #4 - Jan 22nd, 2008 at 1:46pm
Print Post  
Hi
Thanks for the reply, that really helped.
How can I get rid of the first 4 rows that are empty?
as it is adding the first row from the 5th row.

I have copied the following from dbschema but it is not working like dbschema(has 0 rows in the beginning)

---------------------------------------------------------
TableNode tbl = diagram.Factory.CreateTableNode(
15 + tableCount * 3, 15 + tableCount * 4, 50, 60);
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Run Time Drag and Drop
Reply #5 - Jan 22nd, 2008 at 2:16pm
Print Post  
Hi,

Set diagram.TableRowCount to 0 and all new tables will have 0 rows initially. Or after creating tbl set tbl.RowCount = 0.

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



Posts: 37
Joined: Jan 18th, 2008
Re: Run Time Drag and Drop
Reply #6 - Jan 22nd, 2008 at 4:01pm
Print Post  
Hi

I am able to pan and Zoom but I wanted to group certain items and zoom that alone.
How can I do that?
Please give me some direction on grouping concept what it is intended for..etc.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Run Time Drag and Drop
Reply #7 - Jan 22nd, 2008 at 5:39pm
Print Post  
You could call ZoomToRect to zoom to a specific area of the chart /possibly one that encloses an item or a group of items/.

Grouping has many uses, e.g.

- you could build composite shapes as in the Entities sample project
- create additional link labels by attaching nodes to the link segments
- build a tree where dragging the parent will also move the child items
- create a container which when dragged moves the contained items (the Form Designer in the demo)

You can see some other groups in the demo screens - in "Photo Album", Genealogy tree", "Hierarchy Chart", "Grouping", "Network".

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



Posts: 37
Joined: Jan 18th, 2008
Re: Run Time Drag and Drop
Reply #8 - Jan 22nd, 2008 at 9:03pm
Print Post  

Hi
What is the behavior proeprty should be set to? and how do I know which one is appropriate?
I have my form set behavior set to DrawLInks and I could not able to select more than one object.
I am trying to select mulitple controls and make them as group.(trying to select certain portion and zoom only that portion or show it as one box).

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Run Time Drag and Drop
Reply #9 - Jan 23rd, 2008 at 5:50am
Print Post  
Hi,

DrawLinks only allows drawing links between nodes, while the other Behavior types also let users draw nodes of the built-in or custom types. DrawLinks should be fine when you let your users create nodes via drag-and-drop. You can select more than one objects using CTRL.

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



Posts: 37
Joined: Jan 18th, 2008
Re: Run Time Drag and Drop
Reply #10 - Jan 23rd, 2008 at 1:06pm
Print Post  
For some reason I am not able to select multiple controls either by ctrl or with mouse.
I am using the sample flowcharter that has been modified by you.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Run Time Drag and Drop
Reply #11 - Jan 23rd, 2008 at 1:26pm
Print Post  
Hi,

Find this line in MainForms.cs

diagram.Selection.AllowMultipleSelection = false;

and change the property value to "true".

Stoyan
  
Back to top
 
IP Logged
 
SC
YaBB Newbies
*
Offline



Posts: 37
Joined: Jan 18th, 2008
Re: Run Time Drag and Drop
Reply #12 - Feb 1st, 2008 at 6:49pm
Print Post  
Hi

How can I add a custom shape to my component pallet so that I can drag and drop it on canvas.

I am trying to add it the node creation like below but wasn't sure how to add a picture ot it.
new Node[]{new Node("Table", "Query"),new AnchorPattern(new AnchorPoint[] .....}

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Run Time Drag and Drop
Reply #13 - Feb 2nd, 2008 at 6:09am
Print Post  
Hi,

Add an Image property to the flowcharter's Node class, and add a new overloaded Node constructor that receives an Image argument to initialize the property. In the NodeList_OnDrawItem and diagramView_DragDrop event handlers assign that image to the table and shape nodes created there.

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



Posts: 37
Joined: Jan 18th, 2008
Re: Run Time Drag and Drop
Reply #14 - Feb 4th, 2008 at 4:20pm
Print Post  
Hi

Your responses were very helpful and I was able to progress based on those so far.

When I drag and drop my custom image on canvas, if I want the user to be able to edit the name property and show the name below the image instead of showing in the middle of the image, how do I do that.

Thanks
CS
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint