Esempio n. 1
0
        /// <summary>
        /// Unlink the node removing it from its origin linked nodes list and restore it to its
        /// original node class.
        /// </summary>
        public void UnlinkNode()
        {
            LinkedNodeViewModel linkedNode = (LinkedNodeViewModel)this;

            linkedNode.Origin.LinkedNodes.Remove(linkedNode);

            NestedConfigNode parent = (NestedConfigNode)linkedNode.m_parent;

            ConfigNodeViewModel unlinkedNode = getInstance(m_parentExperiment, parent,
                                                           linkedNode.nodeDefinition, m_parentExperiment.AppName);

            // Keep the content of the former ogirin node
            if (!(linkedNode.Origin is ForkedNodeViewModel))
            {
                unlinkedNode.content = linkedNode.Origin.content;
            }
            else
            {
                ForkedNodeViewModel forkedNode = (ForkedNodeViewModel)linkedNode.LinkedNode;
                int valueIndex           = int.Parse(forkedNode.currentValueIndex.Substring(0, 1)) - 1;
                ForkValueViewModel value = (ForkValueViewModel)forkedNode.children[valueIndex];
                unlinkedNode.content = value.configNode.content;
            }
            // For node substitution We don't need the index in the whole tree just
            // the index in the parent children list
            int index = parent.children.IndexOf(linkedNode);

            parent.children.Remove(linkedNode);
            parent.children.Insert(index, unlinkedNode);

            unlinkedNode.CanBeLinked = true;
            unlinkedNode.IsLinkable  = false;
        }
Esempio n. 2
0
        public override void unforkThisNode()
        {
            NestedConfigNode parent = m_parent as NestedConfigNode;
            int childIndex          = parent.children.IndexOf(this);

            parent.children.Remove(this);
            parent.children.Insert(childIndex, selectedForkValue.configNode);
            m_appViewModel.updateNumForkCombinations();
        }
        private void WalkThroughBranch(ref Stack <ConfigNodeViewModel> nodeStack, ConfigNodeViewModel branchRoot)
        {
            if (branchRoot is NestedConfigNode)
            {
                NestedConfigNode branch = (NestedConfigNode)branchRoot;

                if (branch.children.Count > 0)
                {
                    foreach (var node in branch.children)
                    {
                        nodeStack.Push(node);
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        public void CreateLinkedNode()
        {
            // We need the linked node to be shown exactly as the origin node
            LinkedNode = Origin.clone();
            // But we need to protects its identity, so lets put a few things back to normal
            LinkedNode.nodeDefinition = nodeDefinition;
            LinkedNode.LinkedNodes    = LinkedNodes;
            LinkedNode.name           = name;
            LinkedNode.comment        = nodeDefinition.Attributes[XMLTags.commentAttribute].Value;

            if (LinkedNode is NestedConfigNode)
            {
                NestedConfigNode node = (NestedConfigNode)LinkedNode;
            }
        }
        public override void UnforkThisNode()
        {
            //unregister this fork
            m_parentExperiment.forkRegistry.Remove(this);

            NestedConfigNode parent = m_parent as NestedConfigNode;

            if (parent != null)
            {
                int childIndex = parent.children.IndexOf(this);
                parent.children.Remove(this);
                parent.children.Insert(childIndex, selectedForkValue.configNode);
                //the node can again be forked
                selectedForkValue.configNode.parent       = parent;
                selectedForkValue.configNode.bCanBeForked = true;
                m_parentExperiment.updateNumForkCombinations();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Actually perform the linking with the node.
        /// </summary>
        /// <param name="targetNode"></param>
        public void Link(ConfigNodeViewModel targetNode)
        {
            var linkedNode = new LinkedNodeViewModel(m_parentExperiment,
                                                     m_parentExperiment.LinkOriginNode, targetNode);

            var node = m_parentExperiment.DepthFirstSearch(targetNode);

            NestedConfigNode parent = (NestedConfigNode)node.m_parent;
            // For node substitution we just need the index in the parent children list
            int index = parent.children.IndexOf(node);

            parent.children.Remove(node);
            parent.children.Insert(index, linkedNode);

            m_parentExperiment.LinkOriginNode.LinkedNodes.Add(linkedNode.LinkedNode);
            // If the origin is a ForkedNode we also need to link the fork values inside
            // this is for content changes reflection.
            if (m_parentExperiment.LinkOriginNode is ForkedNodeViewModel)
            {
                ForkedNodeViewModel forkedOrigin = (ForkedNodeViewModel)m_parentExperiment.LinkOriginNode;
                int len = forkedOrigin.children.Count;

                for (int i = 0; i < len; i++)
                {
                    ForkedNodeViewModel linkedFork      = (ForkedNodeViewModel)linkedNode.LinkedNode;
                    ForkValueViewModel  linkedForkValue = (ForkValueViewModel)linkedFork.children[i];
                    ((ForkValueViewModel)forkedOrigin.children[i]).configNode.LinkedNodes
                    .Add(linkedForkValue.configNode);
                    linkedForkValue.configNode.name           = targetNode.name;
                    linkedForkValue.configNode.comment        = targetNode.comment;
                    linkedForkValue.configNode.nodeDefinition = targetNode.nodeDefinition;
                }
            }

            linkedNode.LinkedNode.IsLinkable  = false;
            linkedNode.LinkedNode.IsLinked    = true;
            linkedNode.LinkedNode.IsNotLinked = false;
        }