How can I display two labels for one node?
I have a scema with icons of devices. Every device has a label for edit the name. I want to display another data (IP Address) about the device. Maybe above the icon.
_____________
|10.161.51.180| - Top label for IP
_________
| |
------> | Icon | ----->
|________|
_______
|<u>Device 2</u>| - Bottom label for Name
Now I use the base Initialize of GoIconingNode and I override the function
“CreateLabel”:
protected override GoText CreateLabel(String name)
{
GoText l = null;
if (name != null)
{
l = new DeviceNodeLabel();
l.Text = name;
l.Selectable = false;
l.Alignment = MiddleTop;
l.AddObserver(this);
}
if (DeviceType != EDeviceType.Network)
{
l.Editable = true;
Editable = true;
}
return l;
}
(I have also a derived class that inherits “goText” class and “createLabel” uses it:
public class DeviceNodeLabel : GoText
{
public DeviceNodeLabel() { }
// Handle any user edits to ensure uniqueness
public override String ComputeEdit(String oldtext, String newtext)
{
DeviceNode n = this.Parent as DeviceNode;
if (n != null && n.Document != null)
{
return n.MakeUniqueName(newtext);
}
return newtext;
}
public override void DoBeginEdit(GoView view)
{
if ((this.Editor != null))
{
return;
}
base.DoBeginEdit(view);
TextBox ctrl = (TextBox)this.Editor.GetControl(view);
if ((ctrl != null))
{
ctrl.MaxLength = 30;
}
}
}
)