Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Add an unique identifier (Read 2322 times)
mberger
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 44
Joined: Jan 6th, 2009
Add an unique identifier
Jan 6th, 2009 at 9:56pm
Print Post  
Hi,

for my application i have to create some IconNodes.
Therefore i have copy and paste the IconNode class from the sample files.

Is it possible to add this IconNodes an unique identifier like a index or a name (In the same way i would like to add an index or name to a link)?

best regards
Marco

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Add an unique identifier
Reply #1 - Jan 7th, 2009 at 8:31am
Print Post  
Hi,

You could add the following to the IconNode class:

public Guid UniqueID
{
     get { return uniqueID; }
}

private Guid uniqueID = new Guid();

and these two lines to the serialization methods:

// in Saveto
writer.Write(uniqueID.ToString());

// in LoadFrom
uniqueID = new Guid(reader.ReadString());

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


I love YaBB 1G - SP1!

Posts: 44
Joined: Jan 6th, 2009
Re: Add an unique identifier
Reply #2 - Jan 7th, 2009 at 3:34pm
Print Post  
...thanks a lot for your help! Cheesy

But this wasn't the property that im searching for!

for explanation:

I would like to write a little application to calculate the mass flow in a pipe network. this network should be created with some different IconNodes.

After the creation of the IconNode during the runtime, i need a unique name or index for each node to accessing them or to set some values in arrays for a selected node.

for example:

name node 1: Node_1
name node 2: Node_2
name node 3: Node_3
...

Array's

Arr_Node_1_Value_1 = "xxx"
Arr_Node_2_Value_1 = "yyy"

and so on...

(sorry for my poor english... Embarrassed )

best regards
Marco
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Add an unique identifier
Reply #3 - Jan 7th, 2009 at 3:57pm
Print Post  
You could add some string ID property similarly to how IconNode.Label is defined, and use the Dictionary class from System.Collections.Generic to map IDs to Nodes.

I hope that helps,
Stoyan
« Last Edit: Jan 8th, 2009 at 6:42am by Stoyo »  
Back to top
 
IP Logged
 
Aziz ur Rahman
YaBB Newbies
*
Offline



Posts: 43
Joined: Feb 23rd, 2009
Re: Add an unique identifier
Reply #4 - Jun 9th, 2009 at 12:58pm
Print Post  
If Diagram is saved to XML, then each node and each link will be given a unique Id

e.g.
<Node Class="Terminator" Id="1" Version="1">
OR
<Link Class="std:DiagramLink" Id="5" Version="1">

But this "Id" attribute is not exposed in the object model of node or link.

Can u please expose it so that I donot have to go through all the custom labor work mentioned by you.
  

Syed Aziz ur Rahman
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Add an unique identifier
Reply #5 - Jun 9th, 2009 at 6:05pm
Print Post  
That's the value of the ZIndex property of items. You could use it as an id when saving the diagram; ZIndex will have values ranging from 0 to the number of items - 1. However the ZIndex value changes when deleting items or when you call Z order related methods, so you can't use it as a general purppose id that will always refer to the same item. You might assign your IDs each time when a new item is created by using the .NET Guid class, e.g. in NodeCreated handlers:

e.Node.Tag = (new Guid()).ToString();
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint