示例#1
0
        //getNodeKeyByNodeId()

        public Collection <CswNbtNodeKey> getNodeKeysByNodeIdAndViewNode(CswPrimaryKey NodeId, CswNbtViewNode ViewNode)
        {
            Collection <CswNbtNodeKey> ret = new Collection <CswNbtNodeKey>();

            if (NodesById.ContainsKey(NodeId))
            {
                foreach (CswNbtNodeKey NodeKey in NodesById[NodeId])
                {
                    if (NodeKey.ViewNodeUniqueId == ViewNode.UniqueId)
                    {
                        ret.Add(NodeKey);
                    }
                }
            }
            return(ret);
        }
示例#2
0
        private void _makeNbtTreeNode(CswNbtTreeNode ParentNode,
                                      string ElemName,
                                      CswPrimaryKey NodeId,
                                      string NodeName,
                                      Int32 NodeTypeId,
                                      Int32 ObjectClassId,
                                      string Icon,
                                      bool Selectable,
                                      CswNbtViewNode ViewNode,
                                      CswEnumNbtNodeSpecies Species,
                                      bool ShowInTree,
                                      bool Locked,
                                      bool Included,
                                      bool Favorited,
                                      CswPrimaryKey RelationalId,
                                      out CswNbtTreeNode NewNode,
                                      out CswNbtNodeKey NewNodeKey)
        {
            // Make the object
            NewNode = new CswNbtTreeNode(NodeId, NodeName, NodeTypeId, ObjectClassId, RelationalId)
            {
                ElementName  = ElemName,
                IconFileName = Icon,
                Selectable   = Selectable,
                ShowInTree   = ShowInTree,
                Locked       = Locked,
                Included     = Included,
                Favorited    = Favorited,
                ChildNodes   = new Collection <CswNbtTreeNode>(),
                ChildProps   = new Collection <CswNbtTreeNodeProp>()
            };

            CswNbtNodeKey      ParentNodeKey = null;
            CswDelimitedString NodeCountPath = new CswDelimitedString(CswNbtNodeKey.NodeCountDelimiter);

            if (ParentNode != null)
            {
                ParentNodeKey = _getKey(ParentNode);
                string ParentNodeCountPath = ParentNodeKey.NodeCountPath.ToString();
                NodeCountPath.FromString(ParentNodeCountPath);
                NodeCountPath.Add(((ParentNode.ChildNodes.Count()) + 1).ToString());
                ParentNode.ChildNodes.Add(NewNode);
                NewNode.ParentNode = ParentNode;
            }

            // Make the key
            NewNodeKey               = new CswNbtNodeKey();
            NewNodeKey.TreeKey       = _CswNbtTreeKey;
            NewNodeKey.NodeSpecies   = Species;
            NewNodeKey.NodeCountPath = NodeCountPath;
            if (NewNode.ElementName == Elements.Node)
            {
                NewNodeKey.NodeId        = NodeId;
                NewNodeKey.NodeTypeId    = NodeTypeId;
                NewNodeKey.ObjectClassId = ObjectClassId;
                if (ViewNode != null)
                {
                    NewNodeKey.ViewNodeUniqueId = ViewNode.UniqueId;
                }
            }
            else if (NewNode.ElementName == Elements.Tree || NewNode.ElementName == Elements.Group)
            {
                // Nothing
            }
            else if (NewNode.ElementName == Elements.Prop)
            {
                throw (new CswDniException("_makeNbtTreeNode called on an NbtNodeProp element"));
            }
            else
            {
                throw (new CswDniException("Unknown element: " + NewNode.ElementName));
            }

            // Dictionaries
            if (NodeId != null)
            {
                if (false == NodesById.ContainsKey(NodeId))
                {
                    NodesById.Add(NodeId, new Collection <CswNbtNodeKey>());
                }
                NodesById[NodeId].Add(NewNodeKey);
            }
            if (ParentNodeKey != null && !NodesAndParents.ContainsKey(NewNodeKey))
            {
                NodesAndParents.Add(NewNodeKey, ParentNodeKey);
            }

            NewNode.NodeKey = NewNodeKey;
        }