/// <summary> /// Handler called every time a state is moved in the controller. /// </summary> /// <param name="operation">Details of the operation performed.</param> private protected virtual void OnStateMoved(IWriteableMoveNodeOperation operation) { Debug.Assert(operation != null); Debug.Assert(!operation.IsNested); IWriteablePlaceholderNodeState State = operation.State; Debug.Assert(State != null); Debug.Assert(StateViewTable.ContainsKey(State)); }
/// <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(IWriteableMoveNodeOperation operation) { Debug.Assert(operation != null); int BlockIndex = operation.BlockIndex; Debug.Assert(BlockIndex >= 0 && BlockIndex < BlockStateList.Count); IWriteableBlockState BlockState = BlockStateList[BlockIndex]; IWriteablePlaceholderNodeStateReadOnlyList 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(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> /// 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(IWriteableMoveNodeOperation operation) { Debug.Assert(operation != null); int MoveIndex = operation.Index; int Direction = operation.Direction; Debug.Assert(MoveIndex >= 0 && MoveIndex < StateList.Count); Debug.Assert(MoveIndex + operation.Direction >= 0 && MoveIndex + operation.Direction < StateList.Count); IWriteableBrowsingListNodeIndex MovedNodeIndex = StateList[MoveIndex].ParentIndex as IWriteableBrowsingListNodeIndex; Debug.Assert(MovedNodeIndex != null); INode ParentNode = Owner.Node; MoveInStateList(MoveIndex, Direction); NodeTreeHelperList.MoveNode(ParentNode, PropertyName, MoveIndex, Direction); operation.Update(StateList[MoveIndex + Direction]); if (Direction > 0) { for (int i = MoveIndex; i < MoveIndex + Direction; i++) { IWriteableBrowsingListNodeIndex ChildNodeIndex = StateList[i].ParentIndex as IWriteableBrowsingListNodeIndex; Debug.Assert(ChildNodeIndex != null); ChildNodeIndex.MoveDown(); MovedNodeIndex.MoveUp(); } } else if (Direction < 0) { for (int i = MoveIndex; i > MoveIndex + Direction; i--) { IWriteableBrowsingListNodeIndex ChildNodeIndex = StateList[i].ParentIndex as IWriteableBrowsingListNodeIndex; Debug.Assert(ChildNodeIndex != null); ChildNodeIndex.MoveUp(); MovedNodeIndex.MoveDown(); } } }
/// <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 abstract void Move(IWriteableMoveNodeOperation operation);