Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Moving label for Diagram Links (Read 1591 times)
klaatutrout
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Oct 26th, 2021
Moving label for Diagram Links
Dec 7th, 2021 at 10:57pm
Print Post  
Is it possible to move the label of a diagram link by itself (e.g., without moving the corresponding link)?

For example, if I have the following setup:

SHAPE ONE >------------------------------Label Text ---------------->SHAPE TWO

Can I move the label text by itself to be the following (without moving any control points on the link):

SHAPE ONE >----------------Label Text ------------------------------>SHAPE TWO
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Moving label for Diagram Links
Reply #1 - Dec 8th, 2021 at 7:15am
Print Post  
If you mean moving link labels interactively, that's not supported out of the box at this time. If you add LinkLabel object to a link instead of setting Text property, you can set label's precise positions by calling SetControlPointPosition, SetSegmentPosition or SetLinkLengthPosition method. With that you could let users change position from the UI or a keyboard event handler, or maybe using a temporary node as position editor.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
klaatutrout
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Oct 26th, 2021
Re: Moving label for Diagram Links
Reply #2 - Dec 10th, 2021 at 9:50pm
Print Post  
Thanks for the ideas; I'll play around with them and let you know if I have further questions.

In the meantime (and on a related note), how would I go about making a link label with multiple lines be center aligned?

For example, if I have the following label defined for a link between two node shapes:

Application Submitted
Subscriptions: 1

What would I need to change to make it be something like the following:

Application Submitted
    Subscriptions: 1

I've played around with the DiagramLink.TextAlignment property (setting it to StringAlignment.Center) as well as the underlying label's HorizontalAlign property (also setting to StringAlignment.Center).  However, nothing I've tried has proved successful.  (I'm able to make the text center-aligned for node shapes, but not for links.)

Here's how I create the Link and define the text:

01 var link = diagram.Factory.CreateDiagramLink(fromNode, toNode);
02 link.AddLabel("First Line of Text" + "\n\n" + "Second Line of Text");
03 link.TextAlignment = StringAlignment.Center;
04 foreach (var label in link.Labels) {
05      label.HorizontalAlign = StringAlignment.Center
06 }

Neither lines 03 or 05 seem to make a difference.

What else is required that I'm missing?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3148
Joined: Oct 19th, 2005
Re: Moving label for Diagram Links
Reply #3 - Dec 13th, 2021 at 11:53am
Print Post  
It seems the alignment only changes position of label around pin point at this time, so not very useful for multi-line labels. Try this as a work-around:

Code
Select All
var originalGetLayoutRect = LinkLabel.prototype.getLayoutRect;
LinkLabel.prototype.getLayoutRect = function ()
{
    this.text.textAlignment = this.horizontalAlign;
    return originalGetLayoutRect.apply(this, []);
}; 



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