forked from xamarin/Xamarin.Forms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlignmentExtensions.cs
40 lines (38 loc) · 1.03 KB
/
AlignmentExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using Windows.UI.Xaml;
namespace Xamarin.Forms.Platform.UWP
{
internal static class AlignmentExtensions
{
internal static Windows.UI.Xaml.TextAlignment ToNativeTextAlignment(this TextAlignment alignment, EffectiveFlowDirection flowDirection = default(EffectiveFlowDirection))
{
var isLtr = flowDirection.IsLeftToRight();
switch (alignment)
{
case TextAlignment.Center:
return Windows.UI.Xaml.TextAlignment.Center;
case TextAlignment.End:
if (isLtr)
return Windows.UI.Xaml.TextAlignment.Right;
else
return Windows.UI.Xaml.TextAlignment.Left;
default:
if (isLtr)
return Windows.UI.Xaml.TextAlignment.Left;
else
return Windows.UI.Xaml.TextAlignment.Right;
}
}
internal static VerticalAlignment ToNativeVerticalAlignment(this TextAlignment alignment)
{
switch (alignment)
{
case TextAlignment.Center:
return VerticalAlignment.Center;
case TextAlignment.End:
return VerticalAlignment.Bottom;
default:
return VerticalAlignment.Top;
}
}
}
}