blob: 227f984152b01065b026347e5f463c94822c9cef (
plain)
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
41
|
using Android.Content.Res;
using Android.Views;
using Xamarin.Forms.Internals;
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;
}
}
}
}
|