Page 1 of 1
Posted: Sat Aug 27, 2011 1:13 am
How can I handle the new element event? I tried to do a custom state but it does not give me this event. I need to know when a element is added to give it a new name and store its properties and I would like to have the element selected event to show its properties in a grid. It is posible?
Re: new element
Posted: Sat Aug 27, 2011 11:42 am
When a new Element is added via the toolbox, the change is recorded as a DesignerTransaction by the Recorder service as an ElementAddition object. You can listen to these events by overriding PictureDesigner.TransactionCompleted. Call the base class implementation first.
To change the name of the a new object, instead of using the default naming algorithm, you will need to create a custom NameProvider service, replacing the usual one. There are three methods you need to override and it is a little complicated. We would need to provide a sample for you. What is the algorithm you wish to use?
When the selection changes, using any mechanism, the Selector service raises the SelectionChanged event. You can listen to this event, or override the SelectionChanged method on PictureDesigner (be sure to call the base class implementation).
Re: new element
Posted: Sat Aug 27, 2011 11:46 am
I forgot to mention, you don't need to know when a new Element is added, to be able to change the name algorithm or show the selected object properties. There is an undo and a redo stack in the Recorder, so an Element may be added or removed as a result of undo and redo, as well as toolbox creation, or programmatically. The NameProvider and Selector should provide all you need to change the naming algorithm, or show selected object properties.