IfcDoc.FormEdit.toolStripMenuItemFileUpdate_Click C# (CSharp) Méthode

toolStripMenuItemFileUpdate_Click() private méthode

private toolStripMenuItemFileUpdate_Click ( object sender, EventArgs e ) : void
sender object
e EventArgs
Résultat void
        private void toolStripMenuItemFileUpdate_Click(object sender, EventArgs e)
        {
            DialogResult res = this.openFileDialogUpdate.ShowDialog(this);
            if (res == DialogResult.OK)
            {
                foreach (string filename in this.openFileDialogUpdate.FileNames)
                {
                    string ext = System.IO.Path.GetExtension(filename).ToLower();
                    switch (ext)
                    {
                        case ".vex":
                            using (FormatSPF format = new FormatSPF(filename, SchemaVEX.Types, null))
                            {
                                format.Load();

                                // loop through relevent entities, update from database
                                foreach (SEntity entity in format.Instances.Values)
                                {
                                    if (entity is ENTITIES)
                                    {
                                        ENTITIES ent = (ENTITIES)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            // get corresponding instance in documentation database
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.text.ToLowerInvariant(), out tn))
                                            {
                                                DocEntity docEntity = (DocEntity)tn.Tag;

                                                ent.comment.text.text = docEntity.Documentation;

                                                // also update attributes
                                                if (ent.attributes != null)
                                                {
                                                    foreach (ATTRIBUTE_DEF attr in ent.attributes)
                                                    {
                                                        if (attr.comment != null && attr.comment.text != null)
                                                        {
                                                            foreach (DocAttribute docattr in docEntity.Attributes)
                                                            {
                                                                if (docattr.Name.Equals(attr.name.text))
                                                                {
                                                                    attr.comment.text.text = docattr.Documentation;
                                                                }
                                                            }
                                                        }
                                                    }
                                                }

                                                // where rules
                                                if (ent.wheres != null)
                                                {
                                                    foreach (WHERE_RULE attr in ent.wheres)
                                                    {
                                                        if (attr.comment != null && attr.comment.text != null)
                                                        {
                                                            foreach (DocWhereRule docattr in docEntity.WhereRules)
                                                            {
                                                                if (docattr.Name.Equals(attr.name))
                                                                {
                                                                    attr.comment.text.text = docattr.Documentation;
                                                                    attr.rule_context = docattr.Expression; // update where rule expression
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    else if (entity is ENUMERATIONS)
                                    {
                                        ENUMERATIONS ent = (ENUMERATIONS)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.text.ToLowerInvariant(), out tn))
                                            {
                                                DocEnumeration docEntity = (DocEnumeration)tn.Tag;
                                                ent.comment.text.text = docEntity.Documentation;
                                            }

                                        }
                                    }
                                    else if (entity is DEFINED_TYPE)
                                    {
                                        DEFINED_TYPE ent = (DEFINED_TYPE)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.text.ToLowerInvariant(), out tn))
                                            {
                                                DocDefined docEntity = (DocDefined)tn.Tag;
                                                ent.comment.text.text = docEntity.Documentation;
                                            }
                                        }
                                    }
                                    else if (entity is SELECTS)
                                    {
                                        SELECTS ent = (SELECTS)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.text.ToLowerInvariant(), out tn))
                                            {
                                                DocSelect docEntity = (DocSelect)tn.Tag;
                                                ent.comment.text.text = docEntity.Documentation;
                                            }
                                        }
                                    }
                                    else if (entity is GLOBAL_RULE)
                                    {
                                        GLOBAL_RULE rule = (GLOBAL_RULE)entity;
                                        if (rule.comment != null && rule.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(rule.name.ToLowerInvariant(), out tn))
                                            {
                                                DocGlobalRule docEntity = (DocGlobalRule)tn.Tag;
                                                rule.comment.text.text = docEntity.Documentation;
                                                rule.rule_context = docEntity.Expression;
                                            }
                                        }
                                    }
                                    else if (entity is USER_FUNCTION)
                                    {
                                        USER_FUNCTION func = (USER_FUNCTION)entity;
                                        TreeNode tn = null;
                                        if (func.name != null && this.m_mapTree.TryGetValue(func.name.ToLowerInvariant(), out tn))
                                        {
                                            DocFunction docFunc = (DocFunction)tn.Tag;
                                            if (func.comment != null && func.comment.text != null)
                                            {
                                                func.comment.text.text = docFunc.Documentation;
                                            }
                                            func.rule_context = docFunc.Expression;
                                        }
                                    }
                                    else if (entity is USER_PROCEDURE)
                                    {
                                        //?? unused for IFC
                                    }
                                    else if (entity is SCHEMATA)
                                    {
                                        SCHEMATA ent = (SCHEMATA)entity;
                                        if (ent.comment != null && ent.comment.text != null)
                                        {
                                            TreeNode tn = null;
                                            if (this.m_mapTree.TryGetValue(ent.name.ToLowerInvariant(), out tn))
                                            {
                                                DocSchema docSchema = (DocSchema)tn.Tag;
                                                ent.comment.text.text = docSchema.Documentation;
                                            }
                                        }
                                    }
                                }

                                format.Save();
                            }
                            break;
                    }
                }
            }
        }
FormEdit