private void toolStripButtonQuantity_Click(object sender, EventArgs e) { DocEntity docBaseEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; if (this.m_conceptroot != null && this.m_conceptroot.ApplicableEntity != null) { docBaseEntity = this.m_conceptroot.ApplicableEntity; } using (FormSelectQuantity form = new FormSelectQuantity(docBaseEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); Dictionary <string, DocObject> mapEntity = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { mapEntity.Add(docEntity.Name, docEntity); } foreach (DocType docType in docSchema.Types) { mapEntity.Add(docType.Name, docType); } } } CvtValuePath valuepath = CvtValuePath.Parse(value, mapEntity); this.ChangeTemplate(valuepath.ToTemplateDefinition()); this.LoadTemplateGraph(); this.ContentChanged(this, EventArgs.Empty); } } }
private void toolStripButtonProperty_Click(object sender, EventArgs e) { DocEntity docBaseEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; if (this.m_conceptroot != null && this.m_conceptroot.ApplicableEntity != null) { docBaseEntity = this.m_conceptroot.ApplicableEntity; } using (FormSelectProperty form = new FormSelectProperty(docBaseEntity, this.m_project, false)) { if (form.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { string value = form.GenerateValuePath(); Dictionary <string, DocObject> mapEntity = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { mapEntity.Add(docEntity.Name, docEntity); } foreach (DocType docType in docSchema.Types) { mapEntity.Add(docType.Name, docType); } } } if (docBaseEntity.BaseDefinition == "IfcElement" || docBaseEntity.BaseDefinition == "IfcElementComponent" || docBaseEntity.BaseDefinition == "IfcBuildingElement" || docBaseEntity.BaseDefinition == "IfcReinforcingElement" || docBaseEntity.BaseDefinition == "IfcFlowSegment" || docBaseEntity.BaseDefinition == "IfcFeatureElement" || docBaseEntity.BaseDefinition == "IfcContext" || docBaseEntity.BaseDefinition == "IfcSpatialStructureElement" || docBaseEntity.BaseDefinition == "IfcFacility" || docBaseEntity.BaseDefinition == "IfcFacilityPart") { this.ChangeTemplate(this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePsetObject)); string[] psetParamNames = this.Concept.Definition.GetParameterNames(); DocTemplateItem pset = new DocTemplateItem(); pset.Name = form.SelectedPropertySet.Name; if (form.SelectedPropertySet.Name == "Pset_ElementCommon") { pset.Name = form.SelectedPropertySet.Name.Replace("Element", docBaseEntity.Name); } pset.RuleParameters = "PsetName=" + pset.Name; if (this.Concept.Items.Count == 0) { this.Concept.Items.Add(pset); } else { bool addItem = true; foreach (DocTemplateItem existingPsetDefinition in this.Concept.Items) { if (existingPsetDefinition.Name == pset.Name) { addItem = false; } } if (addItem) { this.Concept.Items.Add(pset); } } DocTemplateUsage propertyConcept = new DocTemplateUsage(); DocPropertyTemplateTypeEnum propertyType = form.SelectedProperty.PropertyType; propertyConcept.Operator = DocTemplateOperator.And; DocTemplateItem property = new DocTemplateItem(); string psetName = pset.Name; propertyConcept.Name = String.Join(" ", Regex.Split(form.SelectedProperty.Name, @"(?<!^)(?=[A-Z])")); switch (propertyType) { case DocPropertyTemplateTypeEnum.P_SINGLEVALUE: //propertyConcept.Name = "Single Value"; //propertyRule.RuleParameters = parameterNames[0] + "[Value]=" + "'" + form.SelectedProperty.Name + "'" + parameterNames[1] + "[Type]=" + "'" + form.SelectedProperty.PrimaryDataType + "'"; propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertySingle); //parameterNames = property.Definition.GetParameterNames(); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE: //propertyConcept.Name = "Enumerated Value"; propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyEnumerated); //parameterNames = property.Definition.GetParameterNames(); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_LISTVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyList); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_BOUNDEDVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyBounded); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_REFERENCEVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyReference); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; case DocPropertyTemplateTypeEnum.P_TABLEVALUE: propertyConcept.Definition = this.m_project.GetTemplate(DocTemplateDefinition.guidTemplatePropertyTable); property.RuleParameters = propertyConcept.Definition.GetParameterNames()[0] + "=" + form.SelectedProperty.Name + ";" + propertyConcept.Definition.GetParameterNames()[1] + "=" + form.SelectedProperty.PrimaryDataType + ";"; CreateAndAssignProperty(form, propertyConcept, property, psetName); break; } //foreach(DocModelRule rule in property.Definition.Rules) //{ // if (!string.IsNullOrEmpty(rule.Identification)) // { // } //} } else { CvtValuePath valuepath = CvtValuePath.Parse(value, mapEntity); this.ChangeTemplate(valuepath.ToTemplateDefinition()); } } } }