示例#1
0
 private void RunNavigation()
 {
     if (mSelectPrevious.Active)
     {
         int currentItemIndex = mMenuItems.IndexOf(SelectedItem);
         int nextItemIndex = ((currentItemIndex - 1) % mMenuItems.Count() + mMenuItems.Count()) % mMenuItems.Count();
         while (currentItemIndex != nextItemIndex && !(mMenuItems[nextItemIndex] is SelectableItem))
         {
             nextItemIndex = ((nextItemIndex - 1) % mMenuItems.Count() + mMenuItems.Count()) % mMenuItems.Count();
         }
         if (mMenuItems[nextItemIndex] is SelectableItem)
         {
             SelectedItem = (mMenuItems[nextItemIndex] as SelectableItem);
         }
     }
     if (mSelectNext.Active)
     {
         int currentItemIndex = mMenuItems.IndexOf(SelectedItem);
         int nextItemIndex = (currentItemIndex + 1) % mMenuItems.Count();
         while (currentItemIndex != nextItemIndex && !(mMenuItems[nextItemIndex] is SelectableItem))
         {
             nextItemIndex = (nextItemIndex + 1) % mMenuItems.Count();
         }
         if (mMenuItems[nextItemIndex] is SelectableItem)
         {
             SelectedItem = (mMenuItems[nextItemIndex] as SelectableItem);
         }
     }
 }
示例#2
0
        private void CommitChanges()
        {
            foreach (IMenuItem item in mUncommittedMenuItemAdditions)
            {
                if (SelectedItem == null && item is SelectableItem)
                {
                    SelectedItem = item as SelectableItem;
                }
                item.Menu = this;
                mMenuItems.Add(item);
            }

            foreach (IMenuItem item in mUncommittedMenuItemRemovals)
            {
                // TODO: Handle resetting the selection upon removal.
                item.Menu = null;
                mMenuItems.Remove(item);
            }

            mUncommittedMenuItemAdditions.Clear();
            mUncommittedMenuItemRemovals.Clear();
        }