예제 #1
0
 public static void ExpandAll(NodeItem node)
 {
     node.IsExpanded = true;
     foreach (var item in node.Children)
     {
         ExpandAll(item);
     }
 }
예제 #2
0
        private static NodeItem CreatePropNode(string name, string parentName, string classificationName)
        {
            NodeItem node = new NodeItem();

            node.Name               = name;
            node.Type               = NodeItemType.Property;
            node.ParentName         = parentName;
            node.ClassificationName = classificationName;
            return(node);
        }
예제 #3
0
        public static NodeItem CopyNode(NodeItem node, bool withChildren = true)
        {
            NodeItem newNode = new NodeItem();

            newNode.Name               = node.Name;
            newNode.Type               = node.Type;
            newNode.RefIfcEntity       = node.RefIfcEntity;
            newNode.ParentName         = node.ParentName;
            newNode.ClassificationName = node.ClassificationName;
            newNode.IsExpanded         = node.IsExpanded;
            newNode.IsSelected         = node.IsSelected;
            newNode.ExistCount         = node.ExistCount;
            newNode.ClassEntity        = node.ClassEntity;
            if (withChildren)
            {
                foreach (var item in node.Children)
                {
                    newNode.Children.Add(CopyNode(item));
                }
            }
            return(newNode);
        }
예제 #4
0
 private void GetChildrenNode()
 {
     if (ClassEntity.ClassificationProperties != null)
     {
         List <NodeItem> propSetNodes = new List <NodeItem>();
         foreach (var item in ClassEntity.ClassificationProperties)
         {
             if (!string.IsNullOrEmpty(item.PropertySet))
             {
                 NodeItem newPropSet = CreatePropSetNode(item.PropertySet, Name, Name);
                 if (!Children.Any(o => o.Name == newPropSet.Name))
                 {
                     Children.Add(newPropSet);
                 }
                 NodeItem propSet = Children.Where(o => o.Name == item.PropertySet).FirstOrDefault();
                 if (propSet != null)
                 {
                     propSet.Children.Add(CreatePropNode(item.Name, propSet.Name, Name));
                 }
             }
             else
             {
                 NodeItem newPropSet = CreatePropSetNode(LocalData.UndefinedPset, Name, Name);
                 if (!Children.Any(o => o.Name == newPropSet.Name))
                 {
                     Children.Add(newPropSet);
                 }
                 NodeItem propSet = Children.Where(o => o.Name == LocalData.UndefinedPset).FirstOrDefault();
                 if (propSet != null)
                 {
                     propSet.Children.Add(CreatePropNode(item.Name, propSet.Name, Name));
                 }
             }
         }
     }
 }
예제 #5
0
        public static List <NodeItem> RestructureFlatNodes(List <NodeItem> allNodes, IList <NodeItem> selected)
        {
            List <NodeItem> restructedClasses = new List <NodeItem>();
            List <NodeItem> restructedPropSet = new List <NodeItem>();

            // Classification selected - clear all subnodes
            foreach (var item in selected)
            {
                if (item.Type == NodeItemType.Classification)
                {
                    restructedClasses.Add(item);
                }
            }
            foreach (var item in restructedClasses)
            {
                foreach (var node in selected.Where(x => x.Type == NodeItemType.Classification).ToList())
                {
                    selected.Remove(node);
                }
                foreach (var node in selected.Where(x => x.ClassificationName == item.Name).ToList())
                {
                    selected.Remove(node);
                }
            }
            // PropertySet selected - clear all subnodes
            foreach (var item in selected)
            {
                if (item.Type == NodeItemType.PropertySet)
                {
                    restructedPropSet.Add(item);
                }
            }
            foreach (var item in restructedPropSet)
            {
                foreach (var node in selected.Where(x => x.Type == NodeItemType.PropertySet).ToList())
                {
                    selected.Remove(node);
                }
                foreach (var node in selected.Where(x => x.ClassificationName == item.ClassificationName && x.ParentName == item.Name).ToList())
                {
                    selected.Remove(node);
                }
            }
            // Add Property in PropertySet
            foreach (var prop in selected)
            {
                if (prop.Type == NodeItemType.Property)
                {
                    foreach (var node in allNodes)
                    {
                        NodeItem propSetNode = node.Children.Where(ps => ps.Name == prop.ParentName && ps.ClassificationName == prop.ClassificationName).FirstOrDefault();
                        if (propSetNode != null)
                        {
                            if (!restructedPropSet.Any(ps => ps.Name == propSetNode.Name && ps.ClassificationName == propSetNode.ClassificationName))
                            {
                                restructedPropSet.Add(CopyNode(propSetNode, false));
                            }
                        }
                    }
                    NodeItem newPropSetNode = restructedPropSet.Where(ps => ps.Name == prop.ParentName && ps.ClassificationName == prop.ClassificationName).FirstOrDefault();
                    if (newPropSetNode != null)
                    {
                        newPropSetNode.Children.Add(prop);
                    }
                }
            }
            // Add PropertySet in Classifications
            foreach (var item in restructedPropSet)
            {
                NodeItem classNode = allNodes.Where(x => x.Name == item.ClassificationName).FirstOrDefault();
                if (classNode != null)
                {
                    if (!restructedClasses.Any(x => x.Name == classNode.Name))
                    {
                        restructedClasses.Add(CopyNode(classNode, false));
                    }
                }
                NodeItem newClassNode = restructedClasses.Where(x => x.Name == item.ClassificationName).FirstOrDefault();
                if (newClassNode != null)
                {
                    newClassNode.Children.Add(item);
                }
            }
            return(restructedClasses);
        }