Selection Handle with GoPolygon

I use a GoBasicNode with particular shape and i don’t know how to a add a bigger handle.

I try to define my shape with the IGoHandle implements, but it doesn’t seem to work with GoPolygon.

I try to override AddSelectionHandles and CreateBoundingHandle, but they are not fired.





This is my node, with properties to change its shape:

Thank to help me.



public myNodes(Direction k, string name, GoDocument doc) : base()

{

this.myKind = k;

this.Text = name;

this.Port.Brush = null;

this.Port.Pen = null;

doc.Add(this);

}



private void left()

{

GoPolygon left = new GoPolygon();

left.AddPoint(0, 0);

left.AddPoint(10, 5);

left.AddPoint(10, -5);

this.Shape = left;

this.Kind = Direction.left;

}



private void right()

{

GoPolygon right = new GoPolygon();

right.AddPoint(0, 5);

right.AddPoint(0, -5);

right.AddPoint(10, 0);

this.Shape = right;

this.Kind = Direction.right;

}



protected override void OnLayerChanged(GoLayer oldlayer, GoLayer newlayer, GoObject mainObject)

{

base.OnLayerChanged(oldlayer, newlayer, mainObject);

// make sure the name is unique, ignoring this node itself

this.Text = MakeUniqueName(this.Text);

kindChange();

}





public void kindChange()

{



if (this.Kind == Direction.left) left();

else if (this.Kind == Direction.right) right();

else if (this.Kind == Direction.up) up();

else if (this.Kind == Direction.down) down();

}





CreateBoundingHandle is useful as an override on the SelectionObject, not the node. In this case, it’s probably your GoPolygon.

Thank you to help me.

I’ve already try something like that, without good result : nothing is draw, but CreateBoundingHandle is fired.

As I can’t transform GoPolygon to GoShape, I try with an array of point, but i dont believe that is the problem.





[Serializable>

public class Left : GoShape

{

public Left() { }



public override IGoHandle CreateBoundingHandle()

{

return base.CreateBoundingHandle();

}



public override GraphicsPath MakePath()

{

GraphicsPath path = new GraphicsPath();//(FillMode.Winding);

PointF[> left =

{

new PointF(0 , 0),

new PointF(10 , 5),

new PointF(10 , -5)

};



path.AddLines(left);

path.CloseAllFigures();

return path;

}

}





I try this code with the same property left() of my node :

private void left()

{

this.Shape = new Left();

//this.Shape.pen = new Pen(Color.Black, 1);

//this.Shape.Bounds = this.Bounds;

this.Kind = Direction.left;

}



But nothing is draw. (I try with a black pen, and with bounds, without more results)

Sorry, it could seem easy, but all my attempts failled.

The points for the handle have to be positioned where the shape is, not 0,0.

In this case, I haven’t create a handle, the thing I talk that is not drawed is the shape of the node itself : my node is not draw.

Your MakePath isn’t defining the shape with respect to the size of the Bounds of the object.

OK, thx you.

Just a last little problem :

I’ve create a handle with RectangleF. But I can move my node by dragging this handle (by clicking inside the handle). The RectangleF seems empty.

Any idea?



And thx for your help.