Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Labeling the Nodes (Read 3869 times)
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Labeling the Nodes
Apr 20th, 2017 at 5:38am
Print Post  
Hi,

I have a requirement to label the nodes that dropping on to canvas, is it possible to do if yes how to do it

Step 1

Step 2
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Labeling the Nodes
Reply #1 - Apr 20th, 2017 at 7:49am
Print Post  
Hi,

Call Diagram.BeginEdit(e.Node) from NodeCreated event handler and it will show a text entry box. If you set AllowInplaceEdit = true, users will be able to edit text by double-clicking.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Labeling the Nodes
Reply #2 - Apr 20th, 2017 at 9:38am
Print Post  
I added following code as you mentioned

Code
Select All
        private void OnNodeCreated(object sender, NodeEventArgs e)
        {
            Diagram.BeginEdit(e.Node);
        } 



then got following error

cannot convert from 'MindFusion.Diagramming.Wpf.DiagramNode' to 'MindFusion.Diagramming.Wpf.InplaceEditable'
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Labeling the Nodes
Reply #3 - Apr 20th, 2017 at 9:49am
Print Post  
The interface is implemented by derived node classes, just type-cast the node instance -

Code
Select All
Diagram.BeginEdit((InplaceEditable)e.Node); 

  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Labeling the Nodes
Reply #4 - Apr 20th, 2017 at 10:51am
Print Post  
so with below code

        private void OnNodeCreated(object sender, NodeEventArgs e)
        {
            Diagram.BeginEdit((InplaceEditable)e.Node);
        }


I'm getting following error

An object reference is required for the non-static field, method, or property 'Diagram.BeginEdit(InplaceEditable)'
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Labeling the Nodes
Reply #5 - Apr 20th, 2017 at 12:19pm
Print Post  
Replace Diagram with the name of your instance.
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Labeling the Nodes
Reply #6 - Apr 20th, 2017 at 6:02pm
Print Post  
thanks its working Smiley
  
Back to top
 
IP Logged
 
kelum
Full Member
***
Offline


I Love MindFusion!

Posts: 100
Joined: Mar 25th, 2017
Re: Labeling the Nodes
Reply #7 - Apr 24th, 2017 at 8:10am
Print Post  
currently once this labels entered its placing left top corner of the node, is it possible to center that label name ?

if yes how can do that?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Labeling the Nodes
Reply #8 - Apr 24th, 2017 at 9:01am
Print Post  
Set the node's TextAlignment and TextVerticalAlignment properties.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint