public TreeNode CreatePointer()
        {
            TreeNodePointer obj = new TreeNodePointer(_xmlNode);

            if (this.IsShortcut)
            {
                bool      loaded = false;
                TreeViewX tvx    = this.TreeView as TreeViewX;
                if (tvx != null)
                {
                    TreeNodeX tnx = tvx.GetCategoryNodeById(this.TreeNodeId);
                    if (tnx != null)
                    {
                        VPLUtil.CopyProperties(tnx, obj);
                        loaded = true;
                    }
                }
                if (!loaded)
                {
                    ObjectXmlReader oxr = new ObjectXmlReader();
                    oxr.ReadProperties(_xmlNode, obj);
                }
            }
            else
            {
                VPLUtil.CopyProperties(this, obj);
            }
            return(obj);
        }
        public TreeNodeShortcut CreateShortcut()
        {
            TreeNodeShortcut tns = new TreeNodeShortcut(this.TreeNodeId);

            VPLUtil.CopyProperties(this, tns);
            tns.SetValueList(_data);
            tns.SetReferenceNode(this);
            tns.DataXmlNode = DataXmlNode;
            return(tns);
        }
Beispiel #3
0
 public override void SyncShortcuts(TreeNodeX node)
 {
     if (node.TreeNodeId == this.TreeNodeId)
     {
         _dataNode = node;
         VPLUtil.CopyProperties(node, this);
     }
     else
     {
         base.SyncShortcuts(node);
     }
 }
 public virtual TreeNodeX CreateDuplicatedNode(TreeViewX targetHolder)
 {
     if (_xmlNode == null)
     {
         TreeNodeX tnx = (TreeNodeX)this.Clone();
         return(tnx);
     }
     else
     {
         XmlNode     dataXml;
         XmlDocument docTarget = targetHolder.GetXmlDocument();
         if (docTarget == _xmlNode.OwnerDocument)
         {
             dataXml = _xmlNode.CloneNode(true);
         }
         else
         {
             dataXml = docTarget.ImportNode(_xmlNode, true);
         }
         XmlUtil.SetLibTypeAttribute(dataXml, this.GetType());
         XmlNodeList ndLst = dataXml.SelectNodes(string.Format(System.Globalization.CultureInfo.InvariantCulture,
                                                               "..//*[@{0}]", TreeViewX.XMLATT_Guid));
         Dictionary <Guid, Guid> idMaps = new Dictionary <Guid, Guid>();
         foreach (XmlNode nd in ndLst)
         {
             Guid id = XmlUtil.GetAttributeGuid(nd, TreeViewX.XMLATT_Guid);
             if (id == Guid.Empty)
             {
                 throw new TreeViewXException("Guid not found");
             }
             else
             {
                 Guid id2;
                 if (!idMaps.TryGetValue(id, out id2))
                 {
                     id2 = Guid.NewGuid();
                     idMaps.Add(id, id2);
                 }
             }
             XmlUtil.SetAttribute(nd, TreeViewX.XMLATT_Guid, Guid.NewGuid().ToString("D"));
         }
         TreeNodeX tnx = new TreeNodeX(dataXml);
         VPLUtil.CopyProperties(this, tnx);
         return(tnx);
     }
 }
 public virtual void SyncShortcuts(TreeNodeX node)
 {
     if (this != node)
     {
         if (node.TreeNodeId == this.TreeNodeId)
         {
             VPLUtil.CopyProperties(node, this);
         }
         else
         {
             if (NextLevelLoaded)
             {
                 for (int i = 0; i < Nodes.Count; i++)
                 {
                     TreeNodeX tnx = Nodes[i] as TreeNodeX;
                     if (tnx != null)
                     {
                         tnx.SyncShortcuts(node);
                     }
                 }
             }
         }
     }
 }