Box Resizing Problem

I have a Box like class. The common children are

1. GoRoundedRectangle object as a background and visible border;

2. GoText object at the top-left conner to display its name;

3. A Port (derived from GoPort) object on the top-left corner also.

I tried to override the LayoutChildren to layout the above children in this method.

The problem I encountered is that Layouting the Port object inside the LayoutChildren blocks the resizing. The behavior is that the left and the top sides can be increased but cannot be decreased. No problem to resize right and bottom sides. If the Port position is set out of the LayoutChildren, it works OK.

LayoutChildren(topLeftLabel);

Port.Position = topLeftLabel.Positon.

What did I miss?

GoDiagram version: Win 2.6.2 for .NET 2.0

Can you post the complete LayoutChildren, with the port code? thanks.

public override void LayoutChildren(GoObject childchanged)
{
if (Initializing)
return;

if (_border != null && _topLeftLabel != null && _port != null)
{
   _border.Bounds = this.Bounds;
   RectangleF rect = _border.Bounds;
   _topLeftLabel.SetSpotLocation(TopLeft, new PointF(rect.X+2, rect.Y+2));
   _port.Position = _topLeftLabel.Position;
}

}

======================

class NodePort : GoPort
{
private bool myKeepsLinksBetweenRemoved;

public const int ChangedMaxLinks = LastChangedHint + 10011;
public const int ChangedKeepsLinksWhenRemoved = LastChangedHint + 10012;

public NodePort() : base()
{
   Selectable = false;
   Movable = false;
   IsValidDuplicateLinks = false;
   Style = GoPortStyle.None;
   FromSpot = NoSpot;
   ToSpot = NoSpot;
   KeepsLinksBetweenRemoved = true;
}

public override void CopyObject(GoCopyDictionary env)
{
   NodePort p = (NodePort)base.CopyObject(env);
   if (p != null)
     p.Brush = null;
   return p;
}

public override void ChangeValue(GoChangedEventArgs e, bool undo)
{
   switch (e.SubHint)
   { 
     case ChangedMaxLinks:
        return;
     case ChangedKeepsLinksWhenRemoved:
        this.KeepsLinksBetweenRemoved = (bool)e.GetValue(undo);
        return;
     default:
        base.ChangeValue(e, undo);
        return;
}

bool KeepsLinksBetweenRemoved
{
   get
   { 
     return myKeepsLinksBetweenRemoved;
   }
   set
   { 
     bool old = myKeepsLinksBetweenRemoved;
     if (old != value)
     {
         myKeepsLinksBetweenRemoved = value;
         Changed(ChangedKeepsLinksWhenRemoved, 0, old, NullRect, 0, value, NullRect);
     }
   }
}

public override PointF GetLinkPointFromPoint(PointF p)
{
   GoRectangle rect = new GoRectangle();
   rect.Size = this.ParentNode.Bounds.Size;
   rect.Location = this.ParentNode.Bounds.Location;

   PointF p1 = new PointF(0,0);
   rect.GetNearestIntersectionPoint(p, this.ParentNode.Center, out p1);

   return p1;
}

protected override void OnLayerChanged(GoLayer oldLayer,
    GoLayer newLayer, GoObject mainObj)
{
   // Perform NOOP rather than call base method
}

}

GoGroup.LayoutChildren reference says this:

Implementations of this method probably should not refer, directly or indirectly, to this group's GoObject.Bounds property. Instead, you should just position and size the children based on the bounds of the children (not this group's bounds), and let this group's bounds be determined by the union of the bounds of the children.
For groups that may have many children, overrides will often check the GoObject.Initializing flag. If true, this method usually does nothing; later when all the changes have been performed is that flag set to false and this method is called explicitly with a null argument.
so, I can't explain why the port is causing the problem, but I'd look first to the use of this.Bounds. Look at how BoxArea.cs in Demo1 works.