Example #1
0
 public void AddCustomTreeRoot(String linkType)
 {
     if (!roots.ContainsKey(linkType))
     {
         CustomTreeRoot root = new CustomTreeRoot();
         root.LinkType = linkType;
         root.RootId = -1;
         root.DisplayId = -1;
         root.MyTree = this;
         roots.Add(linkType, root);
     }
 }
Example #2
0
        private void loadNodes(CustomTreeRoot root, XPathNavigator nav, ProcessingNode tParent)
        {
            XPathNodeIterator nodes = nav.Select("Component");

            foreach (XPathNavigator navChild in nodes)
            {
                ProcessingNode childNode = CreateNodeAndProcessFunctions(navChild, tParent.LinkType);

                if (useNodeMap)
                {
                    root.AddNodeToMap(childNode);
                }

                // do we need to branch?
                if (childNode.Functions.Count > 0 && childNode.Functions[0].FunctionName.Equals("RootBranch") && !branching)
                {
                    branching = true;
                    String dynamicLink = this.Controller.GetDynamicLinkType(root.LinkType, ""+childNode.NodeID);
                    IXPathNavigable iRootNav = this.Controller.GetComponentAndChildren(childNode.NodeID, childNode.NodeID, dynamicLink, new ComponentOptions());
                    XPathNavigator newRootNav = iRootNav.CreateNavigator();
                    // optional transform
                    try
                    {
                        CustomTreeRoot xslBuilder = new CustomTreeRoot();
                        xslBuilder.Controller = this.Controller;
                        xslBuilder.Xsl = childNode.Functions[0].FunctionAction;
                        if (xslBuilder.Transform != null)
                        {
                            XmlDocument newDocument = new XmlDocument();
                            using (XmlWriter writer = newDocument.CreateNavigator().AppendChild())
                            {
                                xslBuilder.Transform.Transform(iRootNav, (XsltArgumentList)null, writer);
                            }
                            newRootNav = newDocument.CreateNavigator();
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message);
                    }
                    finally
                    {
                        newRootNav.SelectSingleNode("Components/Component/@LinkID").SetValue("" + childNode.LinkID.Value);
                        XPathNavigator newRootComponents = newRootNav.SelectSingleNode("Components");
                        if (newRootComponents != null)
                        {
                            tParent.LinkType = dynamicLink;
                            loadNodes(root, newRootComponents, tParent);
                            branching = false;
                        }
                    }
                }
                else
                {
                    tParent.Nodes.Add(childNode);

                    if (navChild.HasChildren)
                    {
                        loadNodes(root, navChild, childNode);
                    }
                }
            }
        }
Example #3
0
        private void loadNodeRange(CustomTreeRoot root, XPathNavigator nav, List<ProcessingNode> tParent, String linkType)
        {
            XPathNodeIterator nodes = nav.Select("Component");

            foreach (XPathNavigator navChild in nodes)
            {
                ProcessingNode childNode = CreateNodeAndProcessFunctions(navChild, linkType);

                if (useNodeMap)
                {
                    root.AddNodeToMap(childNode);
                }

                tParent.Add(childNode);

                if (navChild.HasChildren)
                {
                    loadNodes(root, navChild, childNode);
                }
            }
        }
Example #4
0
 public void ChangeCustomTreeRoot(String newLinkType, String oldLinkType)
 {
     CustomTreeRoot oldRoot = null;
     if (roots.TryGetValue(oldLinkType, out oldRoot))
     {
         CustomTreeRoot newRoot = new CustomTreeRoot();
         newRoot.LinkType = newLinkType;
         newRoot.RootId = oldRoot.RootId;
         newRoot.DisplayId = oldRoot.DisplayId;
         roots.Remove(oldLinkType);
         roots.Add(newLinkType, newRoot);
     }
 }