Exemple #1
0
 private void _makeRootNode(string ViewName, CswNbtViewRoot ViewRoot, string IconFileName, bool Selectable)
 {
     if (_RootNode == null)
     {
         _makeNbtTreeNode(_TreeNode,
                          Elements.Node,
                          null,
                          ViewName,
                          0,
                          0,
                          IconFileName,
                          Selectable,
                          ViewRoot,
                          CswEnumNbtNodeSpecies.Root,
                          true,
                          false,
                          false,
                          (ViewRoot != null) && ViewRoot.Included,
                          null,
                          out _RootNode,
                          out _RootNodeKey);
         _CurrentNode = _RootNode;
     }
     else
     {
         throw new CswDniException("CswNbtTreeNodes attempted to add a second root node to the tree");
     }
 }
Exemple #2
0
        // _getTreeNodeFromId()

        private CswNbtNode _getNbtNodeObjFromTreeNode(CswNbtTreeNode TreeNode)
        {
            if (TreeNode.ElementName != Elements.Node)
            {
                throw (new CswDniException("The current node is a " + TreeNode.ElementName + ", not an NbtNode"));
            }

            CswNbtNodeKey NodeKey   = _getKey(TreeNode);
            CswNbtNode    ReturnVal = _CswNbtNodeCollection[TreeNode.CswNodeId];

            if (CswEnumNbtNodeSpecies.Plain == NodeKey.NodeSpecies)
            {
                string IconName            = default(string);
                string PotentialIconSuffix = TreeNode.IconFileName;
                if (false == string.IsNullOrEmpty(PotentialIconSuffix))
                {
                    IconName = CswNbtMetaDataObjectClass.IconPrefix16 + PotentialIconSuffix;
                }
                ReturnVal.IconFileName = IconName;
                ReturnVal.NodeName     = TreeNode.NodeName;
                ReturnVal.NodeTypeId   = TreeNode.NodeTypeId;
            }
            ReturnVal.Selectable = TreeNode.Selectable;
            ReturnVal.ShowInTree = TreeNode.ShowInTree;

            return(ReturnVal);
        }
Exemple #3
0
        // _makeNbtTreeNode()

        public void _makeTreeNodeProp(CswNbtTreeNode TreeNode,
                                      Int32 NodeTypePropId,
                                      Int32 ObjectClassPropId,
                                      Int32 JctNodePropId,
                                      string PropName,
                                      string ObjectClassPropName,
                                      string Gestalt,
                                      CswEnumNbtFieldType FieldType,
                                      string Field1,
                                      string Field2,
                                      Int32 Field1_Fk,
                                      double Field1_Numeric,
                                      bool Hidden,
                                      string Field1_Big)
        {
            CswNbtTreeNodeProp TreeNodeProp = new CswNbtTreeNodeProp(FieldType, PropName, ObjectClassPropName, ObjectClassPropId, NodeTypePropId, JctNodePropId, TreeNode)
            {
                ElementName    = "NbtNodeProp",
                Gestalt        = Gestalt,
                Field1         = Field1,
                Field2         = Field2,
                Field1_Fk      = Field1_Fk,
                Field1_Numeric = Field1_Numeric,
                Hidden         = Hidden,
                Field1_Big     = Field1_Big
            };

            TreeNode.ChildProps.Add(TreeNodeProp);
        }
Exemple #4
0
 public void goToParentNode()
 {
     if (isCurrentPositionRoot())
     {
         throw (new CswDniException("Already at root!"));
     }
     _CurrentNode = _getParentNode();
 }
Exemple #5
0
 public void makeNodeCurrent(CswNbtNodeKey NodeKey)
 {
     if (NodeKey.TreeKey == this._CswNbtTreeKey)
     {
         _CurrentNode = _getTreeNodeFromKey(NodeKey);
     }
     else
     {
         _CurrentNode = null;
     }
 }
