Add Custom Property in NShape Object !!


Author
Message
khaled mahmoud
khaled mahmoud
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)
Group: Forum Members
Posts: 3, Visits: 1
I need to add custom propery in nshape

and

how to create custom shape with image


Thanks
Reply
Ivo Milanov
Ivo Milanov
Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)Forum Member (35 reputation)
Group: Forum Members
Posts: 35, Visits: 32
Hi Wilhelm,

Yes sure - the default diagram property grid uses the PropertyGrid of the .NET framework. If you define a Tag object to each shape then you need to simply subscribe for the NodeSelected and NodeDeselected events of the view event sink service. For a form on which you have dropped a PropertyGrid control use this code (also demonstrates how to make a custom tag):

private void Form1_Load(object sender, EventArgs e)
{
...
// assing a tag to a shape (actually you can assign a tag to all diagram elements)
shape.Tag = new MyTag();

// subscribe for the node selected/deselected events
nDrawingView1.EventSinkService.NodeSelected += new Nevron.Dom.NodeEventHandler(EventSinkService_NodeSelected);

nDrawingView1.EventSinkService.NodeDeselected += new Nevron.Dom.NodeEventHandler(EventSinkService_NodeDeselected);
}

void EventSinkService_NodeDeselected(Nevron.Dom.NNodeEventArgs args)
{
propertyGrid1.SelectedObject = null;
}

void EventSinkService_NodeSelected(Nevron.Dom.NNodeEventArgs args)
{
NDiagramElement element = args.Node as NDiagramElement;
if (element == null)
return;

propertyGrid1.SelectedObject = element.Tag;
}

[Serializable]
public class MyTag : ICloneable
{
public MyTag()
{
}
public object Clone()
{
MyTag clone = new MyTag();
clone.m_BoolField = this.m_BoolField;
clone.m_StringField = this.m_StringField;
return clone;
}
public bool BoolProperty
{
get
{
return m_BoolField;
}
set
{
m_BoolField = value;
}
}
public string StringProperty
{
get
{
return m_StringField;
}
set
{
m_StringField = value;
}
}
bool m_BoolField;
string m_StringField;
}
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search