Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Getting exact vertical point, i.e. y value in x-y axis, of Text in a ShapeNode (Read 1189 times)
Caerlica
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 1
Joined: Nov 21st, 2017
Getting exact vertical point, i.e. y value in x-y axis, of Text in a ShapeNode
Nov 21st, 2017 at 2:50pm
Print Post  
Hi,

We use the MindFusion Diagram component to display among other things, TextNodes, which are ShapeNodes, with bindings applied to TextProperty. We can manipulate the textnode using FontSize, Vertical Alignment, and type in multiple lines of text in the same textnode.

We've built an architecture, to export the Diagram into another format, and need to calculate the exact vertical (Y) coordinate of the text in the TextNode.

I've noticed that it's extremely difficult to try to figure out a equation to calculate the vertical position, when I have to take into account the height of the shapenode, font size, text line count and vertical alignment value.

I'm wondering, if it's anyhow possible to extract the exact Y value of the Text itself, instead of the Y value of the TextNode. This way, I might be able to use the MindFusion component to give a value instead of trying to figure out a nigh-impossible equation to mathematically calculate the Y value given all the possible things.

Can you give any advice for this?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Online


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: Getting exact vertical point, i.e. y value in x-y axis, of Text in a ShapeNode
Reply #1 - Nov 21st, 2017 at 4:12pm
Print Post  
Hi,

We could expose exact positions if you use the EnableStyledText or PolygonalTextLayout - the text is laid out by the diagram control then. Otherwise it's drawn using WPF's DrawingContext.DrawText method and the diagram won't know exact positions either. In both cases it should be possible to find glyph positions using VisualTreeHelper.GetChild, calling it recursively until you find GlyphRun objects.

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