Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Newbie question on attaching attributes to shape (Read 1281 times)
arisco97
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Dec 20th, 2009
Newbie question on attaching attributes to shape
Dec 20th, 2009 at 6:25pm
Print Post  
I did not see any demos so have a question on whether offerings support associating attributes to a shape (For e.g. in Visio: Shape -> Properties). 

And within that what capabilities are offered?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Newbie question on attaching attributes to sha
Reply #1 - Dec 21st, 2009 at 10:03am
Print Post  
Hi,

If you need a predefined set of additional properties, you could add them to your custom ShapeNode -derived class and implement serialization like this:

Code
Select All
protected override void SaveToXml(System.Xml.Linq.XElement xmlElement, XmlPersistContext context)
{
	base.SaveToXml(xmlElement, context);
	context.WriteString(Title, "Title", xmlElement);
	context.WriteString(FullName, "FullName", xmlElement);
}

protected override void LoadFromXml(System.Xml.Linq.XElement xmlElement, XmlPersistContext context)
{
	base.LoadFromXml(xmlElement, context);
	Title = context.ReadString("Title", xmlElement);
	FullName = context.ReadString("FullName", xmlElement);
} 



You should also call the RegisterItemClass method to define the xml element name for your nodes.

If you need to let users set arbitrary properties as in Visio, you could implement that by storing them in Dictionary<string,Object> or Dictionary<string,string>, either by adding the dictionary as a property of a custom class or by storing it as a value of the node.Tag property.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint