Add Objects inside GoBoxNode

Hi Support!!I did a class ( GoBoxNode ) and I would like to insert a GoGrid and a GoText inside it , but I don´t know what is wrong. Can you help me? Is LayoutChildren() wrong ?Thanks![Serializable]public class MyDisplay : GoBoxNode{ //Variables private int CellGridSize = 1; public MyDisplay() { this.LinkPointsSpread = true; this.PortBorderMargin = new SizeF(1, 1); this.Port.BrushColor = Color.White; this.Port.PenColor = Color.Black; GoGroup boxgroup = new GoGroup(); boxgroup.Selectable = true; boxgroup.Add(CreateLabel()); boxgroup.Add(CreateGrid()); this.Body = boxgroup; this.Label.Text = “Display 1”; } //Create Grid protected virtual GoGrid CreateGrid() { GoGrid grid = new GoGrid(); grid.Selectable = false; grid.AutoRescales = true; grid.Resizable = true; grid.ResizesRealtime = true; grid.Bounds = new RectangleF(0, 0, 150, 100); grid.SnapDrag = GoViewSnapStyle.Jump; grid.SnapResize = GoViewSnapStyle.Jump; grid.CellSize = new SizeF(CellGridSize, CellGridSize); grid.Style = GoViewGridStyle.None; grid.Pen = new Pen(Color.Black, 2); grid.BrushColor = Color.White; return grid; } //Create label protected virtual GoText CreateLabel() { //Label Left Side RotatedText label = new RotatedText(); label.Selectable = false; label.Multiline = true; label.Editable = true; label.FontSize = 11; label.TransparentBackground = false; label.BackgroundColor = Color.White; label.Bordered = true; // settings for rotation. label.AutoResizes = false; label.Alignment = Middle; label.Bold = false; label.Angle = 270; return label; } //Get Label public override GoText Label { get { MyDisplay mPool = (MyDisplay)this; if (mPool.Count > 1) { if (mPool[1] is GoGroup) { GoGroup mList = (GoGroup)mPool[1]; if (mList.Count > 1) { if (mList[0] is RotatedText) { RotatedText mPoolGrid = (RotatedText)mList[0]; return mPoolGrid as GoText; } else { return null; } } else { return null; } } else { return null; } } else { return null; } } } //Get Grid public virtual GoGrid Grid { get { MyDisplay mPool = (MyDisplay)this; if (mPool.Count > 1) { if (mPool[1] is GoGroup) { GoGroup mList = (GoGroup)mPool[1]; if (mList.Count > 1) { if (mList[1] is GoGrid) { GoGrid mPoolGrid = (GoGrid)mList[1]; return mPoolGrid as GoGrid; } else { return null; } } else { return null; } } else { return null; } } else { return null; } } } //Object layout changed public override void LayoutChildren(GoObject childchanged) { if (this.Count >= 2) { if (this[1] is GoGroup) { GoGroup mList = (GoGroup)this[1]; if (mList.Count > 1) { GoGrid grid = this.Grid; GoText label = this.Label; if (grid != null && label != null) { label.Width = grid.Height; PointF center = grid.GetSpotLocation(MiddleLeft) - new SizeF(label.Height / 2 + 1, 0); label.Center = center; } } } base.LayoutChildren(childchanged); } }}

I’ll check it out…

Try this. Lots of changes.



Biggest issue was that you can’t use a RotatedText directly in a GoGroup. You have to use a RotatedTextHolder.



<br /> <br /> [Serializable] <br /> public class MyDisplay99 : GoBoxNode { <br /> //Variables <br /> private int CellGridSize = 1; <br /> <br /> public MyDisplay99() { <br /> this.LinkPointsSpread = true; <br /> this.PortBorderMargin = new SizeF(1, 1); <br /> this.Port.BrushColor = Color.White; <br /> this.Port.PenColor = Color.Black; <br /> this.Resizable = true; <br /> } <br /> <br /> protected override GoObject CreateBody() { <br /> GoGroup boxgroup = new GoGroup(); <br /> boxgroup.Selectable = false; <br /> boxgroup.Add(CreateLabel()); <br /> boxgroup.Add(CreateGrid()); <br /> return boxgroup; <br /> } <br /> <br /> //Create Grid <br /> protected virtual GoGrid CreateGrid() { <br /> GoGrid grid = new GoGrid(); <br /> grid.Selectable = false; <br /> grid.AutoRescales = true; <br /> grid.Resizable = true; <br /> grid.ResizesRealtime = true; <br /> grid.Bounds = new RectangleF(0, 0, 150, 100); <br /> grid.SnapDrag = GoViewSnapStyle.Jump; <br /> grid.SnapResize = GoViewSnapStyle.Jump; <br /> grid.CellSize = new SizeF(CellGridSize, CellGridSize); <br /> grid.Style = GoViewGridStyle.None; <br /> grid.Pen = new Pen(Color.Black, 2); <br /> grid.BrushColor = Color.White; <br /> return grid; <br /> } <br /> <br /> //Create label <br /> protected virtual RotatedTextHolder CreateLabel() { <br /> <br /> <br /> RotatedTextHolder holder = new RotatedTextHolder(); <br /> <br /> //Label Left Side <br /> RotatedText label = holder[0] as RotatedText; <br /> label.Multiline = true; <br /> label.Editable = true; <br /> label.FontSize = 11; <br /> label.TransparentBackground = false; <br /> label.Bordered = true; <br /> label.AutoResizes = false; <br /> label.StringTrimming = StringTrimming.EllipsisCharacter; <br /> label.Alignment = Middle; <br /> label.Text = "label here"; <br /> <br /> label.Angle = 270; <br /> <br /> return holder; <br /> } <br /> <br /> //Get Label <br /> public override GoText Label { <br /> get { <br /> RotatedTextHolder holder = this.TextHolder as RotatedTextHolder; <br /> if (holder == null) return null; <br /> foreach (GoObject o in holder) { <br /> if (o is RotatedText) return o as GoText; <br /> } <br /> return null; <br /> } <br /> } <br /> <br /> //Get Label Holder <br /> public virtual RotatedTextHolder TextHolder { <br /> get { <br /> GoGroup body = this.Body as GoGroup; <br /> if (body == null) return null; <br /> foreach (GoObject o in body) { <br /> if (o is RotatedTextHolder) return o as RotatedTextHolder; <br /> } <br /> return null; <br /> } <br /> } <br /> <br /> //Get Grid <br /> public virtual GoGrid Grid { <br /> get { <br /> GoGroup body = this.Body as GoGroup; <br /> if (body == null) return null; <br /> foreach (GoObject o in body) { <br /> if (o is GoGrid) return o as GoGrid; <br /> } <br /> return null; <br /> } <br /> } <br /> <br /> //Object layout changed <br /> public override void LayoutChildren(GoObject childchanged) { <br /> <br /> if (this.Count >= 2 && !Initializing) { <br /> GoGrid grid = this.Grid; <br /> GoText label = this.Label; <br /> <br /> if (grid != null && label != null) { <br /> label.Width = grid.Height; <br /> PointF center = grid.GetSpotLocation(MiddleLeft) - new SizeF(label.Height / 2 + 1, 0); <br /> label.Center = center; <br /> } <br /> } <br /> base.LayoutChildren(childchanged); <br /> } <br /> } <br />

Perfect!!!

<span id=“result_” ="" lang=“en”><span title=“Clique para mostrar traduções alternativas” =“hps”>Is there <span title=“Clique para mostrar traduções alternativas” =“hps”>a <span title=“Clique para mostrar traduções alternativas” =“hps”>way to <span title=“Clique para mostrar traduções alternativas” =“hps”>remove <span title=“Clique para mostrar traduções alternativas” =“hps”>the <span title=“Clique para mostrar traduções alternativas” =“hps”>gray line <span title=“Clique para mostrar traduções alternativas” =“hps”>that surrounds <span title=“Clique para mostrar traduções alternativas” =“hps”>the <span title=“Clique para mostrar traduções alternativas” =“hps”>object?

Thank you very much!!

That’s probably the port. Set the Port Brush and Pen to red to check. If that’s it, then you can set the Brush and Pen to null.

Hi !

1 ) Why when user is changing the width of this objectchanges the position X too, together??

  1. I created 2 objects and link its.
    After I saved xml file,… and ok! But When user loaded xml file, the link was not load.

<mydisplay id="1" label="WWW" port="3" bounds="353.60025 101 150 100" /> </testdiagram>
        t = new GoXmlBindingTransformer("mydisplay", new MyDisplay99());
        t.HandlesChildren = true;                 
        t.IdAttributeUsedForSharedObjects = true;  
        t.AddBinding("label", "Text");
        t.AddBinding("port", "Port");
        t.AddBinding("bounds", "Grid.Bounds");
        rw.AddTransformer(t);

t = new GoXmlBindingTransformer(“link”, new GraphLink());
t.AddBinding(“from”, “FromPort”);
t.AddBinding(“to”, “ToPort”);
t.AddBinding(“label”, “Text”);
t.AddBinding(“pen”, “Pen.DashStyle”);
t.AddBinding(“toarrow”, “ToArrow”);
t.AddBinding(“fromarrow”, “FromArrow”);
t.AddBinding(“fromarrowstyle”, “FromArrowStyle”);
t.AddBinding(“fromarrowfilled”, “FromArrowFilled”);
t.AddBinding(“fromarrowlength”, “FromArrowLength”);
t.AddBinding(“fromarrowwidth”, “FromArrowWidth”);
t.AddBinding(“fromarrowshaftlength”, “FromArrowShaftLength”);
rw.AddTransformer(t);

Thanks!