Exemple #1
0
        /// <summary>
        /// Inserts a new node in a list.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        public virtual void Insert(IWriteableInsertNodeOperation operation)
        {
            Debug.Assert(operation != null);

            int InsertionIndex = operation.Index;

            Debug.Assert(InsertionIndex >= 0 && InsertionIndex <= StateList.Count);

            INode ParentNode = Owner.Node;
            INode Node       = operation.Node;

            NodeTreeHelperList.InsertIntoList(ParentNode, PropertyName, InsertionIndex, Node);

            IWriteableBrowsingListNodeIndex BrowsingIndex = CreateBrowsingNodeIndex(Node, InsertionIndex);
            IWriteablePlaceholderNodeState  ChildState    = (IWriteablePlaceholderNodeState)CreateNodeState(BrowsingIndex);

            InsertInStateList(InsertionIndex, ChildState);

            operation.Update(BrowsingIndex, ChildState);

            while (++InsertionIndex < StateList.Count)
            {
                IWriteablePlaceholderNodeState State = StateList[InsertionIndex];

                IWriteableBrowsingListNodeIndex NodeIndex = State.ParentIndex as IWriteableBrowsingListNodeIndex;
                Debug.Assert(NodeIndex != null);
                Debug.Assert(NodeIndex.Index == InsertionIndex - 1);

                NodeIndex.MoveUp();
            }
        }
        /// <summary>
        /// Handler called every time a state is inserted in the controller.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        private protected virtual void OnStateInserted(IWriteableInsertNodeOperation operation)
        {
            Debug.Assert(operation != null);

            IWriteableNodeState ChildState = operation.ChildState;

            Debug.Assert(ChildState != null);
            Debug.Assert(StateViewTable.ContainsKey(ChildState));

            IWriteableBrowsingCollectionNodeIndex BrowsingIndex = operation.BrowsingIndex;

            Debug.Assert(ChildState.ParentIndex == BrowsingIndex);
        }
Exemple #3
0
        /// <summary>
        /// Inserts a new node in a block list.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        public virtual void Insert(IWriteableInsertNodeOperation operation)
        {
            Debug.Assert(operation != null);

            int BlockIndex = operation.BlockIndex;

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

            IWriteableBlockState BlockState = BlockStateList[BlockIndex];

            int Index = operation.Index;

            Debug.Assert(Index >= 0 && Index <= BlockState.StateList.Count);

            INode  ParentNode = Owner.Node;
            IBlock ChildBlock = BlockState.ChildBlock;
            INode  Node       = operation.Node;

            NodeTreeHelperBlockList.InsertIntoBlock(ChildBlock, Index, Node);

            IWriteableBrowsingBlockNodeIndex BrowsingBlockIndex = CreateBrowsingNodeIndex(Node, BlockIndex, Index);
            IWriteablePlaceholderNodeState   ChildState         = (IWriteablePlaceholderNodeState)CreateNodeState(BrowsingBlockIndex);

            BlockState.Insert(BrowsingBlockIndex, Index, ChildState);

            operation.Update(BrowsingBlockIndex, ChildState);

            while (++Index < BlockState.StateList.Count)
            {
                IWriteablePlaceholderNodeState State = BlockState.StateList[Index];

                IWriteableBrowsingExistingBlockNodeIndex NodeIndex = State.ParentIndex as IWriteableBrowsingExistingBlockNodeIndex;
                Debug.Assert(NodeIndex != null);
                Debug.Assert(NodeIndex.BlockIndex == BrowsingBlockIndex.BlockIndex);
                Debug.Assert(NodeIndex.Index == Index - 1);

                NodeIndex.MoveUp();
            }
        }
 /// <summary>
 /// Inserts a new node in a list or block list.
 /// </summary>
 /// <param name="operation">Details of the operation performed.</param>
 public abstract void Insert(IWriteableInsertNodeOperation operation);