new element

Discuss the use and design of the MicroDesigner custom designer framework, or the creation of custom designers and editors in general.

Moderators: Frank Hileman, Anne Szyjan

Post Reply
laurazoso
Posts: 5
Joined: Mon Aug 22, 2011 2:58 am

new element

Post by laurazoso » Sat Aug 27, 2011 1:13 am

Hello:

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?

Thanks

User avatar
Frank Hileman
Site Admin
Posts: 1400
Joined: Sun Jul 25, 2004 8:16 pm
Location: California
Contact:

Re: new element

Post by Frank Hileman » Sat Aug 27, 2011 11:42 am

Hello Laura,

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).

Regards,

User avatar
Frank Hileman
Site Admin
Posts: 1400
Joined: Sun Jul 25, 2004 8:16 pm
Location: California
Contact:

Re: new element

Post by Frank Hileman » Sat Aug 27, 2011 11:46 am

Hello Laura,

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.

Regards,

Post Reply