Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Flip DrawingLink (Read 4323 times)
Orlov_Valera
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Feb 4th, 2019
Flip DrawingLink
Feb 4th, 2019 at 12:42pm
Print Post  
Hi everyone I need customize DrawingLink - to flip it (turn over). As it on example picture 1.
By default I have next situation (as it is on picture 2)
But I need as it is on picture 3.
  

picture_1.jpg ( 25 KB | 143 Downloads )
picture_1.jpg
picture_2.jpg ( 21 KB | 127 Downloads )
picture_2.jpg
picture_3.jpg ( 21 KB | 125 Downloads )
picture_3.jpg
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3146
Joined: Oct 19th, 2005
Re: Flip DrawingLink
Reply #1 - Feb 4th, 2019 at 5:20pm
Print Post  
Hi,

Are you applying a RenderTransform on the link or diagram? If you only want to move the arrowhead to the other side, set link's BaseShape property and clear HeadShape. If you need to actually reverse the link in the diagram's backing graph, save a copy of link.ControlPoints and reverse the list, then exchange the Origin and Destination references, and assign the reversed points back to ControlPoints.

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


I Love MindFusion!

Posts: 6
Joined: Feb 4th, 2019
Re: Flip DrawingLink
Reply #2 - Feb 5th, 2019 at 10:03am
Print Post  
Thank you for your reply. I have tried your advice.
If I reverse list of the link.ControlPoints then link change it direction.
If I save link.ControlPoints, reverse the list, exchange  the Origin and Destination references, assign the reversed points back to link.ControlPoints  then links is disappear. The reason why text is flipped because whole my form and diagram has FlowDirection = FlowDirection.RightToLeft (arabic version). So in fact I just need to change FlowDirection only for text, not for whole link.
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Flip DrawingLink
Reply #3 - Feb 5th, 2019 at 1:02pm
Print Post  
Hi,

To keep the RightToLeft flow direction of the diagram and just flip link texts, you can try custom drawing the text and applying a scale transform to mirror it. Something like:

Code
Select All
diagram.LinkCreated += (s, e) =>
  {
      e.Link.CustomDraw = CustomDraw.Additional;
      e.Link.TextBrush = null;
      e.Link.Text = "my text";
  };

diagram.DrawLink += (s, e) =>
  {
      e.Graphics.PushTransform(new ScaleTransform(-1.0, 1,
          e.Link.Bounds.Left + e.Link.Bounds.Width / 2,
          e.Link.Bounds.Top + e.Link.Bounds.Height / 2));

      e.Graphics.DrawText(new FormattedText(e.Link.Text, CultureInfo.InvariantCulture,
        FlowDirection.LeftToRight, new Typeface(e.Link.FontFamily.Source), e.Link.FontSize, Brushes.Black), e.Link.Bounds.Location);

      e.Graphics.Pop();
  }; 



Regards,
Lyubo

  
Back to top
 
IP Logged
 
Orlov_Valera
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Feb 4th, 2019
Re: Flip DrawingLink
Reply #4 - Feb 5th, 2019 at 3:39pm
Print Post  
Thank you! That works fine! But LinkCreated event does not fire. Should I switch some property? If there is a way to trigger that text have been added to DiagramLink?
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Flip DrawingLink
Reply #5 - Feb 6th, 2019 at 10:14am
Print Post  
Hi,

Are you creating the links in code? The event is raised only for interactively created links.

You can extract the handler code in a separate method and call it after creating the link and from the LinkCreated event handler. Alternatively, you can set the Diagram.LinkCustomDraw property, so that it affects all links.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Orlov_Valera
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Feb 4th, 2019
Re: Flip DrawingLink
Reply #6 - Feb 6th, 2019 at 11:36am
Print Post  
Hi!
Thank you for your help.
Yes, I'm creating links in the code. Diagram.LinkCustomDraw property works perfect! The event DrawLink fires only when add DiagramLink to the Diagram. In this moment there is an ability to create new text with suitable flow direction. During workflow I add text to the DiagramLink. Is there a way to call Draw method or somehow redraw DiagramLink - to fire DrawLink event - to draw suitable text?
For calling Draw method I need DrawingContext and RenderOptions. Could somebody give an example of calling that method?

Regards,
Valerii.
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Flip DrawingLink
Reply #7 - Feb 6th, 2019 at 2:16pm
Print Post  
Hi,

The LinkDraw event is raised both after setting the link.Text in code and from inplace edit interaction in my test.

To force a repaint, you can try calling the InvalidateVisual method on the link.

Regards,
Lyubo
  
Back to top
 
IP Logged
 
Orlov_Valera
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 6
Joined: Feb 4th, 2019
Re: Flip DrawingLink
Reply #8 - Feb 6th, 2019 at 3:36pm
Print Post  
Thank you!!! That help me a lot!!!!

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