/// <summary> /// Moves a block around in a block list. /// </summary> /// <param name="operation">Details of the operation performed.</param> public virtual void MoveBlock(IWriteableMoveBlockOperation operation) { int BlockIndex = operation.BlockIndex; int Direction = operation.Direction; Debug.Assert(BlockIndex >= 0 && BlockIndex < BlockStateList.Count); Debug.Assert(BlockIndex + Direction >= 0 && BlockIndex + Direction < BlockStateList.Count); int MoveIndex = BlockIndex; IWriteableBlockState BlockState = BlockStateList[MoveIndex]; MoveInBlockStateList(MoveIndex, Direction); NodeTreeHelperBlockList.MoveBlock(Owner.Node, PropertyName, MoveIndex, Direction); if (Direction > 0) { for (int i = MoveIndex; i < MoveIndex + Direction; i++) { for (int j = 0; j < BlockStateList[i].StateList.Count; j++) { IWriteableBrowsingExistingBlockNodeIndex ChildNodeIndex = BlockStateList[i].StateList[j].ParentIndex as IWriteableBrowsingExistingBlockNodeIndex; Debug.Assert(ChildNodeIndex != null); ChildNodeIndex.MoveBlockDown(); } for (int j = 0; j < BlockState.StateList.Count; j++) { IWriteableBrowsingExistingBlockNodeIndex ChildNodeIndex = BlockState.StateList[j].ParentIndex as IWriteableBrowsingExistingBlockNodeIndex; Debug.Assert(ChildNodeIndex != null); ChildNodeIndex.MoveBlockUp(); } } } else if (Direction < 0) { for (int i = MoveIndex; i > MoveIndex + Direction; i--) { for (int j = 0; j < BlockStateList[i].StateList.Count; j++) { IWriteableBrowsingExistingBlockNodeIndex ChildNodeIndex = BlockStateList[i].StateList[j].ParentIndex as IWriteableBrowsingExistingBlockNodeIndex; Debug.Assert(ChildNodeIndex != null); ChildNodeIndex.MoveBlockUp(); } for (int j = 0; j < BlockState.StateList.Count; j++) { IWriteableBrowsingExistingBlockNodeIndex ChildNodeIndex = BlockState.StateList[j].ParentIndex as IWriteableBrowsingExistingBlockNodeIndex; Debug.Assert(ChildNodeIndex != null); ChildNodeIndex.MoveBlockDown(); } } } operation.Update(BlockState); }
/// <summary> /// Handler called every time a block state is moved in the controller. /// </summary> /// <param name="operation">Details of the operation performed.</param> private protected virtual void OnBlockStateMoved(IWriteableMoveBlockOperation operation) { Debug.Assert(operation != null); Debug.Assert(!operation.IsNested); IWriteableBlockState BlockState = operation.BlockState; Debug.Assert(BlockState != null); Debug.Assert(BlockStateViewTable.ContainsKey(BlockState)); }