Exemple #6
0
        // _getTreeNodeFromKey()

        private CswNbtTreeNode _getTreeNodeFromId(CswPrimaryKey NodeId)
        {
            CswNbtTreeNode ret = null;

            if (NodesById.Keys.Contains(NodeId) && NodesById[NodeId].Count > 0)
            {
                CswNbtNodeKey ThisNodeKey = NodesById[NodeId].First();
                ret = _getTreeNodeFromKey(ThisNodeKey);
            }
            return(ret);
        }
 public CswNbtTreeNodeProp(CswEnumNbtFieldType NbtFieldType, string NbtPropName, string NbtObjectClassPropName, int NbtObjectClassPropId,
                           int NbtNodeTypePropId, int NbtJctNodePropId, CswNbtTreeNode TreeNode)
 {
     FieldType           = NbtFieldType;
     PropName            = NbtPropName;
     ObjectClassPropName = NbtObjectClassPropName;
     ObjectClassPropId   = NbtObjectClassPropId;
     NodeTypePropId      = NbtNodeTypePropId;
     JctNodePropId       = NbtJctNodePropId;
     PropOwner           = TreeNode;
 }
Exemple #8
0
        private CswNbtTreeNode _getMatchingGroup(CswNbtTreeNode ParentTreeNode, string ThisGroupName)
        {
            CswNbtTreeNode ret = null;

            foreach (CswNbtTreeNode PotentialGroupNode in ParentTreeNode.ChildNodes)
            {
                if (PotentialGroupNode.ElementName == Elements.Group &&
                    PotentialGroupNode.NodeName == ThisGroupName)
                {
                    ret = PotentialGroupNode;
                }
            }
            return(ret);
        }
Exemple #9
0
        public CswNbtNode getParentNodeOf(CswNbtNodeKey NodeKey)
        {
            CswNbtNode ReturnVal = null;

            CswNbtTreeNode CurrentNodeSave = _CurrentNode;

            makeNodeCurrent(NodeKey);

            if (false == isCurrentPositionRoot())
            {
                ReturnVal = _getNbtNodeObjFromTreeNode(_getTreeNodeFromKey(getNodeKeyForParentOfCurrentPosition()));
            }

            _CurrentNode = CurrentNodeSave;

            return(ReturnVal);
        }
Exemple #10
0
        //goToRoot()

        /// <summary>
        ///     Move the current position to the Nth child of the current node
        /// </summary>
        /// <param name="ChildN">0-based Index of Child</param>
        public void goToNthChild(int ChildN)
        {
            Collection <CswNbtTreeNode> CurrentChildren = _getChildNodes();
            Int32 CurrentChildCount = CurrentChildren.Count();

            if (0 == CurrentChildCount)
            {
                throw (new CswDniException("The current node has no children"));
            }

            if (CurrentChildCount <= ChildN)
            {
                throw (new CswDniException("Requested child node " + ChildN +
                                           " does not exist; current node contains " + CurrentChildCount + " children"));
            }

            _CurrentNode = CurrentChildren[ChildN];
        }
Exemple #11
0
        private CswNbtTreeNode _getTreeNodeFromKey(CswNbtNodeKey NodeKey)
        {
            CswNbtTreeNode ThisNode = _TreeNode;

            foreach (Int32 ThisCount in NodeKey.NodeCountPath.ToIntCollection())
            {
                if (ThisNode != null)
                {
                    if (ThisNode.ChildNodes.Count >= ThisCount)
                    {
                        ThisNode = ThisNode.ChildNodes[ThisCount - 1];
                    }
                    else
                    {
                        ThisNode = null;
                    }
                } // if( ThisNode == null )
            }
            return(ThisNode);
        }
