This project has moved and is read-only. For the latest updates, please go here.

how to find a specific shape

Sep 20, 2012 at 2:30 PM

does a shape have an "ID" or "Name"

i want to find/get a specific shape from [Display1.Diagram.Shapes]

how do i return a specific shape on the diagram by ID or Name???

Sep 20, 2012 at 3:58 PM

For performance reasons, shapes are only addressed by their reference. You can use the Id of a shape, but keep in mind that the Id is null until saving the repository. In most cases, it is better to use the Shape.Tag property (attention: The contents of the Tag property will NOT be saved to the repository).

If you need to persist your tracking Id, you could combine the usage of Shape.Tag (unsaved shapes) and Shape.Id (saved shapes) but deriving your own shapes (Adding a TrackingId property and overriding the explicit omplementations of IEntity.LoadFields and IEntity.SaveFields) would be the the cleanest solution.

Sep 5, 2013 at 9:12 AM
Hi,
 Suppose we want to assign incremental id's to the objects derived from shape class, When should we increment, and assign the id to the object in order to have each object we insert and/or copy/paste have different Ids. 
When I tried incrementing in the constructor, it seems that, a deep copy of the object (which is created for the tool palette) is pasted on the diagram, even the constructor for a genuine instance is being called after that.

The second problem is that:

I want to allow connections from output pins from one object to the input pin of the other object. But the connection point being initially right, depending on the layout, connection jumps to the nearest point of the first object( even the point actually doesn't have connection capability).

In the overriden Connect method of the class (driven from polyline) I try to put an arrow head to depict the direction of the data flow, but after being connected, a new object is being created with no arrow head.

Best Regards.
Sep 9, 2013 at 8:39 AM
Edited Sep 9, 2013 at 8:39 AM
Hello,

you are not supposed to change the Id of a shape. Id's are set by the repository when saving the repository to file/database.
All new and unsaved shapes must not have an Id (Id property must be null).


If you manipulate shapes with the selection tool (pointer tool), the shape will be cloned and transferred into a 'preview' shape. All changes applied to this shape will be lost when releasing the mouse button.

If you want to set an arrow head to the line, you can handle the IRepository.ConnectionInserted event and assign the arrow head to the connectorShape's line cap (if it is an ILinearShape).
Alternatively, you can override the line's EndCapStyle and return an appropriate style in case IsConnected(ControlPointId.LastVertex, null) return true.
You can get the appropriate cap style by overriding the InitializeToDefault method and storing the cap style for connected shapes in a member variable.
Sep 11, 2013 at 11:01 AM
Hi,

Thank you very much Kurt.