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

Display.ShapesSelected event is fired FOUR times when pasting ONE shape

Feb 22, 2013 at 10:44 AM
Edited Feb 22, 2013 at 10:53 AM

The first two times - Display.SelectedShapes.Count = 0.
The second two times - Display.SelectedShapes.Count = 1.

Should be fired ONE time, with Display.SelectedShapes.Count = 1.

[UPDATE] BTW, when shape is added to Diagram from Toolbox (and not pasted), this event is fired TWO times, both with Display.SelectedShapes.Count = 1.
Feb 25, 2013 at 12:28 PM
Edited Feb 25, 2013 at 12:37 PM
First of all:
The ShapesSelected event is more like "Selected shapes changed" than "Shapes added to the selected shapes colection".

Due to this, the event is fired when clearing the selection and when selecting new shapes.
It's also true that the SelectShapes / UnselectShapes methods do not check the contents of Display.SelectedShapes before calling the event. This is because there can be many shapes in the collection - all shapes of a really large diagram in the worst case.

So it's by design that that you receive 2 events:
One for unselecting the shapes and one for selecting the shapes.

I agree that we could check whether the SelectedShapes collection contains any shapes when calling UnselectShapes and suppress the event if there is no shape selected. I added this issue to the ToDo list.
If cannot explain the behavior you watched with the background information provided above, I would like to ask you for a simple demo or a description how to reproduce this issue with the NShapeDesigner:
You can check the events raised with NShape Designer's event monitor (Main Menu: Tools > NShape Event Monitor).
Simply check the Display(s) in the component list on the left of the small window. Every event fired by the display will be logged in the right side of the window.

Ok, I can reproduce it now...
Apr 8, 2013 at 4:13 PM
So, will it be fixed in the next release?
Apr 12, 2013 at 9:16 AM
I've fixed this issue.
The fix will be available with the next release.