maui-linux/Xamarin.Forms.Platform.UAP/AlignmentExtensions.cs

40 строки
1.0 KiB
C#
Исходник Обычный вид История

2016-03-22 23:02:25 +03:00
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))
2016-03-22 23:02:25 +03:00
{
var isLtr = flowDirection.IsLeftToRight();
2016-03-22 23:02:25 +03:00
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;
2016-03-22 23:02:25 +03:00
default:
if (isLtr)
return Windows.UI.Xaml.TextAlignment.Left;
else
return Windows.UI.Xaml.TextAlignment.Right;
2016-03-22 23:02:25 +03:00
}
}
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;
}
}
}
}