/// <summary>
        /// Moves a node around in a list or block list. In a block list, the node stays in same block.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        public virtual void Move(WriteableMoveNodeOperation operation)
        {
            int BlockIndex = operation.BlockIndex;

            Debug.Assert(BlockIndex >= 0 && BlockIndex < BlockStateList.Count);

            IWriteableBlockState BlockState = (IWriteableBlockState)BlockStateList[BlockIndex];
            WriteablePlaceholderNodeStateReadOnlyList StateList = BlockState.StateList;

            int MoveIndex = operation.Index;
            int Direction = operation.Direction;

            Debug.Assert(MoveIndex >= 0 && MoveIndex < StateList.Count);
            Debug.Assert(MoveIndex + Direction >= 0 && MoveIndex + Direction < StateList.Count);

            IWriteableBrowsingExistingBlockNodeIndex ExistingBlockNodeIndex = StateList[MoveIndex].ParentIndex as IWriteableBrowsingExistingBlockNodeIndex;

            Debug.Assert(ExistingBlockNodeIndex != null);

            BlockState.Move(ExistingBlockNodeIndex, MoveIndex, Direction);

            IBlock ChildBlock = BlockState.ChildBlock;

            NodeTreeHelperBlockList.MoveNode(ChildBlock, MoveIndex, Direction);

            operation.Update((IWriteablePlaceholderNodeState)StateList[MoveIndex + Direction]);

            if (Direction > 0)
            {
                for (int i = MoveIndex; i < MoveIndex + Direction; i++)
                {
                    IWriteableBrowsingExistingBlockNodeIndex ChildNodeIndex = StateList[i].ParentIndex as IWriteableBrowsingExistingBlockNodeIndex;
                    Debug.Assert(ChildNodeIndex != null);

                    ChildNodeIndex.MoveDown();
                    ExistingBlockNodeIndex.MoveUp();
                }
            }
            else if (Direction < 0)
            {
                for (int i = MoveIndex; i > MoveIndex + Direction; i--)
                {
                    IWriteableBrowsingExistingBlockNodeIndex ChildNodeIndex = StateList[i].ParentIndex as IWriteableBrowsingExistingBlockNodeIndex;
                    Debug.Assert(ChildNodeIndex != null);

                    ChildNodeIndex.MoveUp();
                    ExistingBlockNodeIndex.MoveDown();
                }
            }
        }
        /// <summary>
        /// Checks whether a node can be moved in a block list.
        /// </summary>
        /// <param name="nodeIndex">Index of the node that would be moved.</param>
        /// <param name="direction">Direction of the move, relative to the current position of the item.</param>
        public virtual bool IsMoveable(IWriteableBrowsingCollectionNodeIndex nodeIndex, int direction)
        {
            bool IsHandled = false;
            bool Result    = false;

            if (nodeIndex is IWriteableBrowsingExistingBlockNodeIndex AsExistingBlockNodeIndex)
            {
                Debug.Assert(AsExistingBlockNodeIndex != null);

                int BlockIndex = AsExistingBlockNodeIndex.BlockIndex;
                Debug.Assert(BlockIndex >= 0 && BlockIndex < BlockStateList.Count);

                IWriteableBlockState BlockState = (IWriteableBlockState)BlockStateList[BlockIndex];
                WriteablePlaceholderNodeStateReadOnlyList StateList = BlockState.StateList;

                int NewPosition = AsExistingBlockNodeIndex.Index + direction;
                Result = NewPosition >= 0 && NewPosition < StateList.Count;

                IsHandled = true;
            }

            Debug.Assert(IsHandled);
            return(Result);
        }