- Welcome, Guest. Please Login or Register
MindFusion  
  We are soon releasing MindFusion.JavaScript pack. Initial version includes chart, diagram, calendar, map, virtual keyboard, gauge and UI components. Here are the beta version and live demo for anyone interested.  
  HomeHelpSearchLoginRegister   
     
     
   
 
Page Index Toggle Pages: 1 Send Topic Print  
Flip DrawingLink
Read 791 times

Orlov_Valera   Offline
YaBB Newbies
*
Posts: 6
I Love MindFusion!


   
     
 
Flip DrawingLink
Feb 4th, 2019 at 12:42pm
 
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 | 45 )
picture_1.jpg
picture_2.jpg (21 KB | 44 )
picture_2.jpg
picture_3.jpg (21 KB | 45 )
picture_3.jpg
 
IP Logged    
 
     

Slavcho   Offline
God Member
*****
Posts: 1718
Gender: male
tech.support


   
     
 
Re: Flip DrawingLink
Reply #1 - Feb 4th, 2019 at 5:20pm
 
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
 
 
 
IP Logged    
 
     

Orlov_Valera   Offline
YaBB Newbies
*
Posts: 6
I Love MindFusion!


   
     
 
Re: Flip DrawingLink
Reply #2 - Feb 5th, 2019 at 10:03am
 
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.
 
 
 
IP Logged    
 
     

Lyubo   Offline
Senior Member
****
Posts: 285
Gender: male
MindFusion team


   
     
 
Re: Flip DrawingLink
Reply #3 - Feb 5th, 2019 at 1:02pm
 
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:
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

 
 
 
IP Logged    
 
     

Orlov_Valera   Offline
YaBB Newbies
*
Posts: 6
I Love MindFusion!


   
     
 
Re: Flip DrawingLink
Reply #4 - Feb 5th, 2019 at 3:39pm
 
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?
 
 
 
IP Logged    
 
     

Lyubo   Offline
Senior Member
****
Posts: 285
Gender: male
MindFusion team


   
     
 
Re: Flip DrawingLink
Reply #5 - Feb 6th, 2019 at 10:14am
 
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
 
 
 
IP Logged    
 
     

Orlov_Valera   Offline
YaBB Newbies
*
Posts: 6
I Love MindFusion!


   
     
 
Re: Flip DrawingLink
Reply #6 - Feb 6th, 2019 at 11:36am
 
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.
 
 
 
IP Logged    
 
     

Lyubo   Offline
Senior Member
****
Posts: 285
Gender: male
MindFusion team


   
     
 
Re: Flip DrawingLink
Reply #7 - Feb 6th, 2019 at 2:16pm
 
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
 
 
 
IP Logged    
 
     

Orlov_Valera   Offline
YaBB Newbies
*
Posts: 6
I Love MindFusion!


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

Regards,
Valerii.
 
 
 
IP Logged    
 
     
Page Index Toggle Pages: 1 Send Topic Print