Hello to all.
[code] [Serializable]
public class Boaz : GoTextNode {
public Boaz() {
this.Label.TextColor = Color.White;
this.Label.Bold = true;
this.TopLeftMargin = new SizeF(22, 30);
this.BottomRightMargin = new SizeF(22, 5);
GoEllipse e = new GoEllipse();
e.Selectable = false;
e.Brush = Brushes.DeepSkyBlue;
e.Pen = null;
Add(e);
TextInfo ti = new TextInfo();
InsertBefore(null, ti);
}
public TextInfo Info {
get { return this[0] as TextInfo; }
}
protected override GoObject CreateBackground() {
GoCylinder c = new GoCylinder();
c.Selectable = false;
c.Orientation = Orientation.Vertical;
c.MinorRadius = 13;
c.Brush = Brushes.CadetBlue;
c.Pen = Pens.LightBlue;
return c;
}
public override void LayoutChildren(GoObject childchanged) {
base.LayoutChildren(childchanged);
GoCylinder c = this.Background as GoCylinder;
GoEllipse e = this[this.Count-1] as GoEllipse;
if (e != null) {
RectangleF b = this.Background.Bounds;
float radius = (c != null ? c.MinorRadius : 13);
e.Bounds = new RectangleF(b.X, b.Y, b.Width, radius*2);
}
TextInfo info = this.Info;
if (info != null) {
info.SetSpotLocation(BottomRight, this.Background, Middle);
}
}
}
[Serializable]
public class TextInfo : GoListGroup {
public TextInfo() {
this.Selectable = false;
this.PickableBackground = true;
this.Brush = Brushes.White;
this.Shadowed = true;
this.Corner = new SizeF(20, 20);
this.TopLeftMargin = new SizeF(10, 10);
this.BottomRightMargin = new SizeF(50, 10);
}
public void AddLine() { AddLine("", null); }
public void AddLine(String first) { AddLine(first, null); }
public void AddLine(String first, String rest) {
GoListGroup lg = new GoListGroup();
lg.Selectable = false;
lg.Orientation = Orientation.Horizontal;
lg.Spacing = 3;
if (first != null) {
GoText a = new GoText();
a.Selectable = false;
a.Bold = true;
a.FontSize = 8;
a.Text = first;
lg.Add(a);
}
if (rest != null) {
GoText b = new GoText();
b.Selectable = false;
b.FontSize = 8;
b.Text = rest;
lg.Add(b);
}
Add(lg);
}
public String Text {
get {
String s = "";
foreach (GoListGroup lg in this) {
if (s != "") s += "\n";
foreach (GoText t in lg) {
s += t.Text + " ";
}
}
return s;
}
}
// this override fixes a bug accounting for shadow; not needed in v3.0 or later
public override RectangleF ExpandPaintBounds(RectangleF rect, GoView view) {
rect = base.ExpandPaintBounds(rect, view);
if (this.Shadowed) {
SizeF offset = GetShadowOffset(view);
if (offset.Width < 0) {
rect.X += offset.Width;
rect.Width -= offset.Width;
} else {
rect.Width += offset.Width;
}
if (offset.Height < 0) {
rect.Y += offset.Height;
rect.Height -= offset.Height;
} else {
rect.Height += offset.Height;
}
}
return rect;
}
}[/code]
Example use:
Boaz bz = new Boaz();
bz.Text = "BOAZ";
TextInfo info = bz.Info;
info.AddLine("BOAZ");
info.AddLine();
info.AddLine("S0/0", "192.168.11.5");
info.AddLine("Fe0/0", "192.168.3.1");
info.AddLine("DTE");
info.AddLine();
bz.Center = new PointF(200, 100);
doc.Add(bz);
Thanks a lot walter