Exemple #12
0
        public Collection <CswNbtNodeKey> _loadNodeAsChild(CswNbtNodeKey ParentNodeKey, bool UseGrouping,
                                                           string GroupName, CswNbtViewRelationship Relationship,
                                                           bool Selectable, bool ShowInTree,
                                                           CswEnumNbtViewAddChildrenSetting AddChildren, Int32 RowCount,
                                                           bool Included,
                                                           string IconFileName, string NameTemplate,
                                                           CswPrimaryKey NodeId, CswPrimaryKey RelationalId, string NodeName, Int32 NodeTypeId,
                                                           string NodeTypeName, Int32 ObjectClassId,
                                                           string ObjectClassName, bool Locked, bool Favorited)
        {
            Collection <CswNbtNodeKey> ReturnKeyColl = new Collection <CswNbtNodeKey>();

            CswNbtTreeNode ParentNode = null;

            ParentNode = _CurrentNode ?? _TreeNode;

            Collection <CswNbtTreeNode> ParentNodes = new Collection <CswNbtTreeNode>();

            if (false == UseGrouping)
            {
                ParentNodes.Add(ParentNode);
            }
            else
            {
                // Interpret commas to denote multiple groups
                string GroupNameForLoop = GroupName;
                string ThisGroupName    = GroupName;
                do
                {
                    if (GroupNameForLoop.IndexOf(',') >= 0)
                    {
                        ThisGroupName    = GroupNameForLoop.Substring(0, GroupNameForLoop.IndexOf(',')).Trim();
                        GroupNameForLoop = GroupNameForLoop.Substring(GroupNameForLoop.IndexOf(',') + 1).Trim();
                    }
                    else
                    {
                        ThisGroupName    = GroupNameForLoop.Trim();
                        GroupNameForLoop = string.Empty;
                    }

                    CswNbtTreeNode MatchingGroup = _getMatchingGroup(ParentNode, ThisGroupName);
                    if (MatchingGroup == null)
                    {
                        CswNbtNodeKey MatchingGroupKey = null;
                        _makeNbtTreeNode(ParentNode,
                                         Elements.Group,
                                         null,
                                         ThisGroupName,
                                         Int32.MinValue,
                                         Int32.MinValue,
                                         "group.gif",
                                         false,
                                         Relationship,
                                         CswEnumNbtNodeSpecies.Group,
                                         true,
                                         false,
                                         true,
                                         false,
                                         null,
                                         out MatchingGroup,
                                         out MatchingGroupKey);
                    }

                    if (MatchingGroup != null)
                    {
                        ParentNodes.Add(MatchingGroup);
                    }
                } // do
                while(GroupNameForLoop != string.Empty);
            }     // if-else( !UseGrouping )


            foreach (CswNbtTreeNode ThisParentNode in ParentNodes)
            {
                CswNbtNodeKey  ThisKey  = null;
                CswNbtTreeNode ThisNode = null;
                _makeNbtTreeNode(ThisParentNode,
                                 Elements.Node,
                                 NodeId,
                                 NodeName,
                                 NodeTypeId,
                                 ObjectClassId,
                                 IconFileName,
                                 Selectable,
                                 Relationship,
                                 CswEnumNbtNodeSpecies.Plain,
                                 ShowInTree,
                                 Locked,
                                 Included,
                                 Favorited,
                                 RelationalId,
                                 out ThisNode,
                                 out ThisKey);
                ReturnKeyColl.Add(ThisKey);
            }

            return(ReturnKeyColl);
        }
Exemple #13
0
 public void makeNodeCurrent(CswPrimaryKey NodeId)
 {
     _CurrentNode = _getTreeNodeFromId(NodeId);
 }
Exemple #14
0
        //addProperty()


        public void removeCurrentNode()
        {
            _getChildNodes(_getParentNode()).Remove(_CurrentNode);
            _CurrentNode = _RootNode;
        }
Exemple #15
0
 private Collection <CswNbtTreeNode> _getChildNodes(CswNbtTreeNode TreeNode)
 {
     return(TreeNode.ChildNodes);
 }
Exemple #16
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;
        }
Exemple #17
0
 private CswNbtTreeNode _getParentNode(CswNbtTreeNode TreeNode)
 {
     return(TreeNode.ParentNode);
 }
Exemple #18
0
 public void goToRoot()
 {
     _CurrentNode = _RootNode;
 }
Exemple #19
0
 private Collection <CswNbtTreeNodeProp> _getChildProps(CswNbtTreeNode TreeNode)
 {
     return(TreeNode.ChildProps);
 }
Exemple #20
0
 private CswNbtNodeKey _getKey(CswNbtTreeNode TreeNode)
 {
     TreeNode.NodeKey.TreeKey = _CswNbtTreeKey;
     return(TreeNode.NodeKey);
 }
 public CswNbtTreeNode(CswPrimaryKey NbtNodeId, string NbtNodeName, int NbtNodeTypeId, int NbtObjectClassId, CswPrimaryKey NbtRelationalId, CswNbtTreeNode ParentNode = null)
 {
     if (null != NbtNodeId)
     {
         NodePk = NbtNodeId.ToString();
     }
     NodeName        = NbtNodeName;
     NodeTypeId      = NbtNodeTypeId;
     ObjectClassId   = NbtObjectClassId;
     this.ParentNode = ParentNode;
     RelationalId    = NbtRelationalId;
 }