private protected virtual void UndoMove(IWriteableOperation operation) { WriteableMoveNodeOperation MoveNodeOperation = (WriteableMoveNodeOperation)operation; MoveNodeOperation = MoveNodeOperation.ToInverseMove(); ExecuteMove(MoveNodeOperation); }
private protected virtual void ExecuteMove(WriteableMoveNodeOperation operation) { Node ParentNode = operation.ParentNode; string PropertyName = operation.PropertyName; IWriteableCollectionInner <IWriteableBrowsingCollectionNodeIndex> Inner = GetInner(ParentNode, PropertyName) as IWriteableCollectionInner <IWriteableBrowsingCollectionNodeIndex>; Inner.Move(operation); NotifyStateMoved(operation); }
/// <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(WriteableMoveNodeOperation operation) { 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(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> /// Moves a node around in a list or block list. In a block list, the node stays in same block. /// </summary> /// <param name="inner">The inner for the list or block list in which the node is moved.</param> /// <param name="nodeIndex">Index for the moved node.</param> /// <param name="direction">The change in position, relative to the current position.</param> public virtual void Move(IWriteableCollectionInner inner, IWriteableBrowsingCollectionNodeIndex nodeIndex, int direction) { Contract.RequireNotNull(inner, out IWriteableCollectionInner Inner); Contract.RequireNotNull(nodeIndex, out IWriteableBrowsingCollectionNodeIndex NodeIndex); IWriteableNodeState State = (IWriteableNodeState)StateTable[NodeIndex]; Debug.Assert(State != null); IndexToPositionAndNode(NodeIndex, out int BlockIndex, out int Index, out _, out Node Node); Action <IWriteableOperation> HandlerRedo = (IWriteableOperation operation) => RedoMove(operation); Action <IWriteableOperation> HandlerUndo = (IWriteableOperation operation) => UndoMove(operation); WriteableMoveNodeOperation Operation = CreateMoveNodeOperation(Inner.Owner.Node, Inner.PropertyName, BlockIndex, Index, direction, HandlerRedo, HandlerUndo, isNested: false); Operation.Redo(); SetLastOperation(Operation); CheckInvariant(); }
/// <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 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); Node ParentNode = Owner.Node; MoveInStateList(MoveIndex, Direction); NodeTreeHelperList.MoveNode(ParentNode, PropertyName, MoveIndex, Direction); operation.Update((IWriteablePlaceholderNodeState)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(); } } }
private protected virtual void RedoMove(IWriteableOperation operation) { WriteableMoveNodeOperation MoveNodeOperation = (WriteableMoveNodeOperation)operation; ExecuteMove(MoveNodeOperation); }
/// <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(WriteableMoveNodeOperation operation);
private protected virtual void NotifyStateMoved(WriteableMoveNodeOperation operation) { StateMovedHandler?.Invoke(operation); }