{
base.PositionMidLabel(lab, a, b);
if (View == null)
return;
PointF alignedCenter = View.FindNearestGridPoint(lab.Center);
lab.SetSpotLocation(Middle, alignedCenter);
}
No GoObject, nor any GoDocument, should have a reference to any GoView.
Is overriding base.PositionMidLabel pointless because it would have aligned to the grid on its own if it had access to it ?
The override is necessary; I was just saying that calling the base method isn’t useful when you’re about to reposition the label anyway. But it doesn’t do any harm.
Well, the idea of the override was to let the base method figure out the approximate position based on the stroke, and then just ‘nudge’ it onto the grid.
I see what you mean, but you can just use the point that is midway between A and B, the argument points. Well, no matter, either method should be OK.
When something is being dropped from a different kind of Control (i.e. not a GoView such as a GoPalette), GoDiagram doesn’t know anything about what you want to create and add to the GoView.Document. That’s why you need to override GoView.DoExternalDrop (and perhaps other methods, such as GoView.GetExternalDragImage) when handling a drop from an unknown kind of Control.
Yes, I am using the GoView.DoExternalDrop and aligning the new GoObject to the grid there works. Thanks!