public void MoveToBottom(C child) { if (Contains(child)) { var command = new SortingManagerCommand <C, P>( child, SortingManagerCommandType.MoveToBottom); if (!SortCommands.Contains(command)) { SortCommands.Enqueue(command); } } }
public void MoveAbove(C child, C target) { if (child != target && Contains(child) && Contains(target)) { var command = new SortingManagerCommand <C, P>( child, target, SortingManagerCommandType.MoveAbove); if (!SortCommands.Contains(command)) { SortCommands.Enqueue(command); } } }
protected void TrySort(SortingManagerCommand <C, P> command) { switch (command.Type) { case SortingManagerCommandType.MoveToTop: if (Children.Contains(command.Child)) { Children.Remove(command.Child); Children.Add(command.Child); } break; case SortingManagerCommandType.MoveToBottom: if (Children.Contains(command.Child)) { Children.Remove(command.Child); Children.Insert(0, command.Child); } break; case SortingManagerCommandType.MoveAbove: if (Children.Contains(command.Child) && Children.Contains(command.Target)) { Children.Remove(command.Child); var targetIndex = Children.IndexOf(command.Target) + 1; Children.Insert(targetIndex, command.Child); } break; case SortingManagerCommandType.MoveBelow: if (Children.Contains(command.Child) && Children.Contains(command.Target)) { Children.Remove(command.Child); var targetIndex = Children.IndexOf(command.Target); Children.Insert(targetIndex, command.Child); } break; } }