In "Transportation" I remove the MenuListItem, add a new one at the end and move it up the menu to it's initial position. Here's the code:
public static class ListExtensions
{
public static void Move<T>(this IList<T> list, int iIndexToMove,
MoveDirection direction)
{
if (direction == MoveDirection.Up)
{
var old = list[iIndexToMove - 1];
list[iIndexToMove - 1] = list[iIndexToMove];
list[iIndexToMove] = old;
}
else
{
var old = list[iIndexToMove + 1];
list[iIndexToMove + 1] = list[iIndexToMove];
list[iIndexToMove] = old;
}
}
}
public enum MoveDirection
{
Up,
Down
}
while (MenuItems.IndexOf(_menuListSources) > MenuItems.IndexOf(_menuListLoads) + 1)
{
MenuItems.Move(MenuItems.IndexOf(_menuListSources), MoveDirection.Up);
}
while (MenuItems.IndexOf(_menuListDestinations) > MenuItems.IndexOf(_menuListLoads) + 2)
{
MenuItems.Move(MenuItems.IndexOf(_menuListDestinations), MoveDirection.Up);
}
_menuListLoads is the 1st item on the list and it's position doesn't change. Here's how the menu looks like: