Beispiel #1
0
        private void ComboBox_IFCSchema_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            string currSelEntity = null;
            string currSelPdef   = null;

            if (m_SingleNodeSelection)
            {
                currSelEntity = PrevSelEntityItem?.Name;
                currSelPdef   = PrevSelPDefItem?.Name;
            }

            string selIFCSchema = ComboBox_IFCSchema.SelectedItem.ToString();

            if (!m_IfcVersion.Equals(selIFCSchema))
            {
                m_IfcVersion = selIFCSchema;
                m_EntityTrie = new IFCEntityTrie();
                LoadTreeviewFilterElement();

                if (m_SingleNodeSelection)
                {
                    PreSelectItem(currSelEntity, currSelPdef);
                }
                else
                {
                    PredefinedTypeTreeView.ItemsSource = null;
                    PrevSelPDefItem = null;
                }
                IfcSchemaEntityTree.GenerateEntityTrie(ref m_EntityTrie);
            }
        }
Beispiel #2
0
        void LoadTreeviewFilterElement()
        {
            button_Reset.IsEnabled = true;
            try
            {
                string schemaFile = m_IfcVersion + ".xsd";
                // Process IFCXml schema here, then search for IfcProduct and build TreeView beginning from that node. Allow checks for the tree nodes. Grey out (and Italic) the abstract entity
                schemaFile = System.IO.Path.Combine(DirectoryUtil.IFCSchemaLocation, schemaFile);
                FileInfo      schemaFileInfo = new FileInfo(schemaFile);
                IFCEntityTrie entityTrie     = new IFCEntityTrie();

                IfcSchemaEntityTree ifcEntityTree = IfcSchemaEntityTree.GetEntityDictFor(m_IfcVersion);
                if (ifcEntityTree != null || m_TreeView.Items.Count == 0)
                {
                    m_TreeView.Items.Clear();
                    m_TreeViewItemDict.Clear();

                    if (!m_ShowTypeNodeOnly)
                    {
                        IfcSchemaEntityNode ifcProductNode;
                        if (ifcEntityTree.IfcEntityDict.TryGetValue("IfcProduct", out ifcProductNode))
                        {
                            // From IfcProductNode, recursively get all the children nodes and assign them into the treeview node (they are similar in the form)
                            TreeViewItem prod = new TreeViewItem();
                            prod.Name = "IfcProduct";
                            if (m_SingleNodeSelection)
                            {
                                prod.Header = ifcProductNode.Name + " " + TreeSelectionDesc;
                            }
                            else
                            {
                                ToggleButton prodNode = new CheckBox();
                                prodNode.Name       = prod.Name;
                                prodNode.Content    = prod.Name;
                                prodNode.IsChecked  = true;
                                prod.Header         = prodNode;
                                prodNode.Checked   += new RoutedEventHandler(TreeViewItem_HandleChecked);
                                prodNode.Unchecked += new RoutedEventHandler(TreeViewItem_HandleUnchecked);
                            }
                            prod.IsExpanded = true;
                            prod.FontWeight = FontWeights.Bold;
                            m_TreeView.Items.Add(GetNode(ifcProductNode, prod, ExclElementSet));
                        }
                    }

                    IfcSchemaEntityNode ifcTypeProductNode;
                    if (ifcEntityTree.IfcEntityDict.TryGetValue("IfcTypeProduct", out ifcTypeProductNode))
                    {
                        // From IfcTypeProductNode, recursively get all the children nodes and assign them into the treeview node (they are similar in the form)
                        TreeViewItem typeProd = new TreeViewItem();
                        typeProd.Name   = "IfcTypeProduct";
                        typeProd.Header = ifcTypeProductNode.Name + " " + TreeSelectionDesc;
                        if (m_SingleNodeSelection)
                        {
                            typeProd.Header = ifcTypeProductNode.Name + " " + TreeSelectionDesc;
                        }
                        else
                        {
                            ToggleButton typeProdNode = new CheckBox();
                            typeProdNode.Name       = typeProd.Name;
                            typeProdNode.Content    = typeProd.Name;
                            typeProdNode.IsChecked  = true;
                            typeProd.Header         = typeProdNode;
                            typeProdNode.Checked   += new RoutedEventHandler(TreeViewItem_HandleChecked);
                            typeProdNode.Unchecked += new RoutedEventHandler(TreeViewItem_HandleUnchecked);
                        }
                        typeProd.IsExpanded = true;
                        typeProd.FontWeight = FontWeights.Bold;
                        m_TreeView.Items.Add(GetNode(ifcTypeProductNode, typeProd, ExclElementSet));
                    }

                    if (!m_ShowTypeNodeOnly)
                    {
                        IfcSchemaEntityNode ifcGroupNode;
                        if (ifcEntityTree.IfcEntityDict.TryGetValue("IfcGroup", out ifcGroupNode))
                        {
                            // For IfcGroup, a header is neaded because the IfcGroup itself is not a Abstract entity
                            TreeViewItem groupHeader = new TreeViewItem();
                            groupHeader.Name = "IfcGroup";
                            if (m_SingleNodeSelection)
                            {
                                groupHeader.Header = "IfcGroup" + " " + TreeSelectionDesc;
                            }
                            else
                            {
                                ToggleButton groupHeaderNode = new CheckBox();
                                groupHeaderNode.Name       = groupHeader.Name;
                                groupHeaderNode.Content    = groupHeader.Name;
                                groupHeaderNode.IsChecked  = true;
                                groupHeader.Header         = groupHeaderNode;
                                groupHeaderNode.Checked   += new RoutedEventHandler(TreeViewItem_HandleChecked);
                                groupHeaderNode.Unchecked += new RoutedEventHandler(TreeViewItem_HandleUnchecked);
                            }
                            groupHeader.IsExpanded = true;
                            groupHeader.FontWeight = FontWeights.Bold;
                            m_TreeView.Items.Add(groupHeader);

                            // From IfcGroup Node, recursively get all the children nodes and assign them into the treeview node (they are similar in the form)
                            TreeViewItem groupNode = new TreeViewItem();
                            ToggleButton groupNodeItem;
                            if (m_SingleNodeSelection)
                            {
                                groupNodeItem = new RadioButton();
                            }
                            else
                            {
                                groupNodeItem = new CheckBox();
                            }
                            groupNode.Name       = "IfcGroup";
                            groupNode.Header     = groupNodeItem;
                            groupNode.IsExpanded = true;
                            m_TreeViewItemDict.Add(groupNode.Name, groupNode);
                            m_EntityTrie.AddIFCEntityToDict(groupNode.Name);

                            groupNodeItem.Name       = "IfcGroup";
                            groupNodeItem.Content    = "IfcGroup";
                            groupNodeItem.FontWeight = FontWeights.Normal;
                            groupNodeItem.IsChecked  = true; // Default is always Checked
                            if (ExclElementSet.Contains(groupNode.Name) || m_SingleNodeSelection)
                            {
                                groupNodeItem.IsChecked = false; // if the name is inside the excluded element hashset, UNcheck the checkbox (= remember the earlier choice)
                            }
                            groupNodeItem.Checked   += new RoutedEventHandler(TreeViewItem_HandleChecked);
                            groupNodeItem.Unchecked += new RoutedEventHandler(TreeViewItem_HandleUnchecked);

                            groupHeader.Items.Add(GetNode(ifcGroupNode, groupNode, ExclElementSet));
                        }
                    }
                }
                else
                {
                    // Check all elements that have been excluded before for this configuration
                    foreach (TreeViewItem tvItem in m_TreeView.Items)
                    {
                        UnCheckSelectedNode(tvItem, ExclElementSet);
                    }
                }
            }
            catch
            {
                // Error above in processing - disable the tree view.
                m_TreeView.IsEnabled = false;
            }
            IFCEntityTreeView.ItemsSource = m_TreeView.Items;
        }