示例#1
0
        private protected virtual void CloneChildren(INode parentNode, IBlock parentBlock)
        {
            for (int i = 0; i < StateList.Count; i++)
            {
                IReadOnlyPlaceholderNodeState ChildState = StateList[i];

                INode ChildNodeClone = ChildState.CloneNode();
                Debug.Assert(ChildNodeClone != null);

                NodeTreeHelperBlockList.InsertIntoBlock(parentBlock, i, ChildNodeClone);
            }
        }
示例#2
0
        /// <summary>
        /// Inserts a new block with one node in a block list.
        /// </summary>
        /// <param name="operation">Details of the operation performed.</param>
        public virtual void InsertNewBlock(IWriteableInsertBlockOperation operation)
        {
            Debug.Assert(operation != null);

            int BlockIndex = operation.BlockIndex;

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

            IBlock NewBlock = operation.Block;

            Debug.Assert(NewBlock != null);

            INode NewNode = operation.Node;

            Debug.Assert(NewBlock != null);

            INode ParentNode = Owner.Node;

            NodeTreeHelperBlockList.InsertIntoBlockList(ParentNode, PropertyName, BlockIndex, NewBlock);
            NodeTreeHelperBlockList.InsertIntoBlock(NewBlock, 0, NewNode);

            IWriteableBrowsingNewBlockNodeIndex      BrowsingNewBlockIndex      = CreateNewBlockNodeIndex(NewNode, BlockIndex);
            IWriteableBrowsingExistingBlockNodeIndex BrowsingExistingBlockIndex = (IWriteableBrowsingExistingBlockNodeIndex)BrowsingNewBlockIndex.ToExistingBlockIndex();

            IWriteableBlockState BlockState = (IWriteableBlockState)CreateBlockState(BrowsingNewBlockIndex, NewBlock);

            InsertInBlockStateList(BlockIndex, BlockState);

            IWriteablePlaceholderNodeState ChildState = (IWriteablePlaceholderNodeState)CreateNodeState(BrowsingExistingBlockIndex);

            BlockState.Insert(BrowsingExistingBlockIndex, 0, ChildState);

            operation.Update(BrowsingExistingBlockIndex, BlockState, ChildState);

            while (++BlockIndex < BlockStateList.Count)
            {
                IWriteableBlockState NextBlockState = BlockStateList[BlockIndex];

                foreach (IWriteablePlaceholderNodeState State in NextBlockState.StateList)
                {
                    IWriteableBrowsingExistingBlockNodeIndex NodeIndex = State.ParentIndex as IWriteableBrowsingExistingBlockNodeIndex;
                    Debug.Assert(NodeIndex != null);
                    Debug.Assert(NodeIndex.BlockIndex == BlockIndex - 1);

                    NodeIndex.MoveBlockUp();
                }
            }
        }
示例#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();
            }
        }