Graph Node(Go List Group)

Dear,

We have add dynamic GoListGroup in graph node.Graph node appears like below,

when we click up image then hide golistgroup,but graph node appears like
below:

but bounds of graph node cant reduce.

regards

sudhanshu

http://www.nwoods.com/forum/forum_posts.asp?TID=2646

Dear,

We follow your suggestion.but after that undo operation
when performing hide the Go List group, donot hide the Go List group
Graph Node appears like below:

regards

sudhanshu

this works for me… this intended as a sample only, and is not something I would consider “production ready”.

[code]
using System;
using System.Drawing;
using Northwoods.Go;
namespace Demo1 {
// A GoTextNode with a decoration near the top right corner,
// showing an image "behind" the Background shape and some text
// centered on the image.
[Serializable]
public class PTextNode : TriangleTextNode, IGoCollapsible
{
public PTextNode() {
ColListGroup lg = CreateListGroup();
myListGroup = lg;
InsertAfter(this.Background, lg);
AddChildName("listgroup", lg);
GoCollapsibleHandle h = new GoCollapsibleHandle();
h.Position = new PointF(0, 0);
Add(h);
AddChildName("handle", h);
// initialize this node...
this.Text = "PTextNode";
}
// this field keeps track of this group's decoration
private ColListGroup myListGroup = null;
// update the field to refer to the copied decoration if the node is copied
protected override void CopyChildren(GoGroup newgroup, GoCopyDictionary env) {
base.CopyChildren(newgroup, env);
PTextNode node = (PTextNode)newgroup;
node.myListGroup = (ColListGroup)env[myListGroup];
}
public ColListGroup ListGroup
{
get { return myListGroup; }
}
public SizeF ListGroupSize
{
get
{
SizeF size = new SizeF(0, 0);
ColListGroup lg = ListGroup;
if (lg != null)
{
size = lg.Size;
}
return size;
}
}
public virtual ColListGroup CreateListGroup ()
{
// second list-group is Item[1]
ColListGroup lg = new ColListGroup();
lg.Selectable = false;
lg.BorderPen = Pens.Black;
lg.BrushColor = Color.White;
GoText t2a = new GoText();
t2a.Selectable = false;
t2a.Text = "item one";
t2a.Bold = true;
t2a.TransparentBackground = true;
lg.Add(t2a);
GoText t2b = new GoText();
t2b.Text = "item two";
t2b.TransparentBackground = false;
t2b.DragsNode = true;
lg.Add(t2b);
GoText t2c = new GoText();
t2c.Text = "item three";
t2c.TransparentBackground = false;
t2c.DragsNode = true;
lg.Add(t2c);
return lg;
}
// position the BottomRight of the decoration's Label to be just
// above this node's Background, aligned with the right edge of this node's Label
public override void LayoutChildren(GoObject childchanged) {
if (Initializing) return;
ColListGroup lg = this.ListGroup;
SizeF sizelg = ListGroupSize;
BottomRightMargin = new SizeF(10 + Math.Abs(sizelg.Width - this.Label.Width), 17 + sizelg.Height);
base.LayoutChildren(childchanged);
if (lg != null && this.Background != null && this.Label != null)
{
PointF pt = new PointF(this.Label.Left, this.Label.Bottom + 10);
lg.SetSpotLocation(TopLeft, pt);
GoObject h = FindChild("handle");
if (h != null) h.SetSpotLocation(BottomRight, lg, TopRight);
}
}

// implement IGoCollapsible:
public bool Collapsible
{
get { return true; }
set { }
}
public void Collapse()
{
ListGroup.Collapse();
LayoutChildren(ListGroup);
}
public void Expand()
{
ListGroup.Expand();
LayoutChildren(ListGroup);
}
public bool IsExpanded
{
get { return ListGroup.IsExpanded; }
}
}
// subclass to allow me to set protected InvalidBounds
public class ColListGroup : GoListGroup, IGoCollapsible
{
public bool Collapsible
{
get { return true; }
set { }
}
public void Collapse()
{
foreach (GoObject o in this)
{
o.Visible = false;
}
this.InvalidBounds = true;
}
public void Expand()
{
foreach (GoObject o in this)
{
o.Visible = true;
}
this.InvalidBounds = true;
}
public bool IsExpanded
{
// yeah, it has to have one item
get { return this[0].Visible; }
}
}
}
[/code]