How I Set Tag Property In Shape

May 13, 2013 at 10:28 AM
Hi All

I have a problems when i try NShape Designer and i insert shape and set property i can't find Tag property,how i can set tag property on my shape?
May 14, 2013 at 10:28 AM
The Tag property is not displayed in the property editor because it is intended to be used programmatically only.
You can access it only with code.
May 14, 2013 at 10:41 AM
Thanks for Reply Kurt, if i want to development diagram software and user give data text to shape How i can Access and get Shape data individually because program i want to develop where user give the name for shape and i want to connected with another my own table
May 17, 2013 at 9:26 AM
I'm not sure if I did understand you correctly but I think you want to develop a diagramming application with the following key features:
  • The user can assign names to shapes
  • The user can click on certain shapes which results in displaying an other diagram
  • The user can connect shapes with table shapes
If you didn't complete the tutorial (see NShape documentation), I would recommend doing this. Moreover, you can search here for the most common information such as connecting shapes.
As far as I can see, you will have to...
  • Create your own shape library assembly with overridden versions of the standard shapes (see your other post for information on how to add property and create a library)
  • Implement connecting shapes programmatically (search this discussion forum for the key word "connect" and/or "shape" and you will find numerous postings on this topic)
If I missed the point of your question or if you have more specific questions, let me know.
May 20, 2013 at 5:03 AM
Thanks Kurt,For key features you said It's right i want create one small application like visio.where user create diagram and they can assign name and when they click the shape and open another diagram and in another diagram and get data from my database and checking if name of shape same the shape automatically change color,if user can't set the tag name how i can get the Data name property of the shape?Please help me kurt thanks
May 21, 2013 at 12:21 PM
Edited May 21, 2013 at 12:24 PM
Shapes do not have a name in NShape because they are simple graphical objects without meaning.
You could assign a model object (any business object that implements IModelObject) which has a name. Using model objects in your application adds a new level of complexity but also enables you to use some cool features (see demo program "ModelMapping Demo" installed with the NShape source code).

If you need a name property for shapes, you have to derive your own shape classes from the standard shapes and add a name property (which is much simpler than using model objects).
In order to use your derived shape classes, you have to create a new assembly (dll), add your shape classes and implement an NShapeInitializer.
See your other post for information on how to add a new property to a shape and implement an NShapeInitializer.

Changing the color of a shape is rather easy (see documentation "Programmer Tasks > Changing the Shape Color"):
RectangleBase shape = ...
shape.FillStyle = project1.Design.FillStyles.Red;