Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF: how does FlowDirection.RightToLeft change a string?

I have a FormattedText item. I have the flowdirection set to RightToLeft, and I am not sure how it works. It changes my strings really inconsistantly.

I imagined that it would just take a string, and display it backwards (either by characters, or by words), but in testing it does wierd things.

==================================================

examples,

the string "90%", is displayed as "%90"

Why does the % sign go from the end to the start?

the string "12 34 56 this is my (string)" 
is displayed as "(this is my (string 56 34 12"

why do the numbers go to the end, and one bracket goes to the beginning and switched direction?

the string "this is a string"
is displayed as "this is a string"

why does nothing happen in this case??

==================================================

my formattedText looks like this:

FormattedText sectionNum = new FormattedText(
   sectNum,
   CultureInfo.CurrentCulture,
   FlowDirection.RightToLeft,
   new Typeface("Verdana"),
   14,
   Brushes.Black);
context.DrawText(sectionNum, new Point(790 - 96, 20));

Anyone know what is going on? I need to be able to display each string so that it reads the same as LeftToRight, when set to RightToLeft.

Thanks!

like image 866
Toadums Avatar asked Aug 12 '11 20:08

Toadums


1 Answers

TextInfo has own FlowDirection and it overrides WPF FlowDirection.

So if you type in arabic or hebrew it will automatically use "Right to left" direction. But there is a problem if you use signs ";", " "(space). Compilor thinks as it can be in both directions and can it put as "Left to right" in arabic, so here your should use custom Wpf FlowDirection.

In your examples compilor knows about english letters and use "Left to right" direction, but goes crazy with spaces and numbers.

Here is similar question with link to good part in the book.

like image 156
Artur A Avatar answered Oct 20 '22 00:10

Artur A