Esempio n. 1
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            var index = item.ItemId % byte.MaxValue;

            if (!Equals(PaneManager.Instance.FromNavContext(OutputPane).CurrentView) || index >= Menu.ButtonCount)
            {
                return(false);
            }

            TextBase.CurrentFocus?.Blur(false);

            var paneId = item.ItemId / byte.MaxValue;

            if (paneId == (int)OutputPane)
            {
                if (Build.VERSION.SdkInt > BuildVersionCodes.JellyBean || Menu.ButtonCount == 1)
                {
                    Droid.Menu.OnClick(Menu, index, this);
                }
                else
                {
                    Droid.Menu.Activated(Menu, EventArgs.Empty);
                }
            }
            else  //Submenus
            {
                var subMenuId = paneId - Enum.GetValues(OutputPane.GetType()).Length;
                var subIndex  = 0;
                for (var i = 0; i < Menu.ButtonCount; i++)
                {
                    var sub = Menu.GetButton(i) as UI.IMenu;
                    if (sub == null)
                    {
                        continue;
                    }
                    if (subMenuId == subIndex)
                    {
                        Droid.Menu.OnClick(sub, index, this);
                        break;
                    }
                    subIndex++;
                }
            }
            return(base.OnOptionsItemSelected(item));
        }