Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Display text at different places in a shape node (Read 7514 times)
MN
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Jun 12th, 2008
Display text at different places in a shape node
Jun 12th, 2008 at 7:37am
Print Post  
Hi,

I am creating a custom shape node and would like to place texts above the shape node and inside the shape node at the same time. I have looked in the help but haven’t found any way to do this. Is there anyone who could help me? I would also like to place texts above my anchor points, is it possible and how do I do it?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Display text at different places in a shape no
Reply #1 - Jun 12th, 2008 at 9:02am
Print Post  
Hi,

You might set the anchors style to Custom and handle the DrawMark event to draw both the point and its text.

To display an additional label for a node, either use the 'Additional' custom drawing style and handle the DrawNode event, or attach a Transparent node containing the text to the main node by calling AttachTo.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
MN
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 2
Joined: Jun 12th, 2008
Re: Display text at different places in a shape no
Reply #2 - Jun 13th, 2008 at 6:19am
Print Post  
Hi,
Thanks for the help. I have a couple of questions though.
Is there a way to make the anchor points with its text visible always, not only when the mouse pointer is above the node?
I’m having trouble making the AttachToNode to work. I have put the code in the DrawNode method. I create a new ShapeNode that contains the additional text, but when I call its AttachToNode method with my original node as in parameter and run it, a nullreferenceexception is thrown, none of the nodes are null, I have a check before the call.  An example would be helpful.

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Display text at different places in a shape no
Reply #3 - Jun 13th, 2008 at 10:38am
Print Post  
Hi,

Set Diagram.ShowAnchors = Always.

Atatching a label to a node drawn by the user could look like this, with a bit of C# 3 syntax

Code
Select All
private void siteMap_NodeCreated(object sender, NodeEventArgs e)
{
	var nb = e.Node.Bounds;
	var label = new ShapeNode
	{
		Transparent = true,
		Locked = true,
		Text = "label",
		Bounds = new Rect(nb.X + nb.Width / 2 - 30, nb.Bottom + 2, 60, 20),
		Font = new Font("Arial", 10, GraphicsUnit.Point)
	};

	var diag = sender as Diagram;
	if (diag != null)
	{
		label.TextFormat.Alignment = StringAlignment.Center;
		diag.Nodes.Add(label);
		label.AttachTo(e.Node, AttachToNode.BottomCenter);
	}
}
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
SC
YaBB Newbies
*
Offline



Posts: 37
Joined: Jan 18th, 2008
Re: Display text at different places in a shape no
Reply #4 - Jul 22nd, 2008 at 9:22pm
Print Post  
How can we edit the newly created label like above at run time?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Display text at different places in a shape no
Reply #5 - Jul 23rd, 2008 at 8:06am
Print Post  
Hi,

You could call Diagram.BeginEdit(label) after creating the label, or in response to a (double-) click event.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
SC
YaBB Newbies
*
Offline



Posts: 37
Joined: Jan 18th, 2008
Re: Display text at different places in a shape no
Reply #6 - Jul 23rd, 2008 at 4:54pm
Print Post  
I have handled that using mouseleftclick event nad it works fine.
But when I type longer text I want to increase the width of the label but its size is fixed.
Locked proeprty is allowing this but at the same time I do nto want to detach th text from the main label,.
How can I increase the size at runtime.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Display text at different places in a shape no
Reply #7 - Jul 23rd, 2008 at 5:25pm
Print Post  
Set larger label.Bounds or call label.ResizeToFitText().
  
Back to top
 
IP Logged
 
SC
YaBB Newbies
*
Offline



Posts: 37
Joined: Jan 18th, 2008
Re: Display text at different places in a shape no
Reply #8 - Jul 29th, 2008 at 4:34pm
Print Post  
label.ResizeToFitText() is working only when the user clicks on it for the second time untill then the text is not displayed completely.

I am trying to set its width by catching keyup (enter key) or with mosue lose focus but those events are never firing aeven after setting the focus explicitly.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Display text at different places in a shape no
Reply #9 - Jul 30th, 2008 at 7:58am
Print Post  
Are you calling ResizeToFit after the text is edited? Try calling it from the NodeTextEdited event handler.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint