RecordNode LayoutChildren question

Hello,

I’m having an issue with a node in my application based largely on the RecordNode example provided. I can recreate the problem by modifying the example and adding the following two lines to the RecordNode constructor:

ListGroup.TopLeftMargin = new SizeF(0, 0);
ListGroup.BottomRightMargin = new SizeF(0, 0);

If I then:

  1. Run the Demo1 example
  2. Create a new document
  3. Drag 2 RecordNodes into the document
  4. Create a link between two RecordItem objects
  5. Position the two RecordNodes side by side with 200 pixels between them
  6. Resize the left RecordNode by dragging the right side
then the logic to calculate the Angle and LinkPoints for the SidewaysPort generate different results than expected and the link draws incorrectly.

It appears that the bounds for the RecordItem objects get calculated incorrectly when the left RecordNode is resized, but get calculated properly if either RecordNode is moved.

Is this the expected behaviour with a margins of (0, 0)? What can I do to recreate the behavior when the margins are the default of (2, 2)?

Cheers,

Brian

I forgot to mention I’m using GoDiagram 3.0.3.2 with Visual Studio 2008.

Cheers,

Brian

Could you please fill in the email address in your profile?

thanks.

There does seem to be a glitch here when margins are zero. The link starts at the port and routes inward, not away from the node. (when the link is like this, select the link and the selection handles will show you what has happened.)

I can’t reproduce the issue with margins at 2.

I need to use margins of 0 in order to get my node to draw correctly. Can you provide an estimate of how long it will take to fix this? I just need to get back to my client.

Thanks,

What happens when the margins are 0.1f ?

This is the result when the margins are 0.1f and/or 0.01f.

Cheers,

Brian

I’ll look at the issue today.

OK, here’s the fix. This is just a bug in the example. Replace RecordNode.LayoutChildren with:


    // make sure each item's port occupies the same bounds as the item
    public override void LayoutChildren(GoObject childchanged) {
      if (this.Initializing) return;
      GoListGroup lg = this.ListGroup;
      float left = lg.Left + lg.TopLeftMargin.Width;
      float width = lg.Width - lg.TopLeftMargin.Width - lg.BottomRightMargin.Width;
      for (int i = 1; i < this.ItemCount; i++) {
        GoObject item = GetItem(i);
        GoObject rightp = GetRightPort(i);  // just one port per item, the "Right" one
        if (item != null && rightp != null) {
          RectangleF rect = new RectangleF(left, item.Bounds.Top, width, item.Bounds.Height);
          rightp.Bounds = rect;
        }
      }
    }

As a further improvement, you may want to use BoxNodePort instead of SidewaysPort:


   public override GoObject CreatePort(bool left, int idx) {
      if (left) return null;
      if (idx == 0) return null;
      GoBoxPort p = new GoBoxPort();
      p.Style = GoPortStyle.None;
      p.AutoRescales = false;
      p.FromSides = MiddleLeft | MiddleRight;
      p.ToSides = MiddleLeft | MiddleRight;
      return p;
    }

if you like that better, you can delete SidewaysPort from the RecordNode file.

Thanks Jake, that works.