Understanding that double-click completes linear shape creation

Feb 13, 2013 at 10:55 AM
In my application, double click on certain types of planar shapes has a "special" meaning - it opens an "editor" of the corresponding shape's model. Handler of the Display.MouseDoubleClick event is responsible for this task.
If I draw a PolyLine shape and perform double-click to complete its creation, and if at this moment the mouse pointer is over such "editable" planar shape - this editor also pops up, because currently I cannot distinguish double-click "I'm completing line creation" from double-click "I want to open editor".

I wonder what is the best way to understand (inside the Display.MouseDoubleClick handler) that double-click completes linear shape creation (and if yes - do not open editor).
Coordinator
Feb 14, 2013 at 8:01 AM
Is there a reason why you do not use the ShapeDoubleClicked event?
In this case, a reference of the double-clicked shape is contained in the event args.
Feb 14, 2013 at 9:33 AM
The reason is described here.
Is it fixed in the latest release?
Coordinator
Feb 14, 2013 at 11:36 AM
Yes, this issue was fixed in NShape 2.0.3.
Feb 15, 2013 at 10:20 AM
Can't say that it is fixed.

I have three overlapping shapes - one "inside" another:
  • the biggest shape - Computer (ZOrder = 0),
  • medium-size shape - Service (is located "inside" the Computer; ZOrder = 20),
  • the smallest shape - Component (is located "inside" the Service; ZOrder = 30).
If I select Component shape and then double-click on it - then e.Shape corresponds to the Service shape :)
And it's clear why: the "first part" of the double-click "rotates" shape selection - from Component to Service, and so when the "second part" completes - then selected shape is Service. As a result, my "Component Editor" is not open.
The only way to get e.Shape equal to Component shape (and so to open my "Component Editor") - is to select Computer shape before performing double-click on the Component Shape: in this case "shape rotation" changes selected shape from Computer to Component :)

I certainly dislike this rotation feature.
And... I still have to use my workaround described here.
Coordinator
Feb 15, 2013 at 11:28 AM
Sorry, I forgot that the "double click event is raised for esch shape"-Problem was not your only problem in this case.
I have added your "Let me disable the selection cycle feature" request to our "Points To Discuss" list.
Feb 18, 2013 at 7:57 AM
Thank You!
Hope it will be implemented in the nearest release :)
Mar 18, 2013 at 3:32 PM
The solution turned out to be very simple - see the 2nd if:
public void OnMouseDoubleClick(object sender, MouseEventArgs e)
{
    if (_display == null)
        return;
    if (_display.SelectedShapes.FirstOrDefault() is ILinearShape)
        return; // this double click completes linear shape creation - nothing to do here
    Point pt = Point.Empty;
    _display.ControlToDiagram(e.Location, out pt);
    Shape shape = _display.Diagram.FindShape<MyShape>(pt);
    if (shape == null)
        return;
    _display.SelectShape(shape);
    if (shape.ModelObject is MyModel)
    {
        this.ShowModelEditor(shape.ModelObject as MyModel);
    }
 }
PS: But I'm still dreaming that in the next release there will be a possibility to disable "selection cycle feature" :))