Custom bounding box

We are implementing a debugger that operates over a GoDiagram graph. When we’re at a breakpoint, stepping, etc, the break position will be one of the graph nodes. We want to display the selection box on this object to represent the fact that this is the current break position.
We can’t find anywhere to replace the pen (not the color, the pen object) used to draw selection handles. We recognize that we can change the selection color, but we need to do more than that. GoSelection seems to have no pen property, nor does the view. Neither CreateBoundingHandle nor DrawXorBox take a pen parameter, and we don’t find any examples in the doc or the sample code. How can we accomplish what we want to do?

I see now that when the documentation was referring to CreateBoundingHandle, it was actually referring to two different implementations of that method. After looking at the description of the GoObject version, I have now tried returning from GoSelection.CreateBoundingHandle, an instance of an object derived from GoRectangle and implementing IGoHandle. After setting the desired Pen in this object, and setting IGoHandle properties as well as I could determine what they should be, no bounding box is drawn at all, so apparently I have not gleaned the correct meaning from the documentation. In any case, this really seems much more complicated than one would hope to simply change out a pen.
However, I’m not sure that this approach will work anyway, since, if I experiment by overriding selection.CreateBoundingHandle to simply change the selection color, and then select a node, the new selection color does not take effect on that select, but on the subsequent select. This is certainly confusing.
Should we perhaps bypass the bounding box drawing logic, and draw and erase the rectangle in our own code? Then again, it is not clear how to specify the pen used for DrawXorBox. Would it be more straightforward to use ControlPaint.DrawReversibleFrame instead?

I resolved the problem of the CreateBoundingHandle override not taking effect immediately, so we can in fact change the bounding box color to indicate a debug break condition at selection.Primary. The problem of how to replace the selection pen in its entirety remains.

There’s an example of changing the bounding handle pen in the LinearGradientRoundedRectangle class in the Demo1 sample. The interesting code is in the override of AddSelectionHandles.

I’m hesitant to ask, since this has all the earmarks of dumb question. This assignment to handle.Pen elicits an exception of “invalid parameter”. I can however assign a pen created with a solid brush without error. Is this a GoDiagram constraint, or simply my misunderstanding of Windows arcana.
public override IGoHandle CreateBoundingHandle(GoObject obj, GoObject selectedObj)
{
GoHandle handle = base.CreateBoundingHandle(obj, selectedObj) as GoHandle;
if (handle == null) return null;
if (someCondition)
handle.Pen = new Pen
(new HatchBrush(HatchStyle.DarkUpwardDiagonal, Color.FromArgb(128, 255, 0, 0),
Color.Transparent), 5);
return handle;
}

Well, this is interesting. When I try your code, it works fine for me. But I’m using version 2.2.2. See if that helps you.
However, when I examine the code, I think the problem is that getting the Pen.Color of a pen that uses a HatchBrush causes an exception. I suspect that is what you are seeing. This is an undocumented problem with that property. We’ll need to investigate further.