Custom Property class binding

Hi,

Is there any example which dose the following.



I want to define my own class which will have some properties and methods and bind this class to a node.When I click on F4 ( or property window ) , I would like to see all public properties in property grid.Subsequently I also want to read the properties from the grid for further use.



Any help on code snippets are highly helpful.



Thanks in advance

Several sample applications do this. Take a look at ProtoApp, for example. In addition to GraphNode, there is a GraphNodeInfo class that just has user-visible properties that just delegate to the corresponding GraphNode instance.
GraphNodeInfo also implements ICustomTypeDescriptor.GetAttributes so that the PropertyGrid can be “read-only” when the GraphDoc is read-only.

Thanks for the reply.But this model implements common properties for all nodes, I mean the property grid has same keys( property bag) for every node.



I would like to have the property grid keys ( property bag ) to be different for some nodes. can you please direct me to the correct sample application which dose this?



You could use different …Info classes.
Or you could figure out how to use the .NET PropertyGrid mechanism more generally…

Thank you for the information.I just started evaluating the software for our application yesterday only.Probably it make sence if i post my questions only after I go through the samples.But the probelm here is, the functionality is scattered in different samples and to understand different techniques used in the samples one needs to compare the samples.



For example, I am making different shapes by inheriting different base calsses ( GoMultiTextNode , GoBasicNode etc.,) and I am trying to bind userobjects to the shapes.

In the samples, GraphNode.cs code seems to be the one which binds Info class and it always inherit from only one of the base calss ( assume GoBasicNode ).Now If I want to bind another info class to the shape which inherits from GoMultiTextNode , do I need to duplicate all the code from graphnode.cs to avoid type msmatch issues and then bind my info class?

No, there’s hardly any interdependence between GraphNode and GraphNodeInfo, or between MainForm and GraphNodeInfo.
ProtoApp uses the IGoNode.UserObject field (aka “Tag”) to hold a reference to a GraphNodeInfo for each node. You’ll note how GraphNode overrides CopyObject and Initialize to make sure the GoNode.UserObject property is set appropriately to an instance of GraphNodeInfo.
Anyway, there’s no required or even any expected correlation between the appearance/design of a node with the implementation of auxiliary data structures such as GraphNodeInfo.

I got what you mean.can you please guide me how to implement different user objects to different shapes ( ex : earth,computer,start,stop ) with minimal changes to protoapp? I think I just need to write extra property classes, but do not know have any clue how to implement them without loosing any protoapp functionality?

Sure–just have those individual classes inherit from GraphNodeInfo, and everywhere the original example code creates GraphNodeInfo’s (i.e. in Initialize and in CopyObject), just instantiate the class you want.