AGENT.Contrib.UI.Menu.buttonHelper_OnButtonPress C# (CSharp) Method

buttonHelper_OnButtonPress() private method

private buttonHelper_OnButtonPress ( Buttons button, InterruptPort port, ButtonDirection direction, System.DateTime time ) : void
button Buttons
port Microsoft.SPOT.Hardware.InterruptPort
direction ButtonDirection
time System.DateTime
return void
        void buttonHelper_OnButtonPress(Buttons button, InterruptPort port, ButtonDirection direction, DateTime time)
        {
            if (direction == ButtonDirection.Up)
            {
                if (button == Buttons.TopRight) SelectedIndex--;
                if (button == Buttons.BottomRight) SelectedIndex++;
                if (SelectedIndex < 0) SelectedIndex = 0;
                if (SelectedIndex >= Items.Count) SelectedIndex = Items.Count-1;

                if (button == Buttons.MiddleRight)
                {
                    MenuItem item = (Items[SelectedIndex] as MenuItem);
                    if (OnMenuItemClicked != null) OnMenuItemClicked(this, item, time);
                }
                else
                {
                    if(AutoRenderOnButtonPress) Render();
                }
            }
        }