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:
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() {
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;
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; } } }