maui-linux/Xamarin.Forms.Platform.Android/Extensions.cs

41 строка
964 B
C#
Исходник Обычный вид История

2016-03-22 23:02:25 +03:00
using Android.Content.Res;
using Android.Views;
using Xamarin.Forms.Internals;
2016-03-22 23:02:25 +03:00
namespace Xamarin.Forms.Platform.Android
{
public static class Extensions
{
internal static IMenuItem FindMenuItemByNameOrIcon(this IMenu menu, string menuName, string iconName)
{
if (menu.Size() == 1)
return menu.GetItem(0);
for (var i = 0; i < menu.Size(); i++)
{
IMenuItem menuItem = menu.GetItem(i);
if (menuItem.TitleFormatted != null && menuName == menuItem.TitleFormatted.ToString())
return menuItem;
if (!string.IsNullOrEmpty(iconName))
{
// TODO : search by iconName
}
}
return null;
}
internal static DeviceOrientation ToDeviceOrientation(this Orientation orientation)
{
switch (orientation)
{
case Orientation.Landscape:
return DeviceOrientation.Landscape;
case Orientation.Portrait:
return DeviceOrientation.Portrait;
default:
return DeviceOrientation.Other;
}
}
}
}