public void AddItem(string text)
 {
     // set position by item order
     Vector2 p = new Vector2(position.X, position.Y + items.Count * height);
     MenuItem item = new MenuItem(text, p);
     items.Add(item);
     // select first item
     if (selectedItem == null)
         selectedItem = item;
 }
 public MenuItemComponent(Game game, Vector2 position, Color unselectedColor, Color selectedColor, int height)
     : base(game)
 {
     this.position = position;
     this.game = game;
     this.unselectedColor = unselectedColor;
     this.selectedColor = selectedColor;
     this.height = height;
     items = new List<MenuItem>();
     selectedItem = null;
 }
 private void SelectPrevItem()
 {
     int index = items.IndexOf(selectedItem);
     if (index > 0)
         selectedItem = items[index - 1];
     else
         selectedItem = items[items.Count - 1];
 }
 private void SelectNextItem()
 {
     int index = items.IndexOf(selectedItem);
     if (index < items.Count - 1)
         selectedItem = items[index + 1];
     else
         selectedItem = items[0];
 }