Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Create Nodes Dynamically (Read 5616 times)
bfairchild
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 23rd, 2007
Create Nodes Dynamically
Jan 2nd, 2009 at 5:53pm
Print Post  
I'm trying to add nodes to the diagram dynamically and am having a few issues. First, when I add nodes like this:

for(int i = 0; i< e.Result.Count; i++)
           {
               ShapeNode node = new ShapeNode(script);
               node.Content = e.Result[i].Name;
               node.Shape = Shapes.Actor;
               node.Width = 100;
               node.Height = 100;
               node.Visible = true;
               node.Name = e.Result[i].Name;
               node.Tag = e.Result[i].Name;
               script.Items.Add(node);
           }

I get the nodes added, but the images on the nodes are not drawn.

Also, in your documentation under Creating and Deleting Items you have this sentence:

There are several shortcut methods provided for creating instances of the predefined node and link types. The methods are members of the diagram's Factory object

But I can't find the "Factory" or the shortcut methods mentioned anywhere in the object tree or the documentation. Where are they?

Help please Smiley.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Create Nodes Dynamically
Reply #1 - Jan 2nd, 2009 at 7:09pm
Print Post  
ShapeNode inherits Content from ContentControl and updates it internally to show its Shape, Text and Image. So you should set these three properties instead of Content. If you need to show anything more elaborate than a label and image inside a node, create a user control class and host its instances inside ControlHost nodes.

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


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 23rd, 2007
Re: Create Nodes Dynamically
Reply #2 - Jan 2nd, 2009 at 7:53pm
Print Post  
That was it. Perfect.

Thanks,
Brian
  
Back to top
 
IP Logged
 
lpastor
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 4
Joined: Jan 10th, 2009
Re: Create Nodes Dynamically
Reply #3 - Jan 10th, 2009 at 5:19pm
Print Post  
HI bfairchild

can you post a correct code ?

I try to create a node dynamically so I need  a good start point . Thanks in advance

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Create Nodes Dynamically
Reply #4 - Jan 12th, 2009 at 6:11am
Print Post  
Hi,

Replace node.Content in that code with node.Text and it should work fine.

Stoyan
  
Back to top
 
IP Logged
 
bfairchild
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 23rd, 2007
Re: Create Nodes Dynamically
Reply #5 - Feb 16th, 2009 at 9:02pm
Print Post  
lpastor,


ShapeNode node = new ShapeNode(script);
              node.Content = e.Result[i].Name;
              node.Shape = Shapes.Actor;
              node.Width = 100;
              node.Height = 100;
              node.Visible = true;
              node.Name = e.Result[i].Name;
              node.Tag = e.Result[i].Name;

Now, just add the newly created node to a child node collection of another node.

For example, you can add the node to the Nodes property of the diagram:

diagram.Items.Add(node);
hth
